SunFounder Smart Video Car Kit Manual

SunFounder Smart Video Car Kit Manual

For raspberry pi

Advertisement

Preface
About SunFounder
SunFounder is a technology company focused on Raspberry Pi and Arduino open
source community development. Committed to the promotion of open source
culture, we strive to bring the fun of electronics making to people all around the
world and enable everyone to be a maker. Our products include learning kits,
development boards, robots, sensor modules and development tools. In addition
to high quality products, SunFounder also offers video tutorials to help you make
your own project. If you have interest in open source or making something cool,
welcome to join us!
About This Kit
The kit is suitable for the Raspberry Pi model B+ and Raspberry Pi 2 model B.
In this book, we will show you how to build the smart car via description,
illustrations of physical components, and schematic diagrams of circuits, in both
hardware and software respects. You may visit our website
www.sunfounder.com
to download the user manual and also the related code by clicking
LEARN -> Get
Tutorials
and watch the videos by clicking VIDEO, or clone the code on our page
of github.com at
https://github.com/sunfounder/Sunfounder_Smart_Video_Car_Kit_for_Raspberr
yPi
If you have any questions, please send an email to support@sunfounder.com. You
can also leave a message and share your projects on our Forum.

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the Smart Video Car Kit and is the answer not in the manual?

Questions and answers

Subscribe to Our Youtube Channel

Summary of Contents for SunFounder Smart Video Car Kit

  • Page 1 Our products include learning kits, development boards, robots, sensor modules and development tools. In addition to high quality products, SunFounder also offers video tutorials to help you make your own project. If you have interest in open source or making something cool,...
  • Page 2: Table Of Contents

    Contents Introduction............................1 Components ............................2 Acrylic Plates ........................2 Mechanical Fasteners ....................... 3 Drive Parts ..........................4 iii. Electrical Components ..................... 5 Self-provided Parts ......................8 Assembly ............................... 9 Mechanical Assembly ....................... 9 Electrical Module Assembly ..................30 iii. Circuit Connecting ......................31 Electrical Components Basics .......................41 Raspberry Pi........................41 Step-down DC-DC Converter Module ..............42...
  • Page 3: Introduction

    Introduction The SunFounder Smart Video Car Kit for Raspberry Pi is composed of Raspberry Pi, step-down DC-DC converter module, USB camera, DC motor driver, and PCA9685-based servo controller. From the perspective of software, the smart car is of client/server (C/S) structure. The TCP server program is run on Raspberry Pi for direct control of the car.
  • Page 4: Components

    Components i. Acrylic Plates...
  • Page 5: Mechanical Fasteners

    i. Mechanical Fasteners Parts Name Quantity M1.2*5 self-tapping screw M2*10 screw M2.5*6 screw M3*10 countersunk screw M3*8 screw M3*12 screw M3*30 screw M4*25 screw M2.5*8 copper pillar M3*24 copper pillar M2 nut M2.5 nut M3 nut M4 self-locking nut F694ZZ flange bearing...
  • Page 6: Drive Parts

    ii. Drive Parts Parts Name Quantity Tower Pro Micro Servo SG90 Gear reducer Driven wheel Active wheel...
  • Page 7: Electrical Components

    iii. Electrical Components Parts Name Quantity Raspberry Pi Model B+ 16-Channel 12-bit PWM driver (servo controller) L298N DC motor driver...
  • Page 8 Step-down DC-DC converter module USB Wi-Fi adapter USB camera 18650*2 Battery holder Ribbon...
  • Page 9 USB cable Cross socket wrench Cross screwdriver 20cm jumper wire (F to F) 10cm jumper wire (F to F) 10cm jumper wire (M to F) 20cm jumper wire (M to M)
  • Page 10: Self-Provided Parts

    iv. Self-provided Parts The following parts are not included in the set. Parts Name Qty. Needed 18650 3.7V rechargeable Li-ion battery TF Card...
  • Page 11: Assembly

    Assembly i. Mechanical Assembly 1. Car Assembly Front Wheels a) Fasten the F694ZZ flange bearing, driven wheel and following acrylic plates with an M4*25 screw and an M4 self-locking nut in the way as shown below. b) When completed, the assembly c) Bear in mind that DO NOT over should look like the figure below.
  • Page 12 a) Fasten the F694ZZ flange bearing, driven wheel and following acrylic plates with an M4*25 screw and an M4 self-locking nut in the way shown as below. b) When completed, the assembly c) Bear in mind that DO NOT over should look like the figure below.
  • Page 13 Note: The acrylic plates next to the bearing in the two wheels are of opposite faces, as shown in the following figure. Back Half Chassis + Rear Wheels a) Assemble the following two acrylic b) When completed, the assembly plates should look like the figure below.
  • Page 14 d) When completed, the assembly should look like the figure below. a) Assemble the following two acrylic b) When completed, the assembly plates should look like the figure below. c) Assemble the gear reducer, the active wheel and the previously assembled part with two M3*30 screws and M3 nuts.
  • Page 15 d) When completed, the assembly should look like the figure below. Back Half Chassis + Copper Standoffs a) Assemble 4 M3*24 copper standoffs b) When completed, the assembly and 4 M3 nuts into the acrylic plate should look like the figure below. part as shown below.
  • Page 16 Servo Adjustment a) The rocker arm can be placed onto and removed from the servo freely as shown in the following figure. b) Turn the rocker arm within an angle of about 180 degrees. c) The rocker arm is placed in a random way at the beginning. You need to adjust it to restrict its turning in an almost equal angle towards right and left.
  • Page 17  Remove the rocker arm and install it again in another angle. Turn right and left to see whether the condition of the angle is met.  Repeat the step until the condition is met. It matters to the subsequent installation.
  • Page 18 Steering Linkage + Servo Rocker Arm a) Connect the following acrylic plate to the second hole of the rocker arm (see the figure below) with an M2*8 self-tapping screw.  The M2*8 self-tapping screw is contained in the package of the servo; it is one of the two longest screws.
  • Page 19 Steering Servo + Upper Plate a) Connect the servo to the acrylic plate below with two M2*10 screws and M2 nuts.  Pay attention to the face of the plate. Refer to the small hole in the plate as pointed by the arrow in the following figure. b) When completed, the assembly should look like the figure below.
  • Page 20 Steering Servo + Steering Linkage a) Connect the following parts with an M2*4 screw.  The M2*4 screw is contained in the package of the servo; it is the shortest of the screws in the package. b) When completed, the assembly should look like the figure below. ...
  • Page 21 Front Chassis + Upper Plate a) Connect the following parts and wheels with M3*8 screws, M3*24 copper standoffs and M3 nuts, 4 for each. b) When completed, the assembly should look like the figure below.
  • Page 22 Upper Plate + Copper Standoffs a) Assemble 16 M2.5*8 copper standoffs and 16 M2.5 nuts into the acrylic plate as shown below. b) When completed, the assembly should look like the figure below. c) The view from the back of the plate:...
  • Page 23 Back Chassis + Upper Plate a) Connect the two assembled parts with 4 M3*8 screws. b) When completed, the assembly should look like the figure below. c) The view from the back of the plate:...
  • Page 24 Battery Holder a) Assemble the battery holder to the plate below with 2 M3*10 countersunk screws and 2 M3 nuts.  You can thread a ribbon through the plate below, so it will be easy to remove the battery, which is up to you. b) When completed, the assembly should look like the figure below.
  • Page 25 2. Mount Assembly Plate + Servo Rocker Arm a) Connect the rocker arm of the b) When completed, the assembly servo to the acrylic plate below should be like the figure below. with 4 M1.2*5 screws.  The rocker packaged together with the servo.
  • Page 26 Plate + Servo a) Connect the servo to the acrylic b) When completed, the assembly plate below with M2*10 should look like the figure below. screws and M2 nuts, and we name it "pan servo". a) Connect the servo to the acrylic b) When completed, the assembly plate below...
  • Page 27 Plate + Plate a) Connect plate parts b) When completed, the assembly together with two M3*12 screws should look like the figure below. and M3 nuts. The two plates should be perpendicular to each other. a) Connect the two parts at a right b) When completed, the assembly angle with two M3*12 screws and should look like the figure below.
  • Page 28 Servo + Rocker Arm a) Connect the following parts without b) When completed, the assembly screws. should look like the figure below.  Top view:  Front view:...
  • Page 29  The assembly should be like this: c) Then fasten them with an M2*4 Before screwing, verify the rotation screw. angle first. Take the orientation of the tilt servo shaft as the right side, The M2*4 screw is contained in as shown below.
  • Page 30 3. Mount + Car a) Assemble the mount part and the car with two M3*12 screws and M3 nuts. b) When completed, the assembly should look like the figure below.
  • Page 31 c) Before the next assembly, you need to check the steerability of the servos. 1) First turn the front wheels right and left; pay attention to the utmost degree of turning: the wheels should be able to turn to a same degree towards both sides.
  • Page 32: Electrical Module Assembly

    ii. Electrical Module Assembly Assemble the electrical components to the car with M2.5*6 screws. See the figure below.
  • Page 33: Circuit Connecting

    iii. Circuit Connecting Preview: This is how it looks when all wiring is done. Looks complicated but don't worry! The detailed procedures will be given below, step by step.
  • Page 34 Step 1: Connect the two DC motors with the motor driver. You may remove the L-shaped PCB connector and plug it back after wiring. Note: It doesn't matter how to wire the motors. After all the assembly is done, if the car moves in an opposite direction of what you control, just swap the wiring of the two motors and it will work normally.
  • Page 35 Step 2: Connect the motor driver with the Raspberry Pi GPIO port based on the following table. Raspberry Pi GPIO Port DC Motor Driver Pin11 Pin12 Pin13 Pin15...
  • Page 36 Step 3: Connect the servo controller with the Raspberry Pi GPIO port as follows: Raspberry Pi GPIO Port Servo Controller Pin2(5V) Pin3(SDA) Pin5(SCL)
  • Page 37 Step 4: Hook up the servo that controls the car's direction to CH0 of the servo controller, and the two servos that control the view of the camera to CH14 and CH15 respectively, as shown below: Step 5: Connect the motor driver with the servo controller.
  • Page 38 Step 6: Connect the servo controller with the step-down DC-DC converter module. For the connector, loosen the screws, insert the wire, and then tighten the screws with a screwdriver. The connection should be like:...
  • Page 39 Step 7: Connect the battery holder with the step-down DC-DC converter module and the DC motor driver. Insert the four wires into two jacks of the connector, two in each.
  • Page 40 The whole picture of wiring should be like this:...
  • Page 41 Step 8: Connect the Raspberry Pi with the step-down DC-DC converter module, USB Wi-Fi adapter and the camera.
  • Page 42 Now the circuit is completed. Congratulations! The car should be assembled successfully as shown below:...
  • Page 43: Electrical Components Basics

    Electrical Components Basics i. Raspberry Pi The Raspberry Pi is a low cost, credit-card sized computer that plugs into a computer monitor or TV, and uses a standard keyboard and mouse. It is a capable little device that enables people of all ages to explore computing, and to learn how to program in languages like Scratch and Python.
  • Page 44: Step-Down Dc-Dc Converter Module

    ii. Step-down DC-DC Converter Module Built based on the chip XL1509, the module converts the battery output of 7.4V to 5V, so as to supply power to Raspberry Pi and the servo. As a DC to DC converter IC, the chip has an input voltage ranging from 4.5V to 40V and generates an output voltage of 5V with a current of as high as 2A.
  • Page 45: Servo

    iii. Servo In this smart car, one servo controls the direction of the car, and the other two, the movement of the camera between X axis and Y axis, thus defining the coverage of the camera. A servo is an automatic control system composed of DC motor, reduction gear set, sensor, and control circuit.
  • Page 46: Dc Motor Driver

    iv. DC Motor Driver As the name suggests, the module is used to drive DC motors. The driver is built based on L298N. As a high-voltage and large-current chip for motor driving, encapsulated with 15 pins, the chip has a maximum operating voltage of 46V and an instant peak current of as high as 3A, with an operating current of 2A and rated power of 25W.
  • Page 47: Servo Controller

    v. Servo Controller The Servo Controller is built based on PCA9685. PCA9685 is a 16-channel LED controller with I2C bus interface. The resolution ratio of each channel is 12 bits =4096 levels). The controller works in a frequency between 40Hz and 1000Hz and its duty cycle can be adjusted in a range of 0 to 100%.
  • Page 48: Software Related

    Get Source Code a) Download the source code directly from Github to your Raspberry Pi. cd ~ git clone https://github.com/sunfounder/Sunfounder_Smart_Video_Car_ Kit_for_RaspberryPi.git If your Raspberry Pi is not connected to the Internet, download the file Sunfounder_Smart_Video_Car_Kit_for_RaspberryPi.tar.gz on our website.
  • Page 49 If your Linux does not support installing git by yum or apt-get, you may go t o the link to download: https://github.com/sunfounder/Sunfounder_Smart_Vid eo_Car_Kit_for_RaspberryPi, or search for Sunfounder in Github and find Sunf ounder_Smart_Video_Car_Kit_for_RaspberryPi Repository. Click Download ZIP on the right side of the page, as below.
  • Page 50: Basic Software Environment

    iii. Basic Software Environment Operation on PC Prepare the PC for remote. Install python-tk for a remote interface sudo install apt-get install python-tk Operation on Raspberry Pi Install python-dev, python-smbus Type in the code below to install python-dev and python-smbus: sudo apt-get install python-dev sudo apt-get install python-smbus Setup I2C port...
  • Page 51 MJPG-streamer Introduction The acquisition and transmission of video data by the SunFounder Smart Video Car is fulfilled based on MJPG-streamer. MJPG-streamer is a command line application that copies JPG-frame from a single input plugin to multiple output plugins. It can be used to stream JPEG files over an IP-based network from the webcam to a viewer like Firefox, Cambozola and Videolanclient or even to a Windows mobile device running the TCPMP-Player.
  • Page 52 Install: make DESTDIR=/usr install Testing Type in sudo ./start.sh and press Enter. Type in the following address (replace 192.168.0.xxx with your Raspberry Pi IP address) at the address bar of your browser (Firefox is recommended): http://192.168.0.xxx:8080/stream.html Press Enter and you will see the view captured by the camera displayed on the screen in a real-time manner.
  • Page 53: Calibration

    Calibration Preparation For Server Make sure that the circuit is connected properly. Power the smart car, open a terminal in Linux. Connect with your Raspberry Pi via ssh. Go to the directory Sunfounder_Smart_Video_Car_Kit_for_RaspberryPi/server, server cali_server.py: cd ~/Sunfounder_Smart_Video_Car_Kit_for_RaspberryPi /server sudo python cali_server.py Then the contents of config are printed and the last line: Waiting for connection…...
  • Page 54 Enter your own address of the Raspberry Pi there. Press Ctrl+O to save and Ctrl+X exit. Run cali_client.py: sudo python cali_client.py You need to enter the password of the Raspberry Pi here since you want to obtain the configuration file on it. Then a line appears as follows, indicating the config file is obtained successfully.
  • Page 55 Then you can start calibrating. Before that, take out your package box and place it vertically with the side face to the table. Put the car onside the box and keep it balanced. The purpose is to keep the wheels of the car off the table. By default, the front wheels should be directly pointed towards the front;...
  • Page 56 you just adjusted is turning forward. If the reversing works normally, click Run again to stop the wheels from spinning. Turing Adjustment Currently the front wheels should be pointed at the exact front direction. But if it is not, you need to make some adjustments. In the Turning section in the Calibration window, click the left (<==) and right (==>) arrow buttons in the upper line to make fine adjustments, and those in the lower to coarsely adjust the turning direction.
  • Page 57 After the password is entered, the prompt message of config sent successfully will be printed in the terminal. And the program will exit. Then the Raspberry Pi returns to the status: Waiting for connection... Press Ctrl+C to exit. Now your car is ready to GO! Get on the Road! You need three terminals open to run the car;...
  • Page 58 - Open another terminal, i.e. Terminal 2, log in the Raspberry Pi remotely, and switch to the directory under which the program of MJPG-streamer lies: cd ~/Sunfounder_Smart_Video_Car_Kit_for_RaspberryPi /mjpg-strea mer/mjpg-streamer Run the program: sudo sh start.sh Then the video data acquisition will start, like this:...
  • Page 59 Type in the following address (replace 192.168.0.xxx with the IP address of your Raspberry Pi) at the address bar of your browser (Firefox is recommended): http://192.168.0.xxx:8080/stream.html Press Enter and you will see the view captured by the camera displayed on the screen in a real-time manner.
  • Page 60 The following picture will appear on your screen: You can click buttons such as Forward and Backward to control the car moving remotely. Or click X+, X-, Y+, and Y- to control the coverage of the camera. Note: The server program must be run before you run the client program. Some settings must be completed for the server before the service is done.
  • Page 61: Program Analysis And Explanation

    v. Program Analysis and Explanation Abstract From the perspective of software, the smart car is of C/S structure. The TCP server program is run on Raspberry Pi to listen to the command from the client and control the car accordingly. The client program is run on the PC and connected with the server through the TCP, which provides the user with a graphical user interface (GUI) to conveniently control the Raspberry Pi remotely.
  • Page 62 Raspberry Pi Introduction of Socket The C/S-structure program of the SunFounder Raspberry Pi-based Smart Car is written based on the socket module of the Python language. Socket wraps and applies the TCP/IP and is used to describe IP address and port. Also it is a network data structure for computer.
  • Page 63 communication does not end until either end closes the connection or sends a null character string. Process Diagram of Server Program 2. Client It is easier to create a TCP client than to do a server. Take the following pseudocode: = socket( ) # Create a client socket.
  • Page 64 Tk_test.py Type in the following code: #!/usr/bin/env python from Tkinter import = Tk() # Create a top window top.title('Sunfounder.com') label = Label(top, text='Hello Geeks !', fg='blue') # Create a label and set its foreground color as blue label.pack() # layout top.mainloop()
  • Page 65 Process Diagram of Client Program...
  • Page 66: Summary

    Wi-Fi adapter, etc. Also you've learnt a lot of software and coding, which lays a solid foundation for your future journey of exploring open-source field. The SunFounder Smart Video Car for Raspberry Pi is not only a toy, but more a meaningful development kit for Raspberry Pi. After all the study and hands-on practice of the kit, you should have a better understanding of Raspberry Pi.

Table of Contents