My Version of the Crealab MotorLib.
Fork of MotorLib by
Diff: motor.h
- Revision:
- 0:bd05fd602a6e
- Child:
- 1:9519ac966b79
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/motor.h Fri Jun 17 11:16:07 2016 +0000 @@ -0,0 +1,42 @@ +// -------------------- Motor --------------------------- +#include "mbed.h" + +enum MotorStateList { // Define Motor States for the State Machine + Motor_IDLE = 0, + Motor_RUN, + Motor_PAUSE, + Motor_ZERO, + Motor_CALIB + } MotorState = Motor_IDLE; + +enum MotorCommandList { // Define Motor State Machine Commands + k_nop = 0, + k_wire, + k_pause, + k_restart, + k_stop, + k_zero + } MotorCommand; + +enum MotorDirectionList { // Define Motor Clockwise or Anticlockwise + d_clock = 0, + d_anti + } MotorDir; + +class Motor { + + Motor(PinName _MPh0, PinName _MPh1, PinName _MPh2, PinName _MPh3); + + DigitalOut *MPh0, *MPh1, *MPh2, *MPh3; + + + int MotorIndex; // --- Motor Variable + + + Ticker MotorSystemTick; // System Callback for Motor + timestamp_t MotorStepTime; // Time in µs for one motor step + uint32_t MotorFullTurn; // Number of step for a complete turn + uint32_t NumWires; // Number of Wires + uint32_t NumSteps; // Number of Steps = NumWire * MotorFullTurn + +} \ No newline at end of file