|
HF-TMC51x0 Driver (TMC5130 & TMC5160) 0.1.0-dev
Hardware Agnostic C++ Driver for the TMC51x0 (TMC5130 & TMC5160)
|
Driver initialization configuration structure. More...
#include <tmc51x0_types.hpp>
Public Member Functions | |
| DriverConfig () noexcept | |
| Default constructor. | |
Public Attributes | |
| MotorSpec | motor_spec {} |
| Motor specifications (physical parameters for automatic current calculation) | |
| PowerStageParameters | power_stage {} |
| Power stage configuration (includes short protection) | |
| MechanicalSystem | mechanical {} |
| Mechanical system configuration (gearing, leadscrew, etc.) for unit conversions. | |
| MotorDirection | direction {MotorDirection::NORMAL} |
| Motor direction (normal or inverse) | |
| ChopperConfig | chopper {} |
| Chopper configuration (SpreadCycle or Classic mode) | |
| StealthChopConfig | stealthchop {} |
| StealthChop configuration. | |
| GlobalConfig | global_config {} |
| Global configuration (GCONF register) | |
| RampConfig | ramp_config {} |
| Ramp generator configuration (with unit support) | |
| ExternalClockConfig | external_clk_config {} |
| External clock configuration (0 = use internal 12 MHz, >0 = external clock frequency) | |
| StallGuardConfig | stallguard {} |
| StallGuard2 configuration (defaults: threshold=0, disabled) | |
| CoolStepConfig | coolstep {} |
| CoolStep configuration (defaults: lower_threshold_sg=0, disabled) | |
| DcStepConfig | dcstep {} |
| DcStep configuration (defaults: min_velocity=0, disabled) | |
| ReferenceSwitchConfig | reference_switch_config {} |
| Reference switch configuration (defaults: stop disabled, latching disabled) | |
| EncoderConfig | encoder_config {} |
| Encoder configuration (includes pulses per rev, invert direction, deviation) | |
| UartConfig | uart_config {} |
| UART communication configuration (node address, send delay) | |
Driver initialization configuration structure.
Complete configuration structure for initializing the TMC5160 driver. Contains all necessary parameters for power stage, motor, and driver operation.
IRUN, IHOLD, and GLOBAL_SCALER are automatically calculated from motor_spec parameters during Initialize(). These values are stored internally and NOT in motor_spec.
Required Parameters for automatic calculation:
motor_spec.sense_resistor_mohm (e.g., 50 for 0.05Ω) - MUST be non-zeromotor_spec.supply_voltage_mv (e.g., 24000 for 24V) - MUST be non-zeromotor_spec.rated_current_ma or motor_spec.run_current_ma (if run_current_ma=0, uses rated_current_ma)Optional Parameters:
motor_spec.winding_resistance_mohm (for StealthChop lower limit validation)motor_spec.winding_inductance_mh (for motor characterization)motor_spec.hold_current_ma (if 0, auto-calculates as 30% of run current)motor_spec.scaler_adjustment_percent, irun_adjustment_percent, ihold_adjustment_percent (for fine-tuning)DO NOT manually set IRUN, IHOLD, or GLOBAL_SCALER - they are calculated automatically.
f_clk is automatically calculated from external_clk_config during Initialize(). The actual clock frequency used for timing calculations (f_clk) is determined internally:
external_clk_config.frequency_hz > 0: f_clk = external_clk_config.frequency_hz (external clock)external_clk_config.frequency_hz == 0: f_clk = 12 MHz (internal clock, default)Clock Mode Selection:
external_clk_config.frequency_hz = 0 (or leave default)external_clk_config.frequency_hz to desired frequencyDO NOT manually set f_clk - it is calculated automatically from external_clk_config.
For ESP32 examples, use helper functions from esp32_tmc5160_test_config.hpp:
ConfigureDriverFromMotor_17HS4401S_Gearbox(cfg)ConfigureDriverFromMotor_17HS4401S_Direct(cfg)ConfigureDriverFromMotor_AppliedMotion_5034(cfg)These functions automatically configure all parameters from compile-time motor/platform specifications.
See tmc5160_motor_calc.hpp for calculation details. See docs/configuration.md for configuration guide.
|
inlinenoexcept |
Default constructor.
Initializes with recommended default values. Motor current settings (IRUN, IHOLD, GLOBAL_SCALER) are calculated automatically during Initialize() if motor_spec.sense_resistor_mohm and motor_spec.supply_voltage_mv are set.
All configurations use safe defaults (disabled/not configured where applicable).
| ChopperConfig tmc51x0::DriverConfig::chopper {} |
Chopper configuration (SpreadCycle or Classic mode)
| CoolStepConfig tmc51x0::DriverConfig::coolstep {} |
CoolStep configuration (defaults: lower_threshold_sg=0, disabled)
| DcStepConfig tmc51x0::DriverConfig::dcstep {} |
DcStep configuration (defaults: min_velocity=0, disabled)
| MotorDirection tmc51x0::DriverConfig::direction {MotorDirection::NORMAL} |
Motor direction (normal or inverse)
| EncoderConfig tmc51x0::DriverConfig::encoder_config {} |
Encoder configuration (includes pulses per rev, invert direction, deviation)
| ExternalClockConfig tmc51x0::DriverConfig::external_clk_config {} |
External clock configuration (0 = use internal 12 MHz, >0 = external clock frequency)
| GlobalConfig tmc51x0::DriverConfig::global_config {} |
Global configuration (GCONF register)
| MechanicalSystem tmc51x0::DriverConfig::mechanical {} |
Mechanical system configuration (gearing, leadscrew, etc.) for unit conversions.
| MotorSpec tmc51x0::DriverConfig::motor_spec {} |
Motor specifications (physical parameters for automatic current calculation)
| PowerStageParameters tmc51x0::DriverConfig::power_stage {} |
Power stage configuration (includes short protection)
| RampConfig tmc51x0::DriverConfig::ramp_config {} |
Ramp generator configuration (with unit support)
| ReferenceSwitchConfig tmc51x0::DriverConfig::reference_switch_config {} |
Reference switch configuration (defaults: stop disabled, latching disabled)
| StallGuardConfig tmc51x0::DriverConfig::stallguard {} |
StallGuard2 configuration (defaults: threshold=0, disabled)
| StealthChopConfig tmc51x0::DriverConfig::stealthchop {} |
StealthChop configuration.
| UartConfig tmc51x0::DriverConfig::uart_config {} |
UART communication configuration (node address, send delay)