Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: SimpleRover PIDRover IMURover incrementalencoder-pid-robot ... more
Revision 1:c75b234558af, committed 2010-09-07
- Comitter:
- aberk
- Date:
- Tue Sep 07 11:21:42 2010 +0000
- Parent:
- 0:f05e09f8f5d9
- Commit message:
- Added functionality to brake high or low.
Changed in this revision
| Motor.cpp | Show annotated file Show diff for this revision Revisions of this file |
| Motor.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/Motor.cpp Thu Sep 02 16:32:57 2010 +0000
+++ b/Motor.cpp Tue Sep 07 11:21:42 2010 +0000
@@ -45,3 +45,16 @@
_pwm.period(period);
}
+
+void Motor::brake(int highLow){
+
+ if(highLow == BRAKE_HIGH){
+ _fwd = 1;
+ _rev = 1;
+ }
+ else if(highLow == BRAKE_LOW){
+ _fwd = 0;
+ _rev = 0;
+ }
+
+}
--- a/Motor.h Thu Sep 02 16:32:57 2010 +0000
+++ b/Motor.h Tue Sep 07 11:21:42 2010 +0000
@@ -25,6 +25,9 @@
#include "mbed.h"
+#define BRAKE_HIGH 1
+#define BRAKE_LOW 0
+
/** Interface to control a standard DC motor
* with an H-bridge using a PwmOut and 2 DigitalOuts
*/
@@ -52,6 +55,15 @@
* @param seconds - Pwm duty cycle in seconds.
*/
void period(float period);
+
+ /** Brake the H-bridge to GND or VCC.
+ *
+ * Defaults to breaking to VCC.
+ *
+ * Brake to GND => inA = inB = 0
+ * Brake to VCC => inA = inB = 1
+ */
+ void brake(int highLow = BRAKE_HIGH);
protected:
PwmOut _pwm;