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.
Fork of Motordriver by
Motor Class Reference
Interface to control a standard DC motor with an H-bridge using a PwmOut and 2 DigitalOuts. More...
#include <motordriver.h>
| Public Member Functions | |
| Motor (PinName pwm, PinName fwd, PinName rev, int brakeable) | |
| Create a motor control interface. | |
| float | speed (float speed) | 
| Set the speed of the motor. | |
| void | coast (void) | 
| Set the the motor to coast. | |
| float | stop (float duty) | 
| Set the motor to dynamicaly brake. | |
| float | state (void) | 
| return the current state of the motor | |
Detailed Description
Interface to control a standard DC motor with an H-bridge using a PwmOut and 2 DigitalOuts.
Definition at line 37 of file motordriver.h.
Constructor & Destructor Documentation
| Motor | ( | PinName | pwm, | 
| PinName | fwd, | ||
| PinName | rev, | ||
| int | brakeable | ||
| ) | 
Create a motor control interface.
- Parameters:
- 
  pwm A PwmOut pin, driving the H-bridge enable line to control the speed fwd A DigitalOut, set high when the motor should go forward rev A DigitalOut, set high when the motor should go backwards set if the motor driver is able to do braking 0 false 1 true. 
Definition at line 33 of file motordriver.cpp.
Member Function Documentation
| void coast | ( | void | ) | 
Set the the motor to coast.
- Parameters:
- 
  void 
- Returns:
- motor coasts until another instruction is recived.
Definition at line 90 of file motordriver.cpp.
| float speed | ( | float | speed ) | 
Set the speed of the motor.
- Parameters:
- 
  speed The speed of the motor as a normalised value between -1.0 and 1.0. 
- Returns:
- the applied speed to the motor after checking to ensure motor doesn't switch from forward to reverse without stopping.
Definition at line 48 of file motordriver.cpp.
| float state | ( | void | ) | 
return the current state of the motor
- Parameters:
- 
  void 
- Returns:
- state of motor, -1 to 1 is speed, -2 is braking, 2 is coasting. -3 is error.
Definition at line 109 of file motordriver.cpp.
| float stop | ( | float | duty ) | 
Set the motor to dynamicaly brake.
- Parameters:
- 
  float 0 - 1.0 provides some control over how hard the motor brakes. 
- Returns:
- duty applied to motor driver. -1 is error, motor driver can't brake.
Definition at line 97 of file motordriver.cpp.
Generated on Thu Jul 14 2022 03:18:13 by
 1.7.2
 1.7.2 
    