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.
Dependents: Pousse_seringue_Ulg 0__Pousse_seringue
Fork of Stepper by
Stepper Class Reference
#include <Stepper.h>
Public Types | |
| enum | direction |
Enum for direction CW=true or 1; CCW=false or 0. More... | |
Public Member Functions | |
| Stepper (PinName clk, PinName dir) | |
| Create Stepper instance connected to pin clk & dir. | |
| void | goesTo (int position) |
| Moving the motor relative to a reference position (set by setPositionZero()) | |
| void | move (int steps) |
| Moving the motor for given steps. | |
| void | rotate (bool direction) |
| Moving the motor until user stop. | |
| void | stop (void) |
| Stop the motor as fast as possible. | |
| void | setSpeed (float speed) |
| Set Rotation Speed. | |
| void | setAcceleration (float acc) |
| Set Acceleration ramp. | |
| void | setDeceleration (float dec) |
| Set Deceleration ramp. | |
| void | setPositionZero (void) |
| Give Origin for motor absolute movement. | |
| bool | stopped (void) |
| Check if motor is stopped. | |
| int | getPosition (void) |
| Get absolute position from origin. | |
| float | getAcceleration (void) |
| Get Acceleration. | |
| float | getDeceleration (void) |
| Get Deceleration. | |
| float | getSpeed (void) |
| Get Speed. | |
Detailed Description
Stepper class.
Used for drive Stepper motor
Example:
#include "mbed.h" #include "Stepper.h" DigitalIn home(p20); Stepper mot(p21,p22); int main() { mot.setSpeed(1200); mot.setAcceleration(4000); mot.setDeceleration(4000); mot.rotate(CW); while(!home); mot.stop(); mot.setPositionZero(); mot.goesTo(1600); while(!mot.stopped()); while(1) { } }
Definition at line 37 of file Stepper.h.
Member Enumeration Documentation
| enum direction |
Constructor & Destructor Documentation
| Stepper | ( | PinName | clk, |
| PinName | dir | ||
| ) |
Create Stepper instance connected to pin clk & dir.
- Parameters:
-
clk pin to connect at clk/step output dir pin to connect at dir output
Definition at line 6 of file Stepper.cpp.
Member Function Documentation
| float getAcceleration | ( | void | ) |
| float getDeceleration | ( | void | ) |
| int getPosition | ( | void | ) |
Get absolute position from origin.
- Returns:
- position [steps] from origin set by setPositionZero()
Definition at line 56 of file Stepper.cpp.
| float getSpeed | ( | void | ) |
| void goesTo | ( | int | position ) |
Moving the motor relative to a reference position (set by setPositionZero())
- Parameters:
-
position steps from position zero
Definition at line 101 of file Stepper.cpp.
| void move | ( | int | steps ) |
Moving the motor for given steps.
- Parameters:
-
steps number of steps to go(>0 CW ; <0 CCW)
Definition at line 85 of file Stepper.cpp.
| void rotate | ( | bool | direction ) |
Moving the motor until user stop.
- Parameters:
-
direction rotation Stepper::CC or Stepper::CCW
Definition at line 77 of file Stepper.cpp.
| void setAcceleration | ( | float | acc ) |
Set Acceleration ramp.
- Parameters:
-
acc acceleration [steps/sec²] (0 = infinite acceleration 1st step @ max speed)
Definition at line 30 of file Stepper.cpp.
| void setDeceleration | ( | float | dec ) |
Set Deceleration ramp.
- Parameters:
-
dec deceleration [steps/sec²] (0 = infinite deceleration last step @ max speed)
Definition at line 41 of file Stepper.cpp.
| void setPositionZero | ( | void | ) |
Give Origin for motor absolute movement.
Definition at line 51 of file Stepper.cpp.
| void setSpeed | ( | float | speed ) |
| void stop | ( | void | ) |
Stop the motor as fast as possible.
Definition at line 69 of file Stepper.cpp.
| bool stopped | ( | void | ) |
Generated on Sat Jul 23 2022 09:55:00 by
1.7.2
