|
HF-TMC51x0 Driver (TMC5130 & TMC5160) 0.1.0-dev
Hardware Agnostic C++ Driver for the TMC51x0 (TMC5130 & TMC5160)
|
Unified fatigue test motion controller. More...
#include <fatigue_motion.hpp>
Classes | |
| struct | Status |
| Status structure containing current motion controller state. More... | |
Public Member Functions | |
| FatigueTestMotion (tmc51x0::TMC51x0< Esp32SPI > *driver, Esp32TmcMutex &driver_mutex) noexcept | |
| Construct a motion controller bound to a TMC51x0 driver instance. | |
| ~FatigueTestMotion () noexcept | |
| Destructor. | |
| void | SetGlobalBounds (float min_bound_degrees, float max_bound_degrees) noexcept |
| Set global (hardware) bounds in degrees. | |
| void | GetGlobalBoundsDegrees (float &min_degrees, float &max_degrees) const noexcept |
| Read current global bounds (degrees). | |
| void | SetUnbounded (float current_position_degrees, float default_range_degrees=175.0f) noexcept |
| Mark the system as unbounded and establish a default travel window. | |
| bool | SetLocalBoundsFromCenterDegrees (float min_degrees_from_center, float max_degrees_from_center, float edge_backoff_deg=3.5f) noexcept |
| Set local oscillation bounds (degrees) relative to the center. | |
| void | GetLocalBoundsFromCenterDegrees (float &min_degrees, float &max_degrees) const noexcept |
| Read local bounds (degrees). | |
| bool | SetMaxVelocity (float vmax_rpm) noexcept |
| Set maximum velocity for oscillation (direct TMC5160 VMAX control). | |
| float | GetMaxVelocity () const noexcept |
| Get configured maximum velocity (RPM). | |
| bool | SetAcceleration (float amax_rev_s2) noexcept |
| Set acceleration for oscillation (direct TMC5160 AMAX control). | |
| float | GetAcceleration () const noexcept |
| Get configured acceleration (rev/s²). | |
| float | GetEstimatedCycleFrequency () const noexcept |
| Get estimated cycle frequency based on current velocity/accel/distance. | |
| bool | SetDwellTimes (uint32_t dwell_at_min_ms, uint32_t dwell_at_max_ms) noexcept |
| Set dwell times at local bounds. | |
| void | GetDwellTimes (uint32_t &dwell_at_min_ms, uint32_t &dwell_at_max_ms) const noexcept |
| Get dwell times at local bounds. | |
| bool | SetTargetCycles (uint32_t cycles) noexcept |
| Set target cycle count (0 = infinite). | |
| uint32_t | GetCurrentCycles () const noexcept |
| Get current completed cycles. | |
| uint32_t | GetTargetCycles () const noexcept |
| Get configured target cycles. | |
| bool | IsCycleComplete () const noexcept |
| Check whether the configured target cycle count has been reached. | |
| void | ResetCycles () noexcept |
| Reset cycle counter and completion flags. | |
| bool | Start () noexcept |
| Start active motion. | |
| void | Pause () noexcept |
| Pause active motion (stops movement but keeps motor energized for resume). | |
| void | Stop () noexcept |
| Stop active motion and command driver stop. | |
| bool | IsRunning () const noexcept |
| Whether the motion controller is currently active. | |
| void | Update () noexcept |
| Periodic update tick. | |
| Status | GetStatus () const noexcept |
| Snapshot current controller status. | |
| bool | IsBounded () const noexcept |
| Whether the controller is in bounded mode (mechanical stops found). | |
Private Types | |
| enum class | MotionState { MOVING_TO_MIN , MOVING_TO_MAX , DWELL_AT_MIN , DWELL_AT_MAX , PAUSED , STOPPED } |
Private Member Functions | |
| void | RecalculateEstimatedFrequency () noexcept |
| void | ClipLocalBoundsToGlobal () noexcept |
Private Attributes | |
| tmc51x0::TMC51x0< Esp32SPI > * | driver_ |
| float | global_min_bound_ |
| float | global_max_bound_ |
| float | local_min_bound_ |
| float | local_max_bound_ |
| float | home_position_ |
| bool | bounded_ |
| float | amplitude_ |
| float | vmax_rpm_ |
| float | amax_rev_s2_ |
| uint32_t | dwell_at_min_ms_ |
| uint32_t | dwell_at_max_ms_ |
| bool | running_ |
| uint64_t | start_time_us_ |
| uint32_t | target_cycles_ |
| uint32_t | current_cycles_ |
| bool | cycle_complete_ |
| MotionState | state_ |
| uint32_t | dwell_start_time_ms_ |
| float | estimated_frequency_hz_ |
| Esp32TmcMutex & | driver_mutex_ |
Unified fatigue test motion controller.
Provides point-to-point back-and-forth motion between bounds for fatigue testing. Supports global bounds (hardware limits) and local bounds (oscillation range).
|
strongprivate |
|
noexcept |
Construct a motion controller bound to a TMC51x0 driver instance.
| driver | Pointer to an initialized driver (must remain valid for the lifetime of this object). |
| driver_mutex | Reference to a mutex that protects ALL driver SPI access. This same mutex must be used by any code that directly accesses the driver. |
|
defaultnoexcept |
Destructor.
|
privatenoexcept |
|
noexcept |
Get configured acceleration (rev/s²).
|
noexcept |
Get current completed cycles.
|
noexcept |
Get dwell times at local bounds.
| dwell_at_min_ms | Output dwell at min (ms). |
| dwell_at_max_ms | Output dwell at max (ms). |
|
noexcept |
Get estimated cycle frequency based on current velocity/accel/distance.
|
noexcept |
Read current global bounds (degrees).
| min_degrees | Output min bound. |
| max_degrees | Output max bound. |
|
noexcept |
Read local bounds (degrees).
| min_degrees | Output min local bound. |
| max_degrees | Output max local bound. |
|
noexcept |
Get configured maximum velocity (RPM).
|
noexcept |
Snapshot current controller status.
|
noexcept |
Get configured target cycles.
|
noexcept |
Whether the controller is in bounded mode (mechanical stops found).
|
noexcept |
Check whether the configured target cycle count has been reached.
|
noexcept |
Whether the motion controller is currently active.
|
noexcept |
Pause active motion (stops movement but keeps motor energized for resume).
Sets ramp mode to HOLD to maintain position. Motion can be resumed with Start().
|
privatenoexcept |
|
noexcept |
Reset cycle counter and completion flags.
|
noexcept |
Set acceleration for oscillation (direct TMC5160 AMAX control).
| amax_rev_s2 | Acceleration in rev/s². |
|
noexcept |
Set dwell times at local bounds.
| dwell_at_min_ms | Dwell at min (ms). |
| dwell_at_max_ms | Dwell at max (ms). |
|
noexcept |
Set global (hardware) bounds in degrees.
These bounds represent the full allowed travel range and are typically produced by bounds finding.
| min_bound_degrees | Minimum bound (degrees). |
| max_bound_degrees | Maximum bound (degrees). |
|
noexcept |
Set local oscillation bounds (degrees) relative to the center.
Local bounds are clipped to global bounds (if bounded) and define the oscillation range. An optional edge_backoff_deg parameter specifies how far inside the mechanical bounds to stay during oscillation.
| min_degrees_from_center | Minimum local bound. |
| max_degrees_from_center | Maximum local bound. |
| edge_backoff_deg | How far inside bounds to stay (default 3.5°, like bounds_finding_test). |
|
noexcept |
Set maximum velocity for oscillation (direct TMC5160 VMAX control).
| vmax_rpm | Maximum velocity in RPM. |
|
noexcept |
Set target cycle count (0 = infinite).
| cycles | Target cycles. |
|
noexcept |
Mark the system as unbounded and establish a default travel window.
Used when no mechanical stops are detected. Sets a default global range around the current position and establishes home/zero at the current position.
| current_position_degrees | Current position (degrees). |
| default_range_degrees | Default travel range to assume (degrees). |
|
noexcept |
Start active motion.
Requires local bounds to be set. Configures the driver for positioning mode.
|
noexcept |
Stop active motion and command driver stop.
|
noexcept |
Periodic update tick.
Intended to be called from a periodic task. Generates and applies updated target positions and handles dwell/cycle completion logic.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |