HF-TMC51x0 Driver (TMC5130 & TMC5160) 0.1.0-dev
Hardware Agnostic C++ Driver for the TMC51x0 (TMC5130 & TMC5160)
Loading...
Searching...
No Matches
tmc51x0::TMC51x0< CommType > Class Template Reference

Main class representing a TMC51x0 stepper motor driver (TMC5130 & TMC5160) More...

#include <tmc51x0.hpp>

Collaboration diagram for tmc51x0::TMC51x0< CommType >:
[legend]

Classes

struct  Communication
 Communication subsystem. More...
 
struct  Encoder
 Encoder subsystem. More...
 
struct  Events
 Motion events / status outputs (X_COMPARE, RAMP_STAT clear) More...
 
struct  HardResetOptions
 Options for HardReset() More...
 
struct  Homing
 Homing subsystem with automatic settings caching. More...
 
struct  Io
 Chip IO / mode pins / IOIN helpers. More...
 
struct  MotorControl
 Motor control subsystem. More...
 
struct  MotorCurrentDebugInfo
 Snapshot of motor-current related calculated/cached values. More...
 
struct  PowerStage
 Power stage + protection subsystem (DRV_CONF, SHORT_CONF) More...
 
struct  Printer
 Register printer subsystem for debugging. More...
 
struct  RampControl
 Ramp control subsystem. More...
 
struct  StallGuard
 StallGuard2 subsystem (COOLCONF/DRV_STATUS + SW_MODE interactions) More...
 
struct  Status
 Status / monitoring subsystem (read-only) More...
 
struct  Switches
 Reference switches / endstops subsystem (SW_MODE / XLATCH) More...
 
struct  Thresholds
 Velocity thresholds / mode thresholds (TPWMTHRS, TCOOLTHRS, THIGH) More...
 
struct  Tuning
 Tuning subsystem for automatic parameter optimization. More...
 
struct  UartConfig
 UART configuration subsystem. More...
 
struct  WriteOnlyRegisters
 

Public Member Functions

 TMC51x0 (CommType &comm, uint8_t daisy_chain_position=0, uint8_t uart_node_address=0) noexcept
 Construct a TMC51x0 driver instance.
 
 ~TMC51x0 () noexcept
 Destructor for TMC51x0, cleans up resources.
 
CommType & GetComm () noexcept
 Get the communication interface used by this TMC51x0 instance.
 
Result< void > Initialize (const DriverConfig &config=DriverConfig(), bool verbose=true) noexcept
 Initialize the TMC51x0 driver with configuration.
 
Result< void > HardReset (const HardResetOptions &opts=HardResetOptions()) noexcept
 Perform a hard reset (power-cycle when available, else software reset)
 
DriverConfig GetDriverConfig () const noexcept
 Get current driver configuration.
 
DriverConfig GetDriverConfig (bool &initialized) const noexcept
 Get current driver configuration with initialization status.
 
std::string GetDriverConfigString () const noexcept
 Get driver configuration as formatted string (heap allocating)
 
void LogConfigSummary (const DriverConfig &cfg, const char *tag="TMC5160", LogLevel lvl=LogLevel::Info) noexcept
 Log a comprehensive, human-readable summary of a DriverConfig.
 
void LogDerivedInitSummary (const char *tag="TMC5160", LogLevel lvl=LogLevel::Info) noexcept
 Log a compact, table-style summary of derived/cached initialization values.
 
void LogLiveStatusReport (const char *tag="TMC5160", LogLevel lvl=LogLevel::Info) noexcept
 Read silicon registers and log a comprehensive live status report.
 
MotorCurrentDebugInfo GetMotorCurrentDebugInfo () const noexcept
 Get motor-current calculated/cached values for application logging.
 

Public Attributes

struct tmc51x0::TMC51x0::RampControlthis
 
struct tmc51x0::TMC51x0::Switchesthis
 
struct tmc51x0::TMC51x0::Eventsthis
 
