Cdrv883 is a wrapper class for using modules based on DRV8833 H-bridge from Texas Instruments.
- First public version released.
See the drv8833Tester example provided in the examples folder.
- 1.0.1 Class file names updated.
- 1.0.0 Initial version.
Default constructor. The object is NOT initialized: the init
member function must be called. Decay mode is set to SLOW.
Specialized constructor. Decay mode is set to SLOW.
input:
in1Pin
: DRV8833 AIN1/BIN1in2Pin
: DRV8833 AIN2/BIN2channel
: ESP32 PWM channel (0..15) - ESP32 ledc functionsswapDirection
: swap motor rotation direction
There are 16 independent channels for PWM modulation inside the ESP32 SOC. Every motor need to have its own channel in order to work independently each other.
Swapping the motor rotation direction is useful (for example):
- wrong cabling
- using two motors to drive a two wheels vehicle (left wheel, right wheel).
Initialize the object. Decay mode is set to SLOW.
input:
in1Pin
: DRV8833 AIN1/BIN1in2Pin
: DRV8833 AIN2/BIN2channel
: ESP32 PWM channel (0..15) - ESP32 ledc functionsswapDirection
: swap motor rotation direction
Return true
if no error occurs.
There are 16 independent channels for PWM modulation inside the ESP32 SOC. Every motor need to have its own channel in order to work independently each other.
Swapping the motor rotation direction is useful (for example):
- wrong cabling
- using two motors to drive a two wheels vehicle (left wheel, right wheel).
Set motor rotation direction/speed.
input:
power
: rotation power. -100..100
Return true
if no error occurs.
The power
parameter set the rotation speed and the direction. Negative values means reverse rotation direction. Value span to -100 (full speed reverse direction) to 100 (full speed forward direction).
Zero stop the motor rotation.
Stop the motor, using fast decay mode.
Return true
if no error occurs.
Stop the motor, using slow decay mode.
Return true
if no error occurs.
Set the decay mode. Default decay mode is set to SLOW.
input:
decayMode
: new decay mode. Values aredrv8833DecaySlow
good torque, but high power consumptiondrv8833DecayFast
poor torque, but low power consumption
Set the frequency used for the PWM modulation(for ESP32 ledc functions). Default value is 5000Hz. Allowed values are 1Hz..50000Hz.
input:
frequency
: new frequency in Hertz. 1..50000Hz
Swap the motor rotation direction. Useful for wrong cabling / driving two opposite motors (left wheel and right wheel of a vehicle)
input:
swapDirection
: swap/unswap the motor rotation directiontrue
: swap rotation directionfalse
: default rotation direction