Example for a Magnevation Board used previously on a OOPICII
Fork of Motordriver by
Motor Class Reference
Interface to control a standard DC motor with an H-bridge using a PwmOut and 2 DigitalOuts Specifically for the Magnevation Board - refer to comments. More...
#include <motordriver.h>
Public Member Functions | |
Motor (PinName pwm, PinName fwdrev, PinName brake, bool direction, bool stop) | |
Create a motor control interface. | |
float | speed (float speed, bool fwdrev, bool stop) |
Create Motor instance. | |
float | stop (float speed, bool stop) |
Set the the motor to coast. | |
Protected Attributes | |
PwmOut | _pwm |
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 Specifically for the Magnevation Board - refer to comments.
Class Declaration
Definition at line 39 of file motordriver.h.
Constructor & Destructor Documentation
Motor | ( | PinName | pwm, |
PinName | fwdrev, | ||
PinName | brake, | ||
bool | direction, | ||
bool | stop | ||
) |
Create a motor control interface.
- Parameters:
-
pwm,A PwmOut pin driving the H-bridge enable line to control the speed fwdrev,A DigitalOut pin note Forward and Reverse is relative to how you connect the motor(s) and Refer to Figure 4 pages 6 & 7 in Instrument LMD18200 data sheet. brake,A DigitalOut pin the Magnevation driver board is able to perform a brake i.e. 0 false brake ON, 1 true brake OFF.
Definition at line 33 of file motordriver.cpp.
Member Function Documentation
float speed | ( | float | speed, |
bool | fwdrev, | ||
bool | stop | ||
) |
Create Motor instance.
Set the speed of the motor
- Parameters:
-
speed The speed of the motor as a normalised value between 0.0 and 1.0. fwdrev Magnevation board sets direction on a pin so does not need -1.0 to 0.0. stop The Magnevation Board has a brake facility and incorporates the Current Limiting features of the LMD18200.
- Returns:
- the applied speed to the motor after checking to ensure motor doesn't switch from forward to reverse without stopping.
Definition at line 51 of file motordriver.cpp.
float stop | ( | float | speed, |
bool | stop | ||
) |
Set the the motor to coast.
In a practical world you would not neccessarily leave anything 'coasting' and acting as a dc generator always better to have a drive under control at all times so I haven't included this from the origanal class constructor for the Magnevation Board. Set the motor to dynamicaly brake
The Magnevation Board has a brake facility and incorporates the Current Limiting features of the LMD18200.
Definition at line 59 of file motordriver.cpp.
Field Documentation
PwmOut _pwm [protected] |
return the current state of the motor
Definition at line 79 of file motordriver.h.
Generated on Tue Jul 19 2022 21:53:41 by
