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

#include <Stepper.h>

Inheritance diagram for Boardcore::Stepper:

Public Types

enum class  PinConfiguration { COMMON_ANODE , COMMON_CATHODE }
 

Public Member Functions

 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 ()
 
virtual void setSpeed (float speed)
 Changes the stepper motor speed.
 
virtual void setMicroStepping (uint16_t microStep)
 Set the motor driver micro stepping configuration.
 
void zeroPosition (float degrees=0)
 Overrides the driver's internal position counter.
 
virtual void move (int16_t steps)
 Move the stepper motor by the specified amount of steps.
 
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 ()
 
virtual float getCurrentDegPosition ()
 Returns the current absolute position of the stepper in degrees [deg].
 
bool isEnabled ()
 Returns whether the stepper is enabled or not.
 
StepperData getState (float moveDeg)
 Returns the current position and the current timestamp.
 

Protected Types

enum  Direction : int8_t { CLOCKWISE = 1 , COUNTER_CLOCKWISE = -1 }
 

Protected Member Functions

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

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 Stepper.h.

Member Enumeration Documentation

◆ Direction

enum Boardcore::Stepper::Direction : int8_t
protected
Enumerator
CLOCKWISE 
COUNTER_CLOCKWISE 

Definition at line 138 of file Stepper.h.

◆ PinConfiguration

Enumerator
COMMON_ANODE 

All + signals connected to Vdd (3v3)

COMMON_CATHODE 

All - signals connected to Gnd.

Definition at line 38 of file Stepper.h.

Constructor & Destructor Documentation

◆ Stepper() [1/2]

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.

By default the direction pin is held low when moving forward. If the given speed is negative the motor wont move.

Parameters
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 Stepper.cpp.

◆ Stepper() [2/2]

Boardcore::Stepper::Stepper ( const Stepper & p)
protecteddelete

Member Function Documentation

◆ disable()

void Boardcore::Stepper::disable ( )

Definition at line 54 of file Stepper.cpp.

◆ enable()

void Boardcore::Stepper::enable ( )

Definition at line 45 of file Stepper.cpp.

◆ getCurrentDegPosition()

float Boardcore::Stepper::getCurrentDegPosition ( )
inlinevirtual

Returns the current absolute position of the stepper in degrees [deg].

Reimplemented in Boardcore::StepperPWM.

Definition at line 196 of file Stepper.h.

◆ getCurrentPosition()

int16_t Boardcore::Stepper::getCurrentPosition ( )
inline

Definition at line 191 of file Stepper.h.

◆ getState()

StepperData Boardcore::Stepper::getState ( float moveDeg)

Returns the current position and the current timestamp.

Definition at line 151 of file Stepper.cpp.

◆ isEnabled()

bool Boardcore::Stepper::isEnabled ( )

Returns whether the stepper is enabled or not.

Definition at line 149 of file Stepper.cpp.

◆ move()

void Boardcore::Stepper::move ( int16_t steps)
virtual

Move the stepper motor by the specified amount of steps.

Reimplemented in Boardcore::StepperPWM.

Definition at line 106 of file Stepper.cpp.

◆ moveDeg()

void Boardcore::Stepper::moveDeg ( float degrees)
inline

Move the stepper motor by the specified amount of degrees.

Definition at line 176 of file Stepper.h.

◆ operator=()

Stepper & Boardcore::Stepper::operator= ( const Stepper & )
protecteddelete

◆ setDirection()

void Boardcore::Stepper::setDirection ( )
protected

Sets the directionPin to the right value to go in the direction stored in currentDirection.

Definition at line 63 of file Stepper.cpp.

◆ setMicroStepping()

void Boardcore::Stepper::setMicroStepping ( uint16_t microStep)
inlinevirtual

Set the motor driver micro stepping configuration.

This method has no effect if micro steps are changed via physical switches.

Reimplemented in Boardcore::StepperPWM.

Definition at line 166 of file Stepper.h.

◆ setPosition()

void Boardcore::Stepper::setPosition ( int16_t steps)
inlinevirtual

Set the position of the stepper motor.

Note that this function uses delayUs, thus it blocks execution based on the stepper motor speed and movement.

Definition at line 181 of file Stepper.h.

◆ setPositionDeg()

void Boardcore::Stepper::setPositionDeg ( float degrees)
inline

Set the position of the stepper motor.

Note that this function uses delayUs, thus it blocks execution based on the stepper motor speed and movement.

Definition at line 186 of file Stepper.h.

◆ setSpeed()

void Boardcore::Stepper::setSpeed ( float speed)
inlinevirtual

Changes the stepper motor speed.

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

Reimplemented in Boardcore::StepperPWM.

Definition at line 164 of file Stepper.h.

◆ zeroPosition()

void Boardcore::Stepper::zeroPosition ( float degrees = 0)
inline

Overrides the driver's internal position counter.

Definition at line 171 of file Stepper.h.

Member Data Documentation

◆ currentDirection

Direction Boardcore::Stepper::currentDirection
protected

Definition at line 160 of file Stepper.h.

◆ currentPositionDeg

float Boardcore::Stepper::currentPositionDeg = 0
protected

Definition at line 161 of file Stepper.h.

◆ directionPin

miosix::GpioPin Boardcore::Stepper::directionPin
protected

Definition at line 151 of file Stepper.h.

◆ enabled

bool Boardcore::Stepper::enabled = false
protected

Definition at line 154 of file Stepper.h.

◆ enablePin

miosix::GpioPin Boardcore::Stepper::enablePin
protected

Definition at line 158 of file Stepper.h.

◆ microStep

uint16_t Boardcore::Stepper::microStep
protected

Definition at line 156 of file Stepper.h.

◆ pinConfig

PinConfiguration Boardcore::Stepper::pinConfig
protected

Definition at line 157 of file Stepper.h.

◆ revertDirection

bool Boardcore::Stepper::revertDirection
protected

Definition at line 155 of file Stepper.h.

◆ speed

float Boardcore::Stepper::speed
protected

Definition at line 152 of file Stepper.h.

◆ stepAngle

float Boardcore::Stepper::stepAngle
protected

Definition at line 153 of file Stepper.h.

◆ stepPin

miosix::GpioPin Boardcore::Stepper::stepPin
protected

Definition at line 150 of file Stepper.h.


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