Emakefun PS2X User manual

Copy right © 2018 Shenzhen Emakefun Technology co., Ltd.
1
PS2X&Motor Drive Board
Instruction Manual
V.1.2

Copy right © 2018 Shenzhen Emakefun Technology co., Ltd.
2
Revision
Date
Version
Description
Author
2018/11/27
V.1.0
Create
Abbott.Chen
2019/1/2
V.1.1
Rearrange the document frame
and fix the error
Ken.chen
2019/1/11
V.1.2
Optimize and supplement
documentation
Abbott.Chen

Copy right © 2018 Shenzhen Emakefun Technology co., Ltd.
3
Catalog
Overview....................................................................................................................................................5
Courseware Structure Diagram..................................................................................................................6
PS2X&Motor Driver Board Composition frame.......................................................................................6
Driver Board Introduction..........................................................................................................................7
Common problems.....................................................................................................................................7
Software Installation..................................................................................................................................8
Install IDE software...........................................................................................................................8
Install driver.......................................................................................................................................9
IDE interface introduction ...............................................................................................................14
Connect to the Arduino UNO R3 development board.............................................................................17
Run the sample code steps.......................................................................................................................17
Driver Board Power Supply.............................................................................................................17
DC Motor.........................................................................................................................................18
Motor control principle....................................................................................................................18
Stepper Motor ..................................................................................................................................22
Encode Motor...................................................................................................................................23
RGB LED light........................................................................................................................................26
RGB WS2812 Introduction..............................................................................................................26
Working principle of WS2812 RGB LED Light.............................................................................27
WS2812 RGB LED Light Driving principle ...................................................................................28
Buzzer......................................................................................................................................................29
Buzzer Introduction .........................................................................................................................29
Working principle of buzzer............................................................................................................30
Drive servo...............................................................................................................................................31
Servo Introduction ...........................................................................................................................31
Working principle of servo..............................................................................................................32
Drive Servo..............................................................................................................................................33
How to use an external power supply to drive the servo.........................................................................35
Ultrasonic obstacle avoidance module.....................................................................................................35
Working Principle of Ultrasonic module.........................................................................................35
Drive Ultrasonic Module .................................................................................................................36
Infrared Remote Control..........................................................................................................................37
Working Principle............................................................................................................................38

Copy right © 2018 Shenzhen Emakefun Technology co., Ltd.
4
PS2 Remote Control ................................................................................................................................40
PS2 Introduction ..............................................................................................................................40
Drive PS2 remote.............................................................................................................................42
NRF2401..................................................................................................................................................44
NRF24L01+ module Introduction ...................................................................................................44
Drive NRF24L01+ module..............................................................................................................44
Appendix..................................................................................................................................................46
External sensor connection method.................................................................................................46

Copy right © 2018 Shenzhen Emakefun Technology co., Ltd.
5
Overview
The PS2X&Motor Driver Board driver can drive 4 DC motors, 2 encoder motors, 2 stepper motors, 6
servos (two external power supplies), and drive current up to 2A. The driver board is specially designed for
the Arduino uno R3 motherboard. It can be directly plugged into the Arduino Uno.The motherboard
integrates a passive buzzer, 2 RGB LED lights, and 1 infrared receiver.
It also reserves for PS2 socket, Uart interface, I2C interface, ultrasonic obstacle avoidance module
socket and other sensor interfaces which is very convenient to externally connect various sensor modules.
Figure 1-1 Function Display

Copy right © 2018 Shenzhen Emakefun Technology co., Ltd.
6
Courseware Structure Diagram
ArduinoDemo --stores the most basic test demo program.
AdvancedExperiment --means a test program that uses the Emakefun_Motor Driver driver library for each
module.
Datasheet-- means the chip detailed data sheet used on the driver board.
Schematic-- means the schematic used by the driver board
Scratch -- means the image library and scratch user manual and sample program
PS2X&Motor Driver Board Composition frame
PS2X&
Motor Driver
Board
DC motor port*4
Passive buzzer*1
switch
Ultrasonic socket
Bluetooth / wifi interface
Servo socket
RGB LED*2
Battery / servo external
power supply
PS2 port
Infrared remote control sensor
NRF24L01 socket
Decoding motor port*2
Stepper motor port*2

