Friday, 29 July 2016

Stepper motor interfacing with 8051

Now I can show you "How to Interface Stepper motor with 8051 micro-controller using some logic's Click here to see the logic's. I miss two logic's on that link I will give below.



These two logic's are also used when the driver is used.Lets go the programming shown in given below

#include<reg51.h>
sbit w = P2^0;                        
sbit x = P2^1;                           // Motor pins assigned to port 2
sbit y = P2^2;                        
sbit z = P2^3;                        
sbit H = P1^0;                         // Home switch is connected to port 1, pin-0
sbit R_45 = P1^2;                    // Rotate_45 switch is connected to port 1, pin-2
sbit R_90 = P1^4;                                // Rotate_90 switch is connected to port 1, pin-4
sbit R_135 = P1^6;                              // Rotate_135 switch is connected to port 1, pin-6
sbit R_180 = P1^7;                              // Rotate_180 switch is connected to port 1, pin-7

                                                   
void Home()                                //  Motor "Home" function (Starting stage)
{
 w = 0;
 x = 1;
 y = 0;
 z = 1;
}

void Rotate_45()                          // Motor "Rotate 45 degree" function
{
 w = 0;
 x = 1;
 y = 0;
 z = 0;
}

void Rotate_90()                          // Motor "Rotate 90 deg" function
{
 w = 1;
 x = 1;
 y = 0;
 z = 0;
}

void Rotate_135()                         // Motor "Rotate 135 deg" function
{
 w = 1;
 x = 1;
 y = 1;
 z = 0;
}

void Rotate_180()                          // Motor "Rotate 180 degree" function
{
 w = 1;
 x = 0;
 y = 1;
 z = 0;
}

void main()                                         // Main function
{
  H = 0;                                              // Initialize all switches to zero
  R_45 = 0;
  R_90= 0;
  R_135 = 0;
R_180 = 0;
  while(1)
     {
         if(H==1)
             Home();                                
         else if(R_45==1)
             Rotate_45();
         else if(R_90==1)
             Rotate_90();
         else if(R_135==1)
          Rotate_135();
       else if(R_180==1)
          Rotate_180();
         else
             Home();
     }
}

Copy this program into Keil software and create hex file. Next do the same hardware connections  as shown in below using Proteus software.


 If you want detailed description see the below video. See you soon with future updates.


5 comments:

Unknown said...
This comment has been removed by a blog administrator.
Unknown said...

can u make the move the stepper in continue flow .like in rotate clock wise with 45 degree step and anticlockwise with same step

Siva Kumar Piratla said...

Yes. Run stepper motor in Half wave mode. see this link for clear understand
https://electronic-guru.blogspot.in/2017/01/stepper-motor-with-driver.html

Unknown said...

Als trailers is the best Highway trailer dealers in new & used RV Sales in Oregon along with finance option. We have all the brands of RV parts and Accessories.

Manjunath mn said...

Sir can you pls make a project on robotic control using micro controller 4 servo controling in one programe