struct tmc51x0::TMC51x0::MotorControlthis
 
struct tmc51x0::TMC51x0::Thresholdsthis
 
struct tmc51x0::TMC51x0::PowerStagethis
 
struct tmc51x0::TMC51x0::Communicationthis
 
struct tmc51x0::TMC51x0::Iothis
 
struct tmc51x0::TMC51x0::Encoderthis
 
struct tmc51x0::TMC51x0::Statusthis
 
struct tmc51x0::TMC51x0::StallGuardthis
 
struct tmc51x0::TMC51x0::Tuningthis
 
struct tmc51x0::TMC51x0::Homingthis
 
struct tmc51x0::TMC51x0::Printerthis
 
struct tmc51x0::TMC51x0::UartConfig this
 

Protected Member Functions

uint8_t GetCommAddress () const noexcept
 Get the appropriate address parameter for ReadRegister/WriteRegister.
 
Result< void > Reset () noexcept
 Reset the TMC51x0 driver.
 
bool IsInitialized () const noexcept
 Check if the driver is initialized.
 

Static Protected Member Functions

static constexpr const char * GetDriverVersion () noexcept
 Get the compiled driver version string.
 
static constexpr uint8_t GetDriverVersionMajor () noexcept
 Get the compiled driver major version number.
 
static constexpr uint8_t GetDriverVersionMinor () noexcept
 Get the compiled driver minor version number.
 
static constexpr uint8_t GetDriverVersionPatch () noexcept
 Get the compiled driver patch version number.
 

Private Member Functions

Result< bool > IsInternalRampMode () noexcept
 Check whether the chip is currently in internal ramp-generator mode (SD_MODE=0).
 
Result< void > RequireInternalRampMode () noexcept
 Require internal ramp-generator mode (SD_MODE=0) for motion-controller operations.
 
float convertSpeedToSteps (float value, Unit unit) const noexcept
 Convert speed value to internal steps/s.
 
float convertAccelerationToSteps (float value, Unit unit) const noexcept
 Convert acceleration value to internal steps/s²
 
float convertPositionToSteps (float value, Unit unit) const noexcept
 Convert position value to steps.
 
float convertStepsToUnit (int32_t steps, Unit unit) const noexcept
 Convert steps to specified unit (for position)
 
float convertSpeedToUnit (float steps_per_sec, Unit unit) const noexcept
 Convert speed (steps/s) to specified unit.
 
int32_t speedToInternal (float speed_hz) const noexcept
 Convert speed from Hz to internal TMC5160 units.
 
float speedFromInternal (int32_t speed_internal) const noexcept
 Convert speed from internal TMC5160 units to Hz.
 
int32_t accelToInternal (float accel_hz) const noexcept
 Convert acceleration from Hz/s to internal TMC5160 units.
 
float accelFromInternal (int32_t accel_internal) const noexcept
 Convert acceleration from internal TMC5160 units to steps/s²
 
int32_t thresholdSpeedToTstep (float speed_hz) const noexcept
 Convert threshold speed to TSTEP format.
 

Private Attributes

CommType & comm_
 Communication interface reference.
 
uint32_t f_clk_ {ClockFreq::DEFAULT_F_CLK}
 TMC51x0 clock frequency in Hz.
 
uint8_t daisy_chain_position_
 
uint8_t uart_node_address_
 
uint8_t send_delay_
 UART send delay (0-15) stored locally from NODECONF register.
 
bool initialized_ {false}
 Initialization status flag.
 
uint8_t chip_version_ {ChipVersion::TMC5160}
 
MotorSpec motor_spec_
 
MechanicalSystem mechanical_system_
 
DriverConfig driver_config_
 
uint16_t calculated_global_scaler_ {0}
 
uint8_t calculated_irun_ {0}
 
uint8_t calculated_ihold_ {0}
 
uint16_t current_microsteps_ {256}
 
struct tmc51x0::TMC51x0::WriteOnlyRegisters write_only_regs_
 

