SunFounder Smart Video Car Kit B+ User Manual

For raspberry pi
Table of Contents

Advertisement

Quick Links

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+, 2 model B and 3 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
user manual on
LEARN -> Get Tutorials
code on our page of github.com at
https://github.com/sunfounder/Sunfounder_Smart_Video_Car_Kit_for_RaspberryPi
Free Support
If you have any TECHNICAL questions, add a topic under
and we'll reply as soon as possible.
For NON-TECH questions like order and shipment issues, please
service@sunfounder.com. You're also welcomed to share your projects on FORUM.
Preface
www.sunfounder.com
and watch related videos under VIDEO, or clone the
to download the related code and view the
FORUM
section on our website
send an email to
Reprint 4.0

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the Smart Video Car Kit B+ 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 B+

  • Page 1 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.
  • Page 2: Table Of Contents

    Contents Introduction .............................. 1 Components ............................. 2 A. Acrylic Plates ..........................2 Mechanical Fasteners ......................3 C. Drive Parts ........................... 4 D. Electrical Components ......................5 Self-provided Parts ........................8 Electrical Components Basics ....................... 9 A. Raspberry Pi ..........................9 Step-down DC-DC Converter Module ................
  • Page 3 D. Steering Servo + Steering Linkage ..................39 Front Chassis + Upper Plate ....................40 Plates + Servo Rocker Arms ....................41 G. Pan/Tilt Servo + Plate ......................42 H. Pan Servo Plate + Tilt Servo Plate ..................43 Servos + Rocker Arm Plates ....................44 Mount + Car ..........................
  • Page 4: 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.
  • Page 5: Components

    Components A. Acrylic Plates...
  • Page 6: Mechanical Fasteners

    B. Mechanical Fasteners Parts Name Qty. M1.2*4 self-tapping screw M2*8 screw M2.5*6 screw M3*10 countersunk screw M3*8 screw M3*10 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 7: Drive Parts

    C. Drive Parts Parts Name Qty. Tower Pro Micro Servo SG90 Gear reducer Driven wheel Active wheel...
  • Page 8: Electrical Components

    D. Electrical Components Parts Name Qty. Raspberry Pi Model B+ 16-Channel 12-bit PWM driver (servo controller) L298N DC motor driver Step-down DC- converter module...
  • Page 9 USB Wi-Fi adapter USB camera 18650*2 Battery holder Ribbon USB cable...
  • Page 10 Cross socket wrench Cross screwdriver Cable Spiral Wrap 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 11: Self-Provided Parts

    E. 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 12: Electrical Components Basics

    Electrical Components Basics A. 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 13: Step-Down Dc-Dc Converter Module

    B. 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 14: Dc Motor Driver

    rotates in a certain degree and does not rotate in a round circle. Also, the former is used for power supply by its whole-circle rotation, while the latter is applied to controlling the rotation angle of an object (like joints of a robot). D.
  • Page 15: Servo Controller

    F. 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 (2 =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 16: Assembly

    Assembly A. Back Half Chassis + Rear Wheels a) Assemble the following two acrylic b) When completed, the assembly should plates look like the figure below. c) Assemble the gear reducer, the active wheel and following acrylic plates with two M3*30 screws and M3 nuts.
  • Page 17 e) Assemble the following two acrylic f) When completed, the assembly should plates look like the figure below. g) Assemble the gear reducer, the active wheel and the previously assembled part with two M3*30 screws and M3 nuts. h) When completed, the assembly should look like the figure below.
  • Page 18: Back Half Chassis + Copper Standoffs

    B. Back Half Chassis + Copper Standoffs a) Assemble 4 M3*24 copper standoffs b) When completed, the assembly should and 4 M3 nuts into the acrylic plate part look like the figure below. as shown below. C. Upper Plate + Copper Standoffs a) Assemble 16 M2.5*8 copper standoffs and 16 M2.5 nuts into the acrylic plate as shown below.
  • Page 19 b) When completed, the assembly should look like the figure below. c) The view from the back of the plate:...
  • Page 20: Battery Holder

    D. 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 21: Back Chassis + Upper Plate

    E. 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.
  • Page 22: Electrical Module Assembly

    c) The view from the back of the plate: F. Electrical Module Assembly Assemble the electrical components to the car with M2.5*6 screws. See the figure below.
  • Page 23: Circuit Connecting

    Circuit Connecting Preview: Looks complicated but don't worry! The detailed procedures will be given below, step by step.
  • Page 24 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 25 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 26 Step 3 : Connect the servo controller with the Raspberry Pi GPIO port as follows: Raspberry Pi GPIO Port Servo Controller Pin 2 (5V) Pin 3 (SDA) Pin 5 (SCL)
  • Page 27 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 28 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 29 Step 7 : Connect the battery holder with the step-down DC-DC converter module and the DC motor driver. Note: Please DO NOT install the batteries at this step! Do it later when you've completed all the wiring. And take care that the red wire is the power and should be connected to the anode of the holder, when the black wire, i.e.
  • Page 30 The whole picture of wiring should be like this:...
  • Page 31 Step 8 : Connect the Raspberry Pi with the step-down DC-DC converter module, the USB Wi- Fi adapter and the camera.
  • Page 32: Servo Calibration(Operation On Raspberry Pi

    Servo Calibration (Operation on Raspberry Pi) In the subsequent part of Operation on Raspberry Pi, you need to log into the Raspberry Pi REMOTELY instead of direct operation on a screen connected to the RPi – which is also impossible because the HDMI port on the smart car is blocked and cannot connect to one such display.
  • Page 33: Car Power Supply

    6) Create a blank file ssh under the /boot directory to enable remote login and delete the suffix in the file name. 7) Create a WiFi configuration file wpa_supplicant.conf under /boot and add the following to the file: ssid= "(name of the Wi-Fi)" psk= "(your Wi-Fi password)"...
  • Page 34 Type in ssh pi@ip_address – ssh is the tool for remote login, pi, the user name, and ip_address, as the name suggests, your Pi's IP address. For example: pi@192.168.0.101 Press Enter to confirm. If you get a prompt that no ssh is found, you need to install an ssh tool like Ubuntu and Debian by yourself: sudo...
  • Page 35: For Windows Users

    For Windows Users If your computer runs on Windows, you need to pen the Bash shell with the help of some software. Here we recommend a tool PuTTY. 1. Download PuTTY 2. Open PuTTY and click Session on the left tree-alike structure (generally it's collapsed upon PuTTY startup).Enter the IP address of the RPi you just got in the textbox under Host Name (or IP address) and 22 under Port (by default it is 22) 3.
  • Page 36: Get Source Code

    This window is just like the Command Line window in Linux. D. Get Source Code Download the source code directly from Github to your Raspberry Pi. clone https://github.com/sunfounder/Sunfounder_Smart_Video_Car_Kit_for_Raspb erryPi.git E. Install python-dev, python-smbus Install and python-smbus: python-dev sudo apt-get update...
  • Page 37 ~/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… At this time, the servo might move a bit (this is the original position set). Note: During the subsequent assembly, cali_server.py should keep running.
  • Page 38: Continue To Assemble

    Continue to Assemble Note: Please keep cali_server.py running in the whole process of assembly. A. 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. Use the cross socket wrench to fasten the M4 self-locking nut.
  • Page 39 d) 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. Pay attention to the direction of this plate e) When completed, the assembly Bear in mind that DO NOT over tighten the nut should look like the figure below.
  • Page 40: Steering Linkage + Servo Rocker Arm

    B. 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 41: Steering Servo + Upper Plate

    C. Steering Servo + Upper Plate a) Connect the servo to the acrylic plate below with two M2*8 screws and M2 nuts. b) When completed, the assembly should look like the figure below. Note: The servo should be placed with its output shaft toward the front of the plate (see ...
  • Page 42: Steering Servo + Steering Linkage

    D. 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.  Keep the Steering Linkage perpendicular with the middle of the car; otherwise, remove it and mount again.
  • Page 43: Front Chassis + Upper Plate

    E. 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 44: Plates + Servo Rocker Arms

    F. Plates + Servo Rocker Arms a) Connect the rocker arm of the b) When completed, the assembly should servo to the acrylic plate below with 4 be like the figure below. M1.2*4 screws.  The rocker packaged together with the servo. c) Connect the rocker arm of the d) When completed, the assembly should servo to the acrylic plate below with...
  • Page 45: Pan/Tilt Servo + Plate

    G. Pan/Tilt Servo + Plate a) Connect the servo to the acrylic plate b) When completed, the assembly should below with two M2*8 screws and M2 nuts, look like the figure below. and we name it "pan servo". c) Connect the servo to the acrylic plate d) When completed, the assembly should below with two M2*8 screws and M2 nuts look like the figure below.
  • Page 46: Pan Servo Plate + Tilt Servo Plate

    H. Pan Servo Plate + Tilt Servo Plate a) Connect plate parts b) When completed, the assembly should together with two M3*10 screws and look like the figure below. M3 nuts. The two plates should be perpendicular to each other. c) Connect the two parts at a right d) When completed, the assembly should angle with two M3*10 screws and M3...
  • Page 47: Servos + Rocker Arm Plates

    I. Servos + Rocker Arm Plates a) Connect the following parts without any b) When completed, the assembly should screws. look like the figure below. The two plates as indicated with arrows below should be assembled in parallel; otherwise, remove and mount again. DO NOT directly rotate them in case of damages to the servo.
  • Page 48: Mount + Car

    J. Mount + Car Assemble the mount part and the car with two M3*10 screws and M3 nuts. When completed, the assembly should look like the figure below.
  • Page 49 ------------------------ Now the car is completed. Congratulations! ----------------------------- The car should be assembled successfully as shown below: To organize the wires, you can use the cable spiral wrap. Bottom view:...
  • Page 50: Car Calibration (Operation On Pc)

    A. Get the source code Download the source code directly from Github to your PC at: https://github.com/sunfounder/Sunfounder_Smart_Video_Car_Kit_for_RaspberryPi, Or search for Sunfounder in Github and find the repository: Sunfounder_Smart_Video_Car_Kit_for_RaspberryPi. Click Download ZIP on the sidebar of the page, as shown below.
  • Page 51: Run Cali_Client

    C. Run cali_client Run the calibration client on PC to connect the server on Raspberry Pi. For Windows users: Click the Start button on your computer, and type in python in the search bar, and you can find the IDLE (Python GUI). Click it and then a window will pop up. Click File ->...
  • Page 52 Find the variable of HOST: 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 No matter what system your computer is running on, Linux or Windows, when you run cali_client.py, a window Raspberry Pi Smart Video Car Calibration will pop up: In the terminal remotely connected with the Raspberry Pi, the IP address of the PC will be printed.
  • Page 53: Start Calibration

    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 54: Turning Adjustment

    If the reversing works normally, click Run again to stop the wheels from spinning. Turning 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...
  • Page 55: Mjpg-Streamer (Operation On Raspberry Pi)

    MJPG-streamer (Operation on Raspberry Pi) A. MJPG-streamer Installation 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.
  • Page 56: Testing

    sudo apt-get install libjpeg8-dev sudo apt-get install imagemagick Compile the source code of MJPG-streamer: /home/pi/Sunfounder_Smart_Video_Car_Kit_for_RaspberryPi/mjpg-streamer/mjpg- streamer sudo make USE_LIBV4L2=true clean all Install: sudo make DESTDIR=/usr install B. Testing Operation on Raspberry Pi Run the program: sudo sh start.sh Then the video data acquisition will start, like this: Type in the following address (replace 192.168.0.126 with your Raspberry Pi IP address) at the address bar of your browser (Firefox is recommended): (operation on PC)
  • Page 58: Get On The Road

    Get on the Road! A. Run TCP server (Operation on Raspberry Pi) Now a terminal's already open for remote login to the Raspberry Pi and run the mjpg- streamer, and you need to keep it RUNNING. Open one more to log into the Raspberry Pi to run tcp_server.
  • Page 59 After modification, save the file and select Run -> Run Module. For Linux users: Open another terminal again. But DO NOT log into the Raspberry Pi remotely in this terminal. Go to the client with cd and edit the file client.py: Similar to changes in calibration, change the IP address in client program in your PC: After the alteration, press Ctrl + O and save and Ctrl + X to exit.
  • Page 60 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

    Raspberry Pi for the client on your PC. 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.
  • Page 62: Server

    1. Server Here we provide a pseudocode which creates a universal TCP server for explanation. Note that this is just one of the methods for server design. After you have a good knowledge about it, you can alter the pseudocode as you want: = socket( ) # Create a socket for the server.
  • Page 63: Process Diagram Of Server Program

    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. c.connect( ) # Try to connect a server. comm_loop: # Communication loop.
  • 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

    Process Diagram of Client Program...
  • Page 66: Summary

    Also you've got a lot of software and coding, which lays a solid foundation for your future journey of exploring open-source field. 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...
  • Page 67 All contents including but not limited to texts, images, and code in this manual are owned by the SunFounder Company. You should only use it for personal study, investigation, enjoyment, or other non-commercial or nonprofit purposes, under the related regulations and copyrights laws, without infringing the legal rights of the author and relevant right holders.

Table of Contents