Hello Everyone
I am using this kind of code to control a stepper motor, but it’s not working accurately:
dir(HIGH);
for(int p=0;p<20000;p++)
{
pulse(HIGH);
delay(t);
pulse(LOW);
delay(t)
}
For a fixed value of "t" the moving distance is same.On Increasing or decreasing "t" the moving distance changes with a different value for "t". As per my knowledge about stepper motor's, it should only affect the speed of a motor, not the accuracy.
I set my stepper driver to 6400 pulse/rev at maximum current.Any help appreciated to solve this problem
I am using smooth acceleration and deacceleration as well.
I am using commercial stepper driver with 4A stepper driver output current. My motor is compatible with the stepper driver for sure.I checked their datasheets
i am using Arduino due with 5v logic level shifter
Also post links to the datasheet for your motor and the datasheet for your motor driver.
And tell us what motor power supply you are using - volts and amps.
for (int interval=500;interval>sp;interval=interval-1)
is trying to move the motor at step rates between 1000 µsecs and 160 µsecs - or 1000 steps per second up to 6250 steps per second.
Try much lower speeds - say 10 steps per second up to 100 steps per second. If that works then gradually increase the higher speed. You are only changing by 1 for each iteration. A much bigger increment should work fine.
The way the speed is controlled will be easier to understand if you have a variable for the width of the pulse (10 microsecs is usually sufficient) and another variable for the interval between pulses. It is the latter that is used to vary the speed. See this Simple Stepper Code
To make it easy for people to help you please use the code button </>