RPi Motor Driver Board

From Waveshare Wiki
Jump to: navigation, search
RPi Motor Driver Board
RPi-Motor-Driver-Board-1.jpg

Raspberry Pi Expansion Board, DC Motor / Stepper Motor Driver
{{{name2}}}

{{{name3}}}

{{{name4}}}

{{{name5}}}

Introduction

Raspberry Pi Expansion Board, DC Motor / Stepper Motor Driver

More

Interface definitions

Interface wiringPi BCM
M1 P28 20
M2 P29 21
PWMA P25 26
M3 P22 6
M4 P23 13
PWMB P26 12

M1 and M2 are connected to the right motor, while M3 and M4 are connected to the left motor. PWMA and PWMB are output enable pins, active high enable. When they are driven to high level, the PWM pulse will be outputted from M1, M2, M3 and M4, so as to control the speed of the robot.

Control work

M1 M2 M3 M4 Descriptions
1 0 1 0 When the motors rotate forwards, the robot goes straight
0 1 0 1 When the motors rotate backwards, the robot draws back
0 0 1 0 When the right motor stops and left motor rotates forwards, the robot turns right
1 0 0 0 When the left motor stops and right motor rotates forwards, the robot turns left
0 0 0 0 When the motors stop, the robot stops

Examples

PS: If you are using the system of the Bullseye branch, you need to change "apt-get" to "apt". The system of the Bullseye branch only supports Python3.

There are two examples for this module, one is for infrared remote control, and the other is for website remote control with real-time monitor via a Raspberry Pi camera. (Notes: The chassis and the camera are not provided with the module, and have to be purchased separately.)

The examples demonstrated in the section below are available from here. To follow along with the examples, you just need to extract the relative file's contents into a folder under the directory of /home/pi in the Raspbian system. (Of course, you should copy them into the Raspberry Pi via your U disk first.)

Infrared remote control

This test demonstrates how to remote control the robot with an infrared remote controller. The pulse signal from the infrared remote controller complies with the NEC standard. The infrared remote receiver outputs the pulse to Pin 18 of the BCM after the relative signal is received. Then, the Raspberry Pi reads the pulse from Pin 18 and decodes it, to control the corresponding motor. For more detailed information, please refer to the source code of the example.

Infrared NEC protocol coding description

RPi-Motor-Driver-Board-Manual-5.png

Data format: Address, ~(Address), Command, ~(Command)

~(Address): bit-wise complement of Address. ~(Command): bit-wise complement of Command

Both address and command are in a format of 8 bits, so a complete signal is 32 bits.

This example is based on the Python library, which has been in the latest Raspbian system. However, if there is any error occurs when running the example, you should install the Python library manually. In case the example is unable to be performed after installing the library, you can try to apply the command chmod +x filename to grant the program the executable permission.

Enter the Linux terminal, and input the following command:

sudo apt-get install p7zip
wget  https://files.waveshare.com/upload/9/96/RPi-Motor-Driver-Board-Demo-Code.tar.gz
tar xzvf RPi-Motor-Driver-Board-Demo-Code.tar.gz
sudo chmod 777 -R RPi-Motor-Driver-Board-Demo-Code
cd ~/RPi-Motor-Driver-Board-Demo-Code/python
sudo python motor.py

Expected result: Pressing the keyboard of the infrared remote controller can control the robot. The key 2 is for go straight, 8 for drawback, 4 for turn left, 6 for turn right, and 5 for stop. The keys – and + are speed control keys. (Notes: Since the keyboard coding varies from different infrared remote controllers, you may need to modify the program as required.)


Resources

Support



Technical Support

If you need technical support or have any feedback/review, please click the Submit Now button to submit a ticket, Our support team will check and reply to you within 1 to 2 working days. Please be patient as we make every effort to help you to resolve the issue.
Working Time: 9 AM - 6 AM GMT+8 (Monday to Friday)