Hello program for StepperMotorUni library
Dependencies: StepperMotorUni mbed
Dependents: StepperMotorUni_Hello
Sample code for stepper motor operation with StepperMotorUni library
4 output pin generates signal for stepper motor driver.
This library can operate in parallel for multiple stepper motors.
The mbed generates pulses on 4 output pins for external driver stage.
The StepperMotorUni library can generate 3 types of pulses.
1 phase drive (wave drive)
#include "mbed.h" #include "StepperMotorUni.h" StepperMotorUni motor( p26, p25, p24, p23 ); int main() { motor.set_operation_phase_mode( StepperMotorUni::ONE_PHASE ); ... ...
2 phase drive
#include "mbed.h" #include "StepperMotorUni.h" StepperMotorUni motor( p26, p25, p24, p23 ); int main() { motor.set_operation_phase_mode( StepperMotorUni::TWO_PHASE ); ... ...
1-2 phase (half step) drive
#include "mbed.h" #include "StepperMotorUni.h" StepperMotorUni motor( p26, p25, p24, p23 ); int main() { motor.set_operation_phase_mode( StepperMotorUni::HALFSTEP ); ... ...
Components pages
Components pages are available for bipolar
and unipolar
motor libraries
main.cpp@0:ae2206213141, 2014-01-19 (annotated)
- Committer:
- okano
- Date:
- Sun Jan 19 11:01:48 2014 +0000
- Revision:
- 0:ae2206213141
- Child:
- 1:80c512ccd0f2
initial release
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
okano | 0:ae2206213141 | 1 | /** "Hello" program for StepperMotorUni class library |
okano | 0:ae2206213141 | 2 | * |
okano | 0:ae2206213141 | 3 | * very simple sample of "StepperMotorUni" operation |
okano | 0:ae2206213141 | 4 | * |
okano | 0:ae2206213141 | 5 | * version 1.0 |
okano | 0:ae2206213141 | 6 | * copyright: 2014 Tedd OKANO |
okano | 0:ae2206213141 | 7 | * released under the Apache 2 license License |
okano | 0:ae2206213141 | 8 | */ |
okano | 0:ae2206213141 | 9 | |
okano | 0:ae2206213141 | 10 | #include "mbed.h" |
okano | 0:ae2206213141 | 11 | #include "StepperMotorUni.h" |
okano | 0:ae2206213141 | 12 | |
okano | 0:ae2206213141 | 13 | StepperMotorUni motor( p26, p25, p24, p23 ); |
okano | 0:ae2206213141 | 14 | |
okano | 0:ae2206213141 | 15 | int main() |
okano | 0:ae2206213141 | 16 | { |
okano | 0:ae2206213141 | 17 | motor.set_pps( 50 ); |
okano | 0:ae2206213141 | 18 | |
okano | 0:ae2206213141 | 19 | while ( 1 ) { |
okano | 0:ae2206213141 | 20 | motor.move_steps( 24 ); |
okano | 0:ae2206213141 | 21 | wait( 1 ); |
okano | 0:ae2206213141 | 22 | |
okano | 0:ae2206213141 | 23 | motor.move_steps( -24 ); |
okano | 0:ae2206213141 | 24 | wait( 1 ); |
okano | 0:ae2206213141 | 25 | } |
okano | 0:ae2206213141 | 26 | } |