Copy right © 2018 Shenzhen Emakefun Technology co., Ltd.
7
Driver Board Introduction
Figure 3-1 PS2X&Motor Driver Board Introduction
Common problems
Q:How to power the PS2X&Motor Driver Board?
A:It can be directly powered by the DC port of Arduino UNO. The voltage range is 6~12V and the
current is 500mA~2A. Or PH2.0 wiring port power supply, the voltage range is 6~12V, there is a power
supply jumper cap on the drive board, you need to short circuit the IN and 5V.
Q:How many motors does the PS2X&Motor Driver Board can drive?
A:The PS2X&Motor Driver Board can drive 4 DC motors ,2 stepper motors or 2 encoder motors.
Q:How does PS2X&Motor Driver Board connect power drive servo?
A:PS2X&Motor Driver Board has D5, D6 two interfaces for external power drive servo.

Copy right © 2018 Shenzhen Emakefun Technology co., Ltd.
8
The switch needs to be toggled to OFF, and the jumper cap is connected to 5V, EX. The external power
supply is connected to the PH2.0-2pin terminal, and Vin is the positive pole.
Q:I want to upload the sample program to the Arduino board, suggesting that the upload failed.
What is the reason?
A:Before uploading the sample program to the Arduino board, you need to check if the board and
the computer are properly connected, then install the driver and try again.
Q:I want to upload the sample program to the Arduino board, and then the motor does not work
after turning on the power. What is the reason?
A:Firstly, check if the green indicator on the Arduino UNO board is on. If it is not on, it means the
power supply is not normal. Check whether the battery voltage is above 6v. Then check whether the motor's
wiring port is consistent with the port set in the program. Turn it on again.
Q:How to install graphical programming library?
A:Download the relevant tutorial under this link: https://github.com/keywish/motor-drive-board
Q:Where can we download the program examples?
A:Download the relevant tutorial under this link: https://github.com/keywish/motor-drive-board
Q:My Arduino will crash when the motor is running. Is the drive broken?
A:When the motor is running, the power consumption is large. You need to ensure that the battery
has sufficient power. You can try to charge the battery before turning it on.
Software Installation
Install IDE software
Unzip the Arduino software installation package (path: MotorDriverBoard\ArduinoIDE) under the
MotorDriverBoard folder, or download it from the Arduino website, download the address :
https://www.arduino.cc/en/Main/OldSoftwareReleases#previous
Figure 4-1 Arduino IDESoftware installation package
Unzip the zip file and double-click the arduino.exe installation file to install it. Because the installation
of “arduino.exe” is very simple, it will not be explained here. It is recommended to quit the anti-virus
software during the installation process, otherwise it may affect the IDE installation. After the installation is
complete, click "arduino.exe" again to enter the IDE programming interface.

Copy right © 2018 Shenzhen Emakefun Technology co., Ltd.
9
After the IDE installation, we connect the Arduino motherboard, right click on "My Computer"→
“Properties”→“Device Manager”→View“Port(COM 和LT)”.If you see the interface below, the
driver has the installation is successful. At this time, we open the IDE and select the corresponding
development board model and port in the toolbar to use it normally.
Figure 4-2 Driver installation successful interface
Notice:
1)If you connect the controller board to your computer, the computer does not respond. Right click on "My
Computer" and select Open Device Manager to view the port (com&lpt). If there is no com or lpt, or if there
is only an unknown device, there is a problem with the controller board or USB cable.
2)Right click on "My Computer" and select Device Manager to view the ports (COM and LPT). If there is
a yellow Arduino UNO exclamation point, this means you need to install the driver yourself, the drive path:
MotorDriverBoard\ArduinoIDE.
3)If the driver is always installed but eventually fail. Please uninstall the driver and reinstall >
automatically install the driver > restart the computer.
Install driver
1、If your computer is a Windows 7 system:
1)Firstly, right click on "My Computer" and open the Device Manager to view the ports (COM and LPT).
At this point you will see a "USB Serial Port", right click on "USB Serial Port" and select the "Update

Copy right © 2018 Shenzhen Emakefun Technology co., Ltd.
10
Driver Software" option.
Figure 4-3 Update Driver

