The motor does not rotate continuously;it rotates a few steps forward and then backward.
I am using ULN2803 as the driver. Can anyone please give me the circuit diagram of this IC with PIC?
Try to see how many steps the motor take to one direction before go to the other direction (make delays bigger in your code). Is it lets say 3 steps CW, 1 CCW. Maybe 1 of the windings is not connected correctly (you are using a unipolar motor, right?).
it doesn't matter whether u use ULN2008 or ULN2803
try this sequence. before that check ur stepper motor is healthy and coils are in good condition by giving the voltage to each coil one by one sequentially and it has to rotate in same direction. if any one of the coil energizing reflects the change in direction change the coil sequence. mostly it'll fix ur prob. otherwise try this code.
Code:
while(1)
{
delay(1000); // this delay will help u to know the starting pulse
delay(1000); // this will help u for debugg ur prob (debugging purpose only)
delay(1000); // after this delay u start track and find which coil going reverse then change the sequence
PORTC=0X08;
delay(1000);
PORTC=0X04;
delay(1000);
PORTC=0X02;
delay(1000);
PORTC=0X01;
delay(1000);
}
I am trying to run the following modified code. The strange thing is that the code ran the motor 2-3 times in 40-50 attempts. The same code on burning and running again does not run the motor. Also I wrote the code to turn the motor 90 degrees but even when the motor ran, it ran continuously;not 90 degrees.
That is what I want. I don't want it run continuously. Anyhow I found out that I had written 1<50 instead of i<50,which is why it was running continuously. Now the problem is that it doesn't run at all;it just vibrates. I have checked all the connections.
On what basis is the delay between two sequence values decided? I know greater the delay, slower will be the motor, but is there some range or criteria to calculate delay?