|
| | Thresholds (TMC51x0 &driver) noexcept |
| |
| Result< void > | SetStealthChopVelocityThreshold (float value, Unit unit) noexcept |
| | Set StealthChop velocity threshold (TPWMTHRS)
|
| |
| Result< float > | GetStealthChopVelocityThreshold (Unit unit) const noexcept |
| | Get StealthChop velocity threshold (TPWMTHRS) from local tracking.
|
| |
| Result< void > | SetTcoolthrs (float threshold, Unit unit) noexcept |
| | Set StallGuard/CoolStep threshold velocity (TCOOLTHRS)
|
| |
| Result< float > | GetTcoolthrs (Unit unit) const noexcept |
| | Get cached StallGuard/CoolStep threshold velocity (TCOOLTHRS)
|
| |
| Result< void > | SetHighSpeedThreshold (float value, Unit unit) noexcept |
| | Set High-Speed velocity threshold (THIGH)
|
| |
| Result< void > | SetDcStepVelocityThreshold (float value, Unit unit) noexcept |
| | Set DcStep velocity threshold (VDCMIN)
|
| |
| Result< float > | GetDcStepVelocityThreshold (Unit unit) const noexcept |
| | Get cached DcStep velocity threshold (VDCMIN)
|
| |
| uint32_t | GetVdcminRegisterValue () const noexcept |
| | Get locally tracked VDCMIN register value (raw)
|
| |
| Result< void > | SetModeChangeSpeeds (float pwm_thrs, float cool_thrs, float high_thrs, Unit unit) noexcept |
| | Convenience: set TPWMTHRS, TCOOLTHRS, and THIGH in one call.
|
| |
| uint32_t | GetTpwmthrsRegisterValue () const noexcept |
| | Get locally tracked TPWMTHRS register value (raw)
|
| |
| uint32_t | GetTcoolthrsRegisterValue () const noexcept |
| | Get locally tracked TCOOLTHRS register value (raw)
|
| |
| uint32_t | GetThighRegisterValue () const noexcept |
| | Get locally tracked THIGH register value (raw)
|
| |
| Result< void > | SetModeHysteresis (float lower_speed, float upper_speed, Unit unit) noexcept |
| | Configure StealthChop to SpreadCycle transition with hysteresis.
|
| |
| Result< void > | UpdateModeHysteresis () noexcept |
| | Update TPWMTHRS based on current chopper mode for hysteresis.
|
| |
| Result< void > | DisableModeHysteresis () noexcept |
| | Disable mode hysteresis (use single TPWMTHRS threshold)
|
| |
| bool | IsModeHysteresisEnabled () const noexcept |
| | Check if mode hysteresis is currently configured.
|
| |
template<typename CommType>
struct tmc51x0::TMC51x0< CommType >::Thresholds
Velocity thresholds / mode thresholds (TPWMTHRS, TCOOLTHRS, THIGH)
Consolidates all "threshold" knobs so users don't have to guess whether a given threshold belongs to motor control, StallGuard, or diagnostics.
template<typename CommType >
Set DcStep velocity threshold (VDCMIN)
- Parameters
-
| value | Velocity threshold value (0 disables) |
| unit | Unit of the value |
- Returns
- Result<void> indicating success or error
VDCMIN is part of the ramp-generator driver feature control register set. Per datasheet, VDCMIN-based DcStep enable is only valid when using the internal ramp generator (SD_MODE=LOW). In external STEP/DIR mode, DcStep is enabled via the external DCEN pin instead.
- Return values
-
| INVALID_STATE | if called while in external STEP/DIR mode |
template<typename CommType >
Configure StealthChop to SpreadCycle transition with hysteresis.
- Parameters
-
| lower_speed | Speed below which StealthChop activates (lower threshold) |
| upper_speed | Speed above which SpreadCycle activates (upper threshold) |
| unit | Speed unit for both thresholds |
- Returns
- Result<void> indicating success or error
Creates a velocity hysteresis band to prevent mode oscillation near the threshold. The motor will:
- Switch to SpreadCycle when accelerating above
upper_speed
- Switch to StealthChop when decelerating below
lower_speed
Implementation note: The TMC5160 has only one TPWMTHRS register. This method dynamically updates TPWMTHRS based on current chopper mode to create the hysteresis effect. Call UpdateModeHysteresis() periodically or after velocity changes for best results.
Example: SetModeHysteresis(50, 70, Unit::RPM) creates a 20 RPM dead band:
- StealthChop → SpreadCycle at 70 RPM (accelerating)
- SpreadCycle → StealthChop at 50 RPM (decelerating)
- Note
- Requires GCONF.en_pwm_mode = 1 (StealthChop enabled globally)
- See also
- Datasheet section 9.2: Switching between SpreadCycle and StealthChop