this tutorial explains the stepper motor(uni-polar) interfacing with 8051. stepper motor has great advantage in field of robotic where precise angular movement is needed.for basic concept of stepper motor read this article stepper motor. here motor is programmed to rotate both in half and full drive mode
PROTEUS DESIGN
two switches one to rotate motor in half drive mode other to rotate it in full drive mode are connected to pin P3.0 and P3.1 of controller respectively. you can use either of L293D and ULN2303 as a driver circuit for your motor since current requirement for motor is approx. 5A depending on winding resistance.for uni-polar stepper motor voltage and current requirement is upto 3.1v and 5A respectively. for satisfying our current requirement we need driver as controller has max source current of 500uA and sinking current of 3.2A in case of intel. output current of each L293D output is 600 mA and uln2003 is 500mA.
CODE
complete code
#define stepper P2
sbit sw1=P3^0;
sbit sw2=P3^1;
void delay(unsigned int);
void main()
{
sw1=sw2=0;
while(1)
{
while(sw1) //Half Drive Stepping
{
stepper=0x01;
delay(500);
stepper=0x02;
delay(500);
stepper=0x04;
delay(500);
stepper=0x08;
delay(500);
}
while(sw2) // full Drive Stepping
{
stepper=0x01;
delay(500);
stepper=0x03;
delay(500);
stepper=0x02;
delay(500);
stepper=0x06;
delay(500);
stepper=0x04;
delay(500);
stepper=0x0C;
delay(500);
stepper=0x08;
delay(500);
stepper=0x09;
delay(500);
}
}
}
void delay(unsigned int x)
{
int i;
for(i=0;i<x;i++);
}
VIDEO
Category: