|
HF-TMC51x0 Driver (TMC5130 & TMC5160) 0.1.0-dev
Hardware Agnostic C++ Driver for the TMC51x0 (TMC5130 & TMC5160)
|
Namespaces | |
| namespace | ChipVersion |
| TMC chip version constants. | |
| namespace | ClockFreq |
| TMC51x0 clock frequency constants. | |
| namespace | MathConstants |
| Mathematical constants. | |
| namespace | MotorCalcConstants |
| namespace | RegisterConstants |
| Register conversion constants. | |
| namespace | Registers |
| TMC51x0 register addresses. | |
Classes | |
| struct | AccelerationValue |
| Self-describing acceleration value with explicit unit. More... | |
| union | CHOPCONF_Register |
| Chopper and driver configuration register (CHOPCONF) More... | |
| struct | ChopperConfig |
| Chopper configuration structure. More... | |
| class | CommInterface |
| CRTP-based communication interface for register read/write operations. More... | |
| class | ConfigBuilder |
| Fluent configuration builder for DriverConfig. More... | |
| union | COOLCONF_Register |
| coolStep smart current control and stallGuard2 configuration register (COOLCONF) More... | |
| struct | CoolStepConfig |
| CoolStep configuration structure. More... | |
| union | DCCTRL_Register |
| dcStep automatic commutation configuration register (DCCTRL) More... | |
| struct | DcStepConfig |
| DcStep configuration structure. More... | |
| struct | Diag0Config |
| DIAG0 pin configuration structure. More... | |
| struct | Diag1Config |
| DIAG1 pin configuration structure. More... | |
| struct | DriverConfig |
| Driver initialization configuration structure. More... | |
| union | DRV_CONF_Register |
| Driver configuration register (DRV_CONF) More... | |
| union | DRV_STATUS_Register |
| stallGuard2 value and driver error flags register (DRV_STATUS) More... | |
| union | ENC_STATUS_Register |
| Encoder status register (ENC_STATUS) More... | |
| union | ENCMODE_Register |
| Encoder configuration register (ENCMODE) More... | |
| struct | EncoderConfig |
| Encoder configuration structure. More... | |
| struct | ExternalClockConfig |
| External clock configuration structure. More... | |
| union | GCONF_Register |
| General configuration register (GCONF) More... | |
| struct | GlobalConfig |
| Global configuration (GCONF) structure. More... | |
| union | GSTAT_Register |
| Global status register (GSTAT) More... | |
| struct | HomingSettingsCache |
| Cached settings for homing operations. More... | |
| union | IHOLD_IRUN_Register |
| Driver current control register (IHOLD_IRUN) More... | |
| struct | InputStatus |
| Input pin status structure. More... | |
| union | IOIN_Register |
| Input pin register (IOIN) - Read-only at address 0x04. More... | |
| struct | MechanicalSystem |
| Mechanical system configuration structure. More... | |
| struct | MicrostepChangeOptions |
| Options for changing microstep resolution (CHOPCONF.MRES) More... | |
| struct | MotorSpec |
| Motor specification structure. More... | |
| union | MSCURACT_Register |
| Actual microstep current register (MSCURACT) More... | |
| union | MSLUTSEL_Register |
| Microstep lookup table segmentation definition register (MSLUTSEL) More... | |
| union | NODECONF_Register |
| UART node address configuration register (NODECONF) More... | |
| union | OFFSET_READ_Register |
| Offset calibration result register (OFFSET_READ) More... | |
| union | OTP_PROG_Register |
| OTP programming register (OTP_PROG) More... | |
| union | OTP_READ_Register |
| OTP read register (OTP_READ) More... | |
| struct | PinActiveLevels |
| Pin active level configuration structure. More... | |
| struct | PowerStageParameters |
| Power stage parameters structure. More... | |
| union | PWM_AUTO_Register |
| stealthChop automatically generated values read out register (PWM_AUTO) More... | |
| union | PWM_SCALE_Register |
| Results of stealthChop amplitude regulator register (PWM_SCALE) More... | |
| union | PWMCONF_Register |
| stealthChop voltage PWM mode chopper configuration register (PWMCONF) More... | |
| union | RAMP_STAT_Register |
| Ramp status and switch event status register (RAMP_STAT) More... | |
| struct | RampConfig |
| Ramp configuration structure. More... | |
| struct | ReferenceSwitchConfig |
| Reference switch configuration structure. More... | |
| class | Result |
| Result type for operations that return a value. More... | |
| class | Result< void > |
| Result type for operations that don't return a value. More... | |
| union | SHORT_CONF_Register |
| Short detector configuration register (SHORT_CONF) More... | |
| struct | SpiCommand |
| TMC5160 SPI command structure with union-based frame representation. More... | |
| class | SpiCommInterface |
| CRTP-based SPI implementation of TMC5160CommInterface. More... | |
| struct | SpiResponse |
| TMC5160 SPI response structure. More... | |
| struct | SpiStatus |
| SPI_STATUS structure - status flags returned with each SPI datagram. More... | |
| struct | StallGuardConfig |
| StallGuard2 configuration structure. More... | |
| struct | StallGuardTuningResult |
| Result structure for StallGuard2 threshold (SGT) tuning. More... | |
| struct | StealthChopConfig |
| StealthChop configuration structure. More... | |
| union | SW_MODE_Register |
| Switch mode configuration register (SW_MODE) More... | |
| class | TMC51x0 |
| Main class representing a TMC51x0 stepper motor driver (TMC5130 & TMC5160) More... | |
| class | TMC51x0DaisyChain |
| High-level manager for multiple TMC51x0 drivers in a daisy-chain configuration. More... | |
| class | TMC51x0MultiNode |
| High-level manager for multiple TMC51x0 drivers in a UART multi-node configuration. More... | |
| struct | TMC51x0PinConfig |
| TMC51x0 GPIO pin configuration structure. More... | |
| class | UartCommInterface |
| CRTP-based UART implementation of TMC5160CommInterface. More... | |
| struct | UartConfig |
| UART communication configuration structure. More... | |
| struct | UartFrame |
| TMC5160 UART command/response frame structure with built-in CRC8. More... | |
| struct | VelocityValue |
| Self-describing velocity value with explicit unit. More... | |
Typedefs | |
| using | ResultVoid = Result<void> |
Enumerations | |
| enum class | RampMode : uint8_t { POSITIONING = 0x00 , VELOCITY_POS = 0x01 , VELOCITY_NEG = 0x02 , HOLD = 0x03 } |
| Ramp mode enumeration values. More... | |
| enum class | PWMFreewheel : uint8_t { NORMAL = 0x00 , ENABLED = 0x01 , SHORT_LS = 0x02 , SHORT_HS = 0x03 } |
| PWM freewheel mode enumeration values. More... | |
| enum class | EncoderSensitivity : uint8_t { NO_EDGE = 0x00 , RISING_EDGE = 0x01 , FALLING_EDGE = 0x02 , BOTH_EDGES } |
| Encoder N channel sensitivity enumeration values. More... | |
| enum class | LogLevel : uint8_t { Error = 0 , Warn = 1 , Info = 2 , Debug = 3 , Verbose = 4 } |
| Driver-native log levels for debug output. More... | |
| enum class | CommMode : uint8_t { SPI , UART } |
| Supported physical communication modes for TMC51x0. More... | |
| enum class | TMC51x0CtrlPin : uint8_t { EN , DIR , STEP , REFL_STEP , REFR_DIR , DIAG0 , DIAG1 , ENCA , ENCB , ENCN , DCEN , DCIN , DCO , CLK , SPI_MODE , SD_MODE } |
| TMC51x0 control pin identifiers with board-agnostic naming. More... | |
| enum class | GpioSignal : uint8_t { INACTIVE = 0 , ACTIVE = 1 } |
| GPIO signal states with board-agnostic naming. More... | |
| enum class | UartFrameType : uint8_t { WriteAccess , ReadRequest , ReadReply } |
| TMC5160 UART frame types. More... | |
| enum class | ErrorCode : uint8_t { OK = 0 , NOT_INITIALIZED , COMM_ERROR , INVALID_VALUE , INVALID_STATE , TIMEOUT , CANCELLED , HARDWARE_ERROR , SHORT_CIRCUIT , OPEN_LOAD , OVERTEMP_WARNING , OVERTEMP_SHUTDOWN , UNSUPPORTED } |
| Error codes for TMC51x0 operations. More... | |
| enum class | ChipCommMode : uint8_t { SPI_INTERNAL_RAMP , SPI_EXTERNAL_STEPDIR = 1 , UART_INTERNAL_RAMP , STANDALONE_EXTERNAL_STEPDIR } |
| Chip communication and motion control mode configuration. More... | |
| enum class | MotorDirection : uint8_t { NORMAL = 0 , INVERSE = 1 } |
| Motor direction enumeration. More... | |
| enum class | MotorType : uint8_t { STEPPER = 0 , DC_MOTOR_SINGLE = 1 , DC_MOTOR_DUAL = 2 , SOLENOID_SINGLE = 3 , SOLENOID_DUAL = 4 } |
| Motor type enumeration. More... | |
| enum class | Unit : uint8_t { Steps , Rad , Deg , Mm , RPM , RevPerSec } |
| Unit enumeration. More... | |
| enum class | DriverStatus : uint8_t { OK , CP_UV , S2VSA , S2VSB , S2GA , S2GB , OT , OTHER_ERR , OTPW } |
| Driver status enumeration. More... | |
| enum class | MechanicalSystemType : uint8_t { DirectDrive , LeadScrew , BeltDrive , Gearbox } |
| Mechanical system type enumeration. More... | |
| enum class | SenseFilterTime : uint8_t { T100ns = 0 , T200ns = 1 , T300ns = 2 , T400ns = 3 } |
| Sense amplifier filter time constant enumeration. More... | |
| enum class | OverTempProtection : uint8_t { Temp150C = 0 , Temp143C = 1 , Temp136C = 2 , Temp120C = 3 } |
| Over-temperature protection level enumeration. More... | |
| enum class | ChopperMode : bool { SPREAD_CYCLE = false , CLASSIC = true } |
| Chopper mode enumeration. More... | |
| enum class | ChopperBlankTime : uint8_t { TBL_16CLK = 0 , TBL_24CLK = 1 , TBL_36CLK = 2 , TBL_54CLK = 3 } |
| Comparator blank time enumeration. More... | |
| enum class | MicrostepResolution : uint8_t { MRES_256 = 0 , MRES_128 = 1 , MRES_64 = 2 , MRES_32 = 3 , MRES_16 = 4 , MRES_8 = 5 , MRES_4 = 6 , MRES_2 = 7 , FULLSTEP = 8 } |
| Microstep resolution enumeration. More... | |
| enum class | MicrostepLutPreset : uint8_t { DEFAULT_SINE = 0 , PURE_SINE = 1 } |
| Microstep lookup table preset waveforms. More... | |
| enum class | StealthChopPwmFreq : uint8_t { PWM_FREQ_0 = 0 , PWM_FREQ_1 = 1 , PWM_FREQ_2 = 2 , PWM_FREQ_3 = 3 } |
| StealthChop PWM frequency enumeration. More... | |
| enum class | StealthChopRegulationSpeed : uint8_t { VERY_SLOW = 1 , SLOW = 2 , MODERATE = 4 , FAST = 8 , VERY_FAST = 15 } |
| StealthChop regulation speed enumeration. More... | |
| enum class | StealthChopJerkReduction : uint8_t { MAXIMUM = 8 , HIGH = 10 , MODERATE = 12 , LOW = 14 , MINIMUM = 15 } |
| StealthChop mode switching jerk reduction enumeration. More... | |
| enum class | StallGuardSensitivity : int8_t { VERY_HIGH = -32 , HIGH = -16 , MODERATE = 0 , LOW = 16 , VERY_LOW = 32 } |
| StallGuard2 sensitivity enumeration. More... | |
| enum class | CoolStepIncrementStep : uint8_t { STEP_1 = 0 , STEP_2 = 1 , STEP_4 = 2 , STEP_8 = 3 } |
| CoolStep current increment step width enumeration. More... | |
| enum class | CoolStepDecrementSpeed : uint8_t { EVERY_32 = 0 , EVERY_8 = 1 , EVERY_2 = 2 , EVERY_1 = 3 } |
| CoolStep current decrement speed enumeration. More... | |
| enum class | CoolStepMinCurrent : uint8_t { HALF_IRUN = 0 , QUARTER_IRUN = 1 } |
| CoolStep minimum current percentage enumeration. More... | |
| enum class | DcStepStallSensitivity : uint8_t { DISABLED = 0 , LOW = 1 , MODERATE = 2 , HIGH = 3 } |
| DcStep stall detection sensitivity enumeration. More... | |
| enum class | ReferenceSwitchActiveLevel : uint8_t { ACTIVE_LOW , ACTIVE_HIGH } |
| Reference switch active level enumeration. More... | |
| enum class | ReferenceLatchMode : uint8_t { DISABLED , ACTIVE_EDGE , INACTIVE_EDGE , BOTH_EDGES } |
| Position latching mode enumeration. More... | |
| enum class | ReferenceStopMode : uint8_t { HARD_STOP , SOFT_STOP } |
| Stop mode enumeration. More... | |
| enum class | EncoderNSensitivity : uint8_t { ACTIVE_LEVEL , RISING_EDGE , FALLING_EDGE , BOTH_EDGES } |
| Encoder N channel sensitivity enumeration. More... | |
| enum class | EncoderClearMode : uint8_t { DISABLED , ONCE , CONTINUOUS } |
| Encoder clear mode enumeration. More... | |
| enum class | EncoderPrescalerMode : uint8_t { BINARY , DECIMAL } |
| Encoder prescaler mode enumeration. More... | |
Functions | |
| const char * | GetRegisterDef (uint8_t address) |
| bool | CalculateMotorCurrent (const MotorSpec &motor_spec, uint32_t sense_resistor_mohm, uint32_t supply_voltage_mv, uint16_t run_current_ma, uint16_t hold_current_ma, uint8_t &irun, uint8_t &ihold, uint16_t &global_scaler) noexcept |
| Calculate motor current settings from physical parameters. | |
| uint16_t | CalculateStealthChopLowerLimit (const MotorSpec &motor_spec, uint32_t supply_voltage_mv, uint8_t tbl, uint8_t pwm_freq, uint32_t f_clk=12000000U) noexcept |
| Calculate StealthChop lower current limit. | |
| uint16_t | CalculateMaxCurrentForSenseResistor (uint32_t sense_resistor_mohm) noexcept |
| Calculate maximum RMS current for a given sense resistor. | |
| uint8_t | CalculateS2VSLevel (uint16_t voltage_mv) noexcept |
| Calculate S2VS_LEVEL register value from voltage threshold. | |
| uint8_t | CalculateS2GLevel (uint16_t voltage_mv, uint32_t supply_voltage_mv=0) noexcept |
| Calculate S2G_LEVEL register value from voltage threshold. | |
| uint8_t | CalculateShortDelay (uint8_t delay_us_x10) noexcept |
| Calculate shortdelay register bit from detection delay time. | |
| constexpr float | StepsToMm (int32_t steps, float steps_per_rev, float lead_screw_pitch_mm) noexcept |
| Convert steps to millimeters. | |
| constexpr int32_t | MmToSteps (float mm, float steps_per_rev, float lead_screw_pitch_mm) noexcept |
| Convert millimeters to steps. | |
| constexpr float | StepsToDegrees (int32_t steps, float steps_per_rev) noexcept |
| Convert steps to degrees. | |
| constexpr int32_t | DegreesToSteps (float degrees, float steps_per_rev) noexcept |
| Convert degrees to steps. | |
| constexpr float | RpmToStepsPerSec (float rpm, float steps_per_rev) noexcept |
| Convert RPM to steps per second. | |
| constexpr float | StepsPerSecToRpm (float steps_per_sec, float steps_per_rev) noexcept |
| Convert steps per second to RPM. | |
| constexpr float | MmPerSecToStepsPerSec (float mm_per_sec, float steps_per_rev, float lead_screw_pitch_mm) noexcept |
| Convert millimeters per second to steps per second. | |
| constexpr float | StepsPerSecToMmPerSec (float steps_per_sec, float steps_per_rev, float lead_screw_pitch_mm) noexcept |
| Convert steps per second to millimeters per second. | |
| constexpr float | AccelerationMmToSteps (float accel_mm_per_sec2, float steps_per_rev, float lead_screw_pitch_mm) noexcept |
| Convert acceleration from mm/s² to steps/s² | |
| constexpr float | AccelerationStepsToMm (float accel_steps_per_sec2, float steps_per_rev, float lead_screw_pitch_mm) noexcept |
| Convert acceleration from steps/s² to mm/s² | |
| constexpr int32_t | BeltTeethToSteps (uint32_t teeth, float steps_per_rev, uint16_t belt_pulley_teeth) noexcept |
| Convert belt drive distance (teeth) to steps. | |
| constexpr float | StepsToBeltTeeth (int32_t steps, float steps_per_rev, uint16_t belt_pulley_teeth) noexcept |
| Convert steps to belt drive distance (teeth) | |
| const char * | GetDriverVersion () noexcept |
| static constexpr uint8_t | calculateCrc8 (const uint8_t *data, size_t length) noexcept |
| Calculate CRC8 checksum for UART communication. | |
| const char * | ErrorMessage (ErrorCode code) |
| Get human-readable error message. | |
| template<std::size_t N, typename T > | |
| decltype(auto) | get (Result< T > &r) noexcept |
| Tuple-like access for structured bindings (C++17) | |
| template<std::size_t N, typename T > | |
| decltype(auto) | get (const Result< T > &r) noexcept |
| template<std::size_t N, typename T > | |
| decltype(auto) | get (Result< T > &&r) noexcept |
| template<std::size_t N> | |
| std::enable_if_t< N==0, ErrorCode > | get (Result< void > &r) noexcept |
| template<std::size_t N> | |
| std::enable_if_t< N==0, ErrorCode > | get (const Result< void > &r) noexcept |
| template<std::size_t N> | |
| std::enable_if_t< N==0, ErrorCode > | get (Result< void > &&r) noexcept |
| constexpr const char * | ToString (MotorDirection d) noexcept |
| Convert MotorDirection to human-readable string. | |
| constexpr const char * | ToString (MotorType t) noexcept |
| Convert MotorType to human-readable string. | |
| constexpr const char * | ToString (Unit u) noexcept |
| Convert Unit to human-readable string. | |
| constexpr const char * | ToString (MechanicalSystemType type) noexcept |
| Convert MechanicalSystemType to human-readable string. | |
| constexpr const char * | ToString (ChopperMode m) noexcept |
| Convert ChopperMode to human-readable string. | |
| constexpr const char * | ToString (MicrostepResolution mres) noexcept |
| Convert MicrostepResolution to human-readable string. | |
| constexpr uint16_t | MicrostepsPerFullStep (MicrostepResolution mres) noexcept |
| Get microsteps-per-full-step for an MRES value. | |
| constexpr const char * | ToString (MicrostepLutPreset preset) noexcept |
| Convert MicrostepLutPreset to human-readable string. | |
| constexpr const char * | ToString (ReferenceSwitchActiveLevel a) noexcept |
| Convert ReferenceSwitchActiveLevel to human-readable string. | |
| constexpr const char * | ToString (ReferenceLatchMode m) noexcept |
| Convert ReferenceLatchMode to human-readable string. | |
| constexpr const char * | ToString (ReferenceStopMode m) noexcept |
| Convert ReferenceStopMode to human-readable string. | |
| constexpr const char * | ToString (EncoderNSensitivity s) noexcept |
| Convert EncoderNSensitivity to human-readable string. | |
| constexpr const char * | ToString (EncoderClearMode m) noexcept |
| Convert EncoderClearMode to human-readable string. | |
| constexpr const char * | ToString (EncoderPrescalerMode m) noexcept |
| Convert EncoderPrescalerMode to human-readable string. | |
| using tmc51x0::ResultVoid = Result<void> |
|
strong |
Chip communication and motion control mode configuration.
This enumeration represents the combination of SPI_MODE and SD_MODE pins that determine the TMC51x0 operating mode. These pins are typically hardwired and read at startup, but can be controlled via GPIO if connected.
WARNING: Changing the mode requires a chip reset to take effect. The mode pins are read at startup, so any changes must be followed by a reset cycle (power cycle since TMC51x0 has no reset pin).
| SD_MODE | SPI_MODE | Mode | Description |
|---|---|---|---|
| LOW (0) | HIGH (1) | SPI_INTERNAL_RAMP | SPI + internal ramp generator (motion controller) |
| HIGH (1) | HIGH (1) | SPI_EXTERNAL_STEPDIR | SPI + external Step/Dir inputs |
| LOW (0) | LOW (0) | UART_INTERNAL_RAMP | UART + internal ramp generator (motion controller) |
| HIGH (1) | LOW (0) | STANDALONE_EXTERNAL_STEPDIR | Standalone Step/Dir (no SPI/UART, CFG pins configure driver) |
|
strong |
Comparator blank time enumeration.
Blank time masks comparator input to block spikes from parasitic capacitances during switching. Longer blank time provides more protection but may limit chopper frequency.
|
strong |
|
strong |
Supported physical communication modes for TMC51x0.
| Enumerator | |
|---|---|
| SPI | SPI (Serial Peripheral Interface) mode - 4-wire synchronous communication |
| UART | UART (Universal Asynchronous Receiver-Transmitter) mode - 2-wire asynchronous communication |
|
strong |
CoolStep current decrement speed enumeration.
Defines how many StallGuard2 measurements above threshold before decrementing current. Higher values provide slower current reduction, preventing rapid oscillations.
|
strong |
CoolStep current increment step width enumeration.
Defines how many current steps to increment per StallGuard2 measurement below threshold. Higher values provide faster response to increasing load but may cause oscillations.
|
strong |
|
strong |
DcStep stall detection sensitivity enumeration.
Defines the sensitivity of stall detection in DcStep mode. Higher sensitivity detects stalls earlier but may trigger false positives.
|
strong |
Driver status enumeration.
Indicates the current status of the TMC51x0 driver, including error conditions and warnings.
|
strong |
Encoder clear mode enumeration.
Defines when and how the encoder counter is cleared on N channel events.
|
strong |
Encoder N channel sensitivity enumeration.
Defines how the N channel event is detected (level-sensitive or edge-sensitive). Similar to ReferenceLatchMode but specifically for encoder N channel edge detection.
|
strong |
Encoder prescaler mode enumeration.
Defines the encoder prescaler divisor mode for ENC_CONST calculation.
|
strong |
Encoder N channel sensitivity enumeration values.
|
strong |
Error codes for TMC51x0 operations.
|
strong |
|
strong |
Driver-native log levels for debug output.
These are intentionally numeric and stable so platform integrations can map them onto their own logging systems.
Convention:
| Enumerator | |
|---|---|
| Error | |
| Warn | |
| Info | |
| Debug | |
| Verbose | |
|
strong |
|
strong |
Microstep lookup table preset waveforms.
Defines preset waveform configurations for the microstep lookup table (MSLUT). The lookup table defines the first quarter of the sine wave (0-90°); the driver mirrors it for the remaining three quarters.
|
strong |
Microstep resolution enumeration.
Defines the number of microsteps per full step. Higher resolution provides smoother motion but may reduce maximum velocity.
|
strong |
|
strong |
Motor type enumeration.
Defines the type of motor being controlled. This is primarily for documentation and configuration purposes. Direct mode can be used with any motor type.
|
strong |
Over-temperature protection level enumeration.
Selects the over-temperature level for bridge disable. Higher values provide more protection but trigger at lower temperatures.
|
strong |
|
strong |
|
strong |
Position latching mode enumeration.
Defines when position should be latched (captured) on switch events. Used to simplify latching configuration instead of separate boolean flags.
|
strong |
Stop mode enumeration.
Defines how the motor stops when a reference switch is triggered.
|
strong |
Reference switch active level enumeration.
Defines the electrical signal level when the switch is active/triggered. Used to automatically configure polarity for proper switch detection.
|
strong |
Sense amplifier filter time constant enumeration.
Filter time constant of sense amplifier to suppress ringing and coupling from second coil operation. Increase setting if motor chopper noise occurs due to cross-coupling of both coils.
| Enumerator | |
|---|---|
| T100ns | ~100ns (reset default) |
| T200ns | ~200ns |
| T300ns | ~300ns |
| T400ns | ~400ns |
|
strong |
StallGuard2 sensitivity enumeration.
Provides intuitive sensitivity levels for StallGuard2 threshold tuning. Lower SGT values = higher sensitivity (detects stalls easier, more false positives). Higher SGT values = lower sensitivity (requires more torque to detect stall, fewer false positives).
|
strong |
StealthChop mode switching jerk reduction enumeration.
Controls current jerk reduction when switching from SpreadCycle to StealthChop. Lower values reduce current spike during mode switching (smoother). Higher values allow faster switching but may cause more current jerk.
|
strong |
StealthChop PWM frequency enumeration.
Provides PWM frequency selection options for StealthChop operation. Lower frequencies reduce current ripple but may limit high-velocity performance. Higher frequencies improve high-velocity performance but increase dynamic power dissipation.
Recommended range: 20-50kHz for most applications.
|
strong |
StealthChop regulation speed enumeration.
Controls how fast the PWM amplitude regulation loop adapts to changes. Specifies maximum PWM amplitude change per half wave when using automatic scaling.
Lower values provide stable, soft regulation (slower response). Higher values provide faster adaptation but may be less stable.
|
strong |
TMC51x0 control pin identifiers with board-agnostic naming.
These pin identifiers abstract the physical pin assignments to provide a consistent interface regardless of board implementation.
Pin functions depend on mode configuration (SPI_MODE, SD_MODE):
|
strong |
|
strong |
Unit enumeration.
Defines the unit of measurement for position, velocity, and acceleration. Steps:
SetTargetPosition(float, Unit) / SetMaxSpeed(float, Unit)), Unit::Steps is treated as motor full-steps for convenience.int32_t positions (these are microsteps). Rad: Radians (per second for velocity, per second^2 for accel) Deg: Degrees (per second for velocity, per second^2 for accel) Mm: Millimeters (linear only) RPM: Revolutions per Minute (Velocity only, typically) RevPerSec: Revolutions per Second (recommended default for velocity)
|
constexprnoexcept |
Convert acceleration from mm/s² to steps/s²
| accel_mm_per_sec2 | Acceleration in millimeters per second squared |
| steps_per_rev | Steps per revolution of the motor |
| lead_screw_pitch_mm | Lead screw pitch in millimeters |
|
constexprnoexcept |
Convert acceleration from steps/s² to mm/s²
| accel_steps_per_sec2 | Acceleration in steps per second squared |
| steps_per_rev | Steps per revolution of the motor |
| lead_screw_pitch_mm | Lead screw pitch in millimeters |
|
constexprnoexcept |
Convert belt drive distance (teeth) to steps.
| teeth | Number of belt teeth |
| steps_per_rev | Steps per revolution of the motor |
| belt_pulley_teeth | Number of teeth on the motor pulley |
|
staticconstexprnoexcept |
Calculate CRC8 checksum for UART communication.
TMC5160 uses CRC8-ATM polynomial (x^8 + x^2 + x^1 + x^0 = 0x07) with initial value of zero. The CRC is applied LSB to MSB, including the sync- and addressing byte. The sync nibble is assumed to always be correct.
Algorithm per datasheet section 5.2: CRC = (CRC << 1) OR (CRC.7 XOR CRC.1 XOR CRC.0 XOR [new incoming bit])
| data | Pointer to the data bytes to checksum |
| length | Number of bytes to include in the checksum calculation |
|
inlinenoexcept |
Calculate maximum RMS current for a given sense resistor.
| sense_resistor_mohm | Sense resistor value in milliohms |
|
inlinenoexcept |
Calculate motor current settings from physical parameters.
Calculates IRUN, IHOLD, and GLOBAL_SCALER based on:
| motor_spec | Motor specifications including rated current, resistance, etc. |
| sense_resistor_mohm | Sense resistor value in milliohms (e.g., 50 for 0.05Ω) |
| supply_voltage_mv | Supply voltage in millivolts (e.g., 24000 for 24V) |
| run_current_ma | Desired run current in milliamps (default: motor rated current) |
| hold_current_ma | Desired hold current in milliamps (default: 30% of run current) |
| irun | Reference to store calculated IRUN value (0-31) |
| ihold | Reference to store calculated IHOLD value (0-31) |
| global_scaler | Reference to store calculated GLOBAL_SCALER value (32-256) |
|
inlinenoexcept |
Calculate S2G_LEVEL register value from voltage threshold.
Converts user-friendly voltage threshold (mV) to S2G_LEVEL register value (2-15). Uses datasheet typical values for interpolation.
| voltage_mv | Voltage threshold in millivolts (0 = auto-calculate to 625mV) |
| supply_voltage_mv | Supply voltage in millivolts (for VS-dependent calculation) |
Datasheet typical values (VS-dependent):
|
inlinenoexcept |
Calculate S2VS_LEVEL register value from voltage threshold.
Converts user-friendly voltage threshold (mV) to S2VS_LEVEL register value (4-15). Uses datasheet typical values for interpolation.
| voltage_mv | Voltage threshold in millivolts (0 = auto-calculate to 625mV) |
Datasheet typical values:
|
inlinenoexcept |
Calculate shortdelay register bit from detection delay time.
Converts user-friendly delay time (µs in 0.1µs units) to shortdelay register bit (0-1).
| delay_us_x10 | Detection delay in 0.1µs units (0 = auto-calculate to 8.5 = 0.85µs) |
Datasheet timing (typical values):
|
inlinenoexcept |
Calculate StealthChop lower current limit.
Calculates the minimum motor current that can be regulated in StealthChop mode based on blank time, PWM frequency, supply voltage, and motor resistance.
| motor_spec | Motor specifications including winding resistance |
| supply_voltage_mv | Supply voltage in millivolts |
| tbl | Blank time setting (0-3, corresponds to 16, 24, 36, 54 clock cycles) |
| pwm_freq | PWM frequency setting (0-3) |
| f_clk | Clock frequency in Hz (default: 12 MHz) |
|
constexprnoexcept |
Convert degrees to steps.
| degrees | Angle in degrees |
| steps_per_rev | Steps per revolution of the motor |
|
inline |
Get human-readable error message.
| code | Error code |
|
noexcept |
|
noexcept |
|
noexcept |
|
noexcept |
Tuple-like access for structured bindings (C++17)
Structured bindings use unqualified get<N>(obj) found via ADL for tuple-like types. These overloads make auto [err, value] = result; work reliably.
|
noexcept |
|
noexcept |
|
inlinenoexcept |
| const char * tmc51x0::GetRegisterDef | ( | uint8_t | address | ) |
|
inlineconstexprnoexcept |
Get microsteps-per-full-step for an MRES value.
|
constexprnoexcept |
Convert millimeters per second to steps per second.
| mm_per_sec | Speed in millimeters per second |
| steps_per_rev | Steps per revolution of the motor |
| lead_screw_pitch_mm | Lead screw pitch in millimeters |
|
constexprnoexcept |
Convert millimeters to steps.
| mm | Distance in millimeters |
| steps_per_rev | Steps per revolution of the motor |
| lead_screw_pitch_mm | Lead screw pitch in millimeters |
|
constexprnoexcept |
Convert RPM to steps per second.
| rpm | Revolutions per minute |
| steps_per_rev | Steps per revolution of the motor |
|
constexprnoexcept |
Convert steps per second to millimeters per second.
| steps_per_sec | Speed in steps per second |
| steps_per_rev | Steps per revolution of the motor |
| lead_screw_pitch_mm | Lead screw pitch in millimeters |
|
constexprnoexcept |
Convert steps per second to RPM.
| steps_per_sec | Speed in steps per second |
| steps_per_rev | Steps per revolution of the motor |
|
constexprnoexcept |
Convert steps to belt drive distance (teeth)
| steps | Number of steps |
| steps_per_rev | Steps per revolution of the motor |
| belt_pulley_teeth | Number of teeth on the motor pulley |
|
constexprnoexcept |
Convert steps to degrees.
| steps | Number of steps |
| steps_per_rev | Steps per revolution of the motor |
|
constexprnoexcept |
Convert steps to millimeters.
| steps | Number of steps |
| steps_per_rev | Steps per revolution of the motor |
| lead_screw_pitch_mm | Lead screw pitch in millimeters (for lead screws) |
For lead screws: distance = (steps / steps_per_rev) * lead_screw_pitch_mm
|
inlineconstexprnoexcept |
Convert ChopperMode to human-readable string.
|
inlineconstexprnoexcept |
Convert EncoderClearMode to human-readable string.
|
inlineconstexprnoexcept |
Convert EncoderNSensitivity to human-readable string.
|
inlineconstexprnoexcept |
Convert EncoderPrescalerMode to human-readable string.
|
inlineconstexprnoexcept |
Convert MechanicalSystemType to human-readable string.
|
inlineconstexprnoexcept |
Convert MicrostepLutPreset to human-readable string.
|
inlineconstexprnoexcept |
Convert MicrostepResolution to human-readable string.
|
inlineconstexprnoexcept |
Convert MotorDirection to human-readable string.
|
inlineconstexprnoexcept |
Convert MotorType to human-readable string.
|
inlineconstexprnoexcept |
Convert ReferenceLatchMode to human-readable string.
|
inlineconstexprnoexcept |
Convert ReferenceStopMode to human-readable string.
|
inlineconstexprnoexcept |
Convert ReferenceSwitchActiveLevel to human-readable string.
|
inlineconstexprnoexcept |
Convert Unit to human-readable string.