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.
- Main Controller: STM32
- Operating Voltage: 7~12V
- Logical Voltage: 5V
- Motor Driver Chip: TB6612FNG
- Communication Interface: I2C
- Default IIC Address: 0 x10
- Continuous Drive Current: 2A
- Working Mode：2-way DC Motor/ 2-way DC Motor with Encoder
- 2 Indicators
- Power Indicator
- Communication Status Indicator
- Dimension: 65×30mm/2.56×1.18”
|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|
- Control Mode: I2C command
- Driving Signal: PWM 100Hz~12750Hz
- Encoder Motor Function(Only DC Motor with Encoder)
- Disable/enable Encoder
- Reduction Ratio Configuration
- Get Revolving Speed of the Encoder Motor
- Basic Function
- Set Driving Signal Frequency
- Set Duty Ratio
- Adjust Speed
- PWM Speed Adjustment (Keep the frequency, change the duty ratio. The larger the duty ratio, the larger the rotating speed)
- Adjust the Driving Signal Frequency
Tutorial (Raspberry Pi)
NOTE: the operating voltage should be within 7~12V, and the motor's current should not be more than 2A.
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:
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:
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:
Step5: Download the DFRobot_RaspberryPi_Motor Library. Enter sudo git clone https://github.com/DFRobot/DFRobot_RaspberryPi_Motor. Input ls to check commands.
Enter the python catalogue in DFRobot_RaspberryPi_Motor library.
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.
Step1. Enable the Encoder:
set_encoder_enable(self, id) eg： board = Board(1,0x10) set_encoder_enable（[board.M1]）#Enable encoder motor M1 set_encoder_enable（[board.M2]）#Enable encoder motor M2 set_encoder_enable（[board.M1,board.M2]）#Enable encoder Motor M1 and M2 set_encoder_enable（board.ALL）#Enable encoder motor M1 and M2
Step2. Set the motor reduction ratio(43:1 in demo). Related with the reduction of the motor.
set_encoder_reduction_ratio(self, id, reduction_ratio)
Step3. Set the frequency of PWM signal (1000Hz in demo)
Step4. Set the rotating direction and speed of motor M1, M2, M1 and M2. (Duty ratio: 0~100)
motor_movement(self, id, orientation, speed)
Step5. Get the speed of the encoder motor
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.
- Program Function: Motor driver generates a signal with 1KHz frequency and a changing duty ratio within 5%~95% to make the encoder motor M1 to rotate clockwise with speed first increasing then decreasing; M2 rotate anti-clockwise with speed first increasing then decreasing, and stop. At the same time, print the rotating speed on the serial port. The whole program is repeatedly executed.
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.
NOTE: For motors without encoder, we cannot get its speed, but only adjust the speed through PWM.
|Raspberyy Pi 4B||√|
|Raspberyy Pi 3B||√|
|Raspberyy Pi 3B+||√|
|Raspberyy Pi Zero W||√|
|Raspberyy Pi 2B+||√|
For any questions, advice or cool ideas to share, please visit the DFRobot Forum
Get DC_Motor_Driver_HAT from DFRobot Store or DFRobot Distributor.
Turn to the Top