added gy80 dcm
Dependencies: mbed DCM_AHRS_GY80 PID MMA8451Q
Fork of quadCommand by
quadCommand/motor/motor.h@59:9dfd9169a5e7, 2013-07-03 (annotated)
- Committer:
- gabdo
- Date:
- Wed Jul 03 04:45:03 2013 +0000
- Revision:
- 59:9dfd9169a5e7
- Parent:
- 56:a550127695b2
Working code, needs to be tuned.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
gabdo | 0:8681037b9a18 | 1 | /******************************* motor.h *********************************/ |
gabdo | 0:8681037b9a18 | 2 | /* Version: 1.0 */ |
gabdo | 0:8681037b9a18 | 3 | /* Last Updated: June 1, 2013 */ |
gabdo | 0:8681037b9a18 | 4 | /* */ |
gabdo | 0:8681037b9a18 | 5 | /* The motor class is used for motor control using a PWM ECS. When a */ |
gabdo | 0:8681037b9a18 | 6 | /*a motor object is created you must pass the PWM pin as the only */ |
gabdo | 0:8681037b9a18 | 7 | /*argument. */ |
gabdo | 0:8681037b9a18 | 8 | /* */ |
gabdo | 0:8681037b9a18 | 9 | /* Wiring diagrams */ |
gabdo | 0:8681037b9a18 | 10 | /* _______ _______ */ |
gabdo | 0:8681037b9a18 | 11 | /* CW ----| | CCW ---\/ --| | */ |
gabdo | 0:8681037b9a18 | 12 | /* ----| Motor | ---/\---| Motor | */ |
gabdo | 0:8681037b9a18 | 13 | /* ----|_______| --/ \--|_______| */ |
gabdo | 0:8681037b9a18 | 14 | /* Straight through Switch wire 1 and 3 */ |
gabdo | 0:8681037b9a18 | 15 | /* */ |
gabdo | 0:8681037b9a18 | 16 | /*************************************************************************/ |
gabdo | 0:8681037b9a18 | 17 | |
gabdo | 0:8681037b9a18 | 18 | |
gabdo | 0:8681037b9a18 | 19 | #ifndef MOTOR_H |
gabdo | 0:8681037b9a18 | 20 | #define MOTOR_H |
gabdo | 0:8681037b9a18 | 21 | |
gabdo | 0:8681037b9a18 | 22 | #include "mbed.h" |
gabdo | 0:8681037b9a18 | 23 | |
gabdo | 0:8681037b9a18 | 24 | class motor |
gabdo | 0:8681037b9a18 | 25 | { |
gabdo | 0:8681037b9a18 | 26 | public: |
gabdo | 0:8681037b9a18 | 27 | motor( PinName ); // motor object constructor. |
gabdo | 56:a550127695b2 | 28 | void setSpeed( int ); // Set the speed for the motor 0-100 |
gabdo | 0:8681037b9a18 | 29 | void setPulseMin( float ); // Set smallest pulse. |
gabdo | 0:8681037b9a18 | 30 | void setPulseMax( float ); // Set largest pulse. |
gabdo | 56:a550127695b2 | 31 | int getSpeed(); |
gabdo | 0:8681037b9a18 | 32 | |
gabdo | 0:8681037b9a18 | 33 | private: |
gabdo | 56:a550127695b2 | 34 | PwmOut *pwmPin; // Pin used for PWM. |
gabdo | 56:a550127695b2 | 35 | int currentSpeed; // Speed of the motor. |
gabdo | 0:8681037b9a18 | 36 | float pulse; // Current pulse of the motor. |
gabdo | 0:8681037b9a18 | 37 | float pulseMin; // Shortest value for the pulse |
gabdo | 55:bca9c9e92da6 | 38 | float pulseMax; // Largest value for the pulse. |
gabdo | 0:8681037b9a18 | 39 | }; |
gabdo | 0:8681037b9a18 | 40 | |
gabdo | 0:8681037b9a18 | 41 | #endif |