Data Structures | |
struct | st2_motor |
Internal structure for holding motor configuration and keeping track of its status. More... | |
Enumerations | |
enum | st2_state_t { State_Idle = 0 , State_Accel , State_Run , State_RunInfinite , State_DecelTo , State_Decel } |
Functions | |
void | st2_motor_register_stopped_callback (st2_motor_t *motor, foreground_task_ptr callback) |
bool | st2_motor_bind_spindle (uint_fast8_t axis_idx) |
Bind and initialize a motor. More... | |
st2_motor_t * | st2_motor_init (uint_fast8_t axis_idx, bool is_spindle) |
Bind and initialize a motor. More... | |
float | st2_get_speed (st2_motor_t *motor) |
Get current speed (RPM). More... | |
float | st2_motor_set_speed (st2_motor_t *motor, float speed) |
Set speed. More... | |
bool | st2_motor_move (st2_motor_t *motor, const float move, const float speed, position_t type) |
Command a motor to move. More... | |
int64_t | st2_get_position (st2_motor_t *motor) |
Get current position in steps. More... | |
bool | st2_set_position (st2_motor_t *motor, int64_t position) |
Set current position in steps. More... | |
__attribute__ ((always_inline)) | |
Execute a move commanded by st2_motor_move(). More... | |
bool | st2_motor_run (st2_motor_t *motor) |
Execute a move commanded by st2_motor_move(). More... | |
bool | st2_motor_stop (st2_motor_t *motor) |
Stop a move. This will initiate deceleration to stop the motor if it is running. More... | |
bool | st2_motor_poll (st2_motor_t *motor) |
Check if motor is run by polling. More... | |
bool | st2_motor_running (st2_motor_t *motor) |
Check if motor is running. More... | |
bool | st2_motor_cruising (st2_motor_t *motor) |
Check if motor is running in cruising phase. More... | |
enum st2_state_t |
__attribute__ | ( | (always_inline) | ) |
Execute a move commanded by st2_motor_move().
motor | pointer to a st2_motor structure. |
int64_t st2_get_position | ( | st2_motor_t * | motor | ) |
Get current position in steps.
motor | pointer to a st2_motor structure. |
float st2_get_speed | ( | st2_motor_t * | motor | ) |
Get current speed (RPM).
motor | pointer to a st2_motor structure. |
bool st2_motor_bind_spindle | ( | uint_fast8_t | axis_idx | ) |
Bind and initialize a motor.
Binds motor 0 as a spindle.
axis_idx | axis index of motor to bind to. 3 = A, 4 = B, ... |
bool st2_motor_cruising | ( | st2_motor_t * | motor | ) |
Check if motor is running in cruising phase.
motor | pointer to a st2_motor structure. |
st2_motor_t* st2_motor_init | ( | uint_fast8_t | axis_idx, |
bool | is_spindle | ||
) |
Bind and initialize a motor.
Allocates and initializes motor configuration/data structure. If is_spindle is set true then axis settings will be changed to step/rev etc. when bound.
NOTE: X, Y or Z motors cannot be bound as a spindle.
NOTE: currently any axis bound as a spindle should not be instructed to move via gcode commands.
axis_idx | axis index of motor to bind to. 0 = X, 1 = Y, 2 = Z, ... |
is_spindle | set to true if axis is to be used as a spindle (infinite motion). |
bool st2_motor_move | ( | st2_motor_t * | motor, |
const float | move, | ||
const float | speed, | ||
position_t | type | ||
) |
Command a motor to move.
NOTE: For all motions except single steps st2_motor_run() has to be called from the foreground process at a high frequency in order for steps to be generated. Typically this is done by registering a function with the hal.on_execute_realtime event that calls st2_motor_run().
motor | pointer to a st2_motor structure. |
move | relative distance to move. |
speed | speed |
type | a position_t enum. |
bool st2_motor_poll | ( | st2_motor_t * | motor | ) |
Check if motor is run by polling.
motor | pointer to a st2_motor structure. |
void st2_motor_register_stopped_callback | ( | st2_motor_t * | motor, |
foreground_task_ptr | callback | ||
) |
bool st2_motor_run | ( | st2_motor_t * | motor | ) |
Execute a move commanded by st2_motor_move().
This should be called from the foreground process as often as possible when step output is not driven by interrupts (polling mode).
motor | pointer to a st2_motor structure. |
bool st2_motor_running | ( | st2_motor_t * | motor | ) |
Check if motor is running.
motor | pointer to a st2_motor structure. |
float st2_motor_set_speed | ( | st2_motor_t * | motor, |
float | speed | ||
) |
Set speed.
Change speed of a running motor. Typically used for motors bound as a spindle. Motor will be accelerated or decelerated to the new speed.
motor | pointer to a st2_motor structure. |
speed | new speed. |
bool st2_motor_stop | ( | st2_motor_t * | motor | ) |
Stop a move. This will initiate deceleration to stop the motor if it is running.
motor | pointer to a st2_motor structure. |
bool st2_set_position | ( | st2_motor_t * | motor, |
int64_t | position | ||
) |
Set current position in steps.
NOTE: position will not be set if motor is moving.
motor | pointer to a st2_motor structure. |
position | position to set. |