Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
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.
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:
-
StepperPin1 Pin 1 on stepper motor StepperPin2 Pin 2 on stepper motor StepperPin3 Pin 3 on stepper motor StepperPin4 Pin 4 on stepper motor StepsPerRev Steps 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 | ( | ) |
int getSpeed | ( | ) |
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:
-
speed Speed in steps/seconds
Definition at line 35 of file Async_4pin_Stepper.cpp.
void setTarget | ( | int | target ) |
Set target.
- Parameters:
-
target Target 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.
Generated on Sat Jul 23 2022 07:35:00 by
