HF-TMC51x0 Driver (TMC5130 & TMC5160) 0.1.0-dev
Hardware Agnostic C++ Driver for the TMC51x0 (TMC5130 & TMC5160)
Loading...
Searching...
No Matches
bounds_finding_test.cpp File Reference

Standalone Bounds Finding Test Tool. More...

#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "../../../inc/tmc51x0.hpp"
#include "test_config/esp32_tmc51x0_bus.hpp"
#include "test_config/esp32_tmc51x0_test_config.hpp"
#include "esp_log.h"
#include "esp_timer.h"
Include dependency graph for bounds_finding_test.cpp:

Typedefs

using TestConfig = tmc51x0_test_config::GetTestConfigForTestRig<SELECTED_TEST_RIG>
 

Enumerations

enum class  TestHomePlacement { AtCenter , AtMin , AtMax , None }
 

Functions

void app_main (void)
 

Variables

static const char * TAG = "BoundsTest"
 
static constexpr tmc51x0_test_config::TestRigType SELECTED_TEST_RIG
 
static constexpr bool BOUNDS_SEARCH_POSITIVE_FIRST = true
 
static constexpr bool OVERRIDE_BOUNDS_SEARCH_SPEED = false
 
static constexpr float BOUNDS_SEARCH_SPEED_RPM_OVERRIDE = 60.0f
 
static constexpr float BOUNDS_SEARCH_SPEED_RPM
 
static constexpr bool OVERRIDE_BOUNDS_SEARCH_ACCEL = false
 
static constexpr float BOUNDS_SEARCH_ACCEL_REV_S2_OVERRIDE = 15.0f
 
static constexpr float BOUNDS_SEARCH_ACCEL_REV_S2
 
static constexpr float BOUNDS_SEARCH_SPAN_DEG = 400.0f
 
static constexpr float BOUNDS_BACKOFF_DEG = 0.0f
 
static constexpr uint32_t BOUNDS_TIMEOUT_MS = 30000
 
static constexpr bool OVERRIDE_STALLGUARD_MIN_VELOCITY = false
 
static constexpr float STALLGUARD_MIN_VELOCITY_RPM_OVERRIDE = 20.0f
 
static constexpr float STALLGUARD_MIN_VELOCITY_RPM
 
static constexpr bool OVERRIDE_STALL_DETECTION_CURRENT_FACTOR = false
 
static constexpr float STALL_DETECTION_CURRENT_FACTOR_OVERRIDE = 0.5f
 
static constexpr float STALL_DETECTION_CURRENT_FACTOR
 
static constexpr bool USE_STALLGUARD = true
 
static constexpr TestHomePlacement HOME_PLACEMENT_MODE = TestHomePlacement::AtCenter
 
static constexpr bool ENABLE_POST_BOUNDS_OSCILLATION = true
 
static constexpr uint32_t POST_BOUNDS_OSCILLATION_COUNT = 5
 
static constexpr float POST_BOUNDS_OSC_SPEED_RPM = 60.0f
 
static constexpr float POST_BOUNDS_OSC_ACCEL_REV_S2 = 5.0f
 
static constexpr float POST_BOUNDS_OSC_EDGE_BACKOFF_DEG = 3.5f
 
static constexpr uint32_t POST_BOUNDS_OSC_LEG_TIMEOUT_MS = 15000
 
static constexpr uint32_t POST_BOUNDS_OSC_POLL_MS = 20
 
static constexpr uint32_t POST_BOUNDS_OSC_SETTLE_MS = 200
 

Detailed Description

Standalone Bounds Finding Test Tool.

This tool tests the bounds finding functionality by performing a complete bounds finding sequence just like the fatigue test unit does. It:

  1. Initializes the driver with the configured motor
  2. Enables the motor
  3. Performs bounds finding using StallGuard
  4. Homes to the center of the found range
  5. Reports detailed results
  6. Disables the motor

USAGE:

  1. Ensure the motor is connected and has mechanical limits (hard stops)
  2. Flash and run this tool
  3. The motor will search for bounds in both directions
  4. Results will be logged including min/max bounds and center position
Author
Nebiyu Tadesse
Date
2025

Typedef Documentation

◆ TestConfig

Enumeration Type Documentation

◆ TestHomePlacement

enum class TestHomePlacement
strong
Enumerator
AtCenter 
AtMin 
AtMax 
None 

Function Documentation

◆ app_main()

void app_main ( void )
Here is the call graph for this function:

Variable Documentation

◆ BOUNDS_BACKOFF_DEG

constexpr float BOUNDS_BACKOFF_DEG = 0.0f
staticconstexpr

◆ BOUNDS_SEARCH_ACCEL_REV_S2

constexpr float BOUNDS_SEARCH_ACCEL_REV_S2
staticconstexpr
Initial value:
=
OVERRIDE_BOUNDS_SEARCH_ACCEL ? BOUNDS_SEARCH_ACCEL_REV_S2_OVERRIDE : TestConfig::Motion::BOUNDS_SEARCH_ACCEL_REV_S2
static constexpr float BOUNDS_SEARCH_ACCEL_REV_S2_OVERRIDE
Definition bounds_finding_test.cpp:65
static constexpr bool OVERRIDE_BOUNDS_SEARCH_ACCEL
Definition bounds_finding_test.cpp:64

◆ BOUNDS_SEARCH_ACCEL_REV_S2_OVERRIDE

constexpr float BOUNDS_SEARCH_ACCEL_REV_S2_OVERRIDE = 15.0f
staticconstexpr

◆ BOUNDS_SEARCH_POSITIVE_FIRST

