Skip to main content

How to interface stepper motor with AT89C51 ( uni-polar stepper motor)

hi, how are you today



Let's learn how to interface a Stepper motor with our baby (8051uC)

Description

 This article helps you to understand the concept behind the interfacing of uni-polar stepper.The name uni-polar means that we have 1 pin to control the motion and other pin is connected to +ve voltage dc supply.Stepper motor is a motor that runs covers angular movement and most commonly used at toll plazas.
Here I tried to teach you how stepper motor works, it can be run in any direction by
simple programming.Mechanism is same as of dc motor but in place of single coil, it
has four coils and that helps to provide angular movement of 90 and 45 degrees.

If we generate magnetic field in one coil than it will attain an angular movement of
90 degrees and if we generate magnetic field in 2 sequence coils than we cn attain an
angular movement of 45 degree.
Uni-polar stepper motor is having 6 wires from which 2 are red and we have to directly
connect them to +ve terminal of power supply and rest 4 are connected in right series
to controller with the help of ULN2803 IC. 

Here we connect 4 pins of port 3 to uln2803 input terminal and their resp.output
is connected to remaining four wires of stepper motor that are used to
provide angular motion(45 or 90 degree) to stepper motor.

Programming

90 degree angle step
1:  #include<reg51.h>      // header file  
2:  void delay(int time)    // function to generate delay  
3:     {  
4:     int i,j;  
5:     for(i=0;i<=time;i++) // i will run from 0 to user defined value  
6:     for(j=0;j<=1275;j++); // j will run from 0 to 1275 "time" times  
7:     }  
8:  sbit m1=P3^0;  
9:  sbit m2=P3^1;  
10:  sbit m3=P3^2;  
11:  sbit m4=P3^3;  
12:                   /*90 degree phase shift*/  
13:  void main()         // main function  
14:     {  
15:      while(1)       // while(1)used to provide continous loop  
16:       {  
17:        m1=1; m2=m3=m4=0;  
18:        delay(500);  
19:        m2=1; m1=m3=m4=0;  
20:        delay(500);  
21:        m3=1; m1=m2=m4=0;  
22:        delay(500);  
23:        m4=1; m1=m2=m3=0;  
24:        delay(500);     
25:       }  
26:     }  

45 degree angle step
1:  #include<reg51.h>      // header file  
2:  void delay(int time)    // function to generate delay  
3:     {  
4:     int i,j;  
5:     for(i=0;i<=time;i++) // i will run from 0 to user defined value  
6:     for(j=0;j<=1275;j++); // j will run from 0 to 1275 "time" times  
7:     }  
8:  sbit m1=P3^0;  
9:  sbit m2=P3^1;  
10:  sbit m3=P3^2;  
11:  sbit m4=P3^3;  
12:                   /*90 degree phase shift*/  
13:  void main()          // main function  
14:     {   
15:      while(1)        // while(1)used to provide continuous loop  
16:       {  
17:        m4=m1=1; m2=m3=0; // here motor will stuck between 4th and 1st  
18:        delay(500);  
19:        m1=1; m2=m3=m4=0; // here motor will stuck at 1st pin  
20:        delay(500);  
21:        m1=m2=1; m3=m4=0; // here motor will stuck between 1st and 2nd  
22:        delay(500);  
23:        m2=1; m1=m3=m4=0; // here motor will stuck at 2nd pin  
24:        delay(500);  
25:        m2=m3=1; m1=m4=0; // here motor will stuck between 2nd and 3rd  
26:        delay(500);  
27:        m3=1; m1=m2=m4=0; // here motor will stuck at 3rd pin  
28:        delay(500);  
29:        m3=m4=1; m1=m2=0; // here motor will stuck between 3rd and 4th  
30:        delay(500);  
31:        m4=1; m1=m2=m3=0; // here motor will stuck at 4th pin  
32:        delay(500);    
33:       }  
34:  }  

For enhance concept just visit www.salahtutorials.com
Hope you all like this post and I wish this must be useful for you.
Thanks :)

Comments

Translate to your language

Popular posts from this blog

Different Stages of I2C communication

Different Stages Of I2C

How to import Pygame in pycharm

hi, how are you today

Working demonstration of UART communication using 2 8051 uController on Proteus with Embedded C code.

Here we are going to use 2 at89c51 uControllers just to understand UART communication in 8051.