#include <Stepper.h>
// 4 is my magic constant which gets the RPM set in the code
// to correspond with the actually observed RPM (tested on 60 RPM).
// I have absolutely no idea why that is
const int stepsPerRevolution = 200 * 16 * 4;
const int directionPin = 3;
const int stepPin = 4;
Stepper myStepper(stepsPerRevolution, directionPin, stepPin);
void setup() {}
void loop() {
myStepper.setSpeed(600); // trying to reach 600 RPM
myStepper.step(stepsPerRevolution);
}
Goal:
I'm trying to reach at least somewhat high RPM, but can't get past ~150 RPM or so no matter how I fiddle with the numbers in the code.
Both CFG1 and CFG2 are open, so I'd assume that the driver is working in microstepping mode (1/16 to be precise) - could it possibly be the reason I'm facing a limit? Maybe it's not supposed to go fast in that mode at all? Or am I doing something wrong?
Try the examples (especially the second one) in this Simple Stepper Code. I believe some people have got high step rates with it.
If you need higher step rates then try the digitalWriteFast library, and if you need still higher rates learn about Port manipulation.
You need to accelerate a stepper motor to higher speeds. See the AccelStepper library - but it can't produce a very high step rate. The simple acceleration code should facilitate the same speeds as the simple stepper code.
Thanks! I will definitely try some of those things you've mentioned.
I was wondering, you don't seem surprised at all such problem exists - have you heard about it before? Is it an expected behaviour when working in microstepping mode?
Max speed depends on supply voltage and motor inductance. Lower impedance motors and higher
supply voltages are ways to go.
However if you don't ramp up the step rate you'll never ever get useful performance out of a
high performance stepper, since they cannot break the laws of physics and accelerate instantly
to top speed (well the very very tiniest ones can, but nothing as large as NEMA17)
The Stepper library doesn't support ramping, so its not useful to you.
The Stepper library doesn't support step+direction interfaces, so its also no use at all to you.