- 8051

Stepper Motor Interfacing with 8051 Microcontroller – CodesExplorer

Stepper Motor Interfacing with 8051 Microcontroller

Fig 1. Stepper Motor

A stepper motor is a brushless motor which divides complete 360 degree rotation into steps. Each step has fixed angle and motor rotates along those angles.In this article we will be interfacing Stepper Motor with 8051 Microcontroller.

In this article we will be rotating stepper motor with 4 steps in clockwise and anticlockwise direction.

Stepper Motor will be connected to any one of the Ports. In our case we will be connecting it to PORT0 .

Please make a note that if we send 1-2-4-8 stepper motor will rotate clockwise and Similarily
8-4-2-1 will rotate anticlockwise.

Lets See the code Now…..

CODE: 

// STEPPER MOTOR INTERFACING USING 8051
//----------------------------------------------------------------
// CONTROLLER   : 8051 AT89C51ED2
// Developed By  : CodesExplorer
//----------------------------------------------------------------
#include <at89c51xd2.h >
void delay();
void clockwise();
void antiClockwise();
void main()
{
 while(1)
 {
  clockwise();
  delay();
  antiClockwise();
 }
}
void delay()
{
 unsigned int i,j;
 for(i=0;i<500;i++)
 {
  for(j=0;j<10;j++);
 }
}
void clockwise()  // Clockwise Rotation of Stepper Motor
{
 P0=0x01;
 delay();
 P0=0x02;
 delay();
 P0=0x04;
 delay();
 P0=0x08;
 delay();
}
void antiClockwise()  // AntiClockwise Rotation of stepper motor
{
 P0=0x08;
 delay();
 P0=0x04;
 delay();
 P0=0x02;
 delay();
 P0=0x01;
 delay();
}

Leave a Reply