BeRTOS
|
Driver to control stepper motor. More...
Go to the source code of this file.
Data Structures | |
struct | StepperConfig |
Stepper configuration. More... | |
struct | Stepper |
Motor context structure. More... | |
Defines | |
#define | STEPS_INFINITE_POSITIVE ((int16_t)0xFFFF) |
Special value for steps to move the motor continuously. | |
#define | STEPS_INFINITE_NEGATIVE ((int16_t)0x8FFF) |
Maximum value for stepper steps. | |
#define | MAX_STEPS 0x7FFF |
Default value -> no level sensor associated to the motor. | |
#define | MOTOR_NO_LEVEL_SENSOR 0xFFFF |
Default value -> no home sensor associated to the motor. | |
#define | MOTOR_NO_HOME_SENSOR 0xFFFF |
Default value for deafsteps in normal movement (no level sensor) | |
#define | DEAFSTEPS_DEFAULT MAX_STEPS |
Out-of-band values for speed. | |
#define | SPEED_STOPPED 0xFFFF |
motor is stopped | |
#define | SPEED_HOMING 0xFFFE |
motor is homing | |
Typedefs | |
typedef enum StepperState(* | fsm_state )(struct Stepper *) |
Pointer to a isr stepper function. | |
typedef void(* | stepper_isr_t )(struct Stepper *) |
Time for steppers motor. | |
Enumerations | |
enum | MotorDirection { DIR_POSITIVE = 1, DIR_NONE = 0, DIR_NEGATIVE = -1 } |
Motor direction. More... | |
enum | StepperState { MSTS_UNINIT, MSTS_RUN, MSTS_IDLE, MSTS_PREIDLE, MSTS_PRERUN, MSTS_PREINIT, MSTS_INIT, MSTS_ENTERING, MSTS_LEAVING, MSTS_OUTHOME, MSTS_ERROR } |
Stepper state-machine conditions. More... | |
Functions | |
void | stepper_init (void) |
Initialize the stepper module. | |
struct Stepper * | stepper_setup (int index, struct StepperConfig *cfg) |
Apply a setup config to motor structure context. | |
void | stepper_disable (void) |
Set the enable for all the motors to 0 before switching on the power. | |
void | stepper_reset (struct Stepper *motor) |
Reset the motor. | |
void | stepper_home (struct Stepper *motor) |
Find the home of a motor assuming no current knowledge about its position. | |
int16_t | stepper_move (struct Stepper *motor, int16_t step, uint16_t speed, int16_t deafstep) |
Move motor to absolute position at specified speed. | |
void | stepper_stop (struct Stepper *motor) |
Stop motor gracefully. | |
void | stepper_break (struct Stepper *motor, enum StepperState state) |
Stop motor immediately, changing the status. | |
bool | stepper_idle (struct Stepper *motor) |
Returns true if the stepper is in error mode. | |
bool | stepper_error (struct Stepper *motor) |
check the home sensor in zero position |
Driver to control stepper motor.
Definition in file stepper.h.
enum MotorDirection |
enum StepperState |
Stepper state-machine conditions.
MSTS_UNINIT |
stepper_init() not yet called |
MSTS_RUN |
running |
MSTS_IDLE |
waiting for a command |
MSTS_PREIDLE |
waiting before going low-current |
MSTS_PRERUN |
waiting after high-current |
MSTS_PREINIT |
preparing to initialize ;-) |
MSTS_INIT |
initializing home procedure |
MSTS_ENTERING |
entering home sensor |
MSTS_LEAVING |
moving away from home (inside the sensor) |
MSTS_OUTHOME |
moving away from home (outside the sensor) |
MSTS_ERROR |
error status Dummy entry to guarantee the right underlying size for the enum |
void stepper_break | ( | struct Stepper * | motor, |
enum StepperState | state | ||
) |
void stepper_home | ( | struct Stepper * | motor | ) |
Find the home of a motor assuming no current knowledge about its position.
This must be done when the motor is desynchronized with the firmware and we do not know anymore where it is.
In normal operation mode, to go back to the home, it is sufficient to use move to step #0 with stepper_move, since the home is always at step #0.
int16_t stepper_move | ( | struct Stepper * | motor, |
int16_t | steps, | ||
uint16_t | speed, | ||
int16_t | deafstep | ||
) |
Move motor to absolute position at specified speed.