|
HF-TMC51x0 Driver (TMC5130 & TMC5160) 0.1.0-dev
Hardware Agnostic C++ Driver for the TMC51x0 (TMC5130 & TMC5160)
|
Motor specification structure. More...
#include <tmc51x0_types.hpp>
Public Member Functions | |
| MotorSpec ()=default | |
| Default constructor. | |
Public Attributes | |
| MotorType | motor_type {MotorType::STEPPER} |
| uint16_t | steps_per_rev {200} |
| uint16_t | rated_current_ma {1500} |
| Rated motor current in milliamps (RMS) | |
| uint32_t | winding_resistance_mohm {3} |
| Winding resistance in milliohms (required for StealthChop lower limit calc) | |
| float | winding_inductance_mh {0.0F} |
| Winding inductance in millihenries (optional, 0 = not specified) (for StealthChop) | |
| uint16_t | run_current_ma {0} |
| Desired run current in milliamps (0 = use rated_current_ma) | |
| uint16_t | hold_current_ma {0} |
| Desired hold current in milliamps (0 = auto-calculate as 30% of run) | |
| uint32_t | sense_resistor_mohm {50} |
| Sense resistor value in milliohms (e.g., 50 for 0.05Ω, 0 = not specified) | |
| uint32_t | supply_voltage_mv {24000} |
| Motor supply voltage in millivolts (e.g., 24000 for 24V, 0 = not specified) | |
| float | scaler_adjustment_percent {0.0F} |
| Percentage adjustment for GLOBAL_SCALER calculation. | |
| float | irun_adjustment_percent {0.0F} |
| Percentage adjustment for IRUN calculation. | |
| float | ihold_adjustment_percent {0.0F} |
| Percentage adjustment for IHOLD calculation. | |
| float | iholddelay_ms {100.0F} |
| Total motor power down delay time (IHOLDDELAY) | |
Motor specification structure.
High-level motor specifications for easy setup from physical parameters. Includes motor electrical specs and driver hardware configuration (sense resistor, supply voltage). Current settings (IRUN, IHOLD, GLOBAL_SCALER) can be automatically calculated from these parameters.
|
default |
Default constructor.
Initializes with common NEMA 17 motor defaults. Sense resistor defaults to 50mΩ (0.05Ω) which is common on TMC51x0 boards. Supply voltage defaults to 24V which is common for stepper motors. Current settings (IRUN, IHOLD, GLOBAL_SCALER) are automatically calculated during initialization.
| uint16_t tmc51x0::MotorSpec::hold_current_ma {0} |
Desired hold current in milliamps (0 = auto-calculate as 30% of run)
| float tmc51x0::MotorSpec::ihold_adjustment_percent {0.0F} |
Percentage adjustment for IHOLD calculation.
Applied after IHOLD is calculated but before constraining to valid range (0-31). Allows fine-tuning the calculated hold current.
Range: -50.0 to +50.0 (percentage) Example: -10.0 means decrease calculated IHOLD by 10%
| float tmc51x0::MotorSpec::iholddelay_ms {100.0F} |
Total motor power down delay time (IHOLDDELAY)
Controls the total delay time for motor power down after motion as soon as standstill is detected (stst=1) and TPOWERDOWN has expired. The smooth transition avoids a motor jerk upon power down.
How Motor Power Down Works:
The motor current is reduced in steps: IRUN → (IRUN-1) → (IRUN-2) → ... → IHOLD
Example: IRUN=31, IHOLD=16, desired total delay=500ms, f_clk=12MHz
Calculation Formula:
The register value (0-15) is calculated from the desired total delay:
Important Notes:
Typical Total Delay Ranges:
| Clock Frequency | Typical Total Delay Range | Notes |
|---|---|---|
| 8 MHz | 0-500 ms | For IRUN=31, IHOLD=16: 0-491ms |
| 12 MHz | 0-500 ms | For IRUN=31, IHOLD=16: 0-328ms |
| 16 MHz | 0-500 ms | For IRUN=31, IHOLD=16: 0-246ms |
| 24 MHz | 0-500 ms | For IRUN=31, IHOLD=16: 0-164ms |
Usage Guidelines:
Note on Resolution: The delay time is quantized to discrete register values (0-15) per step. The actual total delay depends on (IRUN - IHOLD) and may differ from the desired value.
| float tmc51x0::MotorSpec::irun_adjustment_percent {0.0F} |
Percentage adjustment for IRUN calculation.
Applied after IRUN is calculated but before constraining to valid range (0-31). Allows fine-tuning the calculated run current.
Range: -50.0 to +50.0 (percentage) Example: +5.0 means increase calculated IRUN by 5%
| MotorType tmc51x0::MotorSpec::motor_type {MotorType::STEPPER} |
Motor type (stepper, DC motor, or solenoid) Used for documentation. Direct mode can be enabled for any motor type via global_config.direct_mode
| uint16_t tmc51x0::MotorSpec::rated_current_ma {1500} |
Rated motor current in milliamps (RMS)
| uint16_t tmc51x0::MotorSpec::run_current_ma {0} |
Desired run current in milliamps (0 = use rated_current_ma)
| float tmc51x0::MotorSpec::scaler_adjustment_percent {0.0F} |
Percentage adjustment for GLOBAL_SCALER calculation.
Applied after GLOBAL_SCALER is calculated but before constraining to valid range (32-256). Allows fine-tuning the calculated current scaling value.
Range: -50.0 to +50.0 (percentage) Example: +10.0 means increase calculated GLOBAL_SCALER by 10%
| uint32_t tmc51x0::MotorSpec::sense_resistor_mohm {50} |
Sense resistor value in milliohms (e.g., 50 for 0.05Ω, 0 = not specified)
| uint16_t tmc51x0::MotorSpec::steps_per_rev {200} |
Steps per revolution (typically 200 for 1.8° motors) Not used for DC motors/solenoids (set to 0 or ignore)
| uint32_t tmc51x0::MotorSpec::supply_voltage_mv {24000} |
Motor supply voltage in millivolts (e.g., 24000 for 24V, 0 = not specified)
| float tmc51x0::MotorSpec::winding_inductance_mh {0.0F} |
Winding inductance in millihenries (optional, 0 = not specified) (for StealthChop)
| uint32_t tmc51x0::MotorSpec::winding_resistance_mohm {3} |
Winding resistance in milliohms (required for StealthChop lower limit calc)