|
HF-TMC51x0 Driver (TMC5130 & TMC5160) 0.1.0-dev
Hardware Agnostic C++ Driver for the TMC51x0 (TMC5130 & TMC5160)
|
Namespaces | |
| namespace | anonymous_namespace{esp32_tmc51x0_test_config.hpp} |
| namespace | ConfigValidators |
| Validator helper - checks if a type has required members. | |
Classes | |
| struct | BoardConfig_TMC51x0_BOB |
| Board hardware configuration for TMC51x0 Break-Out Board (BOB) More... | |
| struct | BoardConfig_TMC51x0_EVAL |
| Board hardware configuration for TMC51x0 Evaluation Kit. More... | |
| struct | MotorConfig_17HS4401S |
| Motor Configuration for 17HS4401S-PG518 NEMA 17 Stepper Motor (WITH GEARBOX) More... | |
| struct | MotorConfig_17HS4401S_Direct |
| Motor Configuration for 17HS4401S NEMA 17 Stepper Motor (DIRECT DRIVE, NO GEARBOX) More... | |
| struct | MotorConfig_AppliedMotion_5034_369 |
| Motor Configuration for Applied Motion 5034-369 NEMA 34 Stepper Motor. More... | |
| struct | PlatformConfig_CoreDriverTestRig |
| Platform configuration for Core Driver Test Rig. More... | |
| struct | PlatformConfig_FatigueTestRig |
| Platform configuration for Fatigue Test Rig. More... | |
| struct | TestConfig_17HS4401S |
| Test Rig Configuration Defaults. More... | |
| struct | TestConfig_AppliedMotion_5034 |
| Test Configuration for Applied Motion 5034-369 Motor. More... | |
| struct | TestConfigAccessor |
| Test configuration accessor struct. More... | |
| struct | TestRigConfig |
| Base template for test rig configuration (undefined - forces explicit specialization) More... | |
| struct | TestRigConfig< TestRigType::TEST_RIG_CORE_DRIVER > |
| Test rig configuration for TEST_RIG_CORE_DRIVER. More... | |
| struct | TestRigConfig< TestRigType::TEST_RIG_FATIGUE > |
| Test rig configuration for TEST_RIG_FATIGUE. More... | |
Typedefs | |
| template<TestRigType test_rig> | |
| using | GetTestConfigForTestRig = typename TestRigConfig<test_rig>::Test |
| Get test configuration accessor for a given test rig. | |
Enumerations | |
| enum class | MotorType { MOTOR_17HS4401S_GEARBOX , MOTOR_17HS4401S_DIRECT , MOTOR_APPLIED_MOTION_5034 } |
| Motor type enumeration for compile-time motor selection. More... | |
| enum class | BoardType { BOARD_TMC51x0_EVAL , BOARD_TMC51x0_BOB } |
| Board type enumeration. More... | |
| enum class | PlatformType { PLATFORM_CORE_DRIVER_TEST_RIG , PLATFORM_FATIGUE_TEST_RIG } |
| Platform type enumeration. More... | |
| enum class | TestRigType { TEST_RIG_CORE_DRIVER , TEST_RIG_FATIGUE } |
| Test rig type enumeration. More... | |
Functions | |
| Esp32SpiPinConfig | GetDefaultPinConfig () noexcept |
| Complete pin configuration for all tests. | |
| template<BoardType board_type> | |
| void | ApplyBoardConfig (tmc51x0::DriverConfig &cfg) noexcept |
| Helper function to apply board configuration to DriverConfig. | |
| void | ConfigureDriverFromMotor_17HS4401S_Gearbox (tmc51x0::DriverConfig &cfg) noexcept |
| Helper function to populate DriverConfig from 17HS4401S gearbox motor configuration. | |
| void | ConfigureDriverFromMotor_17HS4401S_Direct (tmc51x0::DriverConfig &cfg) noexcept |
| Helper function to populate DriverConfig from 17HS4401S direct drive motor configuration. | |
| void | ConfigureDriverFromMotor_AppliedMotion_5034 (tmc51x0::DriverConfig &cfg) noexcept |
| Helper function to populate DriverConfig from Applied Motion 5034 motor configuration. | |
| template<PlatformType platform_type> | |
| void | ApplyPlatformConfig (tmc51x0::DriverConfig &cfg) noexcept |
| Helper function to apply platform configuration to DriverConfig. | |
| template<PlatformType platform_type> | |
| tmc51x0::ReferenceSwitchConfig | GetReferenceSwitchConfig () noexcept |
| Helper function to configure reference switches from platform config. | |
| template<PlatformType platform_type> | |
| tmc51x0::EncoderConfig | GetEncoderConfig () noexcept |
| Helper function to configure encoder from platform config. | |
| template<PlatformType platform_type> | |
| constexpr uint16_t | GetEncoderPulsesPerRev () noexcept |
| Helper function to get encoder pulses per revolution from platform config. | |
| template<PlatformType platform_type> | |
| bool | GetEncoderInvertDirection () noexcept |
| Helper function to get encoder invert direction flag from platform config. | |
| template<TestRigType test_rig> | |
| constexpr MotorType | GetTestRigMotorType () noexcept |
| Get motor type for a given test rig. | |
| template<TestRigType test_rig> | |
| constexpr BoardType | GetTestRigBoardType () noexcept |
| Get board type for a given test rig. | |
| template<TestRigType test_rig> | |
| constexpr PlatformType | GetTestRigPlatformType () noexcept |
| Get platform type for a given test rig. | |
| template<TestRigType test_rig> | |
| void | ConfigureDriverFromTestRig (tmc51x0::DriverConfig &cfg, bool use_direct_drive=false) noexcept |
| Configure driver from test rig selection. | |
| template<TestRigType test_rig> | |
| tmc51x0::ReferenceSwitchConfig | GetTestRigReferenceSwitchConfig () noexcept |
| Get reference switch configuration for a test rig. | |
| template<TestRigType test_rig> | |
| tmc51x0::EncoderConfig | GetTestRigEncoderConfig () noexcept |
| Get encoder configuration for a test rig. | |
| template<TestRigType test_rig> | |
| constexpr uint16_t | GetTestRigEncoderPulsesPerRev () noexcept |
| Get encoder pulses per revolution for a test rig. | |
| template<TestRigType test_rig> | |
| bool | GetTestRigEncoderInvertDirection () noexcept |
| Get encoder invert direction flag for a test rig. | |
| template<TestRigType test_rig> | |
| constexpr uint16_t | GetTestRigMotorOutputFullSteps (bool use_direct_drive=false) noexcept |
| Get motor output full steps per revolution for a test rig. | |
Variables | |
| constexpr gpio_num_t | SPI_SCK = GPIO_NUM_5 |
| SPI clock pin. | |
| constexpr gpio_num_t | SPI_MOSI = GPIO_NUM_6 |
| SPI MOSI (master out, slave in) | |
| constexpr gpio_num_t | SPI_MISO = GPIO_NUM_2 |
| SPI MISO (master in, slave out) | |
| constexpr gpio_num_t | SPI_CS = GPIO_NUM_18 |
| SPI chip select pin. | |
| constexpr gpio_num_t | DRV_EN = GPIO_NUM_11 |
| Driver enable pin (DRV_ENN) | |
| constexpr gpio_num_t | CLK = GPIO_NUM_10 |
| Clock input pin (CLK, pin 12) | |
| constexpr gpio_num_t | SPI_MODE_PIN = GPIO_NUM_0 |
| SPI_MODE pin (pin 22) - GPIO0 if available as control pin. | |
| constexpr gpio_num_t | SD_MODE_PIN = GPIO_NUM_1 |
| SD_MODE pin (pin 21) - GPIO1 if available as control pin. | |
| constexpr gpio_num_t | DIAG0 = GPIO_NUM_23 |
| Diagnostic output 0 (DIAG0_SWN, pin 26) | |
| constexpr gpio_num_t | DIAG1 = GPIO_NUM_15 |
| Diagnostic output 1 (DIAG1_SWP, pin 27) | |
| constexpr gpio_num_t | DIR = static_cast<gpio_num_t>(-1) |
| Direction pin (optional) | |
| constexpr gpio_num_t | STEP = static_cast<gpio_num_t>(-1) |
| Step pin (optional) | |
| constexpr uint32_t | SPI_CLOCK_SPEED_HZ = 500000 |
| SPI clock speed. | |
| constexpr spi_host_device_t | SPI_HOST = SPI2_HOST |
| SPI host device. | |
| using tmc51x0_test_config::GetTestConfigForTestRig = typename TestRigConfig<test_rig>::Test |
Get test configuration accessor for a given test rig.
Automatically selects the appropriate test config based on the test rig's motor type. This provides compile-time access to test configuration parameters.
Usage: using TestConfig = GetTestConfigForTestRig<SELECTED_TEST_RIG>; float speed = TestConfig::Motion::BOUNDS_SEARCH_SPEED_RPM;
|
strong |
Board type enumeration.
Selects which board configuration to use at compile time. Board configuration includes hardware parameters like sense resistor, supply voltage, MOSFET characteristics, etc.
| Enumerator | |
|---|---|
| BOARD_TMC51x0_EVAL | TMC51x0 Evaluation Kit (0.05Ω sense, 24V, BSC072N08NS5 MOSFETs) |
| BOARD_TMC51x0_BOB | TMC51x0 Break-Out Board (0.11Ω sense, 24V, typical MOSFETs) |
|
strong |
Motor type enumeration for compile-time motor selection.
This enumeration defines the available motor configurations that can be selected at compile time. Each motor has its own configuration namespace with optimized settings for current, chopper, and StealthChop parameters.
MOTOR SELECTION GUIDE:
USAGE: In your example file, declare a static constexpr variable at global scope:
static constexpr tmc51x0_test_config::MotorType SELECTED_MOTOR =
tmc51x0_test_config::MotorType::MOTOR_17HS4401S_GEARBOX;
Then use conditional compilation or if constexpr to select the motor namespace:
if constexpr (SELECTED_MOTOR == MotorType::MOTOR_17HS4401S_GEARBOX) {
namespace Motor = tmc51x0_test_config::MotorConfig_17HS4401S;
} else if constexpr (SELECTED_MOTOR == MotorType::MOTOR_17HS4401S_DIRECT) {
namespace Motor = tmc51x0_test_config::MotorConfig_17HS4401S_Direct;
} else if constexpr (SELECTED_MOTOR == MotorType::MOTOR_APPLIED_MOTION_5034) {
namespace Motor = tmc51x0_test_config::MotorConfig_AppliedMotion_5034_369;
}
Motor type enumeration
Selects which motor configuration to use at compile time.
|
strong |
Platform type enumeration.
Selects which platform configuration to use at compile time. Platform configuration includes reference switches, encoder, mechanical system type, etc.
|
strong |
Test rig type enumeration.
Selects which complete test rig configuration to use at compile time. Each test rig automatically selects the appropriate motor, board, and platform. This simplifies configuration by grouping related hardware together.
TEST RIG CONFIGURATIONS:
|
inlinenoexcept |
Helper function to apply board configuration to DriverConfig.
Applies board-specific configuration (sense resistor, MOSFETs, etc.) to an already-configured DriverConfig. This should be called after motor configuration.
Uses ConfigBuilder internally for improved readability and maintainability.
| [in,out] | cfg | DriverConfig structure (must be configured with motor settings first) |
| [in] | board_type | Board type to use (compile-time constant) |
|
inlinenoexcept |
Helper function to apply platform configuration to DriverConfig.
Applies platform-specific configuration (mechanical system) to an already-configured DriverConfig. This should be called after motor configuration.
Uses ConfigBuilder internally for improved readability and maintainability.
| [in,out] | cfg | DriverConfig structure (must be configured with motor settings first) |
| [in] | platform_type | Platform type to use (compile-time constant) |
|
inlinenoexcept |
Helper function to populate DriverConfig from 17HS4401S direct drive motor configuration.
Configures motor-specific parameters only. Board and platform configuration should be applied separately via ApplyBoardConfig() and ApplyPlatformConfig().
Uses ConfigBuilder internally for improved readability and maintainability.
| [out] | cfg | DriverConfig structure to populate |
|
inlinenoexcept |
Helper function to populate DriverConfig from 17HS4401S gearbox motor configuration.
Configures motor-specific parameters only. Board and platform configuration should be applied separately via ApplyBoardConfig() and ApplyPlatformConfig().
Uses ConfigBuilder internally for improved readability and maintainability.
| [out] | cfg | DriverConfig structure to populate |
|
inlinenoexcept |
Helper function to populate DriverConfig from Applied Motion 5034 motor configuration.
Configures motor-specific parameters only. Board and platform configuration should be applied separately via ApplyBoardConfig() and ApplyPlatformConfig().
Uses ConfigBuilder internally for improved readability and maintainability.
| [out] | cfg | DriverConfig structure to populate |
|
inlinenoexcept |
Configure driver from test rig selection.
This is a convenience function that automatically configures motor, board, platform, reference switches, and encoder based on the test rig selection. For Core Driver rig, defaults to gearbox motor.
| [out] | cfg | DriverConfig structure to populate |
| [in] | test_rig | Test rig type (compile-time constant) |
| [in] | use_direct_drive | For Core Driver rig only: true = direct drive motor, false = gearbox motor (default) |
|
inlinenoexcept |
Complete pin configuration for all tests.
This structure includes both SPI pins and TMC51x0 control pins, allowing all GPIO assignments to be managed in one place. Use this with the Esp32SPI constructor that takes Esp32SpiPinConfig.
|
inlinenoexcept |
Helper function to configure encoder from platform config.
Creates an EncoderConfig structure from platform configuration. This can be used after driver initialization to configure encoder.
| [in] | platform_type | Platform type to use (compile-time constant) |
|
inlinenoexcept |
Helper function to get encoder invert direction flag from platform config.
| [in] | platform_type | Platform type to use (compile-time constant) |
|
constexprnoexcept |
Helper function to get encoder pulses per revolution from platform config.
| [in] | platform_type | Platform type to use (compile-time constant) |
|
inlinenoexcept |
Helper function to configure reference switches from platform config.
Creates a ReferenceSwitchConfig structure from platform configuration. This can be used after driver initialization to configure reference switches.
| [in] | platform_type | Platform type to use (compile-time constant) |
|
constexprnoexcept |
Get board type for a given test rig.
| [in] | test_rig | Test rig type |
|
inlinenoexcept |
Get encoder configuration for a test rig.
Convenience function that automatically selects the platform and returns encoder config.
| [in] | test_rig | Test rig type (compile-time constant) |
|
inlinenoexcept |
Get encoder invert direction flag for a test rig.
| [in] | test_rig | Test rig type (compile-time constant) |
|
constexprnoexcept |
Get encoder pulses per revolution for a test rig.
| [in] | test_rig | Test rig type (compile-time constant) |
|
constexprnoexcept |
Get motor output full steps per revolution for a test rig.
Returns the number of full steps per revolution at the output shaft (accounting for gearbox if present).
| [in] | test_rig | Test rig type (compile-time constant) |
| [in] | use_direct_drive | For Core Driver rig only: true = direct drive motor, false = gearbox motor (default) |
|
constexprnoexcept |
Get motor type for a given test rig.
| [in] | test_rig | Test rig type |
|
constexprnoexcept |
Get platform type for a given test rig.
| [in] | test_rig | Test rig type |
|
inlinenoexcept |
Get reference switch configuration for a test rig.
Convenience function that automatically selects the platform and returns reference switch config.
| [in] | test_rig | Test rig type (compile-time constant) |
|
constexpr |
Clock input pin (CLK, pin 12)
|
constexpr |
Diagnostic output 0 (DIAG0_SWN, pin 26)
|
constexpr |
Diagnostic output 1 (DIAG1_SWP, pin 27)
|
constexpr |
Direction pin (optional)
|
constexpr |
Driver enable pin (DRV_ENN)
|
constexpr |
SD_MODE pin (pin 21) - GPIO1 if available as control pin.
|
constexpr |
SPI clock speed.
|
constexpr |
SPI chip select pin.
|
constexpr |
SPI host device.
|
constexpr |
SPI MISO (master in, slave out)
|
constexpr |
SPI_MODE pin (pin 22) - GPIO0 if available as control pin.
|
constexpr |
SPI MOSI (master out, slave in)
|
constexpr |
SPI clock pin.
|
constexpr |
Step pin (optional)