Detailed Description

template<typename CommType>
class tmc51x0::TMC51x0< CommType >

Main class representing a TMC51x0 stepper motor driver (TMC5130 & TMC5160)

The TMC51x0 class provides a comprehensive high-level interface for configuring and controlling TMC5130 and TMC5160 stepper motor driver chips. This class abstracts the complex low-level register operations into intuitive, easy-to-use methods for stepper motor control applications.

Key Features

The TMC51x0 class supports a wide range of stepper motor control features:

  • Ramp Modes: Positioning, velocity, and hold modes
  • Current Control: Configurable run and hold currents
  • Chopper Modes: spreadCycle and stealthChop operation
  • Encoder Support: Closed-loop control with encoder feedback
  • StallGuard2: Stall detection and prevention
  • Protection Systems: Short circuit, overtemperature, overvoltage protection
  • Communication: SPI or UART interface for platform independence

Communication Interface

The class uses a CRTP-based communication interface for communication, making it completely agnostic to the physical communication layer. This allows the same code to work with SPI, UART, or other communication methods by simply providing the appropriate communication interface implementation.

The driver is a template class that takes the communication interface type as a template parameter, providing compile-time polymorphism with zero runtime overhead.

Operating Modes (SD_MODE) and API Validity

The TMC51x0 family supports two fundamentally different motion sources:

  • Internal ramp generator / motion controller (SD_MODE = 0): The chip executes motion profiles from registers (XTARGET/VMAX/AMAX/…).
  • External Step/Dir (SD_MODE = 1): Motion comes from STEP/DIR pins. The internal ramp generator is not the active motion source.

This driver supports both, but not every API makes sense in every mode. To prevent confusing behavior, motion-controller operations require SD_MODE=0 and will return ErrorCode::INVALID_STATE if the chip reports SD_MODE=1 (external Step/Dir) via IOIN.

Quick mode matrix

Subsystem / Feature SD_MODE=0 (Internal ramp) SD_MODE=1 (External Step/Dir)
rampControl motion/profile setters (XTARGET/VMAX/AMAX/...) ❌ (INVALID_STATE)
homing (sensorless/switch homing routines) ❌ (INVALID_STATE)
tuning (StallGuard tuning routines) ❌ (INVALID_STATE)
motorControl (chopper, stealthChop, currents, LUT) ✅ (feature-dependent)
thresholds (TPWMTHRS/TCOOLTHRS/THIGH/VDCMIN) ✅ (feature-dependent)
powerStage (DRV_CONF/SHORT_CONF)
encoder (ABN encoder config/read) ❌ (INVALID_STATE)
status (GSTAT/DRV_STATUS/RAMP_STAT/IOIN/etc.)
io (SPI_MODE/SD_MODE pin helpers, IOIN/OUTPUT helpers)

Notes:

  • In SD_MODE=1, you typically still configure chopper/StealthChop/CoolStep/ StallGuard thresholds, but you do not command motion via XTARGET/VMAX.
  • Some features (e.g., StallGuard/CoolStep) have additional datasheet requirements (SpreadCycle vs StealthChop, velocity thresholds, etc.).

Usage Example

// Create communication interface (SPI example)
class MySPI : public tmc51x0::SpiCommInterface<MySPI> {
// ... implement required methods
};
MySPI spi_comm;
// Create TMC51x0 driver with template parameter
tmc51x0::TMC51x0<MySPI> driver(spi_comm);
// Initialize driver
cfg.motor.irun = 20;
cfg.motor.ihold = 10;
driver.Initialize(cfg);
// Configure ramp control
driver.rampControl.SetRampMode(tmc51x0::RampMode::POSITIONING);
driver.rampControl.SetTargetPosition(1000);
driver.rampControl.SetMaxSpeed(1000.0f);
driver.rampControl.SetAcceleration(500.0f);
// Enable motor
driver.motorControl.Enable();
CRTP-based SPI implementation of TMC5160CommInterface.
Definition tmc51x0_comm_interface.hpp:1660
Main class representing a TMC51x0 stepper motor driver (TMC5130 & TMC5160)
Definition tmc51x0.hpp:119
@ POSITIONING
Positioning mode using all A, D and V parameters.
Driver initialization configuration structure.
Definition tmc51x0_types.hpp:2870
Template Parameters
CommTypeThe communication interface type (must inherit from SpiCommInterface<CommType> or UartCommInterface<CommType>)

Constructor & Destructor Documentation

◆ TMC51x0()

template<typename CommType >
tmc51x0::TMC51x0< CommType >::TMC51x0 ( CommType & comm,
uint8_t daisy_chain_position = 0,
uint8_t uart_node_address = 0 )
inlineexplicitnoexcept

Construct a TMC51x0 driver instance.

Parameters
commReference to a user-implemented communication interface (SPI, UART, etc)
daisy_chain_positionPosition in daisy chain (0 = first chip/single chip, 1 = second, etc.) Only used for SPI daisy-chaining. Default: 0 (single chip)
uart_node_addressUART node address (0-254). Only used for UART multi-node addressing. Default: 0 (single node or first node). For sequential programming via TMC51x0MultiNode, this is set to 0 initially and updated automatically after ProgramSequentially(). For devices already programmed, specify the known address here.
Note
The clock frequency (f_clk) is determined during Initialize() from DriverConfig::external_clk_config:
  • If external_clk_config.frequency_hz = 0: Uses internal oscillator (~12 MHz, CLK pin tied to GND)
  • If external_clk_config.frequency_hz > 0: Uses external clock at specified frequency (CLK pin receives clock signal)
  • The internal clock has ±4% velocity precision and includes a watchdog that switches back to internal clock if external clock signal is missing for more than ~32 internal clock cycles
  • External clock range: 10-16 MHz recommended, up to 18 MHz with 50% duty cycle

◆ ~TMC51x0()

template<typename CommType >
tmc51x0::TMC51x0< CommType >::~TMC51x0 ( )
inlinenoexcept

Destructor for TMC51x0, cleans up resources.

Member Function Documentation

◆ accelFromInternal()

template<typename CommType >
float tmc51x0::TMC51x0< CommType >::accelFromInternal ( int32_t accel_internal) const
privatenoexcept

Convert acceleration from internal TMC5160 units to steps/s²

Parameters
accel_internalAcceleration in internal TMC5160 units
Returns
Acceleration in steps per second squared

◆ accelToInternal()

template<typename CommType >
int32_t tmc51x0::TMC51x0< CommType >::accelToInternal ( float accel_hz) const
privatenoexcept

Convert acceleration from Hz/s to internal TMC5160 units.

Parameters
accel_hzAcceleration in steps per second squared
Returns
Acceleration in internal TMC5160 units

◆ convertAccelerationToSteps()

template<typename CommType >
float tmc51x0::TMC51x0< CommType >::convertAccelerationToSteps ( float value,
Unit unit ) const
privatenoexcept

Convert acceleration value to internal steps/s²

Parameters
valueAcceleration value in specified unit
unitUnit of the value
Returns
Acceleration in steps/s²

◆ convertPositionToSteps()

template<typename CommType >
float tmc51x0::TMC51x0< CommType >::convertPositionToSteps ( float value,
Unit unit ) const
privatenoexcept

Convert position value to steps.

Parameters
valuePosition value in specified unit
unitUnit of the value
Returns
Position in steps

◆ convertSpeedToSteps()

template<typename CommType >
float tmc51x0::TMC51x0< CommType >::convertSpeedToSteps ( float value,
Unit unit ) const
privatenoexcept

Convert speed value to internal steps/s.

Parameters
valueSpeed value in specified unit
unitUnit of the value
Returns
Speed in steps/s

◆ convertSpeedToUnit()

template<typename CommType >
float tmc51x0::TMC51x0< CommType >::convertSpeedToUnit ( float steps_per_sec,
Unit unit ) const
privatenoexcept

Convert speed (steps/s) to specified unit.

Parameters
steps_per_secSpeed in steps/s
unitTarget unit
Returns
Speed in target unit

◆ convertStepsToUnit()

template<typename CommType >
float tmc51x0::TMC51x0< CommType >::convertStepsToUnit ( int32_t steps,
Unit unit ) const
privatenoexcept

Convert steps to specified unit (for position)

Parameters
stepsPosition in steps
unitTarget unit
Returns
Position in target unit

◆ GetComm()

template<typename CommType >
CommType & tmc51x0::TMC51x0< CommType >::GetComm ( )
inlinenoexcept

Get the communication interface used by this TMC51x0 instance.

Returns
Reference to the communication interface (SPI, UART, etc)
Here is the caller graph for this function:

◆ GetCommAddress()

template<typename CommType >
uint8_t tmc51x0::TMC51x0< CommType >::GetCommAddress ( ) const
inlineprotectednoexcept

Get the appropriate address parameter for ReadRegister/WriteRegister.

Returns
daisy_chain_position_ for SPI, uart_node_address_ for UART

This method is protected so that subsystem classes can access it.

◆ GetDriverConfig() [1/2]

template<typename CommType >
DriverConfig tmc51x0::TMC51x0< CommType >::GetDriverConfig ( ) const
inlinenoexcept

Get current driver configuration.

Returns
Current driver configuration (including all runtime changes)

Retrieves the current driver configuration including all runtime changes. This includes the initial configuration plus any modifications made after initialization.

Note
If the driver is not initialized, the returned config will contain default values.
Here is the caller graph for this function:

◆ GetDriverConfig() [2/2]

template<typename CommType >
DriverConfig tmc51x0::TMC51x0< CommType >::GetDriverConfig ( bool & initialized) const
inlinenoexcept

Get current driver configuration with initialization status.

Parameters
initializedReference to store initialization status (true if initialized, false otherwise)
Returns
Current driver configuration (including all runtime changes)

Retrieves the current driver configuration including all runtime changes. Also returns the initialization status through the initialized parameter.

Note
If the driver is not initialized, the returned config will contain default values.

◆ GetDriverConfigString()

template<typename CommType >
std::string tmc51x0::TMC51x0< CommType >::GetDriverConfigString ( ) const
noexcept

Get driver configuration as formatted string (heap allocating)

Returns
String containing complete driver configuration and status information

Returns a human-readable string with all driver configuration, register values, and current status. Useful for debugging and diagnostics.

Note
The returned string is allocated on the heap (std::string / std::to_string).
For embedded systems, prefer LogConfigSummary() / LogDerivedInitSummary() or implement a fixed-size buffer variant.

◆ GetDriverVersion()

template<typename CommType >
static constexpr const char * tmc51x0::TMC51x0< CommType >::GetDriverVersion ( )
inlinestaticconstexprprotectednoexcept

Get the compiled driver version string.

◆ GetDriverVersionMajor()

template<typename CommType >
static constexpr uint8_t tmc51x0::TMC51x0< CommType >::GetDriverVersionMajor ( )
inlinestaticconstexprprotectednoexcept

Get the compiled driver major version number.

◆ GetDriverVersionMinor()

template<typename CommType >
static constexpr uint8_t tmc51x0::TMC51x0< CommType >::GetDriverVersionMinor ( )
inlinestaticconstexprprotectednoexcept

Get the compiled driver minor version number.

◆ GetDriverVersionPatch()

template<typename CommType >
static constexpr uint8_t tmc51x0::TMC51x0< CommType >::GetDriverVersionPatch ( )
inlinestaticconstexprprotectednoexcept

Get the compiled driver patch version number.

◆ GetMotorCurrentDebugInfo()

template<typename CommType >
MotorCurrentDebugInfo tmc51x0::TMC51x0< CommType >::GetMotorCurrentDebugInfo ( ) const
noexcept

Get motor-current calculated/cached values for application logging.

Returns
A snapshot of motor-current related values.
Note
If the driver has not been initialized yet, values may be defaults.

◆ HardReset()

template<typename CommType >
Result< void > tmc51x0::TMC51x0< CommType >::HardReset ( const HardResetOptions & opts = HardResetOptions())
noexcept

Perform a hard reset (power-cycle when available, else software reset)

Parameters
optsHard reset options
Returns
Result<void> indicating success or error

Behavior:

  • If the platform implements CommInterface::PowerCycle(), this will power-cycle the device (true hard reset / POR semantics).
  • Otherwise, it falls back to Reset() (software reset via GSTAT).
  • If opts.reinitialize=true, Initialize(GetDriverConfig()) is called after reset.

UART multi-node note:

  • A power-cycle resets NODECONF in the chip. To re-initialize reliably, the device must be reachable at UART address 0 (typically the first chip with NAI tied to GND). For multi-node chains, prefer using TMC51x0MultiNode and ProgramSequentially() after power-up.

◆ Initialize()

template<typename CommType >
Result< void > tmc51x0::TMC51x0< CommType >::Initialize ( const DriverConfig & config = DriverConfig(),
bool verbose = true )
noexcept

Initialize the TMC51x0 driver with configuration.

Parameters
configDriver configuration structure
verboseIf true, print configuration summary table (default: true)
Returns
Result<void> indicating success or specific error

This method performs the complete initialization sequence:

  1. Clear reset and error flags
  2. Configure power stage parameters
  3. Configure motor current settings
  4. Configure chopper settings
  5. Configure stealthChop settings
  6. Configure short protection
  7. Set ramp mode to positioning
  8. Configure global settings

The configuration is stored internally as a snapshot of initialization state. This snapshot represents what was configured during Initialize(), not runtime state. Runtime changes (e.g., SetCurrent(), SetMaxSpeed()) do not update this snapshot.

auto result = driver.Initialize(config);
if (!result) { // Bool operator
printf("Error: %s\n", result.ErrorMessage());
}
// Quiet reinitialization (e.g., after chip reset):
auto result2 = driver.Initialize(config, false);
Here is the caller graph for this function:

◆ IsInitialized()

template<typename CommType >
bool tmc51x0::TMC51x0< CommType >::IsInitialized ( ) const
inlineprotectednoexcept

Check if the driver is initialized.

Returns
true if initialized, false otherwise

◆ IsInternalRampMode()

template<typename CommType >
Result< bool > tmc51x0::TMC51x0< CommType >::IsInternalRampMode ( )
privatenoexcept

Check whether the chip is currently in internal ramp-generator mode (SD_MODE=0).

This reads IOIN.SD_MODE from the chip. If SD_MODE=1 (external Step/Dir), the internal ramp generator is not the active motion source and many motion-controller registers will not behave as users expect.

Returns
Result<bool> with true if SD_MODE=0 (internal ramp), false if SD_MODE=1 (external Step/Dir), or an error on communication failure.

◆ LogConfigSummary()

template<typename CommType >
void tmc51x0::TMC51x0< CommType >::LogConfigSummary ( const DriverConfig & cfg,
const char * tag = "TMC5160",
LogLevel lvl = LogLevel::Info )
noexcept

Log a comprehensive, human-readable summary of a DriverConfig.

Uses the driver's communication interface for logging (TMC51X0_LOG_DEBUG).

This is useful both before Initialize() (to verify the config you are about to apply) and after Initialize() (to compare with derived/cached values).

Note
This method is only available when TMC51X0_DISABLE_DEBUG_LOGGING is not defined. When disabled, calls to this method are optimized out at compile time.

◆ LogDerivedInitSummary()

template<typename CommType >
void tmc51x0::TMC51x0< CommType >::LogDerivedInitSummary ( const char * tag = "TMC5160",
LogLevel lvl = LogLevel::Info )
noexcept

