TMC5160 Driver
API reference
Loading...
Searching...
No Matches
Classes | Namespaces
tmc51x0_config_builder.hpp File Reference

Fluent configuration builder for TMC51x0 driver. More...

#include <cstdint>
#include "../tmc51x0_types.hpp"
Include dependency graph for tmc51x0_config_builder.hpp:

Go to the source code of this file.

Classes

class  tmc51x0::ConfigBuilder
 Fluent configuration builder for DriverConfig. More...
 

Namespaces

namespace  tmc51x0
 

Detailed Description

Fluent configuration builder for TMC51x0 driver.

Provides a fluent interface for building DriverConfig with:

Unit Naming Convention

Functions follow a clear unit naming convention for safety and readability:

This convention ensures type safety and prevents unit conversion errors.

The builder follows the same pattern as ESP32 test config:

  1. Motor configuration (motor specs, chopper, StealthChop, StallGuard, ramp defaults)
  2. Board configuration (sense resistor, power stage, clock)
  3. Platform configuration (mechanical system type)
auto config = ConfigBuilder()
// Motor configuration
.WithMotorMa(200, 1500) // 200 steps, 1500mA = 1.5A rated
.WithSupplyVoltageMv(24000) // 24000mV = 24V
.WithSenseResistorMohm(50) // 50mΩ = 0.05Ω
.WithRunCurrentMa(1500) // 1500mA = 1.5A run current
.WithHoldCurrentMa(750) // 750mA = 0.75A hold current
// Chopper configuration
.WithChopperMode(ChopperMode::SPREAD_CYCLE)
.WithChopperToff(5)
.WithChopperBlankTime(ChopperBlankTime::TBL_36CLK)
// StealthChop configuration
.WithStealthChop(true)
.WithStealthChopThreshold({800.0f, Unit::Steps})
// Motion configuration
.WithMaxSpeed({100.0f, Unit::RPM})
.WithAcceleration({50.0f, Unit::RevPerSec})
// Mechanical system
.WithGearbox(5.18f) // 5.18:1 gearbox
.Build();