Basic tank-style drive robot control firmware for Freescale FRDM-K64F. Controls motors on a Dual-Full-H-Bridge with EN, like DBH-1x series, from Bluetooth serial commands
MotorDriveBase.h@0:41ca27337c2b, 2015-07-28 (annotated)
- Committer:
- Mr_What
- Date:
- Tue Jul 28 14:59:19 2015 +0000
- Revision:
- 0:41ca27337c2b
- Child:
- 1:23d0a615756a
sloppy Arduino port, but (mostly) running. Ready to test motor drive.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Mr_What | 0:41ca27337c2b | 1 | // Generic interface for "standard" H-Bridge motor driver |
Mr_What | 0:41ca27337c2b | 2 | |
Mr_What | 0:41ca27337c2b | 3 | class MotorDriveBase |
Mr_What | 0:41ca27337c2b | 4 | { |
Mr_What | 0:41ca27337c2b | 5 | virtual void stop() = 0; |
Mr_What | 0:41ca27337c2b | 6 | virtual void emergencyStop() = 0; |
Mr_What | 0:41ca27337c2b | 7 | |
Mr_What | 0:41ca27337c2b | 8 | |
Mr_What | 0:41ca27337c2b | 9 | // Set speed -MAX_PWM for max reverse, MAX_PWM for max forward |
Mr_What | 0:41ca27337c2b | 10 | inline void setSpeed(const int spdReq) |
Mr_What | 0:41ca27337c2b | 11 | { |
Mr_What | 0:41ca27337c2b | 12 | setSpeed(spdReq,millis()); |
Mr_What | 0:41ca27337c2b | 13 | } |
Mr_What | 0:41ca27337c2b | 14 | |
Mr_What | 0:41ca27337c2b | 15 | // many (all?) drivers may have some mode transition times and pauses. |
Mr_What | 0:41ca27337c2b | 16 | // use these to indicate current time, to avoid repeated calls to millis() |
Mr_What | 0:41ca27337c2b | 17 | virtual void setSpeed(const float spd, const long t) = 0; // pass in current time |
Mr_What | 0:41ca27337c2b | 18 | virtual void update(long t) = 0; // check if some sort of state change needs to be processed |
Mr_What | 0:41ca27337c2b | 19 | }; |