Log a compact, table-style summary of derived/cached initialization values.

Includes f_clk, detected chip version, calculated currents (IRUN/IHOLD/GLOBAL_SCALER), cached write-only registers (IHOLD_IRUN, GLOBAL_SCALER, DRV_CONF), and a decoded IHOLDDELAY timing estimate.

Note
Requires that the driver has been initialized at least once (uses cached values).
This method is only available when TMC51X0_DISABLE_DEBUG_LOGGING is not defined. When disabled, calls to this method are optimized out at compile time.

◆ LogLiveStatusReport()

template<typename CommType >
void tmc51x0::TMC51x0< CommType >::LogLiveStatusReport ( const char * tag = "TMC5160",
LogLevel lvl = LogLevel::Info )
noexcept

Read silicon registers and log a comprehensive live status report.

Performs SPI/UART transactions to capture the current hardware state of the chip (GSTAT, DRV_STATUS, IOIN, CHOPCONF, PWMCONF, etc.) and prints it in a beautiful table format.

This is useful for "recapturing" the actual live state from the driver to verify it matches requested settings or to diagnose issues.

Note
This method is only available when TMC51X0_DISABLE_DEBUG_LOGGING is not defined. When disabled, calls to this method are optimized out at compile time.

◆ RequireInternalRampMode()

template<typename CommType >
Result< void > tmc51x0::TMC51x0< CommType >::RequireInternalRampMode ( )
privatenoexcept

Require internal ramp-generator mode (SD_MODE=0) for motion-controller operations.

Returns
Result<void> OK if internal ramp mode, INVALID_STATE if in external Step/Dir mode, COMM_ERROR if IOIN cannot be read.

◆ Reset()

template<typename CommType >
Result< void > tmc51x0::TMC51x0< CommType >::Reset ( )
protectednoexcept

Reset the TMC51x0 driver.

Returns
Result<void> indicating success or error

Performs a software reset by writing to the GSTAT register.

◆ speedFromInternal()

template<typename CommType >
float tmc51x0::TMC51x0< CommType >::speedFromInternal ( int32_t speed_internal) const
privatenoexcept

Convert speed from internal TMC5160 units to Hz.

Parameters
speed_internalSpeed in internal TMC5160 units
Returns
Speed in steps per second

◆ speedToInternal()

template<typename CommType >
int32_t tmc51x0::TMC51x0< CommType >::speedToInternal ( float speed_hz) const
privatenoexcept

Convert speed from Hz to internal TMC5160 units.

Parameters
speed_hzSpeed in steps per second
Returns
Speed in internal TMC5160 units

◆ thresholdSpeedToTstep()

template<typename CommType >
int32_t tmc51x0::TMC51x0< CommType >::thresholdSpeedToTstep ( float speed_hz) const
privatenoexcept

Convert threshold speed to TSTEP format.

Parameters
speed_hzSpeed threshold in steps per second
Returns
TSTEP value (0 if speed is 0)

Member Data Documentation

◆ calculated_global_scaler_

template<typename CommType >
uint16_t tmc51x0::TMC51x0< CommType >::calculated_global_scaler_ {0}
private

◆ calculated_ihold_

template<typename CommType >
uint8_t tmc51x0::TMC51x0< CommType >::calculated_ihold_ {0}
private

◆ calculated_irun_

template<typename CommType >
uint8_t tmc51x0::TMC51x0< CommType >::calculated_irun_ {0}
private

◆ chip_version_

template<typename CommType >
uint8_t tmc51x0::TMC51x0< CommType >::chip_version_ {ChipVersion::TMC5160}
private

Detected chip version (0x11 = TMC5130, 0x30 = TMC5160)

◆ comm_

template<typename CommType >
CommType& tmc51x0::TMC51x0< CommType >::comm_
private

Communication interface reference.

◆ current_microsteps_

template<typename CommType >
uint16_t tmc51x0::TMC51x0< CommType >::current_microsteps_ {256}
private

