added gy80 dcm
Dependencies: mbed DCM_AHRS_GY80 PID MMA8451Q
Fork of quadCommand by
quadCommand/motor/motor.h@55:bca9c9e92da6, 2013-06-13 (annotated)
- Committer:
- gabdo
- Date:
- Thu Jun 13 01:11:03 2013 +0000
- Revision:
- 55:bca9c9e92da6
- Parent:
- 45:088885f4a13d
- Child:
- 56:a550127695b2
Good job!
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 | 55:bca9c9e92da6 | 24 | #define TRIM_CONST .5 |
gabdo | 55:bca9c9e92da6 | 25 | |
gabdo | 0:8681037b9a18 | 26 | class motor |
gabdo | 0:8681037b9a18 | 27 | { |
gabdo | 0:8681037b9a18 | 28 | public: |
gabdo | 0:8681037b9a18 | 29 | motor( PinName ); // motor object constructor. |
gabdo | 45:088885f4a13d | 30 | void setSpeed( float ); // Set the speed for the motor 0-100 |
gabdo | 0:8681037b9a18 | 31 | void setPulseMin( float ); // Set smallest pulse. |
gabdo | 0:8681037b9a18 | 32 | void setPulseMax( float ); // Set largest pulse. |
gabdo | 45:088885f4a13d | 33 | float getSpeed(); |
gabdo | 0:8681037b9a18 | 34 | float getPulse( void ); |
gabdo | 0:8681037b9a18 | 35 | |
gabdo | 0:8681037b9a18 | 36 | private: |
gabdo | 0:8681037b9a18 | 37 | PwmOut _pwm; // Pin used for PWM. |
gabdo | 55:bca9c9e92da6 | 38 | float currentSpeed; // Speed of the motor. |
gabdo | 0:8681037b9a18 | 39 | float pulse; // Current pulse of the motor. |
gabdo | 0:8681037b9a18 | 40 | float pulseMin; // Shortest value for the pulse |
gabdo | 55:bca9c9e92da6 | 41 | float pulseMax; // Largest value for the pulse. |
gabdo | 55:bca9c9e92da6 | 42 | float trim; |
gabdo | 0:8681037b9a18 | 43 | }; |
gabdo | 0:8681037b9a18 | 44 | |
gabdo | 0:8681037b9a18 | 45 | #endif |