Copy right © 2018 Shenzhen Emakefun Technology co., Ltd.
11
2)Nextly, next select the "Browse my computer for driver software" option.
Figure 4-4 Driver update selection interface
3)Finally select the driver file named "FTDI USB Drivers" located in the "Drivers" folder of the Arduino
software download.

Copy right © 2018 Shenzhen Emakefun Technology co., Ltd.
12
Figure 4-5 Select drive path
Figure 4-6 install driver

Copy right © 2018 Shenzhen Emakefun Technology co., Ltd.
13
4)If you have already installed it, the interface shown in Figure 4-7 below will appear, automatically
notifying you that the drive is successful.
Figure4-7 Driver installation completed
At this time, we return to the "Device Manager" interface, the computer has successfully identified the
Arduino, as shown in Figure 4-8, then open the Arduino compiler environment, you can open the Arduino
journey.
Figure 4-8 Drive successful identification interface

Copy right © 2018 Shenzhen Emakefun Technology co., Ltd.
14
Note: In the Win10 system, after some Arduino is connected to the computer (non-genuine chips are
difficult to be recognized), the system will automatically download the corresponding driver, you don’t
need to install the driver by yourself, but in Win7 system, you need to follow the above steps. Install the
driver manually.
As shown in the figure above, we can see that the USB serial port is recognized as COM15, but different
computers may be different. You may be COM4, COM5, etc., but the Arduino Uno must be the same. If you
do not find the USB serial port, it may be that you installed it incorrectly or the system is not compatible.
IDE interface introduction
Then we introduce the IDE interface of Arduino. Firstly, enter the software directory. Then you can see the
arduino.exe file and double click to open the IDE. As shown in Figure 4-9.
Figure 4-9 Software catalog
1、The first thing that catches your eye is the interface below. The toolbar button functions are
"Compile" - "Upload" - "New Program" - "Open Program" - "Save Program" - "Serial Monitor", as
shown in Figure 4-10.

Copy right © 2018 Shenzhen Emakefun Technology co., Ltd.
15
Figure 4-10 Arduino IDE interface
2、There are 5 menus on the menu bar, but we mainly introduce File and Tools. Click File, the
interface shown in Figure 4-11, you can see the Examples and Preference options.Examples are
some of the Arduino's own programs, these are compiled and can be used normally, which is very
helpful for beginners. The Preference option is mainly the setting of parameters, such as language,
font, etc.
Figure 4-11 File menu bar options
3、Click Tools, the interface shown in Figure 4-12 pops up. Here we can see the two options of Board
and Port. In the Board option, we can see the commonly used Arduino development board models,
you only need to choose according to the development board in your hand. In the Port option, the

Copy right © 2018 Shenzhen Emakefun Technology co., Ltd.
16
USB serial port is mainly selected, as shown in Figure 4-13. If you are not sure, you can view it in
the Device Manager and select the corresponding COM port.
Figure 4-12 Tools interface
Figure 4-13 USB Serial port selection

Copy right © 2018 Shenzhen Emakefun Technology co., Ltd.
17
So far, we have basically completed all the work, the next step is to combat, open any of the programs in
Examples. First compile the program, if compiled correctly, you can directly download to the development
board, then connect the corresponding device and the wire, you can see the corresponding phenomenon.
Connect to the Arduino UNO R3 development board
The pin header on the PS2X&Motor Driver Board can be plugged directly into the Arduino UNO R3
development board. No other flying lines are required. The pins are fully compatible and easy to install.
Run the sample code steps
1) Connect the Arduino UNO R3 development board connected to the PS2X&Motor Driver Board to the
computer via a USB cable;
2) Click “Connect→Serial port→COM4(the number of this COM port is different for different computers)”;
3) Burning sample program (taking DC motor as an example)
4) In the IDE, choose “file →turn on”, Open the DC motor test sample code in the code base (sample
program file path: MotorDriverBoard\ArduinoDemo\TB6612_DC_Motor.ino);
5) Click the Upload button to burn the motor test sample program into the Arduino UNO R3 development
board connected to the PS2X&Motor Driver Board.
Driver Board Power Supply
The power supply on the driver board can be directly powered by the DC port of the Arduino UNO. The
voltage range is 6~12V and the current is 500mA~2A. Or PH2.0 wiring port power supply, the voltage
range is 6~12V, there is a power supply jumper cap on the drive board, you need to short circuit the IN and
5V.

