Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call to disableStealthChop results in isSetupAndCommunicating always returning false #79

Open
benpeart opened this issue Jul 16, 2024 · 2 comments

Comments

@benpeart
Copy link

I'm trying to work out how fast I can move the stepper motor on my platform (ESP32) using your library. As part of my testing, I modified the MoveAtVelocity example to test turning on/off StealthChop based on the current speed as "StealthChop provides silent operation but may limit speed. SpreadCycle allows dynamic motion."

I noticed two unexpected behaviors. First, if you call an API (moveAtVelocity for example), the next time you call isSetupAndCommunicating it will return false. It returns true on all subsequent calls but the first call after making changes will always return false.

The second issue I noticed was that after calling disableStealthChop, all calls to isSetupAndCommunicating it will return false (not just the next call like other APIs).

I've attached the modified sample so you can easily see this for yourself. Build/upload it then open he serial monitor and send a '+' key until the currentSpeed exceeds 32768. At that point, you can no longer successfully interact with the stepper driver.

MoveAtVelocity.txt

@peterpolidoro
Copy link
Member

Interesting, you probably found a bug in the communication. Thanks for reporting that. I will dig into it when I have some time.

As for getting max speed, you definitely want to switch from StealthChop to SpreadCycle at higher velocities. You do not need to call disableStealthChop directly. If you set the TPWMTHRS value the driver will automatically switch from StealthChop to SpreadCycle when the velocity crosses the threshold. I created the method setStealthChopDurationThreshold to set the TPWMTHRS value. The name is a little confusing. The TPWMTHRS is a velocity threshold, but it is actually the duration between steps. At higher velocities, the duration between steps decreases. You can use the method getInterstepDuration() when the motor is spinning to get the value of TPWMTHRS at that velocity. You can then use that value as the threshold for StealthChop by using it in setStealthChopDurationThreshold.

Also if you really want to get maximum velocity, you might get higher numbers by using the step and direction inputs from a stepper controller capable of gentle accelerations, like the TMC429. Each call to moveAtVelocity tries to make an instantaneous jump to a new velocity.

@street-grease-coder
Copy link

@peterpolidoro stallguard then gives me very low values, is that to be expected?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants