Previous_Lesson

Authorized Online Retailers

>

Buy from US Buy from UK Buy from DE Buy from IT Buy from FR Buy from ES

top

Objective

In this lesson, we will install the most important framework in the smart car and make car to do some simple movements as per our python sample code. If you have passed the test movement of this lesson, that means Arduino, voltage meter,motor drive module(Model-PI), motors, batteries,chassis and wire connections between these parts are all functioning well.
As your experiments in future lessons are all based on frame work of Lesson One, it is very important to test the installation and sample code in this Lesson properly.

top

Hardware Installation

Video intutorial for Hardware Installation

STEP1. Install raspberry pi board,model pi driver board and 16 Channel 12-bit PWM compatible module as follows.

STEP1

STEP2:Install the Voltage Meter,Webcam and 5 tracking sensors as follows.

STEP2

STEP3:Connect the electronic parts as follows:

(1)Connect right and left motors to K1 and K3 sockets in model pi driver board.

STEP3-1
(2)Connect voltage meter and battery box to model pi driver board as follows.

STEP3-2
(3)Connect 16 Channel 12-bit PWM compatible module to model pi driver board as follows.

STEP3-3
(4)Connect right and left LED ligth to 16 Channel 12-bit PWM compatible module as follows.

STEP3-4
(5)Connect raspberry pi board to 16 Channel 12-bit PWM compatible module as follows.

STEP3-5
(6)Connect 5 tracking sensors to 16 Channel 12-bit PWM compatible module as follows.

II.Software Installation

Software Preparation:
Imager utility: Win32DiskImager utility
OS: Raspbian (Use OS Raspbian 2018-04-18 in the subsequent tutorials)
Format Tool: SDFormatter (Optional)
SSH Tool: PuTTY (for Windows users)

Step 1:Before connect to Raspberry Pi, you need to install Raspbian Operation System(OS) onto SD card.

You can select the latest version of RASPBIAN system on the official website: https://downloads.raspberrypi.org/raspbian/images/. Write the image via Win32DiskImager utility into your microSD/TF card(minimum 16G), then plug the card into the slot on your Raspberry Pi.

write_raspbian

Step 2: Connect Wifi
Firstly, Connect Raspberry Pi to your HDMI monitor or TV. Put a keyboard and mouse into Raspberry Pi USB ports. Insert SD card into the slot on your Raspberry Pi.Click on the wireless icon top right on desktop, should give a list of access points, select your wifi ssid and connect it. Once your Pi is connect to Wifi, you can hover your mouse to the wifi icon to see the your IP address.

Or your can type sudo ifconfig wlan0 command in terminal. Your local ip address will show in wlan0 block(right side of the word inet addr:). It will look like 192.168……

Please remember above IP address, it will be used in our next steps.

Step 3: Open SSH connection

SSH enable user to type shell command remotely from internet so that we can control the car through wifi.In order to enable SSH function, we need type following command from terminal:

sudo raspi-config

Then select Interfacing Options->SSH->Yes->Ok->Finish

Step 4:Use SSH to connect Raspberry Pi terminal remotely

In order to make the car moving freely, we need disconnect Raspberry Pi from monitor, keyboard/mouse and use SSH to send command to Raspberry Pi terminal remotely.

If you are using Windows to send ssh command. you need download a free software called PuTTy to connect the Raspberry Pi local IP(you got from STEP 1).

If you are using MacBook or other linux computer, please type:

ssh your_raspberry_pi_local_ip_address

*your_raspberry_pi_local_ip_address means the wifi IP address you got from STEP 1

such as :ssh [email protected]

When connecting ssh, you need use default user name pi and default password raspberry to login to Raspberry Pi.

Step 5: Open I2C function

I2C is a protocol which will be used to exchange data with I2C device. In our project, I2C device is PCA9685 module.In order to use I2C function, we need type following command from terminal:

sudo raspi-config

Then select Interfacing Options->I2C->Yes->Ok->Finish


Step 6: Install GPIO Library

cd ~ 
sudo apt-get update
sudo apt-get install build-essential python-pip python-dev python-smbus git
git clone https://github.com/adafruit/Adafruit_Python_GPIO.git
cd Adafruit_Python_GPIO
sudo python setup.py install
cd ~ 
sudo rm -fr Adafruit_Python_GPIO

Testing Previous Installation

cd ~ 
mkdir osoyoo-robot/ 
cd osoyoo-robot/ 
wget http://osoyoo.com/driver/motor-test-tank.tar.gz
tar -zxvf motor-test-tank.tar.gz
cd motor-test

top

Testing

Step 7: Run Testing Python code

cd ~/osoyoo-robot/motor-test
python motor-test.py


After running above python sample code, your car should move forward for 2 seconds, then move backward for 2 seconds , then turn left for 2 seconds and finally turn right for 2 seconds.

If your car does not move as per above scenario, the installation should have some problem. You need double check the wire connection and software installation as per our previous steps.

Previous_Lesson