TMC5160 Driver
API reference
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
tmc51x0::DriverConfig Struct Reference

Driver initialization configuration structure. More...

#include <tmc51x0_types.hpp>

Collaboration diagram for tmc51x0::DriverConfig:
[legend]

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)
 

Detailed Description

Driver initialization configuration structure.

Complete configuration structure for initializing the TMC5160 driver. Contains all necessary parameters for power stage, motor, and driver operation.

Automatic Current Calculation

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:

Optional Parameters:

DO NOT manually set IRUN, IHOLD, or GLOBAL_SCALER - they are calculated automatically.

Clock Configuration

f_clk is automatically calculated from external_clk_config during Initialize(). The actual clock frequency used for timing calculations (f_clk) is determined internally:

Clock Mode Selection:

DO NOT manually set f_clk - it is calculated automatically from external_clk_config.

ESP32 Platform Configuration

For ESP32 examples, use helper functions from esp32_tmc5160_test_config.hpp:

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.

Constructor & Destructor Documentation

◆ DriverConfig()

tmc51x0::DriverConfig::DriverConfig ( )
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).

Member Data Documentation

◆ chopper

ChopperConfig tmc51x0::DriverConfig::chopper {}

Chopper configuration (SpreadCycle or Classic mode)

◆ coolstep

CoolStepConfig tmc51x0::DriverConfig::coolstep {}

CoolStep configuration (defaults: lower_threshold_sg=0, disabled)

◆ dcstep

DcStepConfig tmc51x0::DriverConfig::dcstep {}

DcStep configuration (defaults: min_velocity=0, disabled)

◆ direction

MotorDirection tmc51x0::DriverConfig::direction {MotorDirection::NORMAL}

Motor direction (normal or inverse)

◆ encoder_config

EncoderConfig tmc51x0::DriverConfig::encoder_config {}

Encoder configuration (includes pulses per rev, invert direction, deviation)

◆ external_clk_config

ExternalClockConfig tmc51x0::DriverConfig::external_clk_config {}

External clock configuration (0 = use internal 12 MHz, >0 = external clock frequency)

◆ global_config

GlobalConfig tmc51x0::DriverConfig::global_config {}

Global configuration (GCONF register)

◆ mechanical

MechanicalSystem tmc51x0::DriverConfig::mechanical {}

Mechanical system configuration (gearing, leadscrew, etc.) for unit conversions.

◆ motor_spec

MotorSpec tmc51x0::DriverConfig::motor_spec {}

Motor specifications (physical parameters for automatic current calculation)

◆ power_stage

PowerStageParameters tmc51x0::DriverConfig::power_stage {}

Power stage configuration (includes short protection)

◆ ramp_config

RampConfig tmc51x0::DriverConfig::ramp_config {}

Ramp generator configuration (with unit support)

◆ reference_switch_config

ReferenceSwitchConfig tmc51x0::DriverConfig::reference_switch_config {}

Reference switch configuration (defaults: stop disabled, latching disabled)

◆ stallguard

StallGuardConfig tmc51x0::DriverConfig::stallguard {}

StallGuard2 configuration (defaults: threshold=0, disabled)

◆ stealthchop

StealthChopConfig tmc51x0::DriverConfig::stealthchop {}

StealthChop configuration.

◆ uart_config

UartConfig tmc51x0::DriverConfig::uart_config {}

UART communication configuration (node address, send delay)


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