Google

Wednesday, June 18, 2008

Stepper Motor interfacing with 8051

Components Required


Atmel 89c51 controller


crystal oscillator 11.059 Mhz


capacitor 33pfarads -2


Bipolar stepper motor


resistors -1K -2


push bottons -2


Driver IC ULN 2003A -1


Circuit Diagram






Description

If you press one push botton motor will rotate one direction. If you press another button it start rotating in the other direction.Speed of the motor we can control by using delay routine in C programing.

C program


#include
#define no_of_rotations 4
sbit m= P0^0;
sbit n=P0^1;

void delay()
{
int i,j;
for(i=0;i<=1000;i++)
for(j=0;j<=100;j++);
}
main()
{
int forward,reverse,x;
forward=0x01;
reverse=0x08;
x=no_of_rotations;
while(1)
{
if(m==0)
{
while(x!=0)
{
P1=forward;
forward<<=1;
delay();
if(forward==0x10)
forward=0x01;
}
x--;
}
if(n==0)
{
while(x!=0)
{
P1=reverse;
reverse>>=1;
delay();
if(reverse==0x00)
reverse=0x08;
}
x--;
}
}
}

HEX code

:0300000002008774
:0C008700787FE4F6D8FD758109020003C3
:10006A00E4FFFEE4FDFC0DBD00010CED64654C707F
:0C007A00F50FBF00010EBE03EABFE9E76E
:010086002257
:100003007508007509017B087A0090000420802E92
:10001300E58245836020850990E50925E0F509E53A
:100023000833F50812006AE5096410450870E1F524
:100033000875090180DAE582158270021583208133
:10004300CCE582458360168B90EAA2E713FAEB13A3
:10005300FB12006AEB4A70E9FA7B0880E4E582153B
:070063008270AA158380A63C
:00000001FF


2 comments:

Anonymous said...

Interesting to know.

sekhar said...

thanks for your comment for more detals plz mail to sekharstuff@yahoo.co.in