I am using the Arduino Mega to operate the motor. I want to increase the speed of the stepper.
I have checked the power supply. It is providing 24V as required.
I am sure that the motor can be run at a higher speed as I have seen a demo of the same motor with a demo setup where the speed was higher. So it is not that the stepper is incapable.
I am attaching the code I have used. To increase the speed, the delay between the HIGH-LOW transition can be reduced to influence the speed, from what I understand. I used the asm_nop command to reduce the delay below microsecond ranges as the speed with that too wasn't sufficient. Then I wondered if the problem could be that the digitalWrite is slow. I tried direct port manipulation. The motor now doesn't run. Am I doing the direct port manipulation wrong?
Also, in the program where I use digitalWrite and run the stepper, the motor runs only if there is the print statement in the for loop. I am unsure as to why this is happening.
What do I do to increase the speed? Is my approach right?
For stepper motors there are two parameters, pull in rate, and I think, pull out rate. To reach the very top speed the stepper must be accelerated properly. Starting from 0 RPM there is a maximum speed that can be applied directly. That speed depends on the mechanucal load of the stepper. Running at this speed the stepper speed can be raised, accelerated. Those data are stepper parameters. If the driver is intellegent it can be setup for this. Else the Arduino will have to keep track of the pulsrate.
abhir24:
What do I do to increase the speed? Is my approach right?
You have not told us how many steps per second you are actually achieving or what step rate you would like to achieve.
If you are using a single nop as a timer then IMHO that is much too short - it is just 62.5 nanosecs. I would expect a stepper driver to require a pulse width of the order of 2 to 10 microsecs but I could not find that info on the website you linked to. And the interval between steps would need to be very much greater than that. You certainly won't get a step rate of 1 million per second. For one thing the value of micros() increments in steps of 4.
Have a look at the second example in this Simple Stepper Code. Get it working and then experiment by reducing the interval between steps.
For high step rates you will need to accelerate the motor so have a look at the code in this link
when I could have just read it on the site if you had posted it using the Code tags </>.
There may be others who feel the same way.
I will remember this the next time I put up a query.
Robin2:
You have not told us how many steps per second you are actually achieving or what step rate you would like to achieve.
If you are using a single nop as a timer then IMHO that is much too short - it is just 62.5 nanosecs. I would expect a stepper driver to require a pulse width of the order of 2 to 10 microsecs but I could not find that info on the website you linked to. And the interval between steps would need to be very much greater than that. You certainly won't get a step rate of 1 million per second. For one thing the value of micros() increments in steps of 4