Difference between revisions of "S17: Sphero Droid"

From Embedded Systems Learning Academy
Jump to: navigation, search
(References Used)
(Hardware Design)
Line 358: Line 358:
  
 
[[File:CmpE244_S17_SpheroDroid_Bot_motors_hardware_design.JPG|center|500px|thumb|Internal Hardware connection (Motors)]]
 
[[File:CmpE244_S17_SpheroDroid_Bot_motors_hardware_design.JPG|center|500px|thumb|Internal Hardware connection (Motors)]]
 +
 +
==== GPS module ====
 +
 +
==== Bluetooth module ====
 +
 +
Bluetooth module HC-05 is used to communicate between the spherical robot and mobile application. It is implemented to establish the connection between the two so that we can remotely control the robot (to send start and stop signals) and receive the data from the robot directly on the Android application. The data being sent by the robot is current GPS location, ultrasonic range sensor values, and temperature sensor values
  
 
=== Hardware Interface ===
 
=== Hardware Interface ===

Revision as of 20:53, 25 May 2017

Grading Criteria

  • How well is Software & Hardware Design described?
  • How well can this report be used to reproduce this project?
  • Code Quality
  • Overall Report Quality:
    • Software Block Diagrams
    • Hardware Block Diagrams
      Schematic Quality
    • Quality of technical challenges and solutions adopted.

Sphero Droid

Sphero Droid


Abstract

Robots are revolutionizing almost every industry, primarily in the sectors where human safety is at risk. In hazardous working conditions such as in the mining industry, the lack of knowledge about the geographic nature and the environmental conditions of the mine hinder the rescue operations. Autonomous robots are being employed to improve the plight of mine workers and rescue operators. The robotic vehicle can explore the inaccessible and unworkable mines and disaster-affected areas and send valuable information to the teams to assist in search and rescue operations. But traditional robots could be rendered useless if they are overturned or in terrains having staircases and ledges. Also, there is a possibility of failure of the electrical and mechanical components exposed to the harsh environmental conditions. An autonomous spherical robot is a better option since its shape offers better robustness and rigidity. The spherical robot will enclose all the components within it and will not have any wheels or legs on its exterior. This feature enables it to operate in any hazardous conditions since there will be very less chance for the components to get damaged by the surrounding environment. The spherical design allows it to easily maneuver in different types of terrain, be it stairs or corners, and have no risk of being overturned. These advantages enable the robot for many applications such as exploration and mapping of access routes, surveillance and rescue operations in uncomfortable working conditions.

Objectives & Introduction

The objective of this project is to design an autonomous spherical robot with sensors, Global Positioning System (GPS) module, Bluetooth module and other control units interfaced to the microcontroller, which navigates its way exploring the path and avoiding obstacles. The temperature and the route followed by the robot can be logged on the SD card. These features enable the robot for many applications such as exploration and mapping of access routes, surveillance, and rescue operations in uncomfortable working conditions.

Sphero Droid front view
Sphero Droid side view
Sphero Droid Internal view

Team Members & Responsibilities

  • Harshitha Bura
    • GPS and Temperature Sensor
    • SDCard
    • Wiki page reporting
    • Code integration[Gps and Sdcard card tasks]
  • Naveen Kumar Bhuthakatanahalli Ramalingaiah
    • SDCard
    • Bluetooth module and Android Aplication
    • Hardware design and implementation
    • Code integration[Andriod task integration with overall tasks integration]
  • Shivam Chauhan
    • PCB Designing
    • Servo Motor
    • Ultrasonic Range Finders
    • Hardware design and implementation
    • Code integration[Overall tasks integration]
  • Sushma Nagaraj
    • Servo Motor
    • Ultrasonic Range Finders
    • Wiki page reporting
    • Code integration[Servo,DC motor and Sensor tasks]
  • Virginia Menezes
    • DC Motors
    • Wiki page reporting
    • Code integration[Servo and DC motor tasks]

Schedule

Week# Start Date End Date Task Status Actual Completion Date
1 3/21 3/27
  • Requirement analysis and team discussion to order parts.
  • Determine individual tasks and assigning work based on different modules in project
Done 3/29
2 3/28 4/3
  • Configure and interface the GPS module with the SJOne board
  • Configure and interface individual sensor with SJOne board
  • Interface motors with the SJOne board
  • Upload code on GitLab
Done 4/9
3 4/9 4/18
  • Designing PCB
  • Team discussions to integrate the design and work on the algorithm
  • Continue work on individual module (Sensors, motors, GPS) working with SJOne board
Done 4/21
4 4/18 4/25
  • Integrate the different modules
  • Build the sphere with bearings and enclose the components within it
Done 4/28
5 4/25 5/2
  • Test in different environments and fix bugs based on different issues
  • Team discussion on extra features that can be implemented
