Introduction

This is a Raspberry Pi DC motor driver board with on-board encoder interface, which can drive 2-way DC motor and DC motor with encoder. It communicates with Raspberry Pi via I2C, easy to configure and drive motors. The DC Motor Driver HAT adopts STM32 micro-processor to analyze the command sent by the upper host, and then convert into motor drive signal after calculation. Besides that, a high-performance TB6612FNG motor drive chip is integrated on the module. The single channel continuous current is 1.2A and the peak current is up to 2A. The motor driver supports 7~12V wide input voltage.

Specification

Board Overview

Front View

Back View

Num Name Description
1 + External Power Positive (7~12V)
2 - External Power Negative
3 E1+ Encoder E1 Positive
4 E1- Encoder E1 Negative
5 E1A Encoder E1 A Phase Output
6 E1B Encoder E1 B Phase Output
7 M1+ Motor M1 Positive
8 M1- Motor M1 Negative
9 M2- Motor M2 Negative
10 M2+ Motor M2 Positive
11 E2B Encoder E2 B Phase Output
12 E2A Encoder E2 A Phase Output
13 E2- Encoder E2 Negative
14 E2+ Encoder E2 Positive

Dimension Diagram

Size

Function Configuration

Tutorial (Raspberry Pi)

Requirements

warning_yellow.png NOTE: the operating voltage should be within 7~12V, and the motor's current should not be more than 2A.

Connection Diagram

Connection

Operations

Step1: Plug the DC Motor Driver HAT in a Raspberry Pi's main-board, connect driver and motor, power up.

Step2: Detect if the I2C interface is enabled. Input the command i2cdetec-y 1, if it is disabled, the following interface will appear:

I2C disabled

Step3: Enable I2C interface. (Skip this step if I2C is already enabled.) Input the command sudo raspi-config to enter the configuration interface. Shown as below:

1

2

3

When finished the configuration, input sudo reboot to restart Raspberry Pi.

Step4: Detect I2C address. Input i2cdetect -y 1 to detect the device I2C address, shown as below:

Detect I2C address

Step5: Download the DFRobot_RaspberryPi_Motor Library. Enter sudo git clone https://github.com/DFRobot/DFRobot_RaspberryPi_Motor. Input ls to check commands.

Download DFRobot_RasbperryPi_Motor Library

Example

Enter the python catalogue in DFRobot_RaspberryPi_Motor library.

cd /DFRobot_RaspberryPi_Motor/raspberry

How to drive a DC motor with encoder?

Use the variable M1,M2, ALL for id parameter to represent motor M1, motor M2, M1 and M2.

warning_yellow.png NOTE: Different motors have different reduction ratio. Please revise the reduction ratio of the motor before running the codes in the demo.

Click to check more function configuration and usage description.

Run the example DC_Motor_Demo.py. Print the duty ratio and rotating speed of the encoder motor.

 python DC_Motor_Demo.py

Serial Print

How to drive a DC motor?

Connect the DC motor to the interface of M1+, M1- or M2+, M2-. Disable the function of encoder as the above demo, set frequency, duty ratio, rotating direction.

warning_yellow.png NOTE: For motors without encoder, we cannot get its speed, but only adjust the speed through PWM.

Compatibility Test

MCU Pass Fail
Raspberyy Pi 4B
Raspberyy Pi 3B
Raspberyy Pi 3B+
Raspberyy Pi Zero W
Raspberyy Pi 2B+

FAQ

For any questions, advice or cool ideas to share, please visit the DFRobot Forum

More Documents

Schematic Diagram

DFshopping_car1.png Get DC_Motor_Driver_HAT from DFRobot Store or DFRobot Distributor.

Turn to the Top