constexpr bool BOUNDS_SEARCH_POSITIVE_FIRST = true
staticconstexpr

◆ BOUNDS_SEARCH_SPAN_DEG

constexpr float BOUNDS_SEARCH_SPAN_DEG = 400.0f
staticconstexpr

◆ BOUNDS_SEARCH_SPEED_RPM

constexpr float BOUNDS_SEARCH_SPEED_RPM
staticconstexpr
Initial value:
=
OVERRIDE_BOUNDS_SEARCH_SPEED ? BOUNDS_SEARCH_SPEED_RPM_OVERRIDE : TestConfig::Motion::BOUNDS_SEARCH_SPEED_RPM
static constexpr float BOUNDS_SEARCH_SPEED_RPM_OVERRIDE
Definition bounds_finding_test.cpp:59
static constexpr bool OVERRIDE_BOUNDS_SEARCH_SPEED
Definition bounds_finding_test.cpp:58

◆ BOUNDS_SEARCH_SPEED_RPM_OVERRIDE

constexpr float BOUNDS_SEARCH_SPEED_RPM_OVERRIDE = 60.0f
staticconstexpr

◆ BOUNDS_TIMEOUT_MS

constexpr uint32_t BOUNDS_TIMEOUT_MS = 30000
staticconstexpr

◆ ENABLE_POST_BOUNDS_OSCILLATION

constexpr bool ENABLE_POST_BOUNDS_OSCILLATION = true
staticconstexpr

◆ HOME_PLACEMENT_MODE

constexpr TestHomePlacement HOME_PLACEMENT_MODE = TestHomePlacement::AtCenter
staticconstexpr

◆ OVERRIDE_BOUNDS_SEARCH_ACCEL

constexpr bool OVERRIDE_BOUNDS_SEARCH_ACCEL = false
staticconstexpr

◆ OVERRIDE_BOUNDS_SEARCH_SPEED

constexpr bool OVERRIDE_BOUNDS_SEARCH_SPEED = false
staticconstexpr

◆ OVERRIDE_STALL_DETECTION_CURRENT_FACTOR

constexpr bool OVERRIDE_STALL_DETECTION_CURRENT_FACTOR = false
staticconstexpr

◆ OVERRIDE_STALLGUARD_MIN_VELOCITY

constexpr bool OVERRIDE_STALLGUARD_MIN_VELOCITY = false
staticconstexpr

◆ POST_BOUNDS_OSC_ACCEL_REV_S2

constexpr float POST_BOUNDS_OSC_ACCEL_REV_S2 = 5.0f
staticconstexpr

◆ POST_BOUNDS_OSC_EDGE_BACKOFF_DEG

constexpr float POST_BOUNDS_OSC_EDGE_BACKOFF_DEG = 3.5f
staticconstexpr

◆ POST_BOUNDS_OSC_LEG_TIMEOUT_MS

constexpr uint32_t POST_BOUNDS_OSC_LEG_TIMEOUT_MS = 15000
staticconstexpr

◆ POST_BOUNDS_OSC_POLL_MS

constexpr uint32_t POST_BOUNDS_OSC_POLL_MS = 20
staticconstexpr

◆ POST_BOUNDS_OSC_SETTLE_MS

constexpr uint32_t POST_BOUNDS_OSC_SETTLE_MS = 200
staticconstexpr

◆ POST_BOUNDS_OSC_SPEED_RPM

constexpr float POST_BOUNDS_OSC_SPEED_RPM = 60.0f
staticconstexpr

◆ POST_BOUNDS_OSCILLATION_COUNT

constexpr uint32_t POST_BOUNDS_OSCILLATION_COUNT = 5
staticconstexpr

◆ SELECTED_TEST_RIG

constexpr tmc51x0_test_config::TestRigType SELECTED_TEST_RIG
staticconstexpr
Initial value:
=
@ TEST_RIG_FATIGUE
Fatigue test rig (Applied Motion 5034-369 motor, TMC51x0 EVAL board, reference switches,...

◆ STALL_DETECTION_CURRENT_FACTOR

constexpr float STALL_DETECTION_CURRENT_FACTOR
staticconstexpr
Initial value:
=
: TestConfig::StallGuard::STALL_DETECTION_CURRENT_FACTOR
static constexpr float STALL_DETECTION_CURRENT_FACTOR_OVERRIDE
Definition bounds_finding_test.cpp:89
static constexpr bool OVERRIDE_STALL_DETECTION_CURRENT_FACTOR
Definition bounds_finding_test.cpp:88

◆ STALL_DETECTION_CURRENT_FACTOR_OVERRIDE

constexpr float STALL_DETECTION_CURRENT_FACTOR_OVERRIDE = 0.5f
staticconstexpr

◆ STALLGUARD_MIN_VELOCITY_RPM

constexpr float STALLGUARD_MIN_VELOCITY_RPM
staticconstexpr
Initial value:
=
: TestConfig::StallGuard::MIN_VELOCITY_RPM
static constexpr bool OVERRIDE_STALLGUARD_MIN_VELOCITY
Definition bounds_finding_test.cpp:82
static constexpr float STALLGUARD_MIN_VELOCITY_RPM_OVERRIDE
Definition bounds_finding_test.cpp:83

◆ STALLGUARD_MIN_VELOCITY_RPM_OVERRIDE

constexpr float STALLGUARD_MIN_VELOCITY_RPM_OVERRIDE = 20.0f
staticconstexpr

◆ TAG

const char* TAG = "BoundsTest"
static

◆ USE_STALLGUARD

constexpr bool USE_STALLGUARD = true
staticconstexpr