ME507 Airheads Project v1.1.0
Flight Stabilization for Glider
Loading...
Searching...
No Matches
DRV8871 Class Reference

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.
 

Detailed Description

Class for a motor driver using the DRV8871 chip. Primarily responsible for setting the appropriate PWM signal for an H-bridge motor driver chip.

Constructor & Destructor Documentation

◆ DRV8871()

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.

Parameters
pin_AThe GPIO pin from the ESP32 (non-zero PWM for a positive duty cycle)
pin_BThe GPIO pin from the ESP32 (non-zero PWM for a negative duty cycle)
channel_AThe timing channel for pin_A
channel_BThe timing channel for pin_B

Member Function Documentation

◆ set_duty()

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.

Parameters
duty_cycleThe duty cycle to run the motors

The documentation for this class was generated from the following files: