Fluent configuration builder for DriverConfig.
Definition tmc51x0_config_builder.hpp:87
ConfigBuilder & WithFirstDeceleration(const AccelerationValue &deceleration)
Set first deceleration phase.
Definition tmc51x0_config_builder.hpp:722
ConfigBuilder & WithRampPowerDownDelayMs(float delay_ms)
Set ramp power down delay.
Definition tmc51x0_config_builder.hpp:736
ConfigBuilder & WithStallGuardThreshold(int8_t threshold)
Set StallGuard2 threshold (SGT)
Definition tmc51x0_config_builder.hpp:516
ConfigBuilder & WithLeadScrew(float pitch_mm)
Configure lead screw system.
Definition tmc51x0_config_builder.hpp:812
ConfigBuilder & WithShortFilter(uint8_t filter)
Set short detection filter bandwidth.
Definition tmc51x0_config_builder.hpp:310
ConfigBuilder & WithHysteresisEnd(uint8_t hend)
Set hysteresis end value (SpreadCycle mode)
Definition tmc51x0_config_builder.hpp:378
ConfigBuilder & WithMaxSpeed(const VelocityValue &velocity)
Set maximum velocity.
Definition tmc51x0_config_builder.hpp:640
ConfigBuilder & WithShortDetectionDelayUsX10(uint8_t delay_us_x10)
Set short detection delay.
Definition tmc51x0_config_builder.hpp:321
ConfigBuilder & WithStealthChopPwmOfs(uint8_t ofs)
Set StealthChop PWM offset.
Definition tmc51x0_config_builder.hpp:471
ConfigBuilder & WithS2gVoltageMv(uint16_t voltage_mv)
Set short to GND detector voltage threshold.
Definition tmc51x0_config_builder.hpp:299
ConfigBuilder & WithWindingInductanceMh(float inductance_mh)
Set winding inductance value.
Definition tmc51x0_config_builder.hpp:203
ConfigBuilder & WithHoldCurrentMa(uint16_t hold_current_ma)
Set hold current value.
Definition tmc51x0_config_builder.hpp:145
ConfigBuilder & WithVelocityThreshold(const VelocityValue &velocity)
Set velocity threshold for acceleration/deceleration phase transition.
Definition tmc51x0_config_builder.hpp:700
ConfigBuilder & WithStealthChop(bool enable)
Enable/disable StealthChop.
Definition tmc51x0_config_builder.hpp:435
DriverConfig Build() const
Build the final configuration.
Definition tmc51x0_config_builder.hpp:863
DriverConfig & Config()
Get mutable reference to config for advanced customization.
Definition tmc51x0_config_builder.hpp:875
ConfigBuilder & WithMicrostepResolution(MicrostepResolution mres)
Set microstep resolution.
Definition tmc51x0_config_builder.hpp:411
ConfigBuilder & WithMotorMa(uint16_t steps_per_rev, uint16_t rated_current_ma)
Configure motor specifications.
Definition tmc51x0_config_builder.hpp:122
ConfigBuilder & WithS2vsVoltageMv(uint16_t voltage_mv)
Set short to VS detector voltage threshold.
Definition tmc51x0_config_builder.hpp:288
ConfigBuilder & WithMotorPowerDownDelayMs(float delay_ms)
Set motor power down delay time.
Definition tmc51x0_config_builder.hpp:218
ConfigBuilder(const DriverConfig &cfg)
Construct from existing config.
Definition tmc51x0_config_builder.hpp:105
ConfigBuilder & WithStallGuardMaxVelocity(float velocity, Unit unit=Unit::RPM)
Set StallGuard2 maximum velocity threshold.
Definition tmc51x0_config_builder.hpp:564
ConfigBuilder & WithStallGuard(const StallGuardConfig &sg_config)
Configure StallGuard2 with a complete config struct.
Definition tmc51x0_config_builder.hpp:587
ConfigBuilder & WithFastDecayTime(uint8_t tfd)
Set fast decay time (Classic mode only)
Definition tmc51x0_config_builder.hpp:389
ConfigBuilder & WithInternalClock()
Use internal clock (12MHz)
Definition tmc51x0_config_builder.hpp:759
ConfigBuilder & WithStealthChopAutoscale(bool enable)
Enable/disable StealthChop PWM autoscale.
Definition tmc51x0_config_builder.hpp:482
ConfigBuilder & WithExternalClockHz(uint32_t frequency_hz)
Use external clock.
Definition tmc51x0_config_builder.hpp:770
ConfigBuilder & WithDirectDrive()
Configure direct drive system.
Definition tmc51x0_config_builder.hpp:782
ConfigBuilder & WithRecalibration(bool enable)
Enable/disable recalibration.
Definition tmc51x0_config_builder.hpp:600
ConfigBuilder & WithStallGuardMinVelocity(float velocity, Unit unit=Unit::RPM)
Set StallGuard2 minimum velocity threshold.
Definition tmc51x0_config_builder.hpp:549
ConfigBuilder & WithChopperToff(uint8_t toff)
Set chopper off-time (TOFF)
Definition tmc51x0_config_builder.hpp:345
ConfigBuilder & WithGearbox(float gear_ratio)
Configure gearbox system.
Definition tmc51x0_config_builder.hpp:797
ConfigBuilder & WithInterpolation(bool enable)
Enable/disable interpolation.
Definition tmc51x0_config_builder.hpp:422
DriverConfig config_
Definition tmc51x0_config_builder.hpp:89
ConfigBuilder & WithOverTempProtection(OverTempProtection protection)
Set over-temperature protection level.
Definition tmc51x0_config_builder.hpp:277
ConfigBuilder & WithMosfetMillerChargeNc(float charge_nc)
Set MOSFET Miller charge.
Definition tmc51x0_config_builder.hpp:244
ConfigBuilder & WithStealthChopStepFilter(bool enable)
Enable/disable StealthChop step filter.
Definition tmc51x0_config_builder.hpp:622
ConfigBuilder & WithHysteresisStart(uint8_t hstrt)
Set hysteresis start value (SpreadCycle mode)
Definition tmc51x0_config_builder.hpp:367
ConfigBuilder & WithAcceleration(const AccelerationValue &acceleration)
Set maximum acceleration.
Definition tmc51x0_config_builder.hpp:656
ConfigBuilder & WithDirection(MotorDirection direction)
Set motor direction.
Definition tmc51x0_config_builder.hpp:845
ConfigBuilder()=default
Default constructor.
ConfigBuilder & WithStealthChopAutograd(bool enable)
Enable/disable StealthChop PWM autograd.
Definition tmc51x0_config_builder.hpp:493
ConfigBuilder & WithStopSpeed(const VelocityValue &velocity)
Set stop velocity.
Definition tmc51x0_config_builder.hpp:689
ConfigBuilder & WithRunCurrentMa(uint16_t run_current_ma)
Set run current value.
Definition tmc51x0_config_builder.hpp:134
ConfigBuilder & WithSenseResistorMohm(uint32_t resistance_mohm)
Set sense resistor value.
Definition tmc51x0_config_builder.hpp:177
ConfigBuilder & WithShortStandstillTimeout(bool enable)
Enable/disable short standstill timeout.
Definition tmc51x0_config_builder.hpp:611
ConfigBuilder & WithWindingResistanceMohm(uint32_t resistance_mohm)
Set winding resistance value.
Definition tmc51x0_config_builder.hpp:190
ConfigBuilder & WithPassiveFastDecayTime(uint8_t tpfd)
Set passive fast decay time.
Definition tmc51x0_config_builder.hpp:400
ConfigBuilder & WithBeltDrive(uint16_t pulley_teeth, float belt_pitch_mm)
Configure belt drive system.
Definition tmc51x0_config_builder.hpp:828
ConfigBuilder & WithStallGuardFilter(bool enable)
Enable/disable StallGuard2 filter.
Definition tmc51x0_config_builder.hpp:530
ConfigBuilder & WithStealthChopPwmFreq(uint8_t freq)
Set StealthChop PWM frequency.
Definition tmc51x0_config_builder.hpp:460
const DriverConfig & Config() const
Get const reference to config.
Definition tmc51x0_config_builder.hpp:884
ConfigBuilder & WithFirstAcceleration(const AccelerationValue &acceleration)
Set first acceleration phase.
Definition tmc51x0_config_builder.hpp:711
ConfigBuilder & WithChopperMode(ChopperMode mode)
Set chopper mode.
Definition tmc51x0_config_builder.hpp:334
ConfigBuilder & WithStealthChopThreshold(const VelocityValue &velocity)
Set StealthChop threshold velocity.
Definition tmc51x0_config_builder.hpp:448
ConfigBuilder & WithStepsPerRevolution(uint16_t steps)
Set steps per revolution.
Definition tmc51x0_config_builder.hpp:229
ConfigBuilder & WithStartSpeed(const VelocityValue &velocity)
Set start velocity.
Definition tmc51x0_config_builder.hpp:678
ConfigBuilder & WithSupplyVoltageMv(uint32_t voltage_mv)
Set supply voltage value.
Definition tmc51x0_config_builder.hpp:160
ConfigBuilder & WithZeroWaitTimeMs(float wait_ms)
Set zero velocity wait time.
Definition tmc51x0_config_builder.hpp:747
ConfigBuilder & WithChopperBlankTime(ChopperBlankTime blank_time)
Set chopper blank time.
Definition tmc51x0_config_builder.hpp:356
ConfigBuilder & WithBbmTimeNs(uint32_t time_ns)
Set Break Before Make time.
Definition tmc51x0_config_builder.hpp:255
ConfigBuilder & WithSenseFilter(SenseFilterTime filter_time)
Set sense amplifier filter time.
Definition tmc51x0_config_builder.hpp:266
ConfigBuilder & WithDeceleration(const AccelerationValue &deceleration)
Set maximum deceleration.
Definition tmc51x0_config_builder.hpp:667
Definition tmc51x0_register_defs.cpp:10
MicrostepResolution
Microstep resolution enumeration.
Definition tmc51x0_types.hpp:707
OverTempProtection
Over-temperature protection level enumeration.
Definition tmc51x0_types.hpp:486
ChopperBlankTime
Comparator blank time enumeration.
Definition tmc51x0_types.hpp:692
@ Gearbox
Gearbox reduction.
@ LeadScrew
Lead screw drive.
@ BeltDrive
Belt drive with pulleys.
@ DirectDrive
Direct drive (motor shaft directly connected)
Unit
Unit enumeration.
Definition tmc51x0_types.hpp:176
@ RPM
Revolutions per Minute (Velocity only, typically)
MotorDirection
Motor direction enumeration.
Definition tmc51x0_types.hpp:95
SenseFilterTime
Sense amplifier filter time constant enumeration.
Definition tmc51x0_types.hpp:471
ChopperMode
Chopper mode enumeration.
Definition tmc51x0_types.hpp:671
Self-describing acceleration value with explicit unit.
Definition tmc51x0_types.hpp:1812
ChopperMode mode
Chopper mode selection.
Definition tmc51x0_types.hpp:867
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
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
MicrostepResolution mres
Microstep resolution.
Definition tmc51x0_types.hpp:1006
uint8_t tbl
Comparator blank time.
Definition tmc51x0_types.hpp:908
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
GlobalConfig global_config
Global configuration (GCONF register)
Definition tmc51x0_types.hpp:2878
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
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
uint32_t frequency_hz
External clock frequency in Hz.
Definition tmc51x0_types.hpp:2669
bool en_stealthchop_step_filter
Definition tmc51x0_types.hpp:2759
bool en_stealthchop_mode
Definition tmc51x0_types.hpp:2757
bool en_short_standstill_timeout
Definition tmc51x0_types.hpp:2752
bool recalibrate
Bit 0: Zero crossing recalibration during driver disable.
Definition tmc51x0_types.hpp:2751
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
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
uint32_t winding_resistance_mohm
Winding resistance in milliohms (required for StealthChop lower limit calc)
Definition tmc51x0_types.hpp:332
float iholddelay_ms
Total motor power down delay time (IHOLDDELAY)
Definition tmc51x0_types.hpp:444
float winding_inductance_mh
Winding inductance in millihenries (optional, 0 = not specified) (for StealthChop)
Definition tmc51x0_types.hpp:333
uint16_t rated_current_ma
Rated motor current in milliamps (RMS)
Definition tmc51x0_types.hpp:331
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
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
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
StallGuard2 configuration structure.
Definition tmc51x0_types.hpp:1519
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
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
int8_t threshold
StallGuard2 threshold value.
Definition tmc51x0_types.hpp:1534
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
float velocity_threshold
StealthChop velocity threshold (TPWMTHRS)
Definition tmc51x0_types.hpp:1410
bool pwm_autoscale
Enable automatic current scaling.
Definition tmc51x0_types.hpp:1314
uint8_t pwm_freq
PWM frequency selection.
Definition tmc51x0_types.hpp:1293
bool pwm_autograd
Enable automatic gradient adaptation.
Definition tmc51x0_types.hpp:1332
Self-describing velocity value with explicit unit.
Definition tmc51x0_types.hpp:1778
float value
Velocity magnitude.
Definition tmc51x0_types.hpp:1779
Unit unit
Velocity unit.
Definition tmc51x0_types.hpp:1780
Type definitions and enumerations for TMC51x0 stepper motor driver (TMC5130 & TMC5160)