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
Diff: MotorDrive298.h
- Revision:
- 4:7620d21baef3
- Parent:
- 3:502f90649834
--- a/MotorDrive298.h Thu Aug 13 17:50:28 2015 +0000 +++ b/MotorDrive298.h Sun Aug 16 22:46:25 2015 +0000 @@ -117,10 +117,10 @@ MotorDrive (PinName namEN, PinName namIN1, PinName namIN2, PinName namCS) : IN1(namIN1), IN2(namIN2), +#ifdef DBH1 + CS(namCS), +#endif EN(namEN) -#ifdef DBH1 - ,CS(namCS) -#endif { EN.write(0.0f); IN2.write(0.0f); @@ -153,10 +153,10 @@ //BYTE EN; // enable pin //SHORT _speed; // current speed //SHORT _speedCmd; // commanded speed - CmdSerial.printf("Decel %d ms from ful speed\r\n",_decel); + DiagSerial.printf("Decel %d ms from ful speed\r\n",_decel); //BYTE _mode; //unsigned long _doneTime; // time when mode automatically transitions - CmdSerial.printf("Deadman Timeout %d ms\r\n",_deadTime); + DiagSerial.printf("Deadman Timeout %d ms\r\n",_deadTime); //SHORT _maxPWM; // clip PWM commands to this magnitude //SHORT _startupTime; // ms of full-power pulse to start from dead stop //SHORT _stopTime; // ms to lock-out commands after emergency stop @@ -179,7 +179,7 @@ virtual void emergencyStop() { - CmdSerial.puts("Emergency "); + DiagSerial.puts("Emergency "); _msgCount = 11; // turn on diagnostics for a few commands stop(); _speedCmd=0; @@ -259,7 +259,7 @@ _doneTime = t + _deadTime; setReverse(_mode == MOTOR_REV); // make sure direction is correct EN.write(getPWM(_speedCmd)); // analogWrite(Pin.EN,getPWM(_speedCmd)); - if(_msgCount>0){_msgCount--;CmdSerial.printf("Started %.3f\r\n",_speedCmd);} + if(_msgCount>0){_msgCount--;DiagSerial.printf("Started %.3f\r\n",_speedCmd);} } return; }