24namespace ChipVersion {
34namespace RegisterConstants {
46namespace MathConstants {
47constexpr float PI = 3.14159265359F;
148 return "DC_MOTOR_SINGLE";
150 return "DC_MOTOR_DUAL";
152 return "SOLENOID_SINGLE";
154 return "SOLENOID_DUAL";
272 return "DirectDrive";
753 const uint8_t enc =
static_cast<uint8_t
>(mres);
754 const uint8_t clamped = (enc > 8U) ? 8U : enc;
755 return static_cast<uint16_t
>(256U >> clamped);
791 return "DEFAULT_SINE";
1121 ChopperConfig(uint8_t off_time, uint8_t blank_time = 2, uint8_t hysteresis_start = 4, uint8_t hysteresis_end = 0,
1123 :
toff(off_time),
tbl(blank_time),
hstrt(hysteresis_start),
hend(hysteresis_end),
mres(microstep_res) {}
1137 ChopperConfig(uint8_t off_time, uint8_t fast_decay_time, uint8_t sine_offset, uint8_t blank_time = 2,
1143 tfd(fast_decay_time),
disfdcc(disable_comparator),
mres(microstep_res) {}
1447 uint8_t regulation_speed = 4, uint8_t jerk_reduction = 12)
1465 uint8_t pwm_offset = 30, uint8_t pwm_gradient = 0)
1467 pwm_reg(static_cast<uint8_t>(regulation_speed)),
pwm_lim(static_cast<uint8_t>(jerk_reduction)) {}
1614 StallGuardConfig(int8_t sgt_threshold,
bool enable_filt =
false,
float min_vel = 0.0F,
float max_vel = 0.0F,
2241 return "ACTIVE_LOW";
2243 return "ACTIVE_HIGH";
2273 return "ACTIVE_EDGE";
2275 return "INACTIVE_EDGE";
2277 return "BOTH_EDGES";
2400 return "ACTIVE_LEVEL";
2402 return "RISING_EDGE";
2404 return "FALLING_EDGE";
2406 return "BOTH_EDGES";
2437 return "CONTINUOUS";
2483 ReferenceSwitchActiveLevel::
constexpr uint8_t TMC5160
TMC5160 chip version.
Definition tmc51x0_types.hpp:26
constexpr uint8_t TMC5130
TMC5130 chip version.
Definition tmc51x0_types.hpp:25
constexpr uint32_t MIN_F_CLK
Minimum clock frequency in Hz.
Definition tmc51x0_types.hpp:17
constexpr uint32_t MAX_F_CLK
Maximum clock frequency in Hz.
Definition tmc51x0_types.hpp:18
constexpr uint32_t DEFAULT_F_CLK
Typical internal clock frequency in Hz (12 MHz)
Definition tmc51x0_types.hpp:16
constexpr float PI
π (pi) constant
Definition tmc51x0_types.hpp:47
constexpr float TWO_PI
2π (two pi)
Definition tmc51x0_types.hpp:48
constexpr float DEGREES_PER_REV
Degrees per revolution.
Definition tmc51x0_types.hpp:49
constexpr float TPOWERDOWN_DIVISOR
2^18, used for TPOWERDOWN and TZEROWAIT register conversion
Definition tmc51x0_types.hpp:35
constexpr float ENC_DECIMAL_MULTIPLIER
Multiplier for encoder decimal mode (fractional part)
Definition tmc51x0_types.hpp:39
constexpr float MS_PER_SEC
Milliseconds per second (used for ms to seconds conversion)
Definition tmc51x0_types.hpp:36
constexpr float NS_PER_SEC
Nanoseconds per second (used for ns to seconds conversion)
Definition tmc51x0_types.hpp:38
constexpr float US_PER_SEC
Microseconds per second (used for us to seconds conversion)
Definition tmc51x0_types.hpp:37
constexpr uint32_t ENC_BINARY_MULTIPLIER
Multiplier for encoder binary mode (2^16)
Definition tmc51x0_types.hpp:40
Definition tmc51x0_register_defs.cpp:10
CoolStepMinCurrent
CoolStep minimum current percentage enumeration.
Definition tmc51x0_types.hpp:1976
@ QUARTER_IRUN
Minimum current is 25% of IRUN (1/4)
@ HALF_IRUN
Minimum current is 50% of IRUN (1/2)
MicrostepResolution
Microstep resolution enumeration.
Definition tmc51x0_types.hpp:707
@ FULLSTEP
Full step (no microstepping)
@ MRES_16
16 microsteps per full step (typical)
@ MRES_4
4 microsteps per full step
@ MRES_64
64 microsteps per full step
@ MRES_32
32 microsteps per full step
@ MRES_128
128 microsteps per full step
@ MRES_2
2 microsteps per full step
@ MRES_8
8 microsteps per full step
@ MRES_256
256 microsteps per full step (highest resolution)
OverTempProtection
Over-temperature protection level enumeration.
Definition tmc51x0_types.hpp:486
@ Temp136C
136°C threshold (more protection)
@ Temp143C
143°C threshold
@ Temp150C
150°C threshold (lowest protection, highest temperature)
@ Temp120C
120°C threshold (highest protection, lowest temperature)
ChopperBlankTime
Comparator blank time enumeration.
Definition tmc51x0_types.hpp:692
@ TBL_54CLK
54 clock cycles (~4.5µs @ 12MHz, for high capacitive loads)
@ TBL_36CLK
36 clock cycles (~3.0µs @ 12MHz, typical)
@ TBL_24CLK
24 clock cycles (~2.0µs @ 12MHz)
@ TBL_16CLK
16 clock cycles (~1.33µs @ 12MHz)
EncoderNSensitivity
Encoder N channel sensitivity enumeration.
Definition tmc51x0_types.hpp:2383
EncoderClearMode
Encoder clear mode enumeration.
Definition tmc51x0_types.hpp:2417
MechanicalSystemType
Mechanical system type enumeration.
Definition tmc51x0_types.hpp:259
@ Gearbox
Gearbox reduction.
@ LeadScrew
Lead screw drive.
@ BeltDrive
Belt drive with pulleys.
@ DirectDrive
Direct drive (motor shaft directly connected)
constexpr const char * ToString(MotorDirection d) noexcept
Convert MotorDirection to human-readable string.
Definition tmc51x0_types.hpp:103
ReferenceStopMode
Stop mode enumeration.
Definition tmc51x0_types.hpp:2288
ReferenceLatchMode
Position latching mode enumeration.
Definition tmc51x0_types.hpp:2255
@ DISABLED
No position latching (latch disabled)
MotorType
Motor type enumeration.
Definition tmc51x0_types.hpp:132
@ STEPPER
Stepper motor (default, typically uses step/dir or internal ramp generator)
@ DC_MOTOR_SINGLE
Single DC motor (typically uses direct mode, coil A only)
@ SOLENOID_SINGLE
Single solenoid/actuator (typically uses direct mode, coil A only)
@ SOLENOID_DUAL
Two solenoids/actuators (typically uses direct mode, coil A and B)
@ DC_MOTOR_DUAL
Two DC motors (typically uses direct mode, coil A and B)
DcStepStallSensitivity
DcStep stall detection sensitivity enumeration.
Definition tmc51x0_types.hpp:2096
@ DISABLED
Stall detection disabled (dc_sg = 0)
@ MODERATE
Moderate sensitivity - balanced (dc_sg ≈ dc_time / 16, recommended)
StealthChopJerkReduction
StealthChop mode switching jerk reduction enumeration.
Definition tmc51x0_types.hpp:1205
@ MAXIMUM
Maximum jerk reduction (smoothest switching)
@ MODERATE
Moderate jerk reduction (default, balanced)
@ HIGH
High jerk reduction.
@ MINIMUM
Minimum jerk reduction (fastest switching, may cause spikes)
constexpr uint16_t MicrostepsPerFullStep(MicrostepResolution mres) noexcept
Get microsteps-per-full-step for an MRES value.
Definition tmc51x0_types.hpp:752
Unit
Unit enumeration.
Definition tmc51x0_types.hpp:176
@ Mm
Millimeters (linear only)
@ Rad
Radians (per second for velocity, per second^2 for accel)
@ RevPerSec
Revolutions per Second (recommended default for velocity)
@ Deg
Degrees (per second for velocity, per second^2 for accel)
@ Steps
Steps (see notes above; float APIs treat this as full-steps, register units are microsteps)
@ RPM
Revolutions per Minute (Velocity only, typically)
MotorDirection
Motor direction enumeration.
Definition tmc51x0_types.hpp:95
@ INVERSE
Inverse motor direction.
@ NORMAL
Normal motor direction.
@ BOTH_EDGES
N channel active on N event activation and de-activation.
@ FALLING_EDGE
N channel active when the N event is de-activated.
@ RISING_EDGE
N channel active when the N event is activated.
EncoderPrescalerMode
Encoder prescaler mode enumeration.
Definition tmc51x0_types.hpp:2448
CoolStepDecrementSpeed
CoolStep current decrement speed enumeration.
Definition tmc51x0_types.hpp:1964
@ EVERY_32
Decrement every 32 measurements (slowest reduction, most stable)
@ EVERY_2
Decrement every 2 measurements.
@ EVERY_1
Decrement every measurement (fastest reduction)
@ EVERY_8
Decrement every 8 measurements.
ReferenceSwitchActiveLevel
Reference switch active level enumeration.
Definition tmc51x0_types.hpp:2225
RampMode
Ramp mode enumeration values.
Definition tmc51x0_registers.hpp:32
@ POSITIONING
Positioning mode using all A, D and V parameters.
StealthChopPwmFreq
StealthChop PWM frequency enumeration.
Definition tmc51x0_types.hpp:1168
@ PWM_FREQ_0
fPWM = 2/1024 * fCLK (~23.4kHz @ 12MHz)
@ PWM_FREQ_1
fPWM = 2/683 * fCLK (~35.1kHz @ 12MHz, recommended)
@ PWM_FREQ_3
fPWM = 2/410 * fCLK (~58.5kHz @ 12MHz)
@ PWM_FREQ_2
fPWM = 2/512 * fCLK (~46.9kHz @ 12MHz)
SenseFilterTime
Sense amplifier filter time constant enumeration.
Definition tmc51x0_types.hpp:471
@ T100ns
~100ns (reset default)
StealthChopRegulationSpeed
StealthChop regulation speed enumeration.
Definition tmc51x0_types.hpp:1187
@ SLOW
1 increment per half wave
@ VERY_SLOW
0.5 increments per half wave (slowest, most stable)
@ MODERATE
2 increments per half wave (default, balanced)
@ VERY_FAST
7.5 increments per half wave (fastest, may be less stable)
@ FAST
4 increments per half wave
CoolStepIncrementStep
CoolStep current increment step width enumeration.
Definition tmc51x0_types.hpp:1951
@ STEP_8
Increment by 8 steps per measurement (fastest response)
@ STEP_2
Increment by 2 steps per measurement.
@ STEP_4
Increment by 4 steps per measurement.
@ STEP_1
Increment by 1 step per measurement (slowest, smoothest)
ChipCommMode
Chip communication and motion control mode configuration.
Definition tmc51x0_types.hpp:82
@ SPI_EXTERNAL_STEPDIR
SPI_MODE=HIGH, SD_MODE=HIGH - SPI interface with external step/dir inputs.
@ STANDALONE_EXTERNAL_STEPDIR
SPI_MODE=LOW, SD_MODE=HIGH - Standalone Step/Dir mode (no SPI/UART, CFG pins configure driver)
@ SPI_INTERNAL_RAMP
SPI_MODE=HIGH, SD_MODE=LOW - SPI interface with internal ramp generator (motion controller)
@ UART_INTERNAL_RAMP
SPI_MODE=LOW, SD_MODE=LOW - UART interface with internal ramp generator (motion controller)
StallGuardSensitivity
StallGuard2 sensitivity enumeration.
Definition tmc51x0_types.hpp:1498
@ VERY_HIGH
Very high sensitivity (SGT = -32) - detects stalls very easily.
@ VERY_LOW
Very low sensitivity (SGT = 32) - requires significant torque to detect stall.
PWMFreewheel
PWM freewheel mode enumeration values.
Definition tmc51x0_registers.hpp:42
@ NORMAL
Normal operation.
ChopperMode
Chopper mode enumeration.
Definition tmc51x0_types.hpp:671
@ CLASSIC
Classic constant off-time mode - alternative chopper algorithm.
@ SPREAD_CYCLE
SpreadCycle mode (recommended) - superior microstepping quality.
MicrostepLutPreset
Microstep lookup table preset waveforms.
Definition tmc51x0_types.hpp:767
@ PURE_SINE
Mathematical pure sine wave.
@ DEFAULT_SINE
TMC5160 power-on default (slightly modified sine)
DriverStatus
Driver status enumeration.
Definition tmc51x0_types.hpp:213
@ OT
Overtemperature (error)
@ OTHER_ERR
GSTAT drv_err is set but none of the above conditions is found.
@ S2VSB
Short to supply phase B.
@ CP_UV
Charge pump undervoltage.
@ S2GB
Short to ground phase B.
@ OTPW
Overtemperature pre-warning.
@ S2GA
Short to ground phase A.
@ S2VSA
Short to supply phase A.
Self-describing acceleration value with explicit unit.
Definition tmc51x0_types.hpp:1812
float value
Acceleration magnitude.
Definition tmc51x0_types.hpp:1813
Unit unit
Acceleration unit (per second²)
Definition tmc51x0_types.hpp:1814
constexpr AccelerationValue(float v, Unit u) noexcept
Construct with value and unit.
Definition tmc51x0_types.hpp:1824
static constexpr AccelerationValue FromSteps(float v) noexcept
Definition tmc51x0_types.hpp:1827
static constexpr AccelerationValue FromDeg(float v) noexcept
Definition tmc51x0_types.hpp:1830
static constexpr AccelerationValue FromRevPerSec(float v) noexcept
Definition tmc51x0_types.hpp:1828
static constexpr AccelerationValue FromMm(float v) noexcept
Definition tmc51x0_types.hpp:1831
AccelerationValue()=default
Default constructor.
static constexpr AccelerationValue FromRad(float v) noexcept
Definition tmc51x0_types.hpp:1829
Chopper configuration structure.
Definition tmc51x0_types.hpp:856
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.
Definition tmc51x0_types.hpp:1121
bool diss2vs
Short to supply protection disable.
Definition tmc51x0_types.hpp:1094
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.
Definition tmc51x0_types.hpp:1137
bool diss2g
Short to GND protection disable.
Definition tmc51x0_types.hpp:1079
ChopperMode mode
Chopper mode selection.
Definition tmc51x0_types.hpp:867
bool vhighfs
High velocity fullstep selection.
Definition tmc51x0_types.hpp:1047
uint8_t hend
Hysteresis end value (SpreadCycle mode) or Sine wave offset (Classic mode)
Definition tmc51x0_types.hpp:947
bool intpol
Enable interpolation to 256 microsteps.
Definition tmc51x0_types.hpp:1019
uint8_t toff
Off time (slow decay time) setting.
Definition tmc51x0_types.hpp:891
uint8_t hstrt
Hysteresis start value (SpreadCycle mode only)
Definition tmc51x0_types.hpp:929
bool dedge
Enable double edge step pulses.
Definition tmc51x0_types.hpp:1031
uint8_t tfd
Fast decay time (Classic mode only)
Definition tmc51x0_types.hpp:964
uint8_t tpfd
Passive fast decay time.
Definition tmc51x0_types.hpp:991
bool vhighchm
High velocity chopper mode.
Definition tmc51x0_types.hpp:1064
bool disfdcc
Disable fast decay comparator (Classic mode only)
Definition tmc51x0_types.hpp:977
ChopperConfig()=default
Default constructor.
MicrostepResolution mres
Microstep resolution.
Definition tmc51x0_types.hpp:1006
uint8_t tbl
Comparator blank time.
Definition tmc51x0_types.hpp:908
CoolStep configuration structure.
Definition tmc51x0_types.hpp:1992
float max_velocity
Upper velocity threshold for CoolStep activation.
Definition tmc51x0_types.hpp:2047
uint16_t upper_threshold_sg
Upper StallGuard2 threshold for current decrease.
Definition tmc51x0_types.hpp:2015
bool enable_filter
Enable StallGuard2 filter (reduces measurement rate by 4x)
Definition tmc51x0_types.hpp:2025
CoolStepMinCurrent min_current
Minimum current percentage.
Definition tmc51x0_types.hpp:2022
CoolStepConfig(uint16_t lower_sg, uint16_t upper_sg, float min_vel, float max_vel, Unit vel_unit=Unit::RevPerSec)
Helper constructor for common configuration.
Definition tmc51x0_types.hpp:2079
CoolStepIncrementStep increment_step
Current increment step width.
Definition tmc51x0_types.hpp:2018
uint16_t lower_threshold_sg
Lower StallGuard2 threshold for current increase.
Definition tmc51x0_types.hpp:2003
CoolStepConfig()=default
Default constructor.
CoolStepDecrementSpeed decrement_speed
Current decrement speed.
Definition tmc51x0_types.hpp:2019
Unit velocity_unit
Unit for velocity thresholds.
Definition tmc51x0_types.hpp:2054
float min_velocity
Lower velocity threshold for CoolStep activation.
Definition tmc51x0_types.hpp:2037
DcStep configuration structure.
Definition tmc51x0_types.hpp:2122
DcStepConfig()=default
Default constructor.
float min_velocity
Minimum velocity threshold for DcStep activation.
Definition tmc51x0_types.hpp:2134
DcStepConfig(float min_vel, Unit vel_unit=Unit::RevPerSec, float pwm_time_us=0.0F, DcStepStallSensitivity sensitivity=DcStepStallSensitivity::MODERATE)
Helper constructor for quick setup.
Definition tmc51x0_types.hpp:2204
DcStepStallSensitivity stall_sensitivity
Stall detection sensitivity.
Definition tmc51x0_types.hpp:2171
Unit velocity_unit
Unit for velocity threshold.
Definition tmc51x0_types.hpp:2141
bool stop_on_stall
Enable stop on stall.
Definition tmc51x0_types.hpp:2182
float pwm_on_time_us
PWM on-time limit for commutation (user-friendly)
Definition tmc51x0_types.hpp:2160
DIAG0 pin configuration structure.
Definition tmc51x0_types.hpp:2588
bool pushpull
Bit 12: Output mode (false=open collector active low, true=push pull active high)
Definition tmc51x0_types.hpp:2593
bool error
Bit 5: Enable DIAG0 on driver errors (OT, S2G, UV_CP) - SD_MODE=1 only.
Definition tmc51x0_types.hpp:2589
Diag0Config()=default
Default constructor.
bool otpw
Bit 6: Enable DIAG0 on overtemperature prewarning - SD_MODE=1 only.
Definition tmc51x0_types.hpp:2590
bool stall_step
Bit 7: (SD_MODE=1) DIAG0 on stall, (SD_MODE=0) DIAG0 as STEP output (half frequency,...
Definition tmc51x0_types.hpp:2591
DIAG1 pin configuration structure.
Definition tmc51x0_types.hpp:2613
bool pushpull
Bit 13: Output mode (false=open collector active low, true=push pull active high)
Definition tmc51x0_types.hpp:2618
bool stall_dir
Bit 8: (SD_MODE=1) DIAG1 on stall, (SD_MODE=0) DIAG1 as DIR output.
Definition tmc51x0_types.hpp:2614
bool index
Bit 9: Enable DIAG1 on index position (microstep LUT position 0) - SD_MODE=1 only.
Definition tmc51x0_types.hpp:2615
bool onstate
Bit 10: Enable DIAG1 when chopper is on (second half of fullstep) - SD_MODE=1 only.
Definition tmc51x0_types.hpp:2616
Diag1Config()=default
Default constructor.
bool steps_skipped
Bit 11: Enable output toggle when steps skipped in dcStep mode - SD_MODE=1 only.
Definition tmc51x0_types.hpp:2617
Driver initialization configuration structure.
Definition tmc51x0_types.hpp:2870
RampConfig ramp_config
Ramp generator configuration (with unit support)
Definition tmc51x0_types.hpp:2879
StallGuardConfig stallguard
StallGuard2 configuration (defaults: threshold=0, disabled)
Definition tmc51x0_types.hpp:2886
ExternalClockConfig external_clk_config
External clock configuration (0 = use internal 12 MHz, >0 = external clock frequency)
Definition tmc51x0_types.hpp:2883
UartConfig uart_config
UART communication configuration (node address, send delay)
Definition tmc51x0_types.hpp:2898
CoolStepConfig coolstep
CoolStep configuration (defaults: lower_threshold_sg=0, disabled)
Definition tmc51x0_types.hpp:2887
GlobalConfig global_config
Global configuration (GCONF register)
Definition tmc51x0_types.hpp:2878
ReferenceSwitchConfig reference_switch_config
Reference switch configuration (defaults: stop disabled, latching disabled)
Definition tmc51x0_types.hpp:2894
MotorDirection direction
Motor direction (normal or inverse)
Definition tmc51x0_types.hpp:2875
MotorSpec motor_spec
Motor specifications (physical parameters for automatic current calculation)
Definition tmc51x0_types.hpp:2871
DcStepConfig dcstep
DcStep configuration (defaults: min_velocity=0, disabled)
Definition tmc51x0_types.hpp:2888
DriverConfig() noexcept
Default constructor.
Definition tmc51x0_types.hpp:2909
EncoderConfig encoder_config
Encoder configuration (includes pulses per rev, invert direction, deviation)
Definition tmc51x0_types.hpp:2895
PowerStageParameters power_stage
Power stage configuration (includes short protection)
Definition tmc51x0_types.hpp:2872
MechanicalSystem mechanical
Mechanical system configuration (gearing, leadscrew, etc.) for unit conversions.
Definition tmc51x0_types.hpp:2873
ChopperConfig chopper
Chopper configuration (SpreadCycle or Classic mode)
Definition tmc51x0_types.hpp:2876
StealthChopConfig stealthchop
StealthChop configuration.
Definition tmc51x0_types.hpp:2877
Encoder configuration structure.
Definition tmc51x0_types.hpp:2479
bool ignore_ab_polarity
Definition tmc51x0_types.hpp:2492
uint16_t pulses_per_rev
Encoder pulses per revolution.
Definition tmc51x0_types.hpp:2543
EncoderPrescalerMode prescaler_mode
Encoder prescaler divisor mode (enc_sel_decimal)
Definition tmc51x0_types.hpp:2509
bool invert_direction
Invert encoder direction.
Definition tmc51x0_types.hpp:2555
bool require_a_high
Definition tmc51x0_types.hpp:2488
int32_t allowed_deviation_steps
Allowed encoder deviation in steps.
Definition tmc51x0_types.hpp:2528
ReferenceSwitchActiveLevel n_channel_active
Definition tmc51x0_types.hpp:2482
EncoderClearMode clear_mode
Clear mode for encoder counter on N events.
Definition tmc51x0_types.hpp:2500
bool require_b_high
Definition tmc51x0_types.hpp:2490
EncoderConfig()=default
Default constructor.
EncoderNSensitivity n_sensitivity
N channel event sensitivity (edge/level detection)
Definition tmc51x0_types.hpp:2496
bool clear_enc_x_on_event
Definition tmc51x0_types.hpp:2503
bool latch_xactual_with_enc
Definition tmc51x0_types.hpp:2505
External clock configuration structure.
Definition tmc51x0_types.hpp:2646
ExternalClockConfig()=default
Default constructor.
uint32_t frequency_hz
External clock frequency in Hz.
Definition tmc51x0_types.hpp:2669
Global configuration (GCONF) structure.
Definition tmc51x0_types.hpp:2750
bool en_stealthchop_step_filter
Definition tmc51x0_types.hpp:2759
bool en_stealthchop_mode
Definition tmc51x0_types.hpp:2757
bool enca_dcin_sequencer_stop
Definition tmc51x0_types.hpp:2773
bool invert_direction
Definition tmc51x0_types.hpp:2763
bool en_short_standstill_timeout
Definition tmc51x0_types.hpp:2752
bool direct_mode
Definition tmc51x0_types.hpp:2778
Diag0Config diag0
DIAG0 pin configuration (bits 5, 6, 7, 12)
Definition tmc51x0_types.hpp:2766
bool recalibrate
Bit 0: Zero crossing recalibration during driver disable.
Definition tmc51x0_types.hpp:2751
Diag1Config diag1
DIAG1 pin configuration (bits 8, 9, 10, 11, 13)
Definition tmc51x0_types.hpp:2767
GlobalConfig()=default
Default constructor.
bool en_small_step_frequency_hysteresis
Definition tmc51x0_types.hpp:2769
Cached settings for homing operations.
Definition tmc51x0_types.hpp:2923
bool cached_stealthchop_enabled
Definition tmc51x0_types.hpp:2925
bool ramp_settings_were_modified
Definition tmc51x0_types.hpp:2940
float cached_max_speed
Definition tmc51x0_types.hpp:2934
bool stealthchop_was_modified
Definition tmc51x0_types.hpp:2926
bool sw_mode_was_modified
Definition tmc51x0_types.hpp:2930
SW_MODE_Register cached_sw_mode
Definition tmc51x0_types.hpp:2929
RampMode cached_ramp_mode
Definition tmc51x0_types.hpp:2933
float cached_vstop
Definition tmc51x0_types.hpp:2938
float cached_acceleration
Definition tmc51x0_types.hpp:2935
bool is_valid
Definition tmc51x0_types.hpp:2942
float cached_vstart
Definition tmc51x0_types.hpp:2937
float cached_v1
Definition tmc51x0_types.hpp:2939
float cached_deceleration
Definition tmc51x0_types.hpp:2936
Mechanical system configuration structure.
Definition tmc51x0_types.hpp:290
MechanicalSystem()=default
Default constructor.
float belt_pitch_mm
Belt pitch in mm (for BeltDrive)
Definition tmc51x0_types.hpp:294
uint16_t belt_pulley_teeth
Number of teeth on motor pulley (for BeltDrive)
Definition tmc51x0_types.hpp:293
MechanicalSystemType system_type
Type of mechanical system.
Definition tmc51x0_types.hpp:291
float gear_ratio
Gear ratio (output/input, for Gearbox)
Definition tmc51x0_types.hpp:295
float lead_screw_pitch_mm
Lead screw pitch in mm (for LeadScrew)
Definition tmc51x0_types.hpp:292
Options for changing microstep resolution (CHOPCONF.MRES)
Definition tmc51x0_types.hpp:810
bool preserve_physical_units
Preserve physical meaning of position and motion profile on MRES change.
Definition tmc51x0_types.hpp:820
bool require_standstill
Require standstill before changing MRES.
Definition tmc51x0_types.hpp:828
bool rescale_encoder
Reapply encoder scaling after MRES change (if encoder is configured)
Definition tmc51x0_types.hpp:836
Motor specification structure.
Definition tmc51x0_types.hpp:322
uint16_t steps_per_rev
Definition tmc51x0_types.hpp:329
uint32_t supply_voltage_mv
Motor supply voltage in millivolts (e.g., 24000 for 24V, 0 = not specified)
Definition tmc51x0_types.hpp:341
uint32_t sense_resistor_mohm
Sense resistor value in milliohms (e.g., 50 for 0.05Ω, 0 = not specified)
Definition tmc51x0_types.hpp:340
uint16_t hold_current_ma
Desired hold current in milliamps (0 = auto-calculate as 30% of run)
Definition tmc51x0_types.hpp:337
uint16_t run_current_ma
Desired run current in milliamps (0 = use rated_current_ma)
Definition tmc51x0_types.hpp:336
float irun_adjustment_percent
Percentage adjustment for IRUN calculation.
Definition tmc51x0_types.hpp:369
uint32_t winding_resistance_mohm
Winding resistance in milliohms (required for StealthChop lower limit calc)
Definition tmc51x0_types.hpp:332
float ihold_adjustment_percent
Percentage adjustment for IHOLD calculation.
Definition tmc51x0_types.hpp:383
float scaler_adjustment_percent
Percentage adjustment for GLOBAL_SCALER calculation.
Definition tmc51x0_types.hpp:355
float iholddelay_ms
Total motor power down delay time (IHOLDDELAY)
Definition tmc51x0_types.hpp:444
MotorType motor_type
Definition tmc51x0_types.hpp:324
float winding_inductance_mh
Winding inductance in millihenries (optional, 0 = not specified) (for StealthChop)
Definition tmc51x0_types.hpp:333
MotorSpec()=default
Default constructor.
uint16_t rated_current_ma
Rated motor current in milliamps (RMS)
Definition tmc51x0_types.hpp:331
Power stage parameters structure.
Definition tmc51x0_types.hpp:500
float mosfet_miller_charge_nc
MOSFET Miller charge in nanocoulombs (used to calculate DRVSTRENGTH)
Definition tmc51x0_types.hpp:519
OverTempProtection over_temp_protection
Over-temperature protection level for bridge disable.
Definition tmc51x0_types.hpp:569
uint16_t s2vs_voltage_mv
Short to VS detector voltage threshold in millivolts.
Definition tmc51x0_types.hpp:588
uint32_t bbm_time_ns
Break Before Make time in nanoseconds.
Definition tmc51x0_types.hpp:549
SenseFilterTime sense_filter
Sense amplifier filter time constant.
Definition tmc51x0_types.hpp:559
PowerStageParameters()=default
Default constructor.
uint16_t s2g_voltage_mv
Short to GND detector voltage threshold in millivolts.
Definition tmc51x0_types.hpp:608
uint8_t shortfilter
Spike filtering bandwidth for short detection (0-3)
Definition tmc51x0_types.hpp:619
uint8_t short_detection_delay_us_x10
Short detection delay in microseconds (0.1µs resolution)
Definition tmc51x0_types.hpp:638
Ramp configuration structure.
Definition tmc51x0_types.hpp:1855
RampConfig()=default
Default constructor.
VelocityValue vstart
Start velocity (0 = can be set to zero if not used)
Definition tmc51x0_types.hpp:1857
AccelerationValue dmax
Maximum deceleration (used above V1, 0 = uses AMAX value)
Definition tmc51x0_types.hpp:1865
float tzerowait_ms
Velocity-zero wait time (TZEROWAIT)
Definition tmc51x0_types.hpp:1918
AccelerationValue a1
First acceleration (used between VSTART and V1, 0 = use AMAX)
Definition tmc51x0_types.hpp:1864
float tpowerdown_ms
Definition tmc51x0_types.hpp:1869
AccelerationValue amax
Maximum acceleration (used above V1, 0 = must be set via SetAcceleration() before motion)
Definition tmc51x0_types.hpp:1863
VelocityValue v1
Transition velocity (switches between A1/AMAX and D1/DMAX, 0 = disabled)
Definition tmc51x0_types.hpp:1860
VelocityValue vstop
Stop velocity (must be >= VSTART, minimum 1 recommended)
Definition tmc51x0_types.hpp:1858
VelocityValue vmax
Maximum velocity (0 = must be set via SetMaxSpeed() before motion)
Definition tmc51x0_types.hpp:1859
AccelerationValue d1
First deceleration (used between VSTOP and V1, must not be 0 in positioning mode)
Definition tmc51x0_types.hpp:1866
Reference switch configuration structure.
Definition tmc51x0_types.hpp:2327
ReferenceSwitchConfig()=default
Default constructor.
ReferenceStopMode stop_mode
Stop mode (hard or soft) - only applies if stop is enabled.
Definition tmc51x0_types.hpp:2350
bool en_latch_encoder
Latch encoder position on switch event (for encoder N-channel as third switch)
Definition tmc51x0_types.hpp:2357
ReferenceLatchMode latch_right
Right switch latching mode (must be explicitly set)
Definition tmc51x0_types.hpp:2356
ReferenceLatchMode latch_left
Left switch latching mode (must be explicitly set)
Definition tmc51x0_types.hpp:2355
ReferenceSwitchActiveLevel right_switch_active
Definition tmc51x0_types.hpp:2335
bool right_switch_stop_enable
Definition tmc51x0_types.hpp:2345
ReferenceSwitchActiveLevel left_switch_active
Definition tmc51x0_types.hpp:2331
bool swap_left_right
Swap left and right switch inputs (useful for reversed wiring)
Definition tmc51x0_types.hpp:2352
bool left_switch_stop_enable
Definition tmc51x0_types.hpp:2342
StallGuard2 configuration structure.
Definition tmc51x0_types.hpp:1519
StallGuardConfig()=default
Default constructor.
StallGuardConfig(StallGuardSensitivity sensitivity, bool enable_filt=false, float min_vel=0.0F, float max_vel=0.0F, Unit vel_unit=Unit::Steps, bool stop_on_stall=false)
Helper constructor using sensitivity enum.
Definition tmc51x0_types.hpp:1624
bool enable_filter
Enable StallGuard2 filter.
Definition tmc51x0_types.hpp:1548
float min_velocity
Lower velocity threshold for StallGuard2 operation.
Definition tmc51x0_types.hpp:1560
bool stop_on_stall
Stop motor when stall detected.
Definition tmc51x0_types.hpp:1590
Unit velocity_unit
Unit for velocity thresholds.
Definition tmc51x0_types.hpp:1578
float max_velocity
Upper velocity threshold for StallGuard2 operation.
Definition tmc51x0_types.hpp:1571
StallGuardConfig(int8_t sgt_threshold, bool enable_filt=false, float min_vel=0.0F, float max_vel=0.0F, Unit vel_unit=Unit::RevPerSec, bool stop_on_stall=false)
Helper constructor for quick setup.
Definition tmc51x0_types.hpp:1614
int8_t threshold
StallGuard2 threshold value.
Definition tmc51x0_types.hpp:1534
Result structure for StallGuard2 threshold (SGT) tuning.
Definition tmc51x0_types.hpp:1644
StallGuardTuningResult()=default
Default constructor.
int8_t max_velocity_sgt
SGT value that works at maximum velocity (if requested)
Definition tmc51x0_types.hpp:1693
float actual_min_velocity
Actual minimum velocity that works with optimal SGT.
Definition tmc51x0_types.hpp:1713
bool max_velocity_success
Whether max velocity verification succeeded.
Definition tmc51x0_types.hpp:1701
int8_t optimal_sgt
Optimal SGT value found at target velocity.
Definition tmc51x0_types.hpp:1655
uint16_t min_velocity_sg_result
SG_RESULT value at min velocity (if verified)
Definition tmc51x0_types.hpp:1743
float actual_max_velocity
Actual maximum velocity that works with optimal SGT.
Definition tmc51x0_types.hpp:1725
uint16_t max_velocity_sg_result
SG_RESULT value at max velocity (if verified)
Definition tmc51x0_types.hpp:1751
bool tuning_success
Whether tuning succeeded at target velocity.
Definition tmc51x0_types.hpp:1663
uint16_t target_velocity_sg_result
SG_RESULT value at target velocity with optimal SGT.
Definition tmc51x0_types.hpp:1735
bool min_velocity_success
Whether min velocity verification succeeded.
Definition tmc51x0_types.hpp:1682
int8_t min_velocity_sgt
SGT value that works at minimum velocity (if requested)
Definition tmc51x0_types.hpp:1674
StealthChop configuration structure.
Definition tmc51x0_types.hpp:1234
uint8_t pwm_ofs
PWM amplitude offset.
Definition tmc51x0_types.hpp:1256
Unit velocity_threshold_unit
Unit for velocity threshold.
Definition tmc51x0_types.hpp:1417
uint8_t pwm_grad
PWM amplitude gradient.
Definition tmc51x0_types.hpp:1273
StealthChopConfig(uint8_t pwm_frequency, uint8_t pwm_offset, uint8_t pwm_gradient)
Helper constructor for manual mode.
Definition tmc51x0_types.hpp:1479
float velocity_threshold
StealthChop velocity threshold (TPWMTHRS)
Definition tmc51x0_types.hpp:1410
StealthChopConfig()=default
Default constructor.
bool pwm_autoscale
Enable automatic current scaling.
Definition tmc51x0_types.hpp:1314
uint8_t pwm_freq
PWM frequency selection.
Definition tmc51x0_types.hpp:1293
uint8_t pwm_reg
Regulation speed.
Definition tmc51x0_types.hpp:1356
PWMFreewheel freewheel
Freewheeling mode when I_HOLD=0.
Definition tmc51x0_types.hpp:1393
StealthChopConfig(StealthChopPwmFreq pwm_frequency, StealthChopRegulationSpeed regulation_speed=StealthChopRegulationSpeed::MODERATE, StealthChopJerkReduction jerk_reduction=StealthChopJerkReduction::MODERATE, uint8_t pwm_offset=30, uint8_t pwm_gradient=0)
Helper constructor using enums (most intuitive)
Definition tmc51x0_types.hpp:1462
StealthChopConfig(uint8_t pwm_frequency, uint8_t pwm_offset=30, uint8_t pwm_gradient=0, uint8_t regulation_speed=4, uint8_t jerk_reduction=12)
Helper constructor for automatic tuning mode.
Definition tmc51x0_types.hpp:1446
uint8_t pwm_lim
Mode switching jerk reduction.
Definition tmc51x0_types.hpp:1375
bool pwm_autograd
Enable automatic gradient adaptation.
Definition tmc51x0_types.hpp:1332
UART communication configuration structure.
Definition tmc51x0_types.hpp:2695
uint8_t node_address
UART node address.
Definition tmc51x0_types.hpp:2710
uint8_t send_delay
UART send delay.
Definition tmc51x0_types.hpp:2726
UartConfig()=default
Default constructor.
Self-describing velocity value with explicit unit.
Definition tmc51x0_types.hpp:1778
static constexpr VelocityValue FromSteps(float v) noexcept
Definition tmc51x0_types.hpp:1793
static constexpr VelocityValue FromRPM(float v) noexcept
Definition tmc51x0_types.hpp:1794
static constexpr VelocityValue FromRevPerSec(float v) noexcept
Definition tmc51x0_types.hpp:1795
float value
Velocity magnitude.
Definition tmc51x0_types.hpp:1779
static constexpr VelocityValue FromDeg(float v) noexcept
Definition tmc51x0_types.hpp:1797
VelocityValue()=default
Default constructor.
static constexpr VelocityValue FromMm(float v) noexcept
Definition tmc51x0_types.hpp:1798
static constexpr VelocityValue FromRad(float v) noexcept
Definition tmc51x0_types.hpp:1796
constexpr VelocityValue(float v, Unit u) noexcept
Construct with value and unit.
Definition tmc51x0_types.hpp:1790
Unit unit
Velocity unit.
Definition tmc51x0_types.hpp:1780
Register definitions and bitfield structures for TMC51x0 stepper motor.
Switch mode configuration register (SW_MODE)
Definition tmc51x0_registers.hpp:490