I've been working on a project for a little while now and I'm at the step of programming my microchip to control the rotation of a NEMA 17 stepper motor using the Allegro Controller A3979.
So far the motor works fine after getting help for members of this forum specially phalanx. I opened this new thread to keep it separated from the other ones I have, but for anyone looking around and getting started soon or in a couple of years from now the other thread is Microchip and A3979
Now my problems are with programming. I'm familiar with C and have done it before and can do some simple stuff, but I'm having issue trying to get the motor, A3979 controller, to accomplish what I want to do.
Basically is just to control the Step pin with the microchip to signal the motor to step certain amount of time. I've never used stepper motors before. I have the stepper set to Sixteenth Step micro stepping and want to know if anyone can help me clear this out or correct me if I'm wrong.
1.My motor has a step angle of 1.8 degrees (Full Step, Correct?).
2.Since I'm at Sixteenth Step does this mean that it will then be stepping @ (1.8/16) = 0.1125 degrees/step?
3.That means I got 3200 steps per/rev, correct?
4.Ok now I want to turn the motor 90 degrees, this means that I have to step (90/.1125) = 800 times to turn the motor 90 degrees?
If some one can please let me know if I have all the above correct I'll appreciate. I've tried stepping the motor from 200-800 times, but maybe my code is not working or I'm doing some thing wrong.
This is the function I been trying to use:
step45Degrees
{
int i;
for(i = 0; i < 400; i++) //Step for 400 times for 45degrees
ena = 0; //enable the A3979 to start stepping
dir = 1; //set direction of stepper motor
step = 1; //step the motor logic high
_delay_us(100)
step = 0; //go logic low.
}
I've tried calling the above function from inside and outside the while loop, but I get odd behavior from the motor. It either doesn't start, tries to start or it continuously turn. The minimun step pulse width of A3979 is 1us, so I'm well above that.
So far the motor works fine after getting help for members of this forum specially phalanx. I opened this new thread to keep it separated from the other ones I have, but for anyone looking around and getting started soon or in a couple of years from now the other thread is Microchip and A3979
Now my problems are with programming. I'm familiar with C and have done it before and can do some simple stuff, but I'm having issue trying to get the motor, A3979 controller, to accomplish what I want to do.
Basically is just to control the Step pin with the microchip to signal the motor to step certain amount of time. I've never used stepper motors before. I have the stepper set to Sixteenth Step micro stepping and want to know if anyone can help me clear this out or correct me if I'm wrong.
1.My motor has a step angle of 1.8 degrees (Full Step, Correct?).
2.Since I'm at Sixteenth Step does this mean that it will then be stepping @ (1.8/16) = 0.1125 degrees/step?
3.That means I got 3200 steps per/rev, correct?
4.Ok now I want to turn the motor 90 degrees, this means that I have to step (90/.1125) = 800 times to turn the motor 90 degrees?
If some one can please let me know if I have all the above correct I'll appreciate. I've tried stepping the motor from 200-800 times, but maybe my code is not working or I'm doing some thing wrong.
This is the function I been trying to use:
step45Degrees
{
int i;
for(i = 0; i < 400; i++) //Step for 400 times for 45degrees
ena = 0; //enable the A3979 to start stepping
dir = 1; //set direction of stepper motor
step = 1; //step the motor logic high
_delay_us(100)
step = 0; //go logic low.
}
I've tried calling the above function from inside and outside the while loop, but I get odd behavior from the motor. It either doesn't start, tries to start or it continuously turn. The minimun step pulse width of A3979 is 1us, so I'm well above that.