Done 5/7
6 5/2 5/9
  • Testing and Debugging
  • Work on extra features
  • Work on Project Report on Wiki
Done 5/16
7 5/9 5/20
  • Testing and Debugging
  • Project Presentation and update Wiki
Done 5/24
8 5/16 5/23
  • Complete Wiki Report and Final Demo
Done 5/25

Parts List & Cost

Qty Description Manufacturer Part Number Cost Links
1 SJ One Board [1] Preet SJ-one $80 http://www.socialledge.com/sjsu/index.php?title=SJ_One_Board
2 DC Motor RobotShop Pololu 4.5V, 80rpm Right Angle Plastic Gear Motor $4.95 http://www.robotshop.com/en/pololu-80rpm-right-angle-plastic-gear-motor.html
1 Servo Motor Fry's electronics Metal Gear Digital Servo Part No. LS-0009AF $19.99 http://www.frys.com/product/7027281
1 Motor Driver Fry's electronics Motor Driver $9.99 http://www.frys.com/product/8353697
1 GPS Logger Spark fun Electronics Venus638FLPx $59.95 https://www.sparkfun.com/products/10920
1 Bluetooth Module Amazon.com HC-05 Bluetooth $8.49 https://www.amazon.com/dp/B01G9KSAF6?psc=1
3 Ultrasonic sensor Amazon.com LV Maxsonar -EZ MB1010 $74.85 https://www.amazon.com/Maxbotix-MB1010-LV-MaxSonar-EZ1-Range-Finder/dp/B00A7YGVJI
1 Antenna GPS Embedded SMA Spark fun Electronics VTorch Datasheet $11.95 https://www.sparkfun.com/products/177
1 PCB components Amazon.com (7805, 2 pin SPDT switch, 4004 diode, LD1117, Female pin header, male pin header, USB type B female jack, DC power jack, power supply module) $72.00 https://www.amazon.com/gp/product/B01LRXIJRY/ref=oh_aui_detailpage_o03_s02?ie=UTF8&psc=1
2 Wheels Amazon.com 70 x 8mm Black Robot Wheels $12.00 https://www.amazon.com/gp/product/B00T3MQDHU/ref=oh_aui_detailpage_o08_s00?ie=UTF8&psc=1
2 Bearing Amazon.com 2 Pcs 22mm Outside Dia Plastic Coated Ball  $7.93 https://www.amazon.com/gp/product/B00HR5SJKE/ref=oh_aui_detailpage_o08_s01?ie=UTF8&psc=1
1 Hollow spherical ball Amazon.com Giant Chinchilla Run-About 11-1/2-Inch Exercise Ball $15.76 https://www.amazon.com/gp/product/B0006IK0LA/ref=oh_aui_detailpage_o00_s00?ie=UTF8&psc=1

Design and Implementation

System Block diagram

The Spherodroid contains ultrasonic, motors, GPS, Bluetooth as the main modules of communication. This is illustrated in the image below. Robot is controlled and navigated via a load which pulls it down and wheels which touch the ball from within. This will facilitate the ball movement.

Robot interface
Within the Robot

System State Diagram

The operation of SpheroDroid is divided into states as shown below. This mainly constitutes the start, operational and stop stages. The start is provided by Android application and the device moves forward. Different tasks will start when start condition is provided. The device will stop and when signalled from android application. The MCU will later send the GPS coordinate values which was written and restart when EOF is reached, moving to state one again.

State Diagram

Hardware Design

We have four distinct hardware modules used in this project:

  • Ultrasonic Range Finders (sensors)
  • Motors
  • GPS Module
  • Bluetooth Module

Ultrasonic Range Finders

Used MB1010 LV-MaxSonar-EZ21 Ultrasonic Rangefinder sonar sensors, which can from 6-inches to 254-inches, with 1-inch resolution. Any object from 0-inches to 6-inches is typically ranged as 6-inches. They are used in PW mode for outputting. For efficient working of sensors without any crosstalk, we have configured 3 sensors in the chaining mode called AN output commanded loop. This mode of configuration uses 5 pins of each sensor such as VCC = +5V, GND, TX, RX, and PWM. While triggering, the first sensor RX pin is held high for a time period > 20μs and < than 48ms.This will start the sensor chain. The first sensor will range, then trigger the second sensor to the range and so on for all the sensor in the array.

Mounting of the sensors is made on a curved platform such that the sensors are aimed with a positive slope and not horizontally. This decision is made in order to avoid interference with the ground due to the wide range of detection by the sensors.

MB1010 LV-MaxSonar-EZ21 Ultrasonic sensor
Sensor timing diagram
Sensor's mounting platform

Motors

  • DC Motors

The DC motors used in the project are 100 RPM low-cost single shaft straight geared motors. They are suitable for lightweight robots that do not require high power or torque.
The DC motors are connected to the wheels which are in contact with the base of the ball. The DC motors are driven by a driver module which controls the motor direction and speed.

Plastic geared motor
Driver module
Control inputs of driver module
  • Servo Motors

LS-0009AF Servo motor used is controlled by sending an electrical pulse of variable width or pulse width modulation (PWM), through the control wire. Maximum deflection which can be achieved by using this servo is 90°.The motor's neutral position is defined as the position where the servo has the same amount of potential rotation in the both the clockwise or counter-clockwise direction. The PWM sent to the motor determines the position of the shaft, and based on the duration of the pulse sent via the control wire; the rotor will turn to the desired position. The servo motor expects to see a pulse every 2000 microseconds and the length of the pulse will determine how far the motor turns. For example, a 1500microseconds pulse will make the motor turn to the 45° position. Shorter than 1500microseconds moves it in the counter-clockwise direction toward the 0° position, and any longer than 1500microseconds will turn the servo in a clockwise direction toward the 90° position.

Servo motor LS-0009AF
Servo motor dutycycle

The hardware implementation of how the DC motors are connected to the wheels which are driven from the SJOne board and how the servo motor is connected with the pendulum to steer the robot in right or left direction can be viewed in the figure below.

Internal Hardware connection (Motors)

GPS module

Bluetooth module

Bluetooth module HC-05 is used to communicate between the spherical robot and mobile application. It is implemented to establish the connection between the two so that we can remotely control the robot (to send start and stop signals) and receive the data from the robot directly on the Android application. The data being sent by the robot is current GPS location, ultrasonic range sensor values, and temperature sensor values

Hardware Interface

We have four major hardware modules interfaced with a single SJOne board using different communication protocols. For simplicity sake, we have given a description of how each module is individually interfaced with the SJOne board. In reality, all these modules are connected to a single SJOne microcontroller.

Ultrasonic Range Finders

The ultrasonic range finders have been interfaced with the SJOne board using PWM. To avoid the crosstalk between the sensors and to improve the efficiency, sensors are configured to work in chaining mode. In our project, the Right sensor is triggered first by holding the RX pin high for >20μs and < 48ms.This will start the sensor chain. The Right sensor will range, then trigger the Front sensor to the range which in turn trigger the last Left sensor.

Ultrasonic range finders interfacing with SJOne board via PWM
Sensor's chained triggering

Motors

The DC motor is connected with the SJOne board via the motor driver module using GPIO. The GPIO signals from SJOne board provide inputs to the motor driver module, which in turn drives the DC motors in forward or reverse direction or stop signal. Servo motor is interfaced with the SJOne board using PWM.

DC Motors and driver module connected to SJOne board using GPIO
Servo motors interface with SJOne board via PWM

GPS Module

GPS module communicates with SJOne board via UART. The antenna is connected to the SM connector of the GPS module. A 3.3v supply is given to the module and its Rx and Tx pins are connected to the Tx and Rx pins of the SJOne board respectively. UART 2 of the SJOne board is used for the GPS module and it is configured to run at a baud rate of 38400bps.

GPS interface with SJOne board via UART
Antenna for the GPS module

Bluetooth module

The Bluetooth HC-05 module is connected with the SJOne board via UART communication.The bluetooth module communicates using the Tx and Rx pins of HC-05. This device independently connects to any external bluetooth master device. The HC-05 can work as a Master or a Slave. For our application the device sends the GPS data from SD card and also receive data from Android Application. Since the device can be connected independently without the MCU it can be connected and used with MCU restarting and not affecting the connectivity. UART3 is used for serial communication. The Baud rate set is 9600 for communication between bluetooth device and Android Application.


Bluetooth connection with SJOne via UART
Bluetooth module HC-05
HC-05 Pin connections

Software Design

Ultrasonic Range Finder and Motors

The motors working depends on the input values of sensors (ultrasonic range finders). Depending on whether the sensors can detect an obstacle in its path, the motors continue to run in the forward direction or the servo motor steers the robot towards right or left. The diagrams below shows the algorithm of the logic behind it.

Sensors logic
DC and servo motor logic

GPS module

The configuration of the baud rate and message type of the GPS module is done using SkyTraq GPS Viewer software. The user interface of this software is shown in the picture below. Ther are three start modes which can be selected for the GPS.

GPS Viewer Software

Hot Start: This enables the GPS to obtain a fix in a very less time if it is connected to a 3.3v coin cell battery and it is switched on again within two hours after switching it off. Connecting the battery will help it to store information about the previous fix.

Warm Start: In this mode, it will take the GPS more time to obtain a fix compared to the hot start as the module has been switched off for more than hours. But as the battery is connected and the information of the previous fix is available it will take less time compared to the cold start.

Cold Start: As the battery is not connected and information about the previous fix is not available in this mode, it will take a lot of time to obtain a fix.

The message format can be binary message or NMEA. This format can be selected in the software. The binary message contains only latitude and longitude information. While transmitting data from the GPS module it can be done in only NMEA format. The NMEA message contains the time, latitude, longitude, information whether the data is valid or not, number of satellites in fix etc. The NMEA message looks as follows:

GGA - Global Positioning System Fix Data

$GPGGA,hhmmss.sss,ddmm.mmmm,a1,dddmm.mmmm,a2,V,xx,x.x,x.x,M,,,,xxxx*hh<CR><LF>

Time - hhmmss.sss

Latitude - ddmm.mmmm

Direction (a1) - N or S

Longitude- dddmm.mmmm

Direction (a2) - E or W

Validity - V - 0 or 1. 0 means invalid and 1 means valid.

After this data is received by the SJOne board, string manipulation is done to extract the latitude and longitude from the string (if the data is valid) and they are converted to decimal minutes so that they can be sent to an android application where they are plotted on a map.

Whenever data is received by the SJOne board from the GPS module, a UART interrupt occurs and the data is stored in a buffer. The data is checked if it is valid or not. If it is valid, the latitude and longitude are written to the SDCard. Otherwise, it is written that no GPS signal was available at that point. The flowchart is shown below.

Software Flow for the GPS

PCB Design

We have used EAGLE software to design the PCB layout. The PCB layout is the most crucial part of the project, it may make or break the performance and working of the circuit. The first step towards designing the PCB is including all the required components into the schematic workspace and making connections between them. Once the schematic is ready, next step is to create the board layout from the schematic, which is easy, since EAGLE links the layout file and schematic together automatically.


PCB Schematic


PCB layout


PCB board with components
PCB board connected to SJOne board

SD Card Writing

The data from the GPS, temperature sensor, accelerometer and ultrasonic range finders is continuously being logged onto an SDCard. The purpose of this is to send the data to a remote location once the robot's exploration is complete. In our case, we are reading the data from the SDCard and sending it to a mobile application. The mobile application will receive the latitude and longitude values and will plot a path on a map connecting the geographical locations the robot has visited. Screenshots of the data being logged are shown in the following figures. It can be observed that different GPS locations are being logged onto the SDCard as the robot travels.

GPS Location 1 and 2 written to SDCard
GPS Location 3 and 4 written to SDCard

Android Application

The Android Application development was divided into multiple stages:


1. Building the first App with interactive buttons

2. Communicating with Bluetooth module, hence tried and used many approaches.

3. Sending and Receiving data between Activities within Android App

4. Transmission and Reception of data from bluetooth device connected to SJ One board.

5. Plotting the data on Google Maps using google maps API.


Android App Icon
Permission to turn ON Bluetooth
Android App connected to Bluetooth
Kick start off from the Android App
GPS location values received from Sphero droid
GPS location on Google Map

Testing & Technical Challenges

1. Incorrect sensor values at different voltage levels - This was solved by providing stable IC output at 3.3V.

2. Unbalanced weight distribution and unstable platform - Because of unbalanced weight distribution, the sensors platform connected to the axle was unstable while running. This solved by changing the hardware positioning internally.

3. Abnormal restart of the microcontroller when motors begin - This was solved by providing sufficient power supply and running all modules on single voltage of 3.3V

4. Problem in steering the robot - This issue was solved by increasing the weight connected to the servo motor and the length of the pendulum.

5. Difficulty in finding the end of file while reading from the SD Card - A special character was used to while writing into the file to indicate the end of the file.

6. Unable to read corrupted SD card - On starting the robot, we first validate if the SD card is ready to communicate using sd_initialize(), and if not, then the robot will not respond to start from the application.

7. Initially, we had to dismantle the robot every time and remove the internal modules to restart the robot - We avoided this by using a volatile variable that is sent from the android application. The low priority task that runs will check if the variable has changed, and if changed then it will restart.

Conclusion

Conclude your project here. You can recap your testing and problems. You should address the "so what" part here to indicate what you ultimately learnt from this project. How has this project increased your knowledge?

Project Video

Upload a video of your project and post the link here.

Project Source Code

References

Acknowledgement

We would like to thank Prof. Preetpal Kang for encouraging us and guiding us throughout the semester. We are grateful to you for making this class such a valuable learning experience for us. We would also like to thank the ISA members who have been there to help us and for being approachable anytime.

References Used

[1] CMPE 244 Lecture notes from Preetpal Kang, Computer Engineering, San Jose State University. Jan-May 2017.
[2] Android & Java Forums(www.stackoverflow.com)
[3] Android References (Developer Android)
[4] MaxSonar datasheet
[5] Bluetooth Module HC-05
[6] GPS Visualizer
[7] A literature review on the design of spherical rolling robots by V. Crossley
[8] [2]