Updated for the next revision of the motor board
MotorShield.h@7:e3a2ade56b79, 2020-08-26 (annotated)
- Committer:
- elijahsj
- Date:
- Wed Aug 26 23:42:07 2020 +0000
- Revision:
- 7:e3a2ade56b79
- Parent:
- 5:d2dffc88e94d
Fully functional with high frequency loop
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 |