Closed gautamjain closed 4 years ago
hard stop: definitely OK as a separate call
smooth stop: stop as soon as you can but don't reverse - the entry in early ramp termination (Switch to velocity mode, set VMAX=0 and AMAX to the desired deceleration value. This will stop the motor using a linear ramp.) Looks like the best option for what you want, Or the b) option (at least in the 5130 datasheet): "For a stop in positioning mode, set VSTART=0 and VMAX=0. VSTOP is not used in this case. The driver will use AMAX and A1 (as determined by V1) for going to zero velocity."
As any given app is likely to want to use 1 or other mode of smooth stop, the simple option I think is to have different stop methods and let the app use the one it prefers.
stop here: the current version.
Got it thanks. I didn't realize the current stop method was intentionally driving backwards.
I'll update the PR to so all three methods are available for use.
hard_stop()
, smooth_stop()
, and stop()
Alright, done. Names are slightly different:
stop_here()
- original versionsoft_stop()
- smooth ramp downhard_stop()
- stop immediately/asap
Calling
stop()
did not work as expected for me. It caused the motor to:It seems like
waitStop()
was not polling frequently enough to catch the moment at which the motor velocity reached zero. When the velocity reached zero, the driver would notice the difference betweenXACTUAL
andXTARGET
and drive backwards to compensate.One way to fix this would be to poll more frequently, i.e. reduce the
ticktime
. It must be reduced to less thanTZEROWAIT
, so we can catch the moment when velocity is zero. However,TZEROWAIT
cannot be always initialized to a safe value. (It is derived from the driver's clock frequency and would vary for different circuits).I've changed
stop()
to use one of the other methods described in the datasheet (see 'Early Ramp Termination'). It no longer depends onTZEROWAIT
or even directly onticktime
.I've also added the option to perform a
hard_stop()
which will cause the motor to halt without ramping down (per the same section in the datasheet).Let me know what you think. Thanks!