Kenji Arai / DRV8830

Dependents:   NucleoF401_motor_test_simple Frequency_Counter_w_GPS_1PPS Nucleo_ACM1602_I2C_DC_Angle Frequency_Cntr_1PPS_F746ZG

Embed: (wiki syntax)

« Back to documentation index

DRV8830 Class Reference

DRV8830 Class Reference

DRV8830 class. More...

#include <DRV8830.h>

Public Member Functions

 DRV8830 (PinName p_sda, PinName p_scl, uint8_t addr)
 Configure data pin.
 DRV8830 (I2C &p_i2c, uint8_t addr)
 Configure data pin (with other devices on I2C line)
void speed (float speed)
 Set motor speed.
void set_voltage (float volt)
 Set voltage.
uint8_t status ()
 Read status.
void reset ()
 Reset DRV8830 chip.

Detailed Description

DRV8830 class.

This is a driver code for the DRV8830 H-Bridge Voltage-Controlled Motor Driver. http://www.ti.com/product/drv8830

 #include "mbed.h"
 #include "DRV8830.h"

 // I2C Communication
 DRV8830 motor(PinName p_sda, PinName p_scl, addr);
 // If you connected I2C line not only this device but also other devices,
 //     you need to declare following method.
 I2C     i2c(PinName p_sda, PinName p_scl);
 DRV8830 motor(I2C& p_i2c, addr);
 
 int main() {
 uint8_t status;
    
     //  Speed control
     motor.speed(0.5);    // CW
     motor.speed(-0.5);   // CCW
     motor.speed(0.0);    // Stop(FREE)
     //  Check error and reset
     status = motor.status();
     if (status & DRV8830_F_FAULT){
        motor.reset();
     } 
 }

Definition at line 69 of file DRV8830.h.


Constructor & Destructor Documentation

DRV8830 ( PinName  p_sda,
PinName  p_scl,
uint8_t  addr 
)

Configure data pin.

Parameters:
dataSDA and SCL pins
DRV8830address (H/W configuration of A1,A0)

Definition at line 67 of file DRV8830.cpp.

DRV8830 ( I2C &  p_i2c,
uint8_t  addr 
)

Configure data pin (with other devices on I2C line)

Parameters:
I2Cprevious definition
DRV8830address (H/W configuration of A1,A0)

Definition at line 73 of file DRV8830.cpp.


Member Function Documentation

void reset (  )

Reset DRV8830 chip.

Parameters:
none
Returns:
none

Definition at line 147 of file DRV8830.cpp.

void set_voltage ( float  volt )

Set voltage.

Parameters:
voltage(0 to 5V)
Returns:
none

Definition at line 105 of file DRV8830.cpp.

void speed ( float  speed )

Set motor speed.

Parameters:
speed(Range 0 to 1.0 or 0 to -1.0)
Returns:
none

Definition at line 79 of file DRV8830.cpp.

uint8_t status (  )

Read status.

Parameters:
none
Returns:
FAULT register content

Definition at line 138 of file DRV8830.cpp.