◆ daisy_chain_position_

template<typename CommType >
uint8_t tmc51x0::TMC51x0< CommType >::daisy_chain_position_
private

Position in daisy chain (0 = first chip/single chip)

◆ driver_config_

template<typename CommType >
DriverConfig tmc51x0::TMC51x0< CommType >::driver_config_
private

◆ f_clk_

template<typename CommType >
uint32_t tmc51x0::TMC51x0< CommType >::f_clk_ {ClockFreq::DEFAULT_F_CLK}
private

TMC51x0 clock frequency in Hz.

◆ initialized_

template<typename CommType >
bool tmc51x0::TMC51x0< CommType >::initialized_ {false}
private

Initialization status flag.

◆ mechanical_system_

template<typename CommType >
MechanicalSystem tmc51x0::TMC51x0< CommType >::mechanical_system_
private

◆ motor_spec_

template<typename CommType >
MotorSpec tmc51x0::TMC51x0< CommType >::motor_spec_
private

◆ send_delay_

template<typename CommType >
uint8_t tmc51x0::TMC51x0< CommType >::send_delay_
private
Initial value:
{
0}

UART send delay (0-15) stored locally from NODECONF register.

◆ this [1/15]

template<typename CommType >
struct tmc51x0::TMC51x0::RampControl* tmc51x0::TMC51x0< CommType >::this

◆ this [2/15]

template<typename CommType >
struct tmc51x0::TMC51x0::Switches* tmc51x0::TMC51x0< CommType >::this

◆ this [3/15]

template<typename CommType >
struct tmc51x0::TMC51x0::Events* tmc51x0::TMC51x0< CommType >::this

◆ this [4/15]

template<typename CommType >
struct tmc51x0::TMC51x0::MotorControl* tmc51x0::TMC51x0< CommType >::this

◆ this [5/15]

template<typename CommType >
struct tmc51x0::TMC51x0::Thresholds* tmc51x0::TMC51x0< CommType >::this

◆ this [6/15]

template<typename CommType >
struct tmc51x0::TMC51x0::PowerStage* tmc51x0::TMC51x0< CommType >::this

◆ this [7/15]

template<typename CommType >
struct tmc51x0::TMC51x0::Communication* tmc51x0::TMC51x0< CommType >::this

◆ this [8/15]

template<typename CommType >
struct tmc51x0::TMC51x0::Io* tmc51x0::TMC51x0< CommType >::this

◆ this [9/15]

template<typename CommType >
struct tmc51x0::TMC51x0::Encoder* tmc51x0::TMC51x0< CommType >::this

◆ this [10/15]

template<typename CommType >
struct tmc51x0::TMC51x0::Status* tmc51x0::TMC51x0< CommType >::this

◆ this [11/15]

template<typename CommType >
struct tmc51x0::TMC51x0::StallGuard* tmc51x0::TMC51x0< CommType >::this

◆ this [12/15]

template<typename CommType >
struct tmc51x0::TMC51x0::Tuning* tmc51x0::TMC51x0< CommType >::this

◆ this [13/15]

template<typename CommType >
struct tmc51x0::TMC51x0::Homing* tmc51x0::TMC51x0< CommType >::this

◆ this [14/15]

template<typename CommType >
struct tmc51x0::TMC51x0::Printer* tmc51x0::TMC51x0< CommType >::this

◆ this [15/15]

template<typename CommType >
struct tmc51x0::TMC51x0::UartConfig tmc51x0::TMC51x0< CommType >::this

◆ uart_node_address_

template<typename CommType >
uint8_t tmc51x0::TMC51x0< CommType >::uart_node_address_
private

UART node address (0-254) for multi-node addressing

◆ write_only_regs_

template<typename CommType >
struct tmc51x0::TMC51x0::WriteOnlyRegisters tmc51x0::TMC51x0< CommType >::write_only_regs_
private

The documentation for this class was generated from the following file: