BeRTOS
|
Driver to control stepper motor. More...
#include "stepper.h"
#include "hw/hw_stepper.h"
#include "hw/hw_sensor.h"
#include "cfg/cfg_stepper.h"
#include <cfg/debug.h>
#include <cfg/log.h>
#include <kern/proc.h>
#include <algo/ramp.h>
#include <PP_STRINGIZE(drv/PP_CAT3(stepper, _, CPU_ID).h)>
#include <string.h>
Go to the source code of this file.
Defines | |
Motor timings | |
#define | MOTOR_SWITCH_TICKS 60000 |
Timer ticks to wait for 10ms. | |
#define | MOTOR_SWITCH_COUNT 5 |
Number of intervals, long 10ms, to wait before/after switching current off/on. | |
#define | MOTOR_HOME_MAX_STEPS 30000 |
Steps before giving up when trying to reach home. | |
#define | MOTOR_CURRENT_TICKS 6000 |
Number of intervals, long 10ms, to mantain high current. | |
Functions | |
void FAST_FUNC | stepper_schedule_irq (struct Stepper *motor, stepper_time_t delay, bool do_step) |
Schedule a new stepper IRQ to happen after delay (number of clocks), and optionally doing a step at the same time (if do_step is true). | |
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 steps, 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 | |
Variables | |
static struct Stepper | all_motors [CONFIG_NUM_STEPPER_MOTORS] |
< Stepper motors |
Driver to control stepper motor.
Definition in file stepper.c.
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.
struct Stepper all_motors[CONFIG_NUM_STEPPER_MOTORS] [static] |