Skyward boardcore
|
#include <StepperPWM.h>
Public Member Functions | |
StepperPWM (CountedPWM &pwm, miosix::GpioPin stepPin, miosix::GpioPin directionPin, float speed=1, float stepAngle=1.8, bool revertDirection=false, uint16_t microStep=1, PinConfiguration pinConfiguration=PinConfiguration::COMMON_CATHODE, miosix::GpioPin enablePin=MockGpioPin()) | |
Construct a new StepperPWM object. | |
void | setSpeed (float speed) override |
Changes the stepper motor speed. | |
void | setMicroStepping (uint16_t microStep) override |
Set the motor driver micro stepping configuration. | |
void | move (int16_t steps) override |
Move the stepper motor by the specified amount of steps. | |
float | getCurrentDegPosition () override |
Returns the current angle of the stepper. | |
![]() | |
Stepper (miosix::GpioPin stepPin, miosix::GpioPin directionPin, float speed=1, float stepAngle=1.8, bool revertDirection=false, uint16_t microStep=1, PinConfiguration pinConfiguration=PinConfiguration::COMMON_CATHODE, miosix::GpioPin enablePin=MockGpioPin()) | |
Construct a new Stepper object. | |
void | enable () |
void | disable () |
void | zeroPosition (float degrees=0) |
Overrides the driver's internal position counter. | |
void | moveDeg (float degrees) |
Move the stepper motor by the specified amount of degrees. | |
virtual void | setPosition (int16_t steps) |
Set the position of the stepper motor. | |
void | setPositionDeg (float degrees) |
Set the position of the stepper motor. | |
int16_t | getCurrentPosition () |
bool | isEnabled () |
Returns whether the stepper is enabled or not. | |
StepperData | getState (float moveDeg) |
Returns the current position and the current timestamp. | |
Additional Inherited Members | |
![]() | |
enum class | PinConfiguration { COMMON_ANODE , COMMON_CATHODE } |
![]() | |
enum | Direction : int8_t { CLOCKWISE = 1 , COUNTER_CLOCKWISE = -1 } |
![]() | |
void | setDirection () |
Sets the directionPin to the right value to go in the direction stored in currentDirection . | |
Stepper & | operator= (const Stepper &)=delete |
Stepper (const Stepper &p)=delete | |
![]() | |
miosix::GpioPin | stepPin |
miosix::GpioPin | directionPin |
float | speed |
float | stepAngle |
bool | enabled = false |
bool | revertDirection |
uint16_t | microStep |
PinConfiguration | pinConfig |
miosix::GpioPin | enablePin |
Direction | currentDirection |
float | currentPositionDeg = 0 |
Definition at line 35 of file StepperPWM.h.
Boardcore::StepperPWM::StepperPWM | ( | CountedPWM & | pwm, |
miosix::GpioPin | stepPin, | ||
miosix::GpioPin | directionPin, | ||
float | speed = 1, | ||
float | stepAngle = 1.8, | ||
bool | revertDirection = false, | ||
uint16_t | microStep = 1, | ||
PinConfiguration | pinConfiguration = PinConfiguration::COMMON_CATHODE, | ||
miosix::GpioPin | enablePin = MockGpioPin() ) |
Construct a new StepperPWM object.
By default the direction pin is held low when moving forward. If the given speed is negative the motor wont move.
pwm | The CountedPWM object that will generate the N steps. |
stepPin | Pin connected to the step signal of the driver. |
directionPin | Pin connected to the direction signal of the driver. |
speed | Number of rotations per second. |
stepAngle | Angle covered by one motor step. |
revertDirection | Whether or not revert the direction signal. |
Definition at line 27 of file StepperPWM.cpp.
|
overridevirtual |
Returns the current angle of the stepper.
To calculate the correct angle of the stepper we add the angle reached in the last actuation (saved in the variable currentPositionDeg
) with the conversion in angle of the actual stepper position (so, the number of pulses actuated by the timer till now, that corresponds to the counter register of the CounterTimer).
Notice that on each actuation (calling one of the move or setPosition methods) we save the angle reached using this method.
Reimplemented from Boardcore::Stepper.
Definition at line 93 of file StepperPWM.cpp.
|
overridevirtual |
Move the stepper motor by the specified amount of steps.
Reimplemented from Boardcore::Stepper.
Definition at line 63 of file StepperPWM.cpp.
|
overridevirtual |
Set the motor driver micro stepping configuration.
If micro steps are changed via physical switches we have to call this method with the correct configuration to keep consistency in the speed of the stepper.
microStep | The micro steps that the stepper performs. |
Reimplemented from Boardcore::Stepper.
Definition at line 52 of file StepperPWM.cpp.
|
overridevirtual |
Changes the stepper motor speed.
speed | Speed in rotation per second. [rev/s] |
Reimplemented from Boardcore::Stepper.
Definition at line 46 of file StepperPWM.cpp.