Simon Krogedal / Async_4pin_Stepper

Dependents:   Lift_arm_control

Embed: (wiki syntax)

« Back to documentation index

Async_4pin_Stepper Class Reference

Async_4pin_Stepper Class Reference

Asynchronous Stepper with 4-pin half step output class. More...

#include <Async_4pin_Stepper.h>

Public Types

enum  Dir { , CCW }
 

Single step CCW.

More...

Public Member Functions

 Async_4pin_Stepper (PinName StepperPin1, PinName StepperPin2, PinName StepperPin3, PinName StepperPin4, float StepsPerRev=4075.7728)
 Constructor takes 4 pins and a steps/rev in float presicion.
void setZeroPos ()
 Set current position as 0.
void setTarget (int target)
 Set target.
void goToTarget ()
 Move towards given target.
void setSpeed (int speed)
 Set speed.
int getSpeed ()
 Get speed.
int getPos ()
 Get position.
int getTarget ()
 Get target position.
int distanceToGo ()
 Get distance left to target.
bool isRunning ()
 Check if motor is running.
void relax ()
 Close all gates, reducing current but losing holding torque.
void stop ()
 Stop the motor and detach ticker.

Protected Member Functions

void stepOnceCW ()
 Callback function for stepper, called intermittedly to do a step towards the current target.
void stepOnceCCW ()
 Single step CW.

Detailed Description

Asynchronous Stepper with 4-pin half step output class.

31/05/2021 Team 9 4th Year project

for NUCLEO-F401RE

Definition at line 24 of file Async_4pin_Stepper.h.


Member Enumeration Documentation

enum Dir

Single step CCW.

Enumerator:
CCW 

Clockwise.

Counter-clockwise

Definition at line 51 of file Async_4pin_Stepper.h.


Constructor & Destructor Documentation

Async_4pin_Stepper ( PinName  StepperPin1,
PinName  StepperPin2,
PinName  StepperPin3,
PinName  StepperPin4,
float  StepsPerRev = 4075.7728 
)

Constructor takes 4 pins and a steps/rev in float presicion.

Parameters:
StepperPin1Pin 1 on stepper motor
StepperPin2Pin 2 on stepper motor
StepperPin3Pin 3 on stepper motor
StepperPin4Pin 4 on stepper motor
StepsPerRevSteps per revolution. Defaults to 4075.8, for 28BYJ-48

Definition at line 16 of file Async_4pin_Stepper.cpp.


Member Function Documentation

int distanceToGo (  )

Get distance left to target.

Returns:
Number of steps away from target

Definition at line 49 of file Async_4pin_Stepper.cpp.

int getPos (  )

Get position.

Returns:
Stepper position

Definition at line 46 of file Async_4pin_Stepper.cpp.

int getSpeed (  )

Get speed.

Returns:
Speed in steps/seconds

Definition at line 48 of file Async_4pin_Stepper.cpp.

int getTarget (  )

Get target position.

Returns:
Target step position

Definition at line 47 of file Async_4pin_Stepper.cpp.

void goToTarget (  )

Move towards given target.

Definition at line 103 of file Async_4pin_Stepper.cpp.

bool isRunning (  )

Check if motor is running.

Returns:
0 Motor is not running (ticker is not attached) 1 Motor is running (ticker is attached)

Definition at line 127 of file Async_4pin_Stepper.cpp.

void relax (  )

Close all gates, reducing current but losing holding torque.

Definition at line 126 of file Async_4pin_Stepper.cpp.

void setSpeed ( int  speed )

Set speed.

Parameters:
speedSpeed in steps/seconds

Definition at line 35 of file Async_4pin_Stepper.cpp.

void setTarget ( int  target )

Set target.

Parameters:
targetTarget step, can be positive or negative

Definition at line 101 of file Async_4pin_Stepper.cpp.

void setZeroPos (  )

Set current position as 0.

Definition at line 33 of file Async_4pin_Stepper.cpp.

void stepOnceCCW (  ) [protected]

Single step CW.

Definition at line 87 of file Async_4pin_Stepper.cpp.

void stepOnceCW (  ) [protected]

Callback function for stepper, called intermittedly to do a step towards the current target.

Definition at line 94 of file Async_4pin_Stepper.cpp.

void stop (  )

Stop the motor and detach ticker.

Definition at line 128 of file Async_4pin_Stepper.cpp.