Skyward boardcore
Loading...
Searching...
No Matches
Boardcore::StepperPWM Class Reference

#include <StepperPWM.h>

Inheritance diagram for Boardcore::StepperPWM:
Collaboration diagram for Boardcore::StepperPWM:

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.
 
- Public Member Functions inherited from Boardcore::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

- Public Types inherited from Boardcore::Stepper
enum class  PinConfiguration { COMMON_ANODE , COMMON_CATHODE }
 
- Protected Types inherited from Boardcore::Stepper
enum  Direction : int8_t { CLOCKWISE = 1 , COUNTER_CLOCKWISE = -1 }
 
- Protected Member Functions inherited from Boardcore::Stepper
void setDirection ()
 Sets the directionPin to the right value to go in the direction stored in currentDirection.
 
Stepperoperator= (const Stepper &)=delete
 
 Stepper (const Stepper &p)=delete
 
- Protected Attributes inherited from Boardcore::Stepper
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
 

Detailed Description

Definition at line 35 of file StepperPWM.h.

Constructor & Destructor Documentation

◆ StepperPWM()

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.

Parameters
pwmThe CountedPWM object that will generate the N steps.
stepPinPin connected to the step signal of the driver.
directionPinPin connected to the direction signal of the driver.
speedNumber of rotations per second.
stepAngleAngle covered by one motor step.
revertDirectionWhether or not revert the direction signal.

Definition at line 27 of file StepperPWM.cpp.

Member Function Documentation

◆ getCurrentDegPosition()

float Boardcore::StepperPWM::getCurrentDegPosition ( )
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.

◆ move()

void Boardcore::StepperPWM::move ( int16_t steps)
overridevirtual

Move the stepper motor by the specified amount of steps.

Reimplemented from Boardcore::Stepper.

Definition at line 63 of file StepperPWM.cpp.

◆ setMicroStepping()

void Boardcore::StepperPWM::setMicroStepping ( uint16_t microStep)
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.

Parameters
microStepThe micro steps that the stepper performs.

Reimplemented from Boardcore::Stepper.

Definition at line 52 of file StepperPWM.cpp.

◆ setSpeed()

void Boardcore::StepperPWM::setSpeed ( float speed)
overridevirtual

Changes the stepper motor speed.

Parameters
speedSpeed in rotation per second. [rev/s]

Reimplemented from Boardcore::Stepper.

Definition at line 46 of file StepperPWM.cpp.


The documentation for this class was generated from the following files: