(SKU:RB-01C073)RasPiDrive

From ALSRobot-Wki
Jump to: navigation, search


Qdb12.png

Contents

Product overview

Raspberry Pi including a lot of processing power, which makes it a perfect robot brain, Raspberry Pi, there are a lot of hardware peripherals, but motor controller is not one of them. Latest Raspberry Pi raspberries pie dc motor driver board, developed by robotbase team specifically for the Raspberry pie lovers tailored, solved the problem of the Raspberry pie motor control, extended into a robot controller board. This dc motor driven plate appearance is exquisite, the plug is convenient, stable performance; Perfect combination with Raspberry pie controller, install it as long as the simple send raspberries driver board GPIO mouth Raspberry Pi splice together, it provides two motor control interface, the two state LED display, a Python library can easily control the raspberries pie driven plate. Raspberry Pi and Raspberry pie combined motor driver board, making it easier and cheaper to build a robot, easy to use robots to learn to use the Linux operating system and the Python code, with Raspberry pie controller to make your own cool robot, will quickly build your robot kingdom!

specification

1.Motor control: two-way double motor control
2.input voltage:DC 7 - 12V
3.Output: double open collector output
4.state of light:2×LED green
5.Extension interface: 5 v I2C bus interface and serial interface, 3 v
6.The use of programming: simple Python library modules
7.Connection: use GPIO interface directly with raspberry pie connection
8.overall dimensions:51×51 mm

Pin definition

Method of use

Application of routine

With Raspberry Pi the Python language and hardware to complete a robot

hardware structures

AS in the production, the choice of a 4 wd aluminum alloy car platform, on the basis of the small car platform, in the above added 7 inch hd LCD, wireless keyboard, bluetooth module and motor drive and other accessories, AS shown in figure 1 is listed materials used in the robot. The raspberries pie car system to build in two steps, first is the computer system had blackberry pie, although is a pocket computer, but "the sparrow is small, all-sided", to remove raspberry pie motherboard, still need to prepare a set of standard general USB keyboard mouse, a display (described in this article is a 7 inch monitor for vehicle monitoring equipment, through the RCA interface connected), a battery is used to power the entire system, the last and the most critical need to prepare with Debian system of SD card (for SD card required to read and write in more than 4 MB/S best, larger than 2 gb capacity, capacity, of course, the faster the more better). After complete computer system set up, the next is to complete the construction of the robot system, in principle, the main use of raspberry sent the two exclusive set of pins GPIO function control external raspberries pie dedicated drive (Raspi driver) to realize the motor can make, and reversing control, as well as the use of UART function with bluetooth digital module implements data communication, so you can through the phone the bluetooth remote control to control the car, as shown in figure 2 is a whole hardware structures after JingTu, in figure 3 shows the raspberries pie hardware a chart of the robot.

Ppp1.png
Ppp9.png
Ppp22.png
Ppp3.png

Python library configuration

Before starting to write the car control program need to raspberries pie computer related Python library files for installation Settings, first is GPIO, open LX terminal (LXTerminal), update apt - get software installation package list (note must be in the network connection under normal circumstances), and then perform the install command to install the raspberry - GPIO - Python packages, specific instructions are as follows:

  1. pi@raspberrypi ~ $ sudo apt-get update
  2. pi@raspberrypi ~ $ sudo apt-get install python-rpi.gpio

In Python GPIO library after installation is complete, the next is to install Python library of UART, similar to the above steps before, to update the apt - get software installation package list, after the installation of Python module, serial communication, specific instructions are as follows:

  1. pi@raspberrypi ~ $ sudo apt-get update
  2. pi@raspberrypi ~ $ sudo apt-get install python-serial

Through the above two steps, has been installed Python with raspberry pie external hardware GPIO and UART library files, in the next car control program can direct the calling code, before starting to write control program, need to change the default parameters of the serial port, due to the system default serial port function is used to output the kernel log, related parameters of a serial port equipment is different with the outside world, so I need to change the startup configuration file in LXTerminal by typing "sudo nano/boot/cmdline. TXT" enters the/boot/cmdline. TXT, using the vi editor open cmdline. TXT file, will dwc_otg. The console = ttyAMA0 lpm_enable = 0, 115200 kgdboc = ttyAMA0, 115200 console = devices tty1 root = / dev/mmcblk0p2 rootfstype = corruption elevator = deadline rootwait remove the console = ttyAMA0, 115200 kgdboc = ttyAMA0, 115200 out of the vi editor, pay attention to save the file; Need to edit the system initialization files, at the same time, in LXTerminal type "sudo nano/etc/inittab", and then find the segments of the following contents:

  1. #Spawn a getty on Raspberry Pi serial line
  2. T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100

