|
HF-TMC51x0 Driver (TMC5130 & TMC5160) 0.1.0-dev
Hardware Agnostic C++ Driver for the TMC51x0 (TMC5130 & TMC5160)
|
Ramp control subsystem. More...
#include <tmc51x0.hpp>
Public Member Functions | |
| RampControl (TMC51x0 &driver) noexcept | |
| Construct ramp control subsystem. | |
| Result< void > | SetRampMode (RampMode mode) noexcept |
| Set the ramp mode. | |
| Result< RampMode > | GetRampMode () noexcept |
| Get current ramp mode. | |
| Result< bool > | IsPositionReached () noexcept |
| Check if position target has been reached. | |
| Result< bool > | IsVelocityReached () noexcept |
| Check if velocity target has been reached. | |
| Result< bool > | IsStandstill () noexcept |
| Check if motor is in standstill. | |
| Result< void > | SetTargetPosition (float value, Unit unit) noexcept |
| Set target position (absolute) | |
| Result< void > | MoveRelative (float offset, Unit unit) noexcept |
| Move relative to current position. | |
| Result< float > | GetCurrentPosition (Unit unit) noexcept |
| Get current position. | |
| Result< float > | GetTargetPosition (Unit unit) noexcept |
| Get target position. | |
| Result< int32_t > | GetCurrentPositionMicrosteps () noexcept |
| Get current position in raw driver microsteps (XACTUAL) | |
| Result< int32_t > | GetTargetPositionMicrosteps () noexcept |
| Get target position in raw driver microsteps (XTARGET) | |
| Result< void > | SetCurrentPosition (float value, Unit unit, bool update_encoder=false) noexcept |
| Set current position. | |
| Result< void > | SetMaxSpeed (float value, Unit unit) noexcept |
| Set maximum speed. | |
| Result< void > | SetAcceleration (float value, Unit unit) noexcept |
| Set acceleration and deceleration. | |
| Result< void > | SetAccelerations (float accel_val, float decel_val, Unit unit) noexcept |
| Set acceleration and deceleration separately. | |
| Result< void > | SetDeceleration (float value, Unit unit) noexcept |
| Set deceleration only (DMAX register) | |
| Result< void > | SetRampSpeeds (float start_speed, float stop_speed, float transition_speed, Unit unit) noexcept |
| Set ramp speeds. | |
| Result< float > | GetCurrentSpeed (Unit unit) noexcept |
| Get current speed. | |
| Result< bool > | IsTargetReached () noexcept |
| Check if target position is reached. | |
| Result< bool > | IsTargetVelocityReached () noexcept |
| Check if target velocity is reached. | |
| Result< void > | Stop () noexcept |
| Stop the motor. | |
| Result< void > | SetPowerDownDelay (uint8_t tpowerdown) noexcept |
| Set power down delay (raw register value) | |
| Result< void > | SetPowerDownDelayMs (float delay_ms) noexcept |
| Set power down delay in milliseconds. | |
| Result< void > | SetZeroWaitTime (uint16_t tzerowait) noexcept |
| Set zero wait time (raw register value) | |
| Result< void > | SetZeroWaitTimeMs (float delay_ms) noexcept |
| Set zero wait time in milliseconds. | |
| Result< void > | ConfigureRamp (const RampConfig &config) noexcept |
| Configure ramp generator from RampConfig structure. | |
| Result< void > | SetFirstAcceleration (float a1, Unit unit) noexcept |
| Set first acceleration phase. | |
| Result< void > | SetFinalDeceleration (float d1, Unit unit) noexcept |
| Set final deceleration phase. | |
Private Member Functions | |
| Result< void > | SetTargetPosition (int32_t position) noexcept |
| Set XTARGET directly in register units. | |
| Result< void > | SetCurrentPosition (int32_t position, bool update_encoder=false) noexcept |
Private Attributes | |
| TMC51x0 & | driver_ |
| Reference to parent driver instance. | |
Ramp control subsystem.
Provides methods for controlling motor motion including positioning, velocity control, and hold modes.
|
inlineexplicitnoexcept |
Construct ramp control subsystem.
| driver | Reference to parent TMC51x0 driver instance |
|
noexcept |
Configure ramp generator from RampConfig structure.
| config | Ramp configuration structure with all ramp parameters |
Configures all ramp parameters including velocities, accelerations, and timing using the unit specifications from the config.
|
noexcept |
Get current position.
| unit | Unit to return the position in (default: Steps) |
Returns the current position relative to the zero/home position set via SetCurrentPosition(). If home is unknown, call SetCurrentPosition(0.0f) at the current physical position first.
|
noexcept |
Get current position in raw driver microsteps (XACTUAL)
Use this when you want to inspect the exact microstep-level position used by the ramp generator. This avoids any conversion/rounding to degrees/full-steps.
|
noexcept |
Get current speed.
| speed | Reference to store the current speed |
| unit | Unit to return the speed in (default: Steps) |
|
noexcept |
Get current ramp mode.
|
noexcept |
Get target position.
| unit | Unit to return the position in (default: Steps) |
|
noexcept |
Get target position in raw driver microsteps (XTARGET)
|
noexcept |
Check if position target has been reached.
|
noexcept |
Check if motor is in standstill.
|
noexcept |
Check if target position is reached.
|
noexcept |
Check if target velocity is reached.
|
noexcept |
Check if velocity target has been reached.
|
noexcept |
Move relative to current position.
| offset | Relative movement offset (positive = forward, negative = backward) |
| unit | Unit of the offset value (default: Steps) |
Moves relative to the current position. Automatically calculates the new target position by adding the offset to the current position. No need to manually calculate steps.
Example: MoveRelative(90.0f, Unit::Deg); // Move 90 degrees from current position MoveRelative(-45.0f, Unit::Deg); // Move 45 degrees backward
|
noexcept |
Set acceleration and deceleration.
| value | Acceleration value |
| unit | Unit of the value (default: Steps) |
|
noexcept |
Set acceleration and deceleration separately.
| accel_val | Acceleration value |
| decel_val | Deceleration value |
| unit | Unit of the values (default: Steps) |
|
noexcept |
Set current position.
| value | Position value |
| unit | Unit of the value (default: Steps) |
| update_encoder | If true, also update encoder position |
|
privatenoexcept |
|
noexcept |
Set deceleration only (DMAX register)
| value | Deceleration value |
| unit | Unit of the value (default: Steps) |
Sets only the deceleration rate (DMAX register) without affecting acceleration (AMAX).
|
noexcept |
Set final deceleration phase.
| d1 | Deceleration value |
| unit | Unit of the value (default: Steps) |
Sets the final deceleration phase (D1). Attention: Do not set 0 in positioning mode (datasheet 6.3.1). If set to 0, the driver might behave unexpectedly in positioning mode. A safe minimum (e.g., 100) is recommended if unsure.
|
noexcept |
Set first acceleration phase.
| a1 | First acceleration value |
| unit | Unit of the value (default: Steps) |
Sets the first acceleration phase. If 0.0f, AMAX is used for this phase.
|
noexcept |
Set maximum speed.
| value | Maximum speed value |
| unit | Unit of the value (default: Steps) |
|
noexcept |
Set power down delay (raw register value)
| tpowerdown | Power down delay (0-255, time range ~0 to 5.6 seconds) |
Sets the delay before power down when motor enters standstill. Minimum setting of 2 is required to allow automatic tuning of stealthChop PWM_OFFS_AUTO.
|
noexcept |
Set power down delay in milliseconds.
| delay_ms | Power down delay in milliseconds (0.0 = instant, automatically converted to register value 0-255) |
Sets the delay before power down when motor enters standstill. The delay is automatically converted from milliseconds to register value based on f_clk.
Conversion: tpowerdown = round((delay_ms × f_clk) / (1000 × 2^18))
|
noexcept |
Set the ramp mode.
| mode | Ramp mode (POSITIONING, VELOCITY_POS, VELOCITY_NEG, HOLD) |
|
noexcept |
Set ramp speeds.
| start_speed | Start speed value |
| stop_speed | Stop speed value |
| transition_speed | Transition speed value |
| unit | Unit of the speed values (default: Steps) |
|
noexcept |
Set target position (absolute)
| value | Target position value (absolute position from current zero/home) |
| unit | Unit of the value (default: Steps) |
Sets an absolute target position. The position is relative to the current zero/home position set via SetCurrentPosition(). If home is unknown, call SetCurrentPosition(0.0f) at the current physical position to establish a reference point.
|
privatenoexcept |
Set XTARGET directly in register units.
| position | Target position in microsteps (XTARGET register units) |
|
noexcept |
Set zero wait time (raw register value)
| tzerowait | Waiting time after ramping down to zero velocity in clock cycles (0-65535) |
Sets the waiting time after ramping down to zero velocity before next movement or direction inversion can start.
|
noexcept |
Set zero wait time in milliseconds.
| delay_ms | Velocity-zero wait time in milliseconds (0.0 = no waiting, automatically converted to register value 0-65535) |
Sets the waiting time after ramping down to zero velocity before next movement or direction inversion can start.
The delay is automatically converted from milliseconds to register value based on f_clk.
Conversion: tzerowait = round((delay_ms × f_clk) / (1000 × 2^18))
|
noexcept |
Stop the motor.
Stops the motor by setting VSTART and VMAX to 0.
|
private |
Reference to parent driver instance.