|
HF-TMC51x0 Driver (TMC5130 & TMC5160) 0.1.0-dev
Hardware Agnostic C++ Driver for the TMC51x0 (TMC5130 & TMC5160)
|
Back-and-forth motion controller using positioning mode. More...
Public Member Functions | |
| BackAndForthMotion (tmc51x0::TMC51x0< Esp32SPI > *driver) | |
| Construct a back-and-forth motion controller. | |
| void | Config (float max_vel_rpm, float accel_rev_s2, float travel_dist_deg, int max_cycles=-1) |
| Configure back-and-forth motion parameters. | |
| void | Start () |
| Initialize and start back-and-forth motion. | |
| bool | Update () |
| Update back-and-forth motion (call periodically). | |
| void | Stop () |
| Stop back-and-forth motion. | |
| uint32_t | GetCyclesCompleted () const |
| Get number of completed back-and-forth cycles. | |
Private Attributes | |
| tmc51x0::TMC51x0< Esp32SPI > * | driver_ |
| Pointer to TMC51x0 driver instance. | |
| float | max_velocity_rpm_ |
| Maximum velocity in RPM. | |
| float | acceleration_rev_s2_ |
| Acceleration in rev/s² | |
| float | travel_distance_deg_ |
| Distance to travel in each direction (degrees) | |
| float | center_position_deg_ |
| Center position (starting point) in degrees. | |
| float | target_position_deg_ |
| Current target position in degrees. | |
| bool | moving_forward_ |
| Direction flag (true = forward, false = backward) | |
| bool | initialized_ |
| Whether motion has been initialized. | |
| uint32_t | cycles_completed_ |
| Number of complete back-and-forth cycles. | |
| int | max_cycles_ |
| Maximum cycles (-1 for infinite) | |
Back-and-forth motion controller using positioning mode.
Simple back-and-forth motion using TMC51x0's positioning mode. Sets target position to one end, waits until reached, then sets target to other end. Repeats continuously until max_cycles is reached (if specified).
|
inline |
Construct a back-and-forth motion controller.
| driver | Pointer to TMC51x0 driver instance (must remain valid for lifetime) |
|
inline |
Configure back-and-forth motion parameters.
| max_vel_rpm | Maximum velocity in RPM |
| accel_rev_s2 | Acceleration in rev/s² |
| travel_dist_deg | Distance to travel in each direction (in degrees) |
| max_cycles | Maximum number of back-and-forth cycles (-1 for infinite) |
|
inline |
Get number of completed back-and-forth cycles.
|
inline |
Initialize and start back-and-forth motion.
|
inline |
Stop back-and-forth motion.
Stops the motor and sets ramp mode to HOLD. Motion can be restarted by calling Start() again.
|
inline |
Update back-and-forth motion (call periodically).
Checks if target position has been reached and switches direction. Should be called from a periodic task or main loop.
|
private |
Acceleration in rev/s²
|
private |
Center position (starting point) in degrees.
|
private |
Number of complete back-and-forth cycles.
|
private |
Pointer to TMC51x0 driver instance.
|
private |
Whether motion has been initialized.
|
private |
Maximum cycles (-1 for infinite)
|
private |
Maximum velocity in RPM.
|
private |
Direction flag (true = forward, false = backward)
|
private |
Current target position in degrees.
|
private |
Distance to travel in each direction (degrees)