Stepper motor driver lib.
Dependents: weather_station_proj weather_station_project weather_station_proj_v1_2
Fork of StepperMotor by
Revision 1:3ea32ec0e172, committed 2018-07-01
- Comitter:
- daniel_davvid
- Date:
- Sun Jul 01 12:00:18 2018 +0000
- Parent:
- 0:52fb09e87581
- Commit message:
- no significant updates
Changed in this revision
diff -r 52fb09e87581 -r 3ea32ec0e172 Stepper.cpp --- a/Stepper.cpp Sun Feb 24 16:23:02 2013 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,41 +0,0 @@ -#include "Stepper.h" -#include "mbed.h" - -stepper::stepper(PinName _en, PinName ms1, PinName ms2, PinName ms3, PinName _stepPin, PinName dir):en(_en), - microstepping(ms1, ms2, ms3), - stepPin(_stepPin), - direction(dir) -{ -} - -void stepper::step(int microstep, int dir, float speed) -{ - if (microstep == 1) { - microstepping = 0; - } else if (microstep <= 4) { - microstepping = microstep / 2; - } else if (microstep > 4) { - microstepping = (microstep / 2) - 1; - } - if (dir == 1) { - direction = 0; - } else if (dir == 0) { - direction = 1; - } - - // Step... - stepPin = 1; - wait(1/speed); - stepPin = 0; - wait(1/speed); -} - -void stepper::enable() -{ - en = 0; -} - -void stepper::disable() -{ - en = 1; -} \ No newline at end of file
diff -r 52fb09e87581 -r 3ea32ec0e172 Stepper.h --- a/Stepper.h Sun Feb 24 16:23:02 2013 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,19 +0,0 @@ -#ifndef MBED_STEPPER_H -#define MBED_STEPPER_H -#endif - -#include "mbed.h" - -class stepper -{ -public: - stepper(PinName _en, PinName ms1, PinName ms2, PinName ms3, PinName _stepPin, PinName dir); - void step(int microstep, int dir, float speed); - void enable(); - void disable(); -private: - DigitalOut en; - BusOut microstepping; - DigitalOut stepPin; - DigitalOut direction; -}; \ No newline at end of file
diff -r 52fb09e87581 -r 3ea32ec0e172 stepper.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/stepper.cpp Sun Jul 01 12:00:18 2018 +0000 @@ -0,0 +1,41 @@ +#include "stepper.h" +#include "mbed.h" + +stepper::stepper(PinName _en, PinName ms1, PinName ms2, PinName ms3, PinName _stepPin, PinName dir):en(_en), + microstepping(ms1, ms2, ms3), + stepPin(_stepPin), + direction(dir) +{ +} + +void stepper::step(int microstep, int dir, float speed) +{ + if (microstep == 1) { + microstepping = 0; + } else if (microstep <= 4) { + microstepping = microstep / 2; + } else if (microstep > 4) { + microstepping = (microstep / 2) - 1; + } + if (dir == 1) { + direction = 0; + } else if (dir == 0) { + direction = 1; + } + + // Step... + stepPin = 1; + wait(1/speed); + stepPin = 0; + wait(1/speed); +} + +void stepper::enable() +{ + en = 0; +} + +void stepper::disable() +{ + en = 1; +} \ No newline at end of file
diff -r 52fb09e87581 -r 3ea32ec0e172 stepper.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/stepper.h Sun Jul 01 12:00:18 2018 +0000 @@ -0,0 +1,19 @@ +#ifndef MBED_STEPPER_H +#define MBED_STEPPER_H +#endif + +#include "mbed.h" + +class stepper +{ +public: + stepper(PinName _en, PinName ms1, PinName ms2, PinName ms3, PinName _stepPin, PinName dir); + void step(int microstep, int dir, float speed); + void enable(); + void disable(); +private: + DigitalOut en; + BusOut microstepping; + DigitalOut stepPin; + DigitalOut direction; +}; \ No newline at end of file