How to interface the stepper motor

       This project is an extension to two-phase Unipolar Stepper motor interfacing with AT89C51 using IC L293DIn the previous project, transistor switches were used to interface the stepper motor with the microcontroller. 
       Stepper motor is a variable reluctance DC motor. When correct input sequence of signal is given to the motor, it starts rotation in steps. (For more detail refer Unipolar Stepper motor interfacing with microcontroller AT89C51).
Note: Stepper motor is a DC motor in which the rotor is made to rotate in steps of x- degrees, where x depends on the type of excitation. In this example we would be considering a simple unipolar stepper motor. 
 The conceptual model of the unipolar stepper motor is as shown below
         
       
The rotor aligns itself in the direction of the electromagnetic field, created by exciting a particular winding. The rotor should rotate in steps of 90 degrees in the above model when the windings are excited one by one in a sequence, based on the required direction in the above model. Of course the above model is a simplified one and in a practical stepper motor the windings are distributed in such a way that the rotor rotates 

in finer steps. Also note that in the stepper motor provided, the centre taps are shorted and thus the number of terminals accessible is 5. 
          In practical scenarios various stepping sequences are used based on the considerations like torque, power, vibration etc. In our design problem, we shall consider the simplest kind of excitation, namely the wave-drive stepping sequence. The sequence is as shown below.   



           In other words the sequence 0001, 0010, 0100, 1000 is to be fed to the coil terminals 1a, 1b, 2a, 2b respectively in a periodic manner. To change the direction of rotation the sequence is to be reversed i.e. 0001,0010,0100,1000 is to be fed the coils periodically.  

Hardware Interfacing:       
Note: The microcontroller ground and the driver IC ground should be connected together 





Algorithm 
1.) Send the wave drive sequence 1000,0100,0010,0001so that the stepper motor rotates in one direction 2.) If P1.0 input pin toggles reverse the direction of the motor by applying the sequence 0001, 0010, 0100 ,1000 

C code for interfacing stepper motor in given below:




/************Stepper Motor Interfacing*************************/


#include<reg51.h>


void myMsDelay (unsigned int time);
/* Timer interrupt routine*/

void main(void)
{  
char dir = 0;
P1 = 0x0f;
while(1){
dir = P1 & 0x01;
if(dir == 0){
P1 = 0x10;
myMsDelay(10);
P1 = 0x20;
myMsDelay(10);
P1 = 0x40;
myMsDelay(10);
P1 = 0x80;
myMsDelay(10);
   
}
else{
P1 = 0x80;
myMsDelay(100);
P1 = 0x40;
myMsDelay(100);
P1 = 0x20;
myMsDelay(100);
P1 = 0x10;
myMsDelay(100);

}
}
}
void myMsDelay (unsigned int time)
{
        unsigned int i, j;
        for (i = 0; i < time; i++)
                for (j = 0; j < 710; j++);
}

Popular posts from this blog

Temperature Sensor using 741 OPAMP & LM35

Custom Character Display in 16X2 LCD