Changed as follows, commented on "ttyAMA0" port parameters, exit the vi editor, also need to pay attention to to save the file

  1. #Spawn a getty on Raspberry Pi serial line
  2. #T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100

Restart the raspberries pie, this configuration will take effect, completed the steps above, to get into the next chapter, robot debugging process.

Python GPIO

Commissioning procedures

Use language to let the computer on the computer IO a beating, open system desktop IDLE3 editor, in 4 steps:

  1. Import the GPIO library, in the edit line type in "import RPi. GPIO as GPIO", press "enter" key to perform;
  2. Set the GPIO pin use label mode, if choose the BOARD label, type in the editor "GPIO. Setmode (GPIO. BOARD)" if using the chip itself label pattern, just type in "GPIO. Setmode (GPIO. BCM)";
  3. Set the corresponding GPIO mode, if using the output function "GPIO. Setup (pin_number, GPIO. OUT)", using input function as long as GPIO. OUT amended as GPIO. IN;
  4. In the output mode, make the corresponding pin level employ high or low, as long as the input mode to read the corresponding pin level.

Debug the sample

RasPi Driver out lit LED1 and LED2 on operation

  • import RPi.GPIO as GPIO
  • #### gpio init
  • GPIO.setmode(GPIO.BCM)
  • GPIO.setup(7,GPIO.OUT) #LED2
  • GPIO.setup(8,GPIO.OUT) #LED1
  • GPIO.output(7,GPIO.LOW) #LED2 ON
  • GPIO.output(8,GPIO.HIGH)#LED1 OFF
Ppp4.png

Python UART

For the realization of the function of UART raspberries pie is the use of the methods and steps to the GPIO above similar, is divided into four steps:

  • Step1Import the serial interface library,type“import serial”;
  • Step2 to initialize the serial port, in this setting on the outside of the bluetooth matching parameters,BUAD=9600,timeout = 0.5,corresponding type“ser = serial.Serial('/dev/ttyAMA0', 9600, timeout = 0.5)”;
  • Step3打开使能串口,“if ser.isOpen() == False:ser.open()”;
import serial
import time
ser = serial.Serial('/dev/ttyAMA0', 9600, timeout = 0.5)
while True:
if ser.isOpen() == False:
ser.open()
print ser.read()
ser.write('A')
time.sleep(1)
  • Step4 when reading data using "ser. The read ()", when to send data using "ser. Write (data)". Here by editing a Python program IDLE3 Serial_test. Py, then directly in LXTerminal type "sudo Python Serial_test. Py" (note, because by default is to use the account name: PI, so you need to place the files in the/home/directory, PI can be executed directly, without having to), then the phone bluetooth remote control (as shown in figure 5) connected to the bluetooth passthrough module, after successful communication, can be sent via mobile phone button on the remote control button on the serial port of the corresponding characters see corresponding characters printed to the screen. In this test source program (below), is given by computer the bluetooth virtual serial port and raspberry pie external transparent bluetooth serial port module connection, data transmission, to the computer serial port assistant to send the letter "B", at the same time receive raspberries distributed from the letter "A" and displayed in the debug receiving window, raspberry pie received from the computer to send to the letter "B", and print it out, by this phenomenon can prove raspberries pie UART function test is normal, the following screen shot of the 6 attached experiment.
Ppp8.png
Ppp6.png

Robot control

For control of the AS - 4 wd buggy is relatively simple, in this production used in RasPi dedicated motor driver board, board L293 AS the core of the motor drive circuit, and through two groups each group 2 IO to realize the motor and reversing, and can make. Through the pin layout can see clear, raspberry pie external hardware and RasPi Driver connection relations, through the GPIO4 and GPIO17 one circuit of the motor control and can make (high level) effectively, using GPIO8 to status indicates positive &negative, similarly visible GPIO25 used to transfer one of the positive and negative control, GPIO10 to make energy, GPIO7 status indication; At the same time use the UART interface board external connection with the bluetooth serial port module, specific methods is not in now. For the whole program frame relative to previous MCU version of the remote control car is relatively simple, main function module initialization Settings, circulation judgment value of remote control and output corresponding to the function of sports value, as shown in the system control principle diagram 7. Import library files, the GPIO and serial port configuration, specific parameters and the same, not in detail; After completing the above Settings, are the programs for the control of the car, and read the serial buffer value, then complete the cycle to judge the character data sent by mobile phones bluetooth remote control "A", "B", "C", "D", corresponding to the corresponding motor movements (note: the corresponding to the corresponding action, may be due to the motor driver board wiring reason of high and low level does not correspond to the default action, can be flexibly adjusted wiring or software revision level).

Ppp7.png

Products related to recommend

Buy address:[1]

Personal tools
Namespaces

Variants
Actions
Navigation
Tools