![]() |
ME507 Airheads Project v1.1.0
Flight Stabilization for Glider
|
Class for a motor driver using the DRV8871 chip. Primarily responsible for setting the appropriate PWM signal for an H-bridge motor driver chip. More...
#include <DRV8871.h>
Public Member Functions | |
DRV8871 (uint8_t pin_A, uint8_t pin_B, uint8_t channel_A, uint8_t channel_B) | |
Constructor for the DRV8871 class. More... | |
void | set_duty (int16_t) |
The method to set the appropriate duty cycle. More... | |
Public Attributes | |
int16_t | duty |
The duty cycle to operate the motor. | |
Protected Attributes | |
uint8_t | PIN_A |
PIN_A is the GPIO pin to output a PWM wave for a positive duty cycle. | |
uint8_t | PIN_B |
PIN_B is the GPIO pin to output a PWM wave for a negative duty cycle. | |
uint8_t | CHANNEL_A |
The timing channel for PIN_A. | |
uint8_t | CHANNEL_B |
The timing channel for PIN_B. | |
const uint16_t | frequency = 20000 |
The frequency of the PWM wave. | |
const uint8_t | resolution = 8 |
The resolution of the PWM wave [bits]. | |
const uint8_t | max_duty = uint8_t (pow(2, resolution) - 1) |
The highest value describing a 100% duty cycle as a function of the resolution. | |
Class for a motor driver using the DRV8871 chip. Primarily responsible for setting the appropriate PWM signal for an H-bridge motor driver chip.
DRV8871::DRV8871 | ( | uint8_t | pin_A, |
uint8_t | pin_B, | ||
uint8_t | channel_A, | ||
uint8_t | channel_B | ||
) |
Constructor for the DRV8871 class.
Constructor for the DRV8871 motor driver class.
pin_A | The GPIO pin from the ESP32 (non-zero PWM for a positive duty cycle) |
pin_B | The GPIO pin from the ESP32 (non-zero PWM for a negative duty cycle) |
channel_A | The timing channel for pin_A |
channel_B | The timing channel for pin_B |
void DRV8871::set_duty | ( | int16_t | duty_cycle | ) |
The method to set the appropriate duty cycle.
Outputs the desired PWM signal to the appropriate output pin given a duty cycle.
duty_cycle | The duty cycle to run the motors |