S19: Zeus
Contents
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.
Project Title
Zeus : The Autonomous Car
Abstract
When over a century ago Karl Benz invented the first car, it came as a miracle to people. Now, Almost every household owns a car. The industry has come from a 20 Horse power producing 2.9 liter Ford Model T (1908) to a massive 1500 Horsepower 5 liter Koenigsegg Regera (2018). And as such, further developments into the driving industry are bound to come. One such major field is the realm of Driverless smart cars. This project focuses on developing a driverless smart car(model) that is capable of going from one place to the destination without any manual input, avoiding obstacles along the way.
Objectives & Introduction
Zeus revolves around several SJone boards that have LPC 1758 at the center......(continue here). Following are the objectives of this project.:
- Zeus should successfully navigate from a fixed starting point to a fixed destination based on GPS.
- Obstacles on the way should be avoided.
- Code should be 100% Unit-Tested
- Communication should be established between Zeus and a mobile phone through an APP.
Team Members & Responsibilities
- Aman Chandan
- Material/ Components manager
- GEO module
- Artik Shetty
- Motor Module
- PCB
- Himanshu Gunjal
- Master Module
- BLE Module
- Karan Daryani
- Car Layout Designer
- Motor Module
- PCB
- Namdev Prabhugaonkar
- GEO module
- PCB
- Neel Patel
- Team Lead
- Master Module
- Android App
- BLE Module
- Oliver Zhu
- GIT repository Manager
- Sensor Module
- Wendy Chao
- Sensor Module
Schedule
Week# | Date | Task | Activities | Status | Completion Date |
---|---|---|---|---|---|
1 | 02/12/19 |
|
|
|
|
2 | 02/19/19 |
|
|
|
|
3 | 02/26/19 |
|
|
|
|
4 | 03/05/19 |
|
|
|
|
5 | 03/12/19 |
|
|
|
|
6 | 03/19/19 |
|
|
|
|
7 | 03/26/19 |
|
|
|
|
8 | 04/02/19 |
|
|
|
|
9 | 04/09/19 |
|
|
|
|
10 | 04/16/19 |
|
|
|
|
11 | 04/23/19 |
|
|
|
|
12 | 04/30/19 |
|
|
|
|
13 | 05/07/19 |
|
|
|
|
14 | 05/14/19 |
|
|
|
|
15 | 05/22/19 |
|
|
|
|
Parts List & Cost
Item# | Part Description | Vendor | Qty | Cost $ |
---|---|---|---|---|
1 | RC Car | Sheldon's Hobby Store | 1 | 180.00 |
2 | SJOne board | Preet | 5 | 400.00 |
3 | GPS Module | 1 | ||
4 | Lipo Battery (7200 mAh) | Amazon | 1 | 37.99 |
5 | DB9 Connector | Amazon | 1 | 6.50 |
6 | LIPO Battery Charger | Sheldon's Hobby Store | 1 | 39.99 |
7 | Ultrasonic sensor | Robotshop | 4 | 99.80 |
8 | PCB | |||
9 | CAN Transceiver | Amazon | 5 | 49.95 |
10 | LCD Display | Obtained From Preet | 1 | Free |
11 | Xbee | Obtained From Preet | 1 | Free |
12 | Adapter for Lipo Charger | Amazon | 1 | 15.84 |
Design & Implementation
The design section can go over your hardware and software design. Organize this section using sub-sections that go over your design and implementation.
Motor Module
Motor module is one of the five controllers used in our self-driving car. Motor controller is responsible for driving the car forward and for steering the vehicle. The motor module has two motors viz.DC motor and Servo motor. DC motor makes the car move forward and reverse. Servo motor steers the car either left or right. Along with the two motors, we have the rpm speed sensor which is interfaced with our controller to control the speed of DC and move the car at the desired speed in meters per second (m/s).
Hardware Design
The Motor Module consists of 2 motors viz. DC motor and Servo motor controlled by an SJOne board by varying the PWM signals, which is nothing but the duty cycle. PWM stands for pulse-width modulation, a type of digital signal and can be used to control the motors. Along with two motors, we have interfaced the RPM sensor with the motor module micro-controller to get the wheel feedback and move our car at a constant speed even if the car is going uphill or downhill.
Hardware Interface
Servo Motor
RC car came with a digital servo motor, requiring around 3-5V. The motor is directly controlled by giving a varying PWM signal from the SJOne board. Servo motor is used to convert an electrical signal into a linear motion. As per the PWM pulse received by the servo motor from SJOne board, it will rotate its shaft by a certain degree left or right. Below table gives the PWM values given to the motor for turning the car in the desired direction.
No. | PWM | Direction |
---|---|---|
1 | 5 | Full Left |
2 | 6 | Slight Left |
4 | 7 | Straight |
6 | 8 | Slight Right |
7 | 9 | Full Right |
DC Motor
Like servo motor, the DC motor was also embedded in the RC car. The DC motor is used to convert an electrical signal into mechanical power. DC motor is controlled in the same manner as the servo motor i.e., by varying the PWM signal. The only difference here is that the PWM signal from the SJOne board is given to an Electronic Speed Controller or ESC. The ESC is used to generate three-phase electric power of low voltage in order to vary the speed of the DC motor. In case of no ESC, the DC motor will either not move or will start moving at full throttle. The RC car DC motor required 7.4V of power supply to work. The maximum speed that can be attained by this DC motor is 31mph.
Software Design
Testing & Technical Challenges
Following were the problems faced and their resolutions:
Problem 1: In spite of controlling speed using RPM sensor, the car was not in control while on a downhill.
Solution 1: After trying all possible solutions we could think of, we applied a brake momentarily at the start to reduce the sudden increase in PWM and then controlled the car based on the inclination. Also, made sure that if PWM value went below a certain range, then no brake was applied to the car.
Problem 2: The car did not go reverse all of a sudden even with the working code.
Solution 2: When checked with the transmitter/remote, still didn't work. It was found by reading the manual that ESC has 3 modes which can be set by long pressing the power button. And accidentally, ESC was changed to mode 2 where reverse wouldn't work. The car was set back to Mode 1.
Sensors Controller
Group Member
Oliver Zhu, Wen Yuen Chao
Hardware Design
In this project, the sensor we use is LV-MAXSonar-EZ4, which is ultrasonic sensor. There are three sensors put in the front of our RC car and detect the left, middle and right side independently.
Hardware Interface
There are seven pins in this sensor.
Pin Name | Function | Purpose |
---|---|---|
Pin 1 | BW | Leave open |
Pin 2 | PW | Pulse width |
Pin 3 | AN | Analog voltage |
Pin 4 | RX | Receive |
Pin 5 | TX | Transmit |
Pin 6 | +5V | Vcc |
Pin 6 | GND | Ground |
Software Design
Show your software design. For example, if you are designing an MP3 Player, show the tasks that you are using, and what they are doing at a high level. Do not show the details of the code. For example, do not show exact code, but you may show psuedocode and fragments of code. Keep in mind that you are showing DESIGN of your software, not the inner workings of it.
Implementation
This section includes implementation, but again, not the details, just the high level. For example, you can list the steps it takes to communicate over a sensor, or the steps needed to write a page of memory onto SPI Flash. You can include sub-sections for each of your component implementation.
Android Application and Bridge
Group Members
Design
The bridge controller is responsible for establishing communication between the CAR and an Android Phone. This communication is achieved using Bluetooth technology and HC-05 bluetooth transceiver. The android app "ZeusApp" sends Co-ordinates as well as Start/Stop command to the car. Once the bridge ECU receives this data over UART, it transmits it to corresponding controllers using CAN bus. The HC-05 module communicates with SJONE over UART at 9600bps baud rate. The overall architecture of the system is given below:
Pin Configuration:
Sl. No | Pin on SJOne Board | Pin on HC-05 | Purpose |
---|---|---|---|
1 | TXD3 | RXD | Transmit using UART3(TXD3) to HC-05 |
2 | RXD3 | TXD | Receive using UART3(RXD3) from HC-05 |
3 | 3V3 | VCC | 3.3V voltage supply |
4 | GND | GND | Ground |
Bluetooth Hardware Design
We decided to go with HC-05 as our bluetooth module HC-05 because of the vast amount of information on it on the internet. It is basically a plug and play module which makes the work very convenient. Given below are features of HC-05:
- -80dBm sensitivity
- Up to +4dBm transmit power
- Low Power operation
- UART interface with programmable baud rate.
- Integrated Antenna and edge connector.
- Supported Baud Rate: 9600,19200,38400,57600,115200,230400,460800.
- Auto-connect to the last device on power as default.
- Auto-pairing PINCODE:”0000” as default
- Auto-reconnect in 30 min when disconnected as a result of beyond the range of connection.
Bluetooth Software Design
The BLE ECU is responsible for receiving data over UART and then Packaging it in correct message format and sending it over the can bus. To achieve this a few messages were made in the DBC file. The Message IDs and info is given in the table below:
Sl. No | Message ID | Message name | Purpose |
---|---|---|---|
1 | 181 | APP_DATA | Sends 2 bit start OR stop command |
2 | 182 | APP_DATA_LAT_LONG | Send Destination Latitude and Longitude to the ECU. |
Our BLE is ECU is pretty simple and has one function as its core operation. This Function is given below.
void parse_data() { char coord[100]={0}; getstring(coord,100,0); if(coord[0]==1) { printf("\nStart"); BLE_data.START_CAR=1; c_LED_display_set_number(1); memset(coord,0,sizeof(coord)); } else if(coord[0]==2) { printf("\nStop"); BLE_data.START_CAR=2; c_LED_display_set_number(0); memset(coord,0,sizeof(coord)); } else if(strlen(coord)) { while(coord[i] != ',') { Latitude[i]=coord[i]; i++; } Latitude[i]='\0'; i++; while(coord[i] != '@' ) { Longitude[j]=coord[i]; i++; j++; } Longitude[j]='\0'; i=0; j=0; float LAT1=atof(Latitude); float LON1=atof(Longitude); printf("\nLatitude: %.15f",LAT1); printf("\nLongitude: %.15f",LON1); gps_destination.DEST_LAT=LAT1; gps_destination.DEST_LONG=LON1; } dbc_encode_and_send_APP_DATA(&BLE_data); dbc_encode_and_send_APP_DATA_LAT_LONG(&gps_destination); }
As seen in the code above, there are two DBC structures that are made, BLE_data to send start/stop command and gps_destination to send the destination co-ordinates. The android app sends a string over bluetooth to HC-05 which passes it on to SJone over UART. By parsing this string we can figure out which command was received from the App. If the 1st character of string is '1' the its a START command, if its '2' the it is STOP command and otherwise it parses the string to find Coordinates. Through the app i am sending coordinates in the format of LATITUDE,LONGITUDE so, in parse_data() function, two global character arrays were accessed. Until the iterator reaches the comma it puts everything in the Latitude array and after the till the end of string it puts everything in the Longitude array. Library function atof() was used to convert the character array to float to be able to send it over CAN.
The function parse_data() is periodically called at 1hz (so every one second). This means that the UART data is parsed and a can message is sent every second.
Android Application Design
Implementation
The main purpose of the android application is to provide the user with a way to interact with the Car using a smartphone. This app was built using Android Studio developed by Google and Jetbrains. You have the option of writing the code in either Java or Kotlin. For ZeusApp we decided to go with Java. One of the most important features that needed to be integrated into the app was Google Maps to show current position and the destination coordinates. A Google Maps API key is required to integrate Maps withing the application. This key can be acquired through the Google Developers Console. This key is mainly used to track activity of the app. Google uses the tracking to figure out charges (if any). Since our app is not a public app it doesnt cost anything for us. There are two main activities that form the app.
1. StartScreen.java is the first page that the user is greeted with its a basic home page that allows the user to go to the Map where he/she can interact with the car.
2. MapDemoActivity.java is the main activity where all the important work happens. This is the page which displays Google map fragment and all the controls associated with the car. The map fragment loads and updates the users location which he/she can see by clicking the recenter button. A pin can be dropped on the map by just touching the desired location on it. This activity also lets user connect to HC-05 bluetooth transceiver by simply clicking the Connect button. Once the app is connected to the car, user can then start the car using START button and similarly stop it using the STOP button. After marking the destination there is a button that lets the user send coordinates in the form of LATITUDE, LONGITUDE to the car.
Bluetooth - Android Side
The MapDemoActivity.java , besides UI for map. has one more integral purpose. It establishes a socket communication between the smartphone and HC-05 transceiver. For this a few things need to be done.
1. We need to specify certain permission in the AndroidManifest.xml. These permissions are given below
<uses-permission android:name="android.permission.BLUETOOTH" /> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
2. Import the following libraries
import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothSocket; import android.content.BroadcastReceiver; import java.io.InputStream; import java.io.OutputStream;
This lets us define variables that are needed for establishing communication over bluetooth. Input and Output stream classes lets us make buffers to write data to and read data from.
3. For basic communication we need need three things a Bluetooth Device, Bluetooth Adapter and a Bluetooth Socket. These are declared as follows:
BluetoothSocket mBTsocket = null; BluetoothDevice BoardSJONE = null; BluetoothAdapter ZeusAdapter;
Bluetooth adapter lets you represent local device(smartphone) bluetooth adapter and lets you perform bluetooth tasks such as device query, instantiate a BluetoothDevice using MAC ID or UUID and create a socket. The Bluetooth adapter itself can be initialized as follows:
ZeusAdapter = BluetoothAdapter.getDefaultAdapter();
For this app we have initialized the adapter int the onStart function. This funtion is called when the activity becomes visible to the User, so, before anything can be done BluetoothAdapter is initialized.
4. Once the Adapter has been initialized and the device has been paired we now need to establish RF communication between the phone and HC-05. For that we use BluetoothSocket as below.
mBTsocket = BoardSJONE.createInsecureRfcommSocketToServiceRecord(BTMODULEUUID); mBTsocket.connect(); pairedDevice = BoardSJONE;
Here, BTMODULEUUID is the Universallu Unique Identifier which is a 128 bit ID of the smartphone. Now the Socket connection has been established.
5. For sending data, Output Stream can be used.
tOUTPUT = mBTsocket.getOutputStream(); tOUTPUT.write(string.getBytes()); tOUTPUT.flush();
The parameters inside write() function is the data you want to send over bluetooth. A coordinate string in our case.
Testing & Technical Challenges
Describe the challenges of your project. What advise would you give yourself or someone else if your project can be started from scratch again? Make a smooth transition to testing section and described what it took to test your project.
Include sub-sections that list out a problem and solution, such as:
<Bug/issue name>
Discuss the issue and resolution.
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
Any acknowledgement that you may wish to provide can be included here.
References Used
List any references used in project.
Appendix
You can list the references you used.