|
HF-TMC51x0 Driver (TMC5130 & TMC5160) 0.1.0-dev
Hardware Agnostic C++ Driver for the TMC51x0 (TMC5130 & TMC5160)
|
Tuning subsystem for automatic parameter optimization. More...
#include <tmc51x0.hpp>
Public Member Functions | |
| Tuning (TMC51x0 &driver) noexcept | |
| Construct tuning subsystem. | |
| Result< void > | TuneStallGuard (float target_velocity, StallGuardTuningResult &result, int8_t min_sgt=-20, int8_t max_sgt=20, float acceleration=5.0F, float min_velocity=0.0F, float max_velocity=0.0F, Unit velocity_unit=Unit::RPM, Unit acceleration_unit=Unit::RevPerSec) noexcept |
| Automatically tune StallGuard threshold (SGT) with comprehensive velocity range analysis. | |
| Result< void > | AutoTuneStallGuard (float target_velocity, StallGuardTuningResult &result, int8_t min_sgt=-20, int8_t max_sgt=20, float acceleration=5.0F, float min_velocity=0.0F, float max_velocity=0.0F, Unit velocity_unit=Unit::RPM, Unit acceleration_unit=Unit::RevPerSec, float current_reduction_factor=0.3F) noexcept |
| Comprehensive automatic StallGuard tuning with current reduction and optional encoder verification. | |
Private Attributes | |
| TMC51x0 & | driver_ |
| Reference to parent driver instance. | |
Tuning subsystem for automatic parameter optimization.
Provides methods for automatically tuning driver parameters such as StallGuard2 threshold (SGT) for optimal performance.
|
inlineexplicitnoexcept |
Construct tuning subsystem.
| driver | Reference to parent TMC51x0 driver instance |
|
noexcept |
Comprehensive automatic StallGuard tuning with current reduction and optional encoder verification.
| target_velocity | Target velocity for tuning (most important - optimal SGT is determined here) |
| result | Reference to store comprehensive tuning results |
| min_sgt | Minimum SGT to try (default: -20, range: -64 to +63) |
| max_sgt | Maximum SGT to try (default: +20, range: -64 to +63) |
| acceleration | Acceleration/deceleration in rev/s² (default: 5.0) |
| min_velocity | Minimum velocity to verify tuning at (0 = disabled) |
| max_velocity | Maximum velocity to verify tuning at (0 = disabled) |
| velocity_unit | Unit for velocity parameters (default: RPM) |
| acceleration_unit | Unit for acceleration parameter (default: RevPerSec, RPM is not valid for acceleration) |
| current_reduction_factor | Current reduction factor as percentage (0.0-1.0, where 0.3 = 30% of current motor current). Default: 0.3 (30%) per Duet3D best practices for stall detection. Set to 0 to disable. |
This is an enhanced version of TuneStallGuard that implements comprehensive automatic tuning following Trinamic application note AN-002 guidelines and industry best practices:
Key Features:
Tuning Process:
Current Reduction: If current_reduction_factor > 0, reduces current to (current_motor_current * current_reduction_factor). Example: 0.3 = 30% of current motor current. The function uses the driver's current calculation functions to determine the appropriate IRUN and GLOBAL_SCALER values. The current is constrained to ensure the motor can still move (minimum IRUN=8 for StealthChop compatibility).
|
noexcept |
Automatically tune StallGuard threshold (SGT) with comprehensive velocity range analysis.
| target_velocity | Target velocity for tuning (most important - optimal SGT is determined here) |
| result | Reference to store comprehensive tuning results |
| min_sgt | Minimum SGT to try (default: -20, range: -64 to +63) |
| max_sgt | Maximum SGT to try (default: +20, range: -64 to +63) |
| acceleration | Acceleration/deceleration in rev/s² (default: 5.0) |
| min_velocity | Minimum velocity to verify tuning at (0 = disabled, used to determine SGT range) |
| max_velocity | Maximum velocity to verify tuning at (0 = disabled, used to determine SGT range) |
| velocity_unit | Unit for velocity parameters (default: RPM) |
| acceleration_unit | Unit for acceleration parameter (default: RevPerSec, RPM is not valid for acceleration) |
Implements a comprehensive automatic tuning algorithm that prioritizes target velocity:
The algorithm ensures:
|
private |
Reference to parent driver instance.