Copy right © 2018 Shenzhen Emakefun Technology co., Ltd.
18
Figure 5-1 Power schematic
DC Motor
Motor control principle
The PS2X&Motor Driver Board uses the PCA9685 to output the PWM control motor driver chip
TB6612FNG. Now we’ll briefly introduce the two chips.
The main parameters of PCA9685 are as follows:
◆I2C interface control can control 16-channel PWM and support up to 16 servos or PWM output, 12-bit
resolution for per channel (4096 levels)
◆Built-in 25MHz crystal oscillator, can be connected to external crystal oscillator or can also not be
connected to external crystal oscillator, up to 50MHz.
◆Supporting 2.3V-5.5V voltage, maximum withstand voltage is 5.5V
With power-on reset, software reset and other functions
The device address of the PCA9685 is determined by the pins A0, A1, A2, A3, A4, and A5, and the pin
cannot be left floating. Since there are six pins that together determine the device address, there are 64
device addresses. Since the IC keeps the LED All Call address (E0h, 1110 000) and Software Reset address
(06h, 0000 0110) after power-on, there are only 62 available device addresses. Therefore, theoretically one
I2C interface can control the way 16* 62=992 PWM, the pin control device address is shown in the figure

Copy right © 2018 Shenzhen Emakefun Technology co., Ltd.
19
below:
Figure 6-1 Device address schematic
For detailed use of the chip, please refer to《MotorDriverBoard\Datasheet\PCA9685.pdf》
TB6612FNG Introduction
The PS2X&Motor Driver Board uses TB6612FNG to drive the motor. The TB6612FNG has a high-current
MOSFET-H bridge structure, dual-channel circuit output, and a continuous drive current of up to 1.2 A per
channel. The peak current is 2A/3.2 A (continuous pulse/single pulse). 4 kinds of motor control modes:
forward/reverse/brake/stop; standby state; PWM supports frequency up to 100 kHz; on-chip low-voltage
detection circuit and thermal shutdown protection circuit, main pin function of TB6612FNG: AINl/AIN2
BIN1/BIN2, PWMA/PWMB are control signal input terminals; AO1/A02, B01/B02 are 2 motor control
output terminals; STBY is normal working/standby state control pin; VM (4.5~15 V) and VCC ( 2.7 to 5.5
V) are the motor drive voltage input and the logic level input, respectively.
In the Arduino, the analog voltage cannot be output, and only the digital voltage value of 0 or 5V can be
output. We use the high-resolution counter to modulate the square wave's duty cycle to the level of a specific
analog signal to encode. The PWM signal is still digital because at any given time, the full-scale DC supply
is either 5V (ON) or 0V (OFF). The voltage or current source is applied to the analog load in a repeating
pulse sequence of ON or OFF. When the DC power is applied to the load, the power is disconnected when
the power is turned off. Any analog value can be encoded using PWM as long as the bandwidth is sufficient.
The output voltage value is calculated by the on and off times. Output voltage = (on time / pulse time) *
maximum voltage value, Figure 6-2 is the voltage corresponding to the pulse change.

Copy right © 2018 Shenzhen Emakefun Technology co., Ltd.
20
Figure 6-2 Diagram of pulse and voltage
For detailed use of the chip, please refer to《MotorDriverBoard\Datasheet\TB6612FNG.pdf》
Driving DC motor
The PS2X&Motor Driver Board has four DC motor interfaces, namely DC motor interface 1, DC motor
interface 2, DC motor interface 3 and DC motor interface 4, which can be directly connected to the drive via
the terminals. Connect 4 DC motors to DC motor interface 1, 2, 3, 4 (as shown in Figure 6-3). After
connecting the motor, connect the battery to the development board, turn on the power switch, and the
program starts running. We will see the motor will turn up, and the drive schematic of the DC motor is
shown in Figure 6-4.
Table of contents
Other Emakefun Remote Control manuals