DC Motor Driver HAT for Raspberry Pi Wiki - DFRobot

DFR0592 DC Motor Driver HAT(V1.0) for Raspberry Pi

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

DFR0592 DC Motor Driver HAT(V1.0) for Raspberry Pi Board Overview DFR0592 DC Motor Driver HAT(V1.0) for Raspberry Pi Board Overview
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

DFR0592 DC Motor Driver HAT(V1.0) for Raspberry Pi Dimension Diagram

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

DFR0592 DC Motor Driver HAT(V1.0) for Raspberry Pi Connection Diagram

Raspberry pi 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:

DFR0592 DC Motor Driver HAT(V1.0) for Raspberry Pi Operations

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:

DFR0592 DC Motor Driver HAT(V1.0) for Raspberry Pi Operations DFR0592 DC Motor Driver HAT(V1.0) for Raspberry Pi Operations DFR0592 DC Motor Driver HAT(V1.0) for Raspberry Pi Operations

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:

DFR0592 DC Motor Driver HAT(V1.0) for Raspberry Pi Operations

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

DFR0592 DC Motor Driver HAT(V1.0) for Raspberry Pi Operations

rock 4se Operations

install libmraa

step1: Plug the DC Motor Driver HAT in a rock 4se main-board, connect driver and motor, power up.

step2: enable rock 4se i2c

Firstly, modify the /boot/hw_intfc.conf file as following and then reboot to enable i2c7.

# Hardware Interface Config 
   # For more details, check https://wiki.radxa.com/Rockpi4/hardware/devtree_overlays. 
   # Set "on" to enable the optional hardware interfaces while set "off" to disable
   intfc:pwm0=off
   intfc:pwm1=off
   intfc:uart2=off
   intfc:uart4=off
   intfc:spi1=off
   intfc:spi2=off
   intfc:i2c2=off
   intfc:i2c6=off
   intfc:i2c7=on

step3: install smbus

pip install smbus

Note: It is advisable to utilize Python 3 when executing Python files on Rock Pi. For the operating system, Ubuntu is recommended.

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
DFR0592 DC Motor Driver HAT(V1.0) for Raspberry Pi How to drive a DC motor with encoder?

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