#include <stdint.h>
#include <stdbool.h>
#include "task.h"
Go to the source code of this file.
◆ st2_motor_t
◆ position_t
Enumerator |
---|
Stepper2_Steps | 0
|
Stepper2_InfiniteSteps | 1
|
Stepper2_mm | 2
|
◆ st2_get_position()
Get current position in steps.
- Parameters
-
- Returns
- current position as number of steps.
◆ st2_get_speed()
Get current speed (RPM).
- Parameters
-
- Returns
- current speed in RPM.
◆ st2_motor_bind_spindle()
bool st2_motor_bind_spindle |
( |
uint_fast8_t |
axis_idx | ) |
|
Bind and initialize a motor.
Binds motor 0 as a spindle.
- Parameters
-
axis_idx | axis index of motor to bind to. 3 = A, 4 = B, ... |
- Returns
- true if successful, false if not.
◆ st2_motor_cruising()
Check if motor is running in cruising phase.
- Parameters
-
- Returns
- true if motor is cruising (not acceleration or decelerating), false if not.
◆ st2_motor_init()
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.
- Parameters
-
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). |
- Returns
- pointer to a st2_motor structure if successful, NULL if not.
◆ st2_motor_move()
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().
- Parameters
-
motor | pointer to a st2_motor structure. |
move | relative distance to move. |
speed | speed |
type | a position_t enum. |
- Returns
- true if command is accepted, false if not.
◆ st2_motor_poll()
Check if motor is run by polling.
- Parameters
-
- Returns
- true if motor is run by polling, false if not.
◆ st2_motor_register_stopped_callback()
◆ st2_motor_run()
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).
- Parameters
-
- Returns
- true if motor is moving (steps are output), false if not (motion is completed).
◆ st2_motor_running()
Check if motor is running.
- Parameters
-
- Returns
- true if motor is running, false if not.
◆ st2_motor_set_speed()
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.
- Parameters
-
motor | pointer to a st2_motor structure. |
speed | new speed. |
- Returns
- new speed in steps/s.
◆ st2_motor_stop()
Stop a move. This will initiate deceleration to stop the motor if it is running.
- Parameters
-
- Returns
- true if motor was running, false if not.
◆ st2_set_position()
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.
- Parameters
-
motor | pointer to a st2_motor structure. |
position | position to set. |
- Returns
- true if new position was accepted, false if not.