A fork of a fine man's work. simplified. No microstepping etc, just a work in progress
Fork of BipoarStepperMotor by
Diff: sMotor.h
- Revision:
- 5:f9404f00deda
- Parent:
- 4:a3d8d60147dd
--- a/sMotor.h Tue Feb 03 01:02:39 2015 +0000 +++ b/sMotor.h Tue Feb 03 03:41:10 2015 +0000 @@ -7,6 +7,10 @@ to adapt to the stepper motor + linear actuator supplied by Selim Yilmaz +Now includes functional stepper pulses, a motor enable pin +(motor and l293D were getting very warm if the enable pin was +always HIGH) + */ #ifndef MBED_SMOTOR_H #define MBED_SMOTOR_H @@ -16,11 +20,13 @@ class sMotor { public: - sMotor(PinName A0, PinName A1, PinName A2, PinName A3, const int maxSteps); //motor constructor + sMotor(PinName A0, PinName A1, PinName A2, PinName A3, PinName motorEnable, const int maxSteps); //motor constructor + void setMotorPosition(int position); // for use ONLY if the stepper init is skipped + int getMotorPosition(void){ return _motorPosition; }; void step(int num_steps, int direction, int speed); - void anticlockwise(int num_steps); - void clockwise(int num_steps); + void up(int num_steps); + void down(int num_steps); private: @@ -29,8 +35,10 @@ DigitalOut _A1; DigitalOut _A2; DigitalOut _A3; + DigitalOut _motorEnable; int _motorPosition; int _maxSteps; + int _motorSpeed; };