Motor Shield Example code for 2.74 Class @ MIT
Dependents: experiment_example motor_shield_example Lab3_experiment_example jumping_leg_clicky
MotorShield.h@8:46feb6919761, 2022-09-16 (annotated)
- Committer:
- adimmit
- Date:
- Fri Sep 16 01:36:38 2022 +0000
- Revision:
- 8:46feb6919761
- Parent:
- 7:e3a2ade56b79
updated for new motor driver
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
elijahsj | 0:f2ede00aed8a | 1 | /* Library to interface with 2.74 Motor Shield |
elijahsj | 3:2f46953e7c8b | 2 | ** Uses low level HAL libraries to enable high speed PWM |
elijahsj | 5:d2dffc88e94d | 3 | ** Use as follows: |
elijahsj | 5:d2dffc88e94d | 4 | ** - Create shield object and specify PWM period for the motors |
elijahsj | 5:d2dffc88e94d | 5 | ** - Set the duty cycle and direction for each motor |
elijahsj | 0:f2ede00aed8a | 6 | */ |
elijahsj | 0:f2ede00aed8a | 7 | |
elijahsj | 0:f2ede00aed8a | 8 | class MotorShield { |
elijahsj | 0:f2ede00aed8a | 9 | |
elijahsj | 0:f2ede00aed8a | 10 | public: |
elijahsj | 0:f2ede00aed8a | 11 | |
elijahsj | 3:2f46953e7c8b | 12 | MotorShield(int periodTicks); |
elijahsj | 5:d2dffc88e94d | 13 | void motorAWrite(float duty_cycle, int direction); |
elijahsj | 5:d2dffc88e94d | 14 | void motorBWrite(float duty_cycle, int direction); |
elijahsj | 5:d2dffc88e94d | 15 | void motorCWrite(float duty_cycle, int direction); |
elijahsj | 5:d2dffc88e94d | 16 | void motorDWrite(float duty_cycle, int direction); |
elijahsj | 7:e3a2ade56b79 | 17 | uint32_t readCurrentA(); |
elijahsj | 7:e3a2ade56b79 | 18 | uint32_t readCurrentB(); |
elijahsj | 7:e3a2ade56b79 | 19 | uint32_t readCurrentC(); |
elijahsj | 7:e3a2ade56b79 | 20 | uint32_t readCurrentD(); |
elijahsj | 3:2f46953e7c8b | 21 | void changePeriod(int periodTicks); |
elijahsj | 0:f2ede00aed8a | 22 | |
elijahsj | 0:f2ede00aed8a | 23 | private: |
elijahsj | 0:f2ede00aed8a | 24 | |
elijahsj | 3:2f46953e7c8b | 25 | int periodTickVal; |
elijahsj | 3:2f46953e7c8b | 26 | void init(); |
elijahsj | 0:f2ede00aed8a | 27 | |
elijahsj | 0:f2ede00aed8a | 28 | }; |
elijahsj | 0:f2ede00aed8a | 29 |