Provides an API software interface to TIMER2 to control upto four stepper motors.
Diff: inc/SimpleSteppers.h
- Revision:
- 3:71ab7209adb3
- Parent:
- 2:1fb2ae5bf3df
- Child:
- 4:7b7940df7865
--- a/inc/SimpleSteppers.h Mon May 02 10:06:00 2011 +0000 +++ b/inc/SimpleSteppers.h Mon May 02 10:17:33 2011 +0000 @@ -50,9 +50,61 @@ * Note, SimpleStepper uses the SimpleStepperController class to manage * the TIMER2. SimpleStepperController and SimpleStepper take total * control of the LPC17xx's TIMER2. Your application or other library that - * your application uses, should use TIMER2. + * your application uses, should <b>not</b>use TIMER2. + * + * This library is a software interface to the TIMER2 MATCH system. It does + * <b>not</b> provide position and/or acceleration, PID control, etc, of + * the motors. Your application or other library should provide the control + * function needed to position/run your stepper motor(s). * - * @include SimpleSteppers/inc/example1.h + * @code + * #include "mbed.h" + * #include "SimpleSteppers.h" + * + * SimpleStepperOutput led1(LED1); + * + * // SimpleStepperOutput is basically the same as + * // Mbed's DigitalOut class. However, it's more + * // portable to other platforms without having + * // to also port the entire Mbed library. + * SimpleStepperOutput sdir0(p17); + * SimpleStepperOutput sdir1(p18); + * SimpleStepperOutput sdir2(p19); + * SimpleStepperOutput sdir3(p20); + * + * // Create four steppers. + * // Stepper0 has the pulse output on p8 and dir on p17 + * SimpleStepper stepper0(p8, &sdir0); + * // Stepper1 has the pulse output on p7 and dir on p18 + * SimpleStepper stepper1(p7, &sdir1); + * // Stepper2 has the pulse output on p7 and dir on p19 + * SimpleStepper stepper2(p6, &sdir2); + * // Stepper3 has the pulse output on p7 and dir on p20 + * SimpleStepper stepper3(p5, &sdir3); + * + * int main() { + * + * // We do not need to maintain the stepper position + * // for this simple example. This reduces the amount + * // of work the ISR has to do. + * stepper0.setMaintainPositionData(false); + * stepper1.setMaintainPositionData(false); + * stepper2.setMaintainPositionData(false); + * stepper3.setMaintainPositionData(false); + * + * // Set all steppers to top speed of 5000 pulses/second. + * stepper0.setSpeed(5000); + * stepper1.setSpeed(5000); + * stepper2.setSpeed(5000); + * stepper3.setSpeed(5000); + * + * while(1) { + * led1 = !led1; + * wait(0.2); + * } + * } + * @endcode + * @see example1.h */ class SimpleStepper {