Modified phase table in stepper.cpp to enable stepping a bipolar motor using a twin H-bridge driver.
Fork of stepper by
STEPPER Class Reference
Unipolar Type Stepping Motor Driver using 4 Outputs(DigitalOut) with timer interrupt(Ticker) More...
#include <stepper.h>
Public Types | |
enum | MOTOR_STATE |
pulse width definition -> Use for start and stop phase = data * TIMEBASE -> e.g following data = 5 then 5*15000/1000 = 75mS More... | |
Public Member Functions | |
STEPPER (PinName xp, PinName xn, PinName yp, PinName yn) | |
Configure data pin. | |
void | move (int32_t steps) |
Move steps. | |
void | set_max_speed (uint32_t time_base_us) |
Set time period (max speed of stepper) | |
uint8_t | status (void) |
Check status. | |
void | stop () |
De-energize coils. |
Detailed Description
Unipolar Type Stepping Motor Driver using 4 Outputs(DigitalOut) with timer interrupt(Ticker)
Driver circuit: Low side driver (4ch for one Stepper) e.g. TD62003AP CAUTION: This is only for Unipolar Type Stepping Motor! Cannot use for Bipolar Type Plese refer http://en.wikipedia.org/wiki/Stepper_motor
#include "mbed.h" #include "stepper.h" #define TIMEBASE 15000 // 15mS STEPPER sm(D5, D4, D3, D2); uint8_t pls_width[10] = {5, 4, 3, 2, 1, 1, 1, 1, 1, 1 }; int main() { sm_r.set_max_speed(TIMEBASE); sm.move(+100); while (sm.status){ ;} sm.move(-1000); wait(10); sm.move(0); while(true){;} }
Definition at line 56 of file stepper.h.
Member Enumeration Documentation
enum MOTOR_STATE |
Constructor & Destructor Documentation
STEPPER | ( | PinName | xp, |
PinName | xn, | ||
PinName | yp, | ||
PinName | yn | ||
) |
Member Function Documentation
void move | ( | int32_t | steps ) |
void set_max_speed | ( | uint32_t | time_base_us ) |
Set time period (max speed of stepper)
- Parameters:
-
time,: e.g. 10mS(=10000) -> 100 PPS(Puls per Sec)
- Returns:
- none
Definition at line 91 of file stepper.cpp.
uint8_t status | ( | void | ) |
Check status.
- Parameters:
-
none
- Returns:
- running(= 1), stopped(= 0)
Definition at line 100 of file stepper.cpp.
void stop | ( | void | ) |
Generated on Thu Jul 14 2022 02:17:18 by 1.7.2