Skip to content

About

C/C++ firmware library for the **Pan Robotics DRV8234 DC Motor Driver Expander Breakout Module** based on the Texas Instruments **DRV8234 / DRV8235** 2-A Brushed DC Motor Driver IC with I2C Interface, Sensorless Ripple Counting, and Stall Detection.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DRV8234 DC Motor Driver Expander Firmware & Driver Library

Professional C/C++ firmware library for the Pan Robotics DRV8234 DC Motor Driver Expander Breakout Module based on the Texas Instruments DRV8234 / DRV8235 2-A Brushed DC Motor Driver IC with I2C Interface, Sensorless Ripple Counting, and Stall Detection.


Key Hardware & Driver Features

  • High Voltage & Current: Up to 38V VM motor supply and 2A peak drive current.
  • 7-Bit I2C Interface: Configurable via 3-state address pins A1 and A0 (Default: 0x38 with onboard 2.2k pull-ups). Up to 9 devices on a single I2C bus.
  • Dual Bridge Control Modes:
    • Hardware Mode (I2C_BC = 0): Standard MCU PWM / GPIO control via IN1 and IN2 pins.
    • Pure I2C Mode (I2C_BC = 1): Zero MCU PWM pins required; forward, reverse, braking, and duty cycle (0–100%) commanded directly over the 2-wire I2C bus.
  • Sensorless Commutation Ripple Counting:
    • Integrated 16-bit hardware ripple accumulator (RC_CNT).
    • Target ripple count threshold and automatic Hi-Z brake on target reached.
    • Real-time estimated ripple speed feedback in rad/s.
  • Hardware Stall Detection:
    • Programmable inrush time blanking (tINRUSH, 5 ms to 6.7 s).
    • Latch Hi-Z or continue driving response modes.
    • Open-drain nFAULT pin notification.
  • Real-Time Telemetry:
    • Live motor terminal voltage monitoring ($0\text{ to }38\text{ V}$).
    • Live motor current monitoring ($0\text{ to }4\text{ A}$ across selectable gain ranges).
  • Protection Circuits:
    • Overcurrent Protection (OCP) with configurable auto-retry / latch-off.
    • Thermal Shutdown (TSD) with auto-retry.
    • Overvoltage Protection (OVP) active low-side braking during regenerative deceleration.

Connector Pinout (Expander Board)

Connector Pin(s) Net Name Description
J1 1, 2 GND Power Ground
J1 3, 4 VM Motor Power Supply ($4.5\text{V} - 38\text{V}$)
J2 1, 2 NSLEEP Active-Low Sleep Control (High = Run, Low = Sleep)
J2 3, 4 IN1 / EN PWM Speed Input / Enable Pin
J2 5, 6 IN2 / PH Direction Input / Phase Pin
J3 1, 2 IPROPI Analog Current Sense Output (1.2k onboard shunt to GND)
J3 3, 4 RC_OUT Open-Drain Commutation Ripple Pulse Output
J3 5, 6 NFAULT Open-Drain Fault Interrupt Output (Active-Low)
J4 1, 2 A1 I2C Address Bit 1 (Pulled up to VCC_MCU via 2.2k)
J4 3, 4 A0 I2C Address Bit 0 (Pulled up to VCC_MCU via 2.2k)
J4 5, 6 SDA I2C Serial Data (Pulled up to VCC_MCU via 2.2k)
J4 7, 8 SCL I2C Serial Clock (Pulled up to VCC_MCU via 2.2k)
J5 1, 2 OUT1 Motor Terminal 1
J5 3, 4 OUT2 Motor Terminal 2
J6 1, 2 VCC_MCU Logic Power Reference ($1.8\text{V} - 5.0\text{V}$)
J6 3, 4 GND Logic Ground
J6 5, 6 +3V3 / VREF Analog Reference Voltage Input for Current Regulation

Directory Structure

Firmware/
├── include/
│   └── drv8234.h          # ISO C99 low-level register map & API
├── src/
│   ├── drv8234.c          # C Driver implementation
│   ├── DRV8234.h          # Arduino / C++ Class wrapper header
│   └── DRV8234.cpp        # Arduino / C++ Class wrapper implementation
├── examples/
│   ├── Basic_Motor_Control/
│   │   └── Basic_Motor_Control.ino
│   ├── I2C_Software_Bridge_Control/
│   │   └── I2C_Software_Bridge_Control.ino
│   ├── Ripple_Counting_Position/
│   │   └── Ripple_Counting_Position.ino
│   └── Stall_Detection_Diagnostics/
│       └── Stall_Detection_Diagnostics.ino
├── test/
│   └── test_drv8234.c     # Host validation & unit test suite
├── library.properties     # Arduino IDE package metadata
├── keywords.txt           # Arduino IDE syntax highlighting
└── README.md              # Documentation

Quick Start (Arduino)

#include <Wire.h>
#include <DRV8234.h>

// Instantiate motor object on default I2C address (0x38)
DRV8234 motor(DRV8234_I2C_ADDR_DEFAULT);

void setup() {
    Serial.begin(115200);
    Wire.begin();

    if (!motor.begin(Wire)) {
        Serial.println("DRV8234 init failed!");
        while (1);
    }

    // Drive forward at 75% duty cycle
    motor.forward(75.0);
}

void loop() {
    drv8234_telemetry_t telem;
    if (motor.getTelemetry(telem)) {
        Serial.print("Voltage: "); Serial.print(telem.motor_voltage_v); Serial.print(" V | ");
        Serial.print("Current: "); Serial.print(telem.motor_current_a * 1000.0); Serial.println(" mA");
    }
    delay(250);
}

Custom C HAL Integration (STM32, ESP-IDF, Raspberry Pi Pico)

For pure C environments, populate drv8234_hal_t with your platform's I2C and delay functions:

#include "drv8234.h"

int my_i2c_write(uint8_t dev_addr, uint8_t reg_addr, const uint8_t *data, size_t len) {
    // Platform-specific I2C write (e.g. HAL_I2C_Mem_Write)
    return 0;
}

int my_i2c_read(uint8_t dev_addr, uint8_t reg_addr, uint8_t *data, size_t len) {
    // Platform-specific I2C read (e.g. HAL_I2C_Mem_Read)
    return 0;
}

void my_delay_ms(uint32_t ms) {
    // Platform delay
}

drv8234_handle_t motor;
drv8234_hal_t hal = {
    .i2c_write = my_i2c_write,
    .i2c_read  = my_i2c_read,
    .delay_ms  = my_delay_ms
};

void motor_init(void) {
    drv8234_init(&motor, &hal, NULL);
    drv8234_set_duty_cycle(&motor, 60.0f);
    drv8234_set_motor_state(&motor, DRV8234_MOTOR_FORWARD);
}

About

C/C++ firmware library for the **Pan Robotics DRV8234 DC Motor Driver Expander Breakout Module** based on the Texas Instruments **DRV8234 / DRV8235** 2-A Brushed DC Motor Driver IC with I2C Interface, Sensorless Ripple Counting, and Stall Detection.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages