9
ECE 1570: Robotics & Controls Laboratory Lab #6: Wireless Communications Instructor: Sami Mian ([email protected]) 1. Introduction 1.1. Instructions of the Lab Welcome to ECE 1570: Robotics & Controls. Once you have formed your lab groups, your instructor will assign you to your lab station for the semester. Pitt email will be used to distribute relevant lab material throughout the course. Thus, it is the student’s responsibility to actively monitor their Pitt email throughout the semester. Each lab will build upon the prior lab, and all labs are designed such that students will actively work together to complete and nish the lab’s goals within the lab time. Therefore, missing a lab and/or showing up unprepared will not only cause individual problems, but will simultaneously denigrate the entire team’s ability to nish in the allotted time. So the moral of the story is: Don’t miss lab. All requests for make-up labs should be made to the instructor. Only in the event that the instructor is noti ed at least one week prior to the scheduled lab with a valid reason for missing lab, will a make-up lab be honored. 1.2. Purpose of the Lab This lab will focus on enabling wireless communications for our robots. There are two parts of this lab. The first part will use the modules included in the robot kits to setup communications with individual phones. This can be done using WIFI or Bluetooth. The second part of the lab will connect the robot with a custom PCB controller using RF communications. 2. Adding Comms module to robot Step 1) Install ESP8266 Expansion Board on UNO R3 board:

sam415/ECE1570LAB/Lab 6.docx · Web viewEach lab will build upon the prior lab, and all labs are designed such that students will actively work together to complete and finish the

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: sam415/ECE1570LAB/Lab 6.docx · Web viewEach lab will build upon the prior lab, and all labs are designed such that students will actively work together to complete and finish the

ECE 1570: Robotics & Controls LaboratoryLab #6: Wireless Communications

Instructor: Sami Mian ([email protected])

1. Introduction

1.1. Instructions of the Lab

Welcome to ECE 1570: Robotics & Controls. Once you have formed your lab groups, your instructor will assign you to your lab station for the semester. Pitt email will be used to distribute relevant lab material throughout the course. Thus, it is the student’s responsibility to actively monitor their Pitt email throughout the semester.Each lab will build upon the prior lab, and all labs are designed such that students will actively work together to complete and finish the lab’s goals within the lab time. Therefore, missing a lab and/or showing up unprepared will not only cause individual problems, but will simultaneously denigrate the entire team’s ability to finish in the allotted time. So the moral of the story is: Don’t miss lab. All requests for make-up labs should be made to the instructor. Only in the event that the instructor is notified at least one week prior to the scheduled lab with a valid reason for missing lab, will a make-up lab be honored.

1.2. Purpose of the Lab

This lab will focus on enabling wireless communications for our robots. There are two parts of this lab. The first part will use the modules included in the robot kits to setup communications with individual phones. This can be done using WIFI or Bluetooth. The second part of the lab will connect the robot with a custom PCB controller using RF communications.

2. Adding Comms module to robot

Step 1) Install ESP8266 Expansion Board on UNO R3 board:

Page 2: sam415/ECE1570LAB/Lab 6.docx · Web viewEach lab will build upon the prior lab, and all labs are designed such that students will actively work together to complete and finish the

Step 2) Move every wire connected to digit ports(D2 to D13 , A1-A3)) in UNO R3 board to its counterpart digit pin in ESP8266 Expansion Board.

Page 3: sam415/ECE1570LAB/Lab 6.docx · Web viewEach lab will build upon the prior lab, and all labs are designed such that students will actively work together to complete and finish the
Page 4: sam415/ECE1570LAB/Lab 6.docx · Web viewEach lab will build upon the prior lab, and all labs are designed such that students will actively work together to complete and finish the

Note: If you want control the car through bluetooth, please install bluetooth module on ESP8266

Step 3) Turn the switch of esp8266 to “1.2” position, as following photo shows:

Step 4) Load the lesson 1 code form the website onto your arduino

Page 5: sam415/ECE1570LAB/Lab 6.docx · Web viewEach lab will build upon the prior lab, and all labs are designed such that students will actively work together to complete and finish the

Note: Bluetooth module and Arduino board communicate with each other through UART serial port. Please remove bluetooth module before uploading sketch in Arduino board, otherwise the sketch will be uploaded unsuccessfully.

Step 5) If you want use wifi to control the car, turn the switch of esp8266 to “on” position(as the following picture). If you want use Bluetooth control car, put switch in "1,2" position.

Step 6) Turn on switch in the battery box. If there car can make movement as described in Lesson 1 (go forward 5 seconds, then go backward 5 seconds, then left turn for 5 seconds, then right turn for 5 seconds, then stop), it means wire connection with ESP8266 Expansion Board and R3 UNO board are all correct. Otherwise please check each Digital Pin connection in ESP8266 Expansion Board and UNO R3.

Page 6: sam415/ECE1570LAB/Lab 6.docx · Web viewEach lab will build upon the prior lab, and all labs are designed such that students will actively work together to complete and finish the

3. Software setup for module

Step 1: Before upload code in esp8266, please turn the switch of esp8266 to “1.2” position, as shown before.

Step 2: Download the Lab 6 code and install it on the Arduino

Note: Bluetooth module and Arduino board communicate with each other through UART serial port. Please remove bluetooth module before uploading sketch in Arduino board, or the sketch will be uploaded unsuccessfully.

Step 3: Download the relevant app from the app store. For iPhone, search OSOYOO Robot; for Android, search “OSOYOO ARDUINO ROBOT CAR V1.0”

Step 4: If you want to control the robot car through Bluetooth, please put switch on esp8266 module in "1,2" position and turn on bluetooth of your Android phone which you have installed APP and scan bluetooth(different bluetooth module will scan different bluetooth name), Click connect and enter password "1234" or "0000" if no change (You can change wifi or bluetooth settings in Android phone to switch to control car through wifi or bluetooth):Step 5: There are three working mode: manual control, obstacle avoidance and tracking. Users can switch freely among three working mode.1) In manual control mode, you can click buttons (^) (V) (<) (>) to control the Robot car to move forward and backward, turn right and left. Meanwhile, the APP can observe the car real time movement.

2) Click "tracking" button of App to switch the current mode to tracking mode. The Robot car will move forward along the black line in white background. Meanwhile, the APP can observe the car real time movement. Press "||" button to stop moving and click other button to change Robot car working mode. To learn more about this mode, please review our lesson 4:

3) Click "Obstacle" button to switch the current mode to obstacle avoidance mode. The Robot car can be driven forward continuously and stopped and steered away once any obstacle in its way. Press "||" button to stop moving and then click other button to change Robot car working mode. To learn more about this mode, please review our lesson 3:

4. Setting up the PCB Controller

Instructions in separate document: PCB Controller

Page 7: sam415/ECE1570LAB/Lab 6.docx · Web viewEach lab will build upon the prior lab, and all labs are designed such that students will actively work together to complete and finish the

5. Software for the Remote Control

The example sketches provided use the RF24.ZIP library, so you need to install it before compiling.Click Add.ZIP Library to add the RF24.ZIP to the libraries folder. After the library is installed successfully, you can find the RF24.ZIP under Sketchbook location: on the window popped up by clicking Preferences.

After the preparations above, next we will upload the program (example sketches provided) tothe Arduino Nano Board and Adeept UNO R3 Boards. The car kit comprises of two parts: theremote control based on Arduino Nano Boardand the car controller on Adeept UNO R3 Board.First, upload the sketch to Arduino Nano Board. Open the file for the remote control, the fileAdeeptRemoteControl.ino.

Connect the Arduino Nano the computer. Select Tool -> Board: "Arduino Nano"-> Arduino Nano,and Port ->COM13. COMx is the port number assigned to the Arduino Nano and can be COM1,COM2, COM3...So it depends.

Now comes the fun part, you need to write code on the Arduino Uno on the robot to interface with the controller using the 2nd RF module. You can find an example for interfacing with the RF module at the following link:https://randomnerdtutorials.com/nrf24l01-2-4ghz-rf-transceiver-module-with-arduino/

6. Controller software for robot

Write control logic on the Arduino to enable the following functionality:Use the analog joysticks on the controller to drive the robot (tank drive or arcade drive)Use a button to enable the light sensorsUse a button to enable the ultrasonic sensor (1 for servo, 1 for sensor read)Use a button to create an autospin feature (spin in 180-360 degrees)