gin66 / FastAccelStepper

A high speed stepper library for Atmega 168/328p (nano), Atmega32u4, Atmega 2560, ESP32, ESP32S2, ESP32S3, ESP32C3, ESP32C6 and Atmel SAM Due
MIT License
313 stars 71 forks source link

(suggestion) Include setDelayToEnable and setDelayToDisable in usage example to fix TMC5160/etc. not moving #22

Closed laminarturbulent closed 3 years ago

laminarturbulent commented 3 years ago

I am using a TTGO T-Display ESP32 and a TMC5160 SilentStepStick v1.5.

It took me a while before I found out what was making the StepperDemo example work while the usage example didn't (it would enable the driver but the motor did not move).

The answer was actually right under the usage example, but I missed it:

Some drivers need time to e.g. stabilize voltages until stepping should start. For this the start on delay has been added. See issue #5.

While trying to find the problem, I found that getCurrentPosition() would stay at 0 after a move() command when I didn't have the enable delays set. After adding

stepper->setDelayToEnable(50);
stepper->setDelayToDisable(1000);

to the usage example, everything worked as expected. I think it'd be good to add this to the usage example so it will work with more stepper drivers without needing modification.

It was confusing when getCurrentPosition() stayed at 0 because it seems like the ESP32 was actually aware that the driver didn't move the motor, but I thought that this shouldn't be possible since the driver doesn't send any information back to the ESP32 (at least not to FastAccelStepper, I should also mention that I'm using TMCStepper with software SPI).

gin66 commented 3 years ago

Thanks for the suggestion. Just what you mention, that the getCurrentPosition() stayed at 0 is unexpected. So I prefer to call it a bug. Now I have checked this on my hardware setup and can confirm, it does not work as expected without the delays.

The bug has been fixed in the 0.16.1 and a new example called UsageExample.ino has been added.

Sorry for the inconvenience

laminarturbulent commented 3 years ago

Awesome, thanks for fixing this so quickly!