Hello everyone, i need some help with AccelStepper library.
I would like to know how I can accelerate and decelerate the engine speed while it is running. For example, if I have 300 RPM and I want to reach 250, I will decelerate from the current speed and not stop and accelerate to 250 RPM. I tried to use the moveTo, setMaxSpeed functions, but I still don't realize it because it still stops and accelerates from 0 when I change its speed.
AccelStepper is position controlled not speed controlled.
For Speed control you need to use my modified Speed Stepper library Stepper Speed Control Library project with plotting
Also see my tutorial on Multi-tasking in Arduino
which covers how to get the most speed out of your stepper and how to control it via user inputs and sensors
The project says
"This sketch is configured to work with Serial, e.g. UNO and Mega etc. For running on the SparkFun Redboard Turbo see below."
meaning is uses the Serial connection for debug and cmds.
Further down near the bottom it explains When moving the SpeedStepperSetup sketch from the Uno/Mega to the Redboard Turbo you might naïvely just replace #define SERIAL Serial with #define SERIAL SerialUSB to suit the Redboard Turbo usb serial connection, however you would find that the resulting stepper latency is about 10mS. That is 10x slower then for the UNO. This due to how the Redboard cpu handles the USB connection.
So good for any board that has hardware Serial and does not use the main processor to handle the USB connection, i.e. most boards including Nano