※本產品原廠代理從國外進口,有些交期較長,下訂前請詢問!
This compact expansion board plugs directly into the GPIO header on a Raspberry Pi B+ and provides an easy and low-cost solution for driving a pair of small brushed DC motors. Its integrated DRV8835 dual motor driver allows it to operate from 1.5 V to 11 V, making it a great control option for low-voltage motors. The board can deliver a continuous 1.2 A (1.5 A peak) per motor, or a continuous 2.4 A (3 A peak) to a single motor when configured with both channels connected in parallel.
Overview
This motor driver kit and its corresponding Python library make it easy to control a pair of bidirectional, brushed DC motors with a Raspberry Pi Model B+. The expansion board features Texas Instruments’ DRV8835 dual H-bridge motor driver IC, which allows it to operate from 1.5 V to 11 V and makes it particularly well suited for driving small, low-voltage motors. The board can deliver a continuous 1.2 A per channel and tolerate peak currents up to 1.5 A per channel for a few seconds, and the channels can be optionally configured to run in parallel to deliver twice the current to a single motor. The board ships fully populated with its SMD components, including the DRV8835 driver and a FET for reverse battery protection; header pins for interfacing with a Raspberry Pi and terminal blocks for connecting motors and power are included but are not soldered in (see the Assembly with included hardware section below).
The board uses GPIO pins 5, 6, 12, and 13 to control the motor driver, making use of the Raspberry Pi’s hardware PWM outputs, although the pin mappings can be customized if the defaults are not convenient. Note that it is designed specifically for the Model B+ version of the Raspberry Pi; it is not practical to use this expansion board with a Raspberry Pi Model A or Model B due to differences in their pinout and form factor.
We also have a similar DRV8835 shield for Arduinos and Arduino-compatible boards and a smaller DRV8835 carrier for those using a different controller or with tighter space constraints.
Assembly with included hardware
Before the motor driver board can be plugged into your Raspberry Pi, female headers must be soldered into the appropriate holes. The kit ships with two 17-pin 0.1″ female headers that should be mounted to the bottom of the board (the side with surface-mount components). Once the kit is assembled, it should be plugged into the leftmost position on the Model B+’s GPIO header, leaving six pins exposed on the right, as shown in the picture below.
Using the motor driver
In the board’s default state, the motor driver and Raspberry Pi are powered separately, though they share a common ground and the DRV8835 receives its logic supply voltage (VCC) from one of the Raspberry Pi’s 3V3 power pins. When used this way, the Raspberry Pi must be powered via its USB Micro-B receptacle, and the motor driver board must be supplied with 1.5 V to 11 V through its large VIN and GND pads. However, the motor driver board provides a set of three through-holes where you can conveniently connect an appropriate voltage regulator, allowing the motor supply to also power the Raspberry Pi (see the Powering the Raspberry Pi from the motor driver board section below).
Configuring the board for IN/IN mode
The operating mode of the driver is controlled by the MODE pin, which the board pulls high to VCC through a 20 kΩ resistor to select PHASE/ENABLE mode by default. The pin labeled “MODE” can be driven low (or connected directly to ground) to switch the control interface to IN/IN, which allows for slightly more advanced control options as described in the table below:
Drive/coast or drive/brake operation with MODE=0 (IN/IN) |
xIN1 | xIN2 | MxA | MxB | operating mode |
0 | 0 | OPEN | OPEN | coast (outputs off) |
0 | PWM | L | PWM | reverse/coast at speed PWM % |
PWM | 0 | PWM | L | forward/coast at speed PWM % |
PWM | 1 | L | PWM | reverse/brake at speed 100% − PWM % |
1 | PWM | PWM | L | forward/brake at speed 100% − PWM % |
1 | 1 | L | L | brake low (outputs shorted to ground) |
IN/IN mode is generally only useful if you only care about on/off control of the motors or if you can supply PWM signals to all four inputs. Since the Raspberry Pi Model B+ only has two hardware PWM outputs, additional work (such as setting up software PWM) is necessary to achieve speed control with IN/IN mode.
Configuring the board for single-channel mode (parallel outputs)
In order to use the two motor channels in parallel to control a single motor, it is important to ensure that both channels will always receive the same control signals, so the reconfiguration process begins with a modification to the control inputs. First, locate the 2×4 grouping of 0.1″ through-holes along the right side of the board. The traces on the underside of the PCB between each pair of holes effectively link the Raspberry Pi’s GPIO pins to the DRV8835 control pins. If you want to remap one of these control pins, you can cut the desired trace with a knife and then run a wire from the inner hole to a new GPIO pin. The remapping for single-channel mode requires you cut one PWM (12 or 13) and one DIR (5 or 6) trace. If you then solder a row of header pins along the interior row of holes, you can safely connect both PWM lines together and both DIR lines together using shorting blocks. In this configuration, the two uncut Raspberry Pi control lines determine the behavior of both motor channels.
The last step is to connect the output channels together. An easy way to do this is to solder wires to the two small holes labeled “M2A” and “M2B” above the motor outputs. You can then connect the M2A wire to the large M1A output pad and the M2B wire to the large M1B output pad, which in turn means you can get up to 3 A from the connection points for M2 (you can have your motor connected just to the M2A and M2B terminal blocks rather than trying to find a way to connect it to all four motor outputs).
Powering the Raspberry Pi from the motor driver board
On the left side of the expansion board is a set of three pins surrounded by a box and labeled “5V”, “GND”, and “VOUT”. The “5V” pin is connected to the Raspberry Pi’s 5V power rail, while the VOUT pin provides access to the driver board’s motor supply voltage after reverse-voltage protection. If a suitable voltage regulator is connected to these three pins, it can generate 5 V to power the Raspberry Pi from the board’s motor supply voltage. We suggest using our S7V7F5 switching step-up/step-down regulator, which has a 2.7 V to 11.8 V input voltage range (similar to that of the DRV8835) and can supply up to 1 A of current to the Raspberry Pi.
This schematic is also available as a downloadable pdf (215k pdf).