MiniMoto DRV8830 Hookup Guide

This Tutorial is Retired!

This tutorial covers concepts or technologies that are no longer current. It's still here for you to read and enjoy, but may not be as useful as our newest tutorials.

Pages
Contributors: SFUptownMaker
Favorited Favorite 1

Arduino Library

In order to make the MiniMoto as easy as possible to use, we've created a simple library for Arduino. Here's the information you'll need to get it working.

Setting the I2C Address

The MiniMoto board has two jumpers for setting its I2C address. The jumpers can be in one of three states: open, 1, or 0. They ship by default in the 1-1 state, which sets an address of 0xD0 for the part.

By adding or removing solder, you can change the address. Here's a little chart explaining the settings.

A1A0Address
000xC0
0open0xC2
010xC4
open00xC6
openopen0xC8
open10xCA
100xCC
1open0xCE
110xD0

When you declare an object of MiniMoto class, the only parameter to pass is the address of that board, according to this chart.

Library Functions

The DRV8830 chip on the MiniMoto is a fairly simple chip, having only two registers, and the library is similarly simple.

language:cpp
MiniMoto(byte addr);

This is the class constructor for the MiniMoto class. The addr parameter is the value from the chart above, determined by the jumper settings on the board.

void drive(int speed);

The MiniMoto drives the motor by PWM; the magnitude can range from 6-63. Attempts to set speed lower than 6 will be ignored; speeds higher than 63 will be truncated to 63. The sign of the value determines the direction of the motion.

void stop();
void brake();

Both of these functions will halt the motor's motion; stop() allows the motor to coast to a halt, while brake() basically shorts the motor wires together, presenting a heavy load to the motor and dragging it to a halt quicker. It will also cause the motor to be harder to turn, providing a braking function on slopes or against loads attempting to turn the motor.

byte getFault();

There are several faults which can occur; when a fault occurs, the FAULTn line will be asserted low and the getFault() function can be called to determine the nature of the fault. Calling getFault() clears the fault bit and allows the driver to resume operation, although if the condition which caused the fault still exists, the driver may immediately return to fault status.

To determine the nature of the fault, several constants have been defined:

  • FAULT - if FAULT bit is not set, no fault has occurred. This is an important check, as the FAULTn pin can be asserted, and other bits in the return value can be set, without fault conditions existing.
  • ILIMIT - the ILIMIT bit will be set if the current limit set by the sense resistor has been violated for more than 275ms. This will not result in the motor driver being disabled.
  • OTS - indicates a thermal shutdown event. The output will be disabled, but operation will resume automatically when the die temperature has fallen to safe levels.
  • UVLO - undervoltage lockout due to supply voltage dipping below a safe level (~2.5V). Operation will resume when the supply voltage rises to a safe level again (~2.75V).
  • OCP - a significant overcurrent event has occurred. This is different to the ILIMIT fault because it is intrinsic to the driver; it generally indicates that the output is shorted or some similar issue. When an OCP error occurs, operation will be suspended until the fault bit is cleared.

Note that it is possible for the FAULTn line to be asserted without a fault having occurred; however, the FAULT bit will always be set if a fault has occurred.