Er_pank
Newbie level 4
- Joined
- Oct 22, 2013
- Messages
- 5
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 47
Hi friends
I am having problem in interfacing 8051 uC with stepper motor.
My aim is to rotate the stepper motor by +90 degree when i push a "UP" button once and when I push the "UP" button twice +180 degree and then +270 then 0 degree.
And when I push "DOWN" button rotate by -90 degree and when I push DOWN twice -180 degree and so on.
I am working on a Proteus but I think there is problem in program and I am not able to get proper result.
Can you any one give me proper Program for that :
Thanks in advance :smile:
My WRONG program was :
And Proteus diagram is :
<a title="stepper_motor_protues.JPG" href="http://obrazki.elektroda.pl/6857363500_1382873179.jpg"><img src="http://obrazki.elektroda.pl/6857363500_1382873179_thumb.jpg" alt="stepper_motor_protues.JPG" /></a>
https://obrazki.elektroda.pl/6857363500_1382873179.jpg
I am having problem in interfacing 8051 uC with stepper motor.
My aim is to rotate the stepper motor by +90 degree when i push a "UP" button once and when I push the "UP" button twice +180 degree and then +270 then 0 degree.
And when I push "DOWN" button rotate by -90 degree and when I push DOWN twice -180 degree and so on.
I am working on a Proteus but I think there is problem in program and I am not able to get proper result.
Can you any one give me proper Program for that :
Thanks in advance :smile:
My WRONG program was :
Code:
void delay(int);
sbit zin= P0^0;
sbit zout= P0^1;
void main()
{ int num=0;
P0=0;
P2=0;
do
{
if(zin==1)
{
P2=0x0C;
num++;
}
if(zout==1)
{
P2=0x03;
num--;
}
}
while(1);
}
void delay(int k)
{
int i,j;
for(i=0;i<k;i++)
{
for(j=0;j<100;j++)
{}
}
}
And Proteus diagram is :
<a title="stepper_motor_protues.JPG" href="http://obrazki.elektroda.pl/6857363500_1382873179.jpg"><img src="http://obrazki.elektroda.pl/6857363500_1382873179_thumb.jpg" alt="stepper_motor_protues.JPG" /></a>
https://obrazki.elektroda.pl/6857363500_1382873179.jpg