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
MotorDriver Class Reference
MotorDriver class. More...
#include <MotorDriver.h>
Public Member Functions | |
| MotorDriver (DigitalOut in1, DigitalOut in2, PwmOut pwm, float pwmFreq, bool isBrakeable=false) | |
| Constructor of MotorDriver Objects. | |
| State_t | setSpeed (float speed) |
| Sets speed of motor normalized between -1.0 to 1.0. | |
| State_t | forceSetSpeed (float speed) |
| Same as setSpeed(float speed), however does not impose the safety disallowing instantaneous reversal of motor direction. | |
| State_t | brake (float intensity) |
| Put motor into braked config. | |
| State_t | coast () |
| Put motor into stop/coast config. | |
| State_t | getState () |
| Get state of the motor. | |
Detailed Description
MotorDriver class.
Used for DIY project "RC-AutoBot" by Clownface.space
Example:
#include "mbed.h" #include "MotorDriver.h" MotorDriver m1(in1, in2, pwm); void dist(int distance) { //put code here to happen when the distance is changed printf("\r\n** Distance changed to %dmm\r\n", distance); sensorDistance = distance; } int main() { m1.setSpeed(1); }
Definition at line 70 of file MotorDriver.h.
Constructor & Destructor Documentation
| MotorDriver | ( | DigitalOut | in1, |
| DigitalOut | in2, | ||
| PwmOut | pwm, | ||
| float | pwmFreq, | ||
| bool | isBrakeable = false |
||
| ) |
Constructor of MotorDriver Objects.
- Parameters:
-
in_1 Direction Input 1 in_2 Direction Input 2 pwm PWM speed control input pwmFreq PWM frequency, some motors may whine at lower freqs isBrakable Boolean value indicating whether or not the motor driver is brakeable(see your datasheet)
Definition at line 6 of file MotorDriver.cpp.
Member Function Documentation
| State_t brake | ( | float | intensity ) |
Put motor into braked config.
- Parameters:
-
intensity How hard to brake (0.0 to 1.0)
- Returns:
- state of the motors
Definition at line 76 of file MotorDriver.cpp.
| State_t coast | ( | ) |
Put motor into stop/coast config.
Definition at line 88 of file MotorDriver.cpp.
| State_t forceSetSpeed | ( | float | speed ) |
Same as setSpeed(float speed), however does not impose the safety disallowing instantaneous reversal of motor direction.
It is up to the user to ensure they do not blow up their motor.
- Parameters:
-
speed How fast to run the motor
Definition at line 63 of file MotorDriver.cpp.
| State_t getState | ( | ) |
| State_t setSpeed | ( | float | speed ) |
Sets speed of motor normalized between -1.0 to 1.0.
- Parameters:
-
speed Value -1.0 to 1.0 (>0 CW at speed as percentage) (<0 CCW at speed as percentage) (=0 speed is zero)
- Returns:
- state of the motor NOTE: This method will NOT allow user to instantaneously swithch from CW to CCW or vise versa. Doing so will cause the motor to be put in to a BRAKE condition, while the motor_state.code will be updated to MOTOR_ERROR. User should avoid trying to do this, call first setSpeed(0) or brake().
Definition at line 38 of file MotorDriver.cpp.
Generated on Thu Jul 14 2022 10:50:07 by
1.7.2
