MicroBahner/MobaTools

Need help regarding setSpeed and setSpeedSteps

Closed this issue · 2 comments

Hi!

It is a bit unclear to me when or how to use setSpeed or setSpeedSteps. If I look at the Stepper_Reference.ino example, both commands are used, but I cannot figure out why or how one or the other.

From the documentation I know that setSpeed is RPM*10, and setSpeedSteps is steps/10sec, but I somehow don't understand the relation between those two or simply am not able to translate one to the other.

The only thing I noticed is that at some point setSpeed does not allow me to raise the speed anymore so I think I would have to use setSpeedStepsin this regard.

As example:
My test environment uses a stepper and driver with a resolution of 1600 steps per rev. Now, if I want the stepper to go 60 rpm, what would I have to do? And what if I want to go 120 rpm later? Simply setting setSpeed to the desired value did not work as I expected... the problem is me, I know, but....

Please, could you clarify it for me a bit more in depth?

Many thanks in advance, regards,
Holger

Hi Holger
In the end, a stepper needs step pulses. And the higher the frequency of these pulses, the faster the stepper rotates. However, the library has limits as to how fast it can generate the step pulses. These limits depend on the processor used and are explained in chapter 3.2.3 of the documentation.

Sometimes you are not interested in the step frequency, but in the rpm of the stepper. setSpeed() is a convenient function to translate the rpm into the step frequency and in the end it calls setSpeedSteps() with the translated value. Internally, the step frequency is always used, and so the limits of the step frequency are the same - regardless of whether you use setSpeed or setSpeedSteps.

Back to your example: 60rpm with 1600steps/revolution means 60 * 1600 = 96000 steps/min or 96000 / 60 = 1600 steps/second. So whether you use setSpeed(600) or setSpeedSteps(16000) will result in the same speed of the stepper (provided that you have set the stepsPerRev correctly when creating the stepper object - this parameter is only needed for this conversion).
The same with 120rpm means 3200 steps/sec. On a UNO the limit is 2500 steps/sec, so this speed cannot be reached on the UNO and is internally limited to 2500 steps/sec or 2500*60=150000 steps/min or 150000/1600=93.75rpm.

I hope I could clarify things a little.
Regards
Franz-Peter

@MicroBahner
MANY MANY thanks! That clarifies everything and now I understand my observations better. I think you should put all this into your wonderful PDF. I already read about the processor limitations regarding step pulses, but now I better understand how this all is coming together.