This is a library that drives a stepper motor with given parameters for speed and direction.
About
This is a stepper motor library that is based on the sMotor library by Samuel Matildes (sam.naeec@gmail.com). It was designed to drive specifically a 5718m-05e-05 stepper motor in conjunction with an L293NE quad h-bridge chip. I am not responsible for any damage caused due to the execution of this program on your hardware as I can only confirm that it works for the above specified model. High torque mode is currently not complete.
mMotor.h@0:acf5b8fc382b, 2013-04-24 (annotated)
- Committer:
- mdu7078
- Date:
- Wed Apr 24 17:39:30 2013 +0000
- Revision:
- 0:acf5b8fc382b
- Child:
- 1:6e0a307d0f9b
First commit to motor library.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mdu7078 | 0:acf5b8fc382b | 1 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * |
mdu7078 | 0:acf5b8fc382b | 2 | * This is a stepper motor library for testing * |
mdu7078 | 0:acf5b8fc382b | 3 | * 4 step stepper motors. The speed of stepping is * |
mdu7078 | 0:acf5b8fc382b | 4 | * variable as well as the amount of steps. * |
mdu7078 | 0:acf5b8fc382b | 5 | * ------------------------------------------------- * |
mdu7078 | 0:acf5b8fc382b | 6 | * This library is based on the sMotor library by * |
mdu7078 | 0:acf5b8fc382b | 7 | * Samuel Matildes (sam.naeec@gmail.com). * |
mdu7078 | 0:acf5b8fc382b | 8 | * ------------------------------------------------- * |
mdu7078 | 0:acf5b8fc382b | 9 | * * |
mdu7078 | 0:acf5b8fc382b | 10 | * Created by: Michael Dushkoff (mad1841@rit.edu) * |
mdu7078 | 0:acf5b8fc382b | 11 | * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
mdu7078 | 0:acf5b8fc382b | 12 | |
mdu7078 | 0:acf5b8fc382b | 13 | #ifndef MBED_MSTEPMOTOR_H |
mdu7078 | 0:acf5b8fc382b | 14 | #define MBED_MSTEPMOTOR_H |
mdu7078 | 0:acf5b8fc382b | 15 | |
mdu7078 | 0:acf5b8fc382b | 16 | #include "mbed.h" |
mdu7078 | 0:acf5b8fc382b | 17 | |
mdu7078 | 0:acf5b8fc382b | 18 | class mMotor { |
mdu7078 | 0:acf5b8fc382b | 19 | public: |
mdu7078 | 0:acf5b8fc382b | 20 | |
mdu7078 | 0:acf5b8fc382b | 21 | mMotor(PinName M0, PinName M1, PinName M2, PinName M3); //motor constructor |
mdu7078 | 0:acf5b8fc382b | 22 | |
mdu7078 | 0:acf5b8fc382b | 23 | void step(int num_steps, int direction, int speed); |
mdu7078 | 0:acf5b8fc382b | 24 | void counterclockwise(); |
mdu7078 | 0:acf5b8fc382b | 25 | void clockwise(); |
mdu7078 | 0:acf5b8fc382b | 26 | |
mdu7078 | 0:acf5b8fc382b | 27 | |
mdu7078 | 0:acf5b8fc382b | 28 | private: |
mdu7078 | 0:acf5b8fc382b | 29 | |
mdu7078 | 0:acf5b8fc382b | 30 | DigitalOut _M0; |
mdu7078 | 0:acf5b8fc382b | 31 | DigitalOut _M1; |
mdu7078 | 0:acf5b8fc382b | 32 | DigitalOut _M2; |
mdu7078 | 0:acf5b8fc382b | 33 | DigitalOut _M3; |
mdu7078 | 0:acf5b8fc382b | 34 | |
mdu7078 | 0:acf5b8fc382b | 35 | }; |
mdu7078 | 0:acf5b8fc382b | 36 | |
mdu7078 | 0:acf5b8fc382b | 37 | #endif |