Controls an H-bridge motor driver controlled by a PCA9685 Tested on the Alfredo Systems NoU3 https://github.com/AlfredoSystems/Alfredo-NoU3.
More...
#include <JMotorDriverPCA9685HBridge.h>
|
| JMotorDriverPCA9685HBridge (PCA9685 &_pca9685, byte _channelPos, byte _channelNeg, bool _reverse=false, bool _breakWhenEnabled=true, bool _breakWhenDisabled=false) |
| Controls an H-bridge motor driver controlled by a PCA9685.
|
|
void | setBreakWhenEnabled (bool _breakWhenEnabled) |
| activate electrical break mode when motor is enabled and speed is 0
|
|
void | setBreakWhenDisabled (bool _breakWhenDisabled) |
| activate electrical break mode when motor is disabled
|
|
void | setReverse (bool _reverse) |
|
bool | set (float val) |
| set motor power
|
|
bool | setEnable (bool _enable) |
| use to enable or disable a motor, and sets up pin states
|
|
bool | getEnable () |
| get the enable state of the driver
|
|
float | getMaxRange () |
| high end of the range
|
|
float | getMinRange () |
| low end of the range
|
|
bool | enable () |
| enable motor
|
|
bool | disable () |
| disable motor
|
|
Controls an H-bridge motor driver controlled by a PCA9685 Tested on the Alfredo Systems NoU3 https://github.com/AlfredoSystems/Alfredo-NoU3.
◆ JMotorDriverPCA9685HBridge()
JMotorDriverPCA9685HBridge::JMotorDriverPCA9685HBridge |
( |
PCA9685 & |
_pca9685, |
|
|
byte |
_channelPos, |
|
|
byte |
_channelNeg, |
|
|
bool |
_reverse = false , |
|
|
bool |
_breakWhenEnabled = true , |
|
|
bool |
_breakWhenDisabled = false |
|
) |
| |
|
inline |
Controls an H-bridge motor driver controlled by a PCA9685.
- Note
- The PCA9685 must be initialized before this class is used to control a motor example PCA9685 setup: Wire1.begin(PIN_I2C_SDA_IMU, PIN_I2C_SCL_IMU, 400000); pca9685.setupSingleDevice(Wire1, 0x40); pca9685.setupOutputEnablePin(12); pca9685.enableOutputs(12); pca9685.setToFrequency(1500);
- Parameters
-
_pca9685 | reference to an instance of janelia-arduino/PCA9685 |
_channelPos | PCA channel that makes the motor go forward |
_channelNeg | PCA channel that makes the motor go backward |
_reverse | (bool, default=false) set to true if the motor is wired backwards |
_breakWhenEnabled | (bool, default=true) set to true to turn on electrical break mode when motor is enabled and speed is 0 |
_breakWhenDisabled | (bool, default=false) set to true to turn on electrical break mode when motor is disabled |
◆ getEnable()
bool JMotorDriverPCA9685HBridge::getEnable |
( |
| ) |
|
|
inlinevirtual |
get the enable state of the driver
- Return values
-
(bool) | true if enabled, false if disabled |
Reimplemented from JMotorDriver.
◆ getMaxRange()
float JMotorDriverPCA9685HBridge::getMaxRange |
( |
| ) |
|
|
inlinevirtual |
high end of the range
- Note
- usually 1.0
- Return values
-
Reimplemented from JMotorDriver.
◆ getMinRange()
float JMotorDriverPCA9685HBridge::getMinRange |
( |
| ) |
|
|
inlinevirtual |
low end of the range
- Note
- usually -1.0, if 0, that indicates a motor controller with no reverse function
- Return values
-
Reimplemented from JMotorDriver.
◆ set()
bool JMotorDriverPCA9685HBridge::set |
( |
float |
val | ) |
|
|
inlinevirtual |
set motor power
- Note
- val should be between getMinRange and getMaxRange, but constrained internally
- Parameters
-
- Return values
-
(bool) | false if at end of power range, true otherwise |
Reimplemented from JMotorDriver.
◆ setBreakWhenDisabled()
void JMotorDriverPCA9685HBridge::setBreakWhenDisabled |
( |
bool |
_breakWhenDisabled | ) |
|
|
inline |
activate electrical break mode when motor is disabled
◆ setBreakWhenEnabled()
void JMotorDriverPCA9685HBridge::setBreakWhenEnabled |
( |
bool |
_breakWhenEnabled | ) |
|
|
inline |
activate electrical break mode when motor is enabled and speed is 0
◆ setEnable()
bool JMotorDriverPCA9685HBridge::setEnable |
( |
bool |
_enable | ) |
|
|
inlinevirtual |
use to enable or disable a motor, and sets up pin states
- Note
- setEnable(true) must be called before a motor driver will activate
- Parameters
-
_enable | (bool) true=enable, false=disable |
- Return values
-
(bool) | true if state changed, false if state already set |
Reimplemented from JMotorDriver.
◆ setReverse()
void JMotorDriverPCA9685HBridge::setReverse |
( |
bool |
_reverse | ) |
|
|
inline |
◆ breakWhenDisabled
bool JMotorDriverPCA9685HBridge::breakWhenDisabled |
|
protected |
◆ breakWhenEnabled
bool JMotorDriverPCA9685HBridge::breakWhenEnabled |
|
protected |
◆ channelNeg
byte JMotorDriverPCA9685HBridge::channelNeg |
|
protected |
◆ channelPos
byte JMotorDriverPCA9685HBridge::channelPos |
|
protected |
◆ enabled
bool JMotorDriverPCA9685HBridge::enabled = false |
|
protected |
◆ lastVal
float JMotorDriverPCA9685HBridge::lastVal |
|
protected |
◆ pca9685
PCA9685& JMotorDriverPCA9685HBridge::pca9685 |
|
protected |
◆ reverse
bool JMotorDriverPCA9685HBridge::reverse |
|
protected |
The documentation for this class was generated from the following file: