|
HF-TMC51x0 Driver (TMC5130 & TMC5160) 0.1.0-dev
Hardware Agnostic C++ Driver for the TMC51x0 (TMC5130 & TMC5160)
|
Chopper configuration structure. More...
#include <tmc51x0_types.hpp>
Public Member Functions | |
| ChopperConfig ()=default | |
| Default constructor. | |
| ChopperConfig (uint8_t off_time, uint8_t blank_time=2, uint8_t hysteresis_start=4, uint8_t hysteresis_end=0, MicrostepResolution microstep_res=MicrostepResolution::MRES_256) | |
| Helper constructor for SpreadCycle mode. | |
| ChopperConfig (uint8_t off_time, uint8_t fast_decay_time, uint8_t sine_offset, uint8_t blank_time=2, bool disable_comparator=false, MicrostepResolution microstep_res=MicrostepResolution::MRES_16) | |
| Helper constructor for Classic mode. | |
Public Attributes | |
| ChopperMode | mode {ChopperMode::SPREAD_CYCLE} |
| Chopper mode selection. | |
| uint8_t | toff {5} |
| Off time (slow decay time) setting. | |
| uint8_t | tbl {2} |
| Comparator blank time. | |
| uint8_t | hstrt {4} |
| Hysteresis start value (SpreadCycle mode only) | |
| uint8_t | hend {0} |
| Hysteresis end value (SpreadCycle mode) or Sine wave offset (Classic mode) | |
| uint8_t | tfd {0} |
| Fast decay time (Classic mode only) | |
| bool | disfdcc {false} |
| Disable fast decay comparator (Classic mode only) | |
| uint8_t | tpfd {0} |
| Passive fast decay time. | |
| MicrostepResolution | mres {MicrostepResolution::MRES_256} |
| Microstep resolution. | |
| bool | intpol {true} |
| Enable interpolation to 256 microsteps. | |
| bool | dedge {false} |
| Enable double edge step pulses. | |
| bool | vhighfs {false} |
| High velocity fullstep selection. | |
| bool | vhighchm {false} |
| High velocity chopper mode. | |
| bool | diss2g {false} |
| Short to GND protection disable. | |
| bool | diss2vs {false} |
| Short to supply protection disable. | |
Chopper configuration structure.
User-friendly configuration for SpreadCycle and Classic chopper modes. SpreadCycle is a cycle-by-cycle current control providing superior microstepping quality. Classic mode is an alternative constant off-time chopper algorithm.
The chopper frequency is an important parameter. Most motors work optimally in 16-30kHz range. Frequency is influenced by TOFF, TBL, hysteresis settings, motor inductance, and supply voltage.
|
default |
Default constructor.
Initializes with recommended default values for SpreadCycle mode:
|
inline |
Helper constructor for SpreadCycle mode.
Creates a SpreadCycle configuration with typical settings.
| off_time | Off time setting (0=disabled, 1-15, 5=typical) |
| blank_time | Blank time (ChopperBlankTime enum or 0-3, TBL_36CLK=typical) |
| hysteresis_start | Hysteresis start (0-7, 4=typical) |
| hysteresis_end | Hysteresis end (0-15 encoded, 0=typical) |
| microstep_res | Microstep resolution (MicrostepResolution enum, MRES_256=typical) |
|
inline |
Helper constructor for Classic mode.
Creates a Classic constant off-time chopper configuration.
| off_time | Off time setting (0=disabled, 1-15, 5=typical) |
| fast_decay_time | Fast decay time (0-15, similar to off_time) |
| sine_offset | Sine wave offset (0-15 encoded, 4-6=typical positive offset) |
| blank_time | Blank time (ChopperBlankTime enum or 0-3, TBL_36CLK=typical) |
| disable_comparator | Disable fast decay comparator (false=enable, true=time only) |
| microstep_res | Microstep resolution (MicrostepResolution enum, MRES_16=typical) |
| bool tmc51x0::ChopperConfig::dedge {false} |
Enable double edge step pulses.
Enables step impulse at each step edge (both rising and falling).
| bool tmc51x0::ChopperConfig::disfdcc {false} |
Disable fast decay comparator (Classic mode only)
Controls whether current comparator can terminate fast decay cycle.
| bool tmc51x0::ChopperConfig::diss2g {false} |
Short to GND protection disable.
Controls whether short to GND protection is enabled.
| bool tmc51x0::ChopperConfig::diss2vs {false} |
Short to supply protection disable.
Controls whether short to VS (supply) protection is enabled.
| uint8_t tmc51x0::ChopperConfig::hend {0} |
Hysteresis end value (SpreadCycle mode) or Sine wave offset (Classic mode)
SpreadCycle mode (chm=0): Hysteresis end value after decrements.
Classic mode (chm=1): Sine wave offset for zero crossing correction.
| uint8_t tmc51x0::ChopperConfig::hstrt {4} |
Hysteresis start value (SpreadCycle mode only)
Adds to hysteresis end value to create effective hysteresis start. Forces minimum current ripple into motor coils for best microstepping results.
Range: 0-7 (adds 1-8 to HEND)
Effective hysteresis = HSTRT + HEND (with encoding)
| bool tmc51x0::ChopperConfig::intpol {true} |
Enable interpolation to 256 microsteps.
Extrapolates MRES setting to 256 microsteps for smoother motion.
| ChopperMode tmc51x0::ChopperConfig::mode {ChopperMode::SPREAD_CYCLE} |
Chopper mode selection.
| MicrostepResolution tmc51x0::ChopperConfig::mres {MicrostepResolution::MRES_256} |
Microstep resolution.
Defines number of microsteps per full step. Higher resolution provides smoother motion but may reduce maximum velocity.
Uses MicrostepResolution enum for type safety.
Typical: MRES_256 (256 microsteps) for balanced performance.
| uint8_t tmc51x0::ChopperConfig::tbl {2} |
Comparator blank time.
Masks comparator input to block spikes from parasitic capacitances during switching. Typically 1-2 microseconds. Longer blank time provides more protection but may limit frequency.
Can be specified as:
Recommended: TBL_36CLK (~3.0µs @ 12MHz) for most applications.
| uint8_t tmc51x0::ChopperConfig::tfd {0} |
Fast decay time (Classic mode only)
Sets fixed fast decay time following each on phase in Classic mode. Should be long enough to follow falling slope but not cause excess ripple.
Range: 0-15 (uses hstrt_tfd bits + tfd_3 bit)
| uint8_t tmc51x0::ChopperConfig::toff {5} |
Off time (slow decay time) setting.
Sets the slow decay time and limits maximum chopper frequency. Higher values increase slow decay time and reduce chopper frequency.
Range: 0-15
Calculation for target chopper frequency: t_OFF = (1 / f_chopper) * (slow_decay_percent / 100) * (1 / 2) TOFF = (t_OFF * f_CLK - 12) / 32
Example (25kHz target, 50% slow decay, 12MHz clock): t_OFF = (1/25000) * 0.5 * 0.5 = 10µs TOFF = (10µs * 12MHz - 12) / 32 ≈ 3.0 → use 3
| uint8_t tmc51x0::ChopperConfig::tpfd {0} |
Passive fast decay time.
Adds passive fast decay time after bridge polarity change. Helps reduce mid-range resonances.
Range: 0-15
| bool tmc51x0::ChopperConfig::vhighchm {false} |
High velocity chopper mode.
Enables switching to chm=1 (Classic mode) and fd=0 when VHIGH is exceeded. This way, a higher velocity can be achieved.
vhighfs for maximum velocity. | bool tmc51x0::ChopperConfig::vhighfs {false} |
High velocity fullstep selection.
Enables switching to fullstep when VHIGH is exceeded. Switching takes place only at 45° position. The fullstep target current uses the current value from the microstep table at the 45° position.
vhighchm for maximum velocity.