Maker Pro
Maker Pro

Stepper Motor Control

I need some help with debugging a unipolar stepper motor I am using a PIC24 and a ULN2003A chip to drive the motor. It seems to have no problem moving forward, but only twitches when I attempt to go backward.

This is the half-step sequence I am using:
uint8 coil1Seq[8] = {1,1,1,0,0,0,0,0};
uint8 coil2Seq[8] = {0,0,0,0,1,1,1,0};
uint8 coil3Seq[8] = {1,0,0,0,0,0,1,1};
uint8 coil4Seq[8] = {0,0,1,1,1,0,0,0};

The logic I am using is to move a certain number of steps, a for loop increments through this array and assigns these values to the pins. To go backwards, it decrements from the last position it was in the array. Is this correct?
 
Could it be that there is a code bug and you are not indexing correctly when you are decrementing? Are you just ANDing the decremented value with 7 or are you doing compares? If you are just ANDing, could it be that you are using some over-protective compiler that prevents you from decrementing past 0 in violation of C language specifications?

Is your step/coil sequence correct? It is possible that an incorrect coil sequence may work in one direction, but not in the other?

---55p
 
Top