Difference between revisions of "F15: ThunderBird"

From Embedded Systems Learning Academy
Jump to: navigation, search
(Introduction)
(Introduction)
Line 17: Line 17:
 
Our Autonoumous self-driving car is designed in a way that it has five controllers to deal with different functions of the car and these controllers communicate through CAN bus, below is the description for various controllers.
 
Our Autonoumous self-driving car is designed in a way that it has five controllers to deal with different functions of the car and these controllers communicate through CAN bus, below is the description for various controllers.
  
* '''Bridge Controller''' : Bridge controller receives the start and stop, check points from the android application and it sends the start and stop messages over CAN bus in order to start and stop the car
+
* '''Bridge Controller''' : Bridge controller receives the start and stop, check points from the android application and it sends the start and stop messages over CAN bus in order to start and stop the car.
 +
* '''Motors and I/O Controller''' : Motor controller receives the steer and direction information from the master controller and navigates the car in required direction.
 +
* '''Sensors Controller''' : There are four sensors mounted on the car, three in front and one on rear, sensor controller update the motor with obstacle information by sending the updates from the sensors.
 +
* '''GPS Controller''' : GPS controller sends the updated direction and the distance to the destination.
 +
* '''Master Controller''' : Master controller collaborate the messages from Brdidge, sensor and GPS controllers and directs the motor in required direction.
  
 
=== Controllers ===
 
=== Controllers ===

Revision as of 06:20, 14 December 2015

ThunderBird : Self Driving Car

Abstract

ThunderBird is a 1/10 2 WD electric short self-driving truck. The truck is equipped with sensors to detect obstacles, GPS for getting directions, Compass for the truck's orientation, Bluetooth for communicating with the android device and LCD for displaying the sensor values on screen. The modules are interfaced using 5 SJ One boards which features a Cortex-M3 LPC1758. CAN bus is used for communicating between the modules. Android device is used to send start message and enter the destination coordinates through Bluetooth. Based on the GPS co-ordinates master directs the motor in respective direction and if the sensors detect obstacles, it signals the motors to drive the car accordingly. based on GPS co-ordinates and sensor values Master directs the motor until destination is reached

Objectives & Introduction

Objective

Objective of this project is to be able to work as a team of ten members to develop an Autonomous self driving Car. which gives us the real time work experience as the team of ten members has to be divided into subteams and work on individual modules(Sensors controller, Motor and I/O controller, GPS controller, Android controller and Master controller ) by collaborating with other sub team members for communication between the modules.

Main goal of this project is to understand how CAN protocol works and its architecture in detail, as all controllers of the system communicate through CAN bus.

Introduction

Our Autonoumous self-driving car is designed in a way that it has five controllers to deal with different functions of the car and these controllers communicate through CAN bus, below is the description for various controllers.

  • Bridge Controller : Bridge controller receives the start and stop, check points from the android application and it sends the start and stop messages over CAN bus in order to start and stop the car.
  • Motors and I/O Controller : Motor controller receives the steer and direction information from the master controller and navigates the car in required direction.
  • Sensors Controller : There are four sensors mounted on the car, three in front and one on rear, sensor controller update the motor with obstacle information by sending the updates from the sensors.
  • GPS Controller : GPS controller sends the updated direction and the distance to the destination.
  • Master Controller : Master controller collaborate the messages from Brdidge, sensor and GPS controllers and directs the motor in required direction.

Controllers

Team Members & Responsibilities

  • Master Controller and Android application
    • Sravani Aitha
    • Vishnu Vardhana Reddy Mandalapu
    • James Sushanth Anandraj
    • Athavan Kanagasabapathy
  • Motors and I/O
  • Sensors
  • GPS
    • Rishit Borad
    • Ravi Vanjara

Schedule

Team Schedule

Sl.No Start Date End Date Task Status Actual Completion Date
1 09/22/2015 09/29/2015 Order RC Car Completed 09/26/2015
2 09/30/2014 10/6/2015 Ordered components Completed 10/04/2015
3 10/07/2015 10/13/2015 Study about the modules and the RC car Completed 10/13/15
4 10/14/2015 10/20/2015 Test motors using PWM Completed 10/16/15
5 10/21/2015 10/28/2015 Interface sensor modules Completed 10/26/15
6 10/29/2015 11/05/2015 Interface GPS and compass
7 11/12/2015 11/19/2015 Interface LCD Completed 11/28/15
8 11/20/2015 11/27/2015 Interface modules over CAN bus
9 11/28/2015 12/05/2015 Integrating modules
10 12/6/2015 12/13/2015 Testing
11 12/14/2015 12/19/2015 More Testing

Motor and I/O Schedule

Sl. No Start Date End Date Task Status Actual Completion Date
1 10/6/2015 10/13/2015 Determining the ESC initialization sequence Completed 10/11/15
2 10/13/2015 10/20/2015 Testing the Servo and DC motor using SJ One board PWM's Completed 10/16/2015
3 10/20/2015 10/27/2015 Design motor control using messages from the CAN bus Completed 10/27/15
4 10/27/2015 11/3/2015 Implement code to accept messages from other modules over CAN bus and display it on the LCD Completed 11/28/15
5 11/3/2015 11/10/2015 Update motor speeds on the LCD in real time Completed 11/28/15
6 11/10/2015 11/17/2015 Interface I/O and motor modules with master controller and establish communication Completed 11/28/15
7 11/17/2015 11/24/2015 Fine turning motors for precise control
8 11/24/2015 12/01/2015 Fine tuning (buffer)
9 12/01/2015 12/08/2015 Testing and debugging

Geographical Position Controller Schedule

Sl. No Start Date End Date Task Status Actual Completion Date
1 10/6/2015 10/13/2015 Research & order GPS module Completed 10/8/2015
2 10/13/2015 10/20/2015 Interface GPS using I2C with SJOne board Ongoing
3 10/20/2015 10/27/2015 Interface Compass with SJOne board
4 10/27/2015 11/3/2015 Calibrate Compass and GPS
5 11/3/2015 11/10/2015 Parse raw data and create meaningful data
6 11/10/2015 11/17/2015 Implement CAN communication with SJOne board
7 11/17/2015 11/24/2015 Test and debug GPS & Compass locally
8 11/24/2015 12/01/2015 Integrate GPS/Compass module with Master board
9 12/01/2015 12/08/2015 Implement routing algorithm for Car
10 12/08/2015 12/15/2015 Test and Debug GPS/Compass integration with master

Sensor Controller Schedule

Sl. No Start Date End Date Task Status Actual Completion Date
1 10/5/2015 10/11/2015 Finalize and order the sensors Completed 10/11/2015
2 10/12/2015 10/18/2015 Wire the sensors and write a sample test code to check the sensors. Completed 10/18/2015
3 10/19/2015 11/01/2015 Transfer the sensor data to master controller via can bus. Completed 10/31/2015
4 11/2/2015 11/9/2015 Implement and integrate the code for all the sensors. Completed 11/15/2015
5 11/2/2015 11/15/2015 Test and Debug the integrated module. Completed 10/15/2015
6 11/16/2015 11/29/2015 Collaborate with the other module teams to make sure that the sensors are in working condition. Completed 11/30/2015
7 11/30/2015 12/06/2015 Test for stability of sensors and report. Ongoing
8 12/07/2015 12/13/2015 Prepare for Demo.

Master controller and android controller Schedule

Sl. No Start Date End Date Task Status Actual Completion Date
1 10/6/2015 10/13/2015 Car purchase ,dismantle and setup for project Completed 10/8/2015
2 10/13/2015 10/20/2015 Can setup components purchase, Can bus design and soldering Ongoing
3 10/20/2015 10/27/2015 Basic Can communication testing by sending and receiving data and can msg specification for all controllers and messages.
4 10/27/2015 11/3/2015 Development and implementation of Algorithm for driving car and obstacle avoidance.
5 11/3/2015 11/10/2015 Interface bt dongle with sjone board and android device and test with commands
6 11/10/2015 11/17/2015 Develop Android GUI and application to interact with car using bluetooth. Implement all necessary commands on sjone board for communication with android device. Interface with Motor and IO Controller.
7 11/17/2015 11/24/2015 Test and debug Master algorithm and Android interface locally and with Motor controller interfaced by providing predetermined directional commands.
8 11/24/2015 12/01/2015 Integrate Master Board with all boards and implement heartbeat protocol.
9 12/01/2015 12/08/2015 Test run 1 with all boards integrated and with all planned features developed.
10 12/08/2015 12/15/2015 Test run 2 after solving issues found in test run 1.

Parts List & Cost

S.R. Description Manufacturer Part Number Qty Total Cost
1 SJOne Board - - 5 $400.00
2 RC Car Furry Arrma - 2 Wheel Drive - 1/10 - 1 $185.00
3 Ultrasonic Sensor LV-MaxSonar - EZ1 MB1010 5 $140.00
4 1.8 Color TFT LCD display with MicroSD Card Breakout Adafruit ST7735R 1 $19.95
5 SparkFun Venus GPS with SMA Connector Sparkfun GPS-11058 1 $49.95
6 Triple-axis Magnetometer (Compass) Board Adafruit HMC5883L 1 $9.95
7 CAN Transceiver (Free Samples) Microchip MCP2551 6 $0.00
Total (Including Shipping and Taxes ----

Design & Implementation

CAN 11-bit ID Format

MSG DST SRC
5 bits (11-6) 3 bits (5-3) 3 bits (2-0)

Controller ID Table

Controller ID Controller Type
0x000 All Controller
0x001 Master Controller
0x010 Motor Controller
0x011 GPS
0x100 Sensor
0x101 I/O Controller
0x110 Android Controller

Controller Communication Table

Message ID Destination ID Source ID CAN ID Message function Message Data From Receieved By
0x00000 0x000 0x000 0x000 Kill NoData Master All
0x00001 0x001 0x110 0x04E Android stop NoData Android Bridge Master
0x00010 0x001 0x110 0x08E Android start NoData Android Bridge Master
0x00011 0x001 0x100 0x0CC Sensor data Byte[0]: Left sensor
Byte[1]: Front sensor
Byte[2]: Right sensor
Byte[3]: Rear sensor
Byte[4]: Speed
Sensors Master
0x00100 0x011 0x001 0x119 Current position request NoData Master GPS
0x00101 0x001 0x011 0x14B Geo direction Byte[0]: Current Angle
Byte[1]: Desired Angle
GPS Master
0x00110 0x001 0x011 0x18B Geo data Byte[0]: Latitude1
Byte[1]: Latitude2
Byte[2]: Longitude1
Byte[3]: Longitude2
Byte[4]: Distance to next checkpoint
Byte[5]: Checkpoint reached?
GPS Master
0x00111 0x010 0x001 0x1D1 Motor Command Byte[0] Forward : 0
Byte[0] Left : 1
Byte[0] Right : 2
Byte[0] Reverse : 3
Byte[0] Stop : 4
Master I/O & Motor
0x01000 0x101 0x001 0x229 Display Start NoData Master I/O & Motor
0x01001 0x101 0x001 0x269 Display data Byte[0]: Speed
Byte[1]: Distance to next checkpoint
Master I/O & Motor

Hardware Design

Discuss your hardware design here. Show detailed schematics, and the interface here.

Hardware Interface

In this section, you can describe how your hardware communicates, such as which BUSes used. You can discuss your driver implementation here, such that the Software Design section is isolated to talk about high level workings rather than inner working of your project.

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.

Sensor Controller

Fig 1. LV-EZ Ultrasonic Range Finder


Fig 2. sonarback


We have used four Maxbotix LV-EZ Ultrasonic Range Finder sensors (MB1010), three for front (left, right, mid) and one for the rear. These ultrasonic sensors are used to detect the obstacle which our car can encounter on its route. These sensors are connected to the SJOne board and the CAN bus and can work on 3.3V-5.0V.

The pin configuration for the sensor is as follows:
1) Pin 2-PW: This pin outputs a pulse width representation of range. The distance can be calculated using the scale factor of 147uS per inch.
2) Pin 4-RX: This pin is internally pulled high. The LV-MaxSonar-EZ will continually measure range and output if RX data is left unconnected or held high. If held low the sensor will stop ranging. Bring high for 20uS or more to command a range reading.
3) Pin 6-+5V: Vcc – Operates on 2.5V - 5.5V. Recommended current capability of 3mA for 5V, and 2mA for 3V.
4) Pin 7-GND: Return for the DC power supply. GND (& Vcc) must be ripple and noise free for best operation.

Sensor Hardware Design


Fig 3. Board-Block-Diagram


250mS after power-up, the LV-MaxSonar-EZ is ready to accept the RX command. If the RX pin is left open or held high, the sensor will first run a calibration cycle (49mS), and then it will take a range reading (49mS). After the power up delay, the first reading will take an additional ~100mS. Subsequent readings will take 49mS. The LV-MaxSonar-EZ checks the RX pin at the end of every cycle. Range data can be acquired once every 49mS.

Each 49mS period starts by the RX being high or open, after which the LV-MaxSonar-EZ sends the transmit burst, after which the pulse width pin (PW) is set high. When a target is detected the PW pin is pulled low. The PW pin is high for up to 37.5mS if no target is detected. The remainder of the 49mS time (less 4.7mS) is spent adjusting the analog voltage to the correct level. When a long distance is measured immediately after a short distance reading, the analog voltage may not reach the exact level within one read cycle. During the last 4.7mS, the serial data is sent.

Sensor Software Design and Algorithm

The following steps are for initializing, getting readings and calculating distance in inches for one sensor-

1) Configure the PW pin of sensor as input.

2) Configure RX pin of the sensor as output and set it high.

3) Enable the Rising and the Falling edge interrupt on the PW pin of the sensor

4) Note down the sys_get_uptime_us() at the rising interrupt. Let this time be T1.

5) Note down the sys_get_uptime_us() again when the falling edge is encountered. Let this time be T2.

6) To calculate the distance in inches, do - (T2-T1)/147.

7) Send this value to the Master controller via the CAN bus.

This is the snippet of our Interrupt function callbacks.

eint3_enable_port2(RightSensorPW_Pin, eint_rising_edge, eintCallbackright_Rise);
eint3_enable_port2(RightSensorPW_Pin, eint_falling_edge, eintCallbackright_Fall);


Fig 4. Sensor State Diagram
Fig 5. Sensor Flow chart


Sensor: Technical Challenges


1) Fluctuating sensor values: We observed random shoots in the sensor values. Sometimes, the value was even zero.

2) The beams from two adjacent sensors collided with one another.

3) The sensor when mounted on the car detected ground as obstacle

4) The sensors did not work on independent 5V supply.

5) The sensors (Left and Right sensor) gave faulty values when placed at 45 degrees on the corner of the base board.

Motor and I/O Controllers

ThunderBird is a 2 WD truck. It is equipped with a ARRMA BLX brushless DC motor connected to an BLX80 ESC(Electronic Speed Control). The ESC drives the DC motor according to the PWM(Pulse Width Modulation) signal. The truck's front wheels are connected to a waterproof ADS-7M Metal Geared Steering Servo. The servo and the DC motor are controlled using the PWM pins of the SJOne board.

Motors

Pulse Width Modulation - Controlling DC motor

Fig 1. Initializing pwm signal
Fig 2. Forward pwm signal
Fig 3. Reverse pwm signal
Fig 4. Servo pwm signal

Pulse width modulation is a technique which is used to encode the analog signal into a pulsating signal. The signal is represented as a series of pulses. This signal can be easily generated using the pwm pins of the SJOne board. The ESC is initialized upon passing a PWM signal which is sent by the RF module on the truck. The type of signal is observed by hooking the PWM pin to the digital oscilloscope. The initialization signal is shown in figure 1. A resolution of 1ms is set on the oscilloscope. The PWM signal has a width of 1.5 ms. This signal initializes the ESC. Once the ESC's are initialized, the motors require a signal to accelerate and decelerate. The type of signals for moving the motor forward and backward are realized by hooking the output pin of the RF module to the digital oscilloscope. The forward and backward pwm signals at full throttle are shown in figures 2 and 3 respectively. The respective pwm signal pulses for moving the motors forward and backward are shown below.

  • Acceleration PWM signal
    • Forward full throttle - 2 ms
    • Forward medium throttle - 1.8 ms
    • Neutral - 1.5 ms
  • Reverse PWM signal
    • Reverse full throttle - 1 ms
    • Reverse medium throttle - 1.2 ms
    • Neutral - 1.5 ms


PWM Calculations

The PWM value to be set is determined from these calculations:

  • PWM is a percentage of the signal frequency
  • The signal is of 50 Hz i.e. 20 ms duration
  • A 10% of the signal value gives a duration of 2 ms - 10/100 * 20 = 2 ms

The respective percentages for all the signal were calculated and the PWM signals were generated using the PWM.set function. The generated pulses from the SJOne PWM pin is passed to the ESC for initialization and controlling the DC motor. The ESC has 3 connections - Vcc, GND and PWM. SJOne board's GND and PWM are connected to the ESC. The Vcc is supplied from the battery pack.

A sample code demonstrating the PWM signals is written and the motors were controlled using the on-board SJOne switches.

DC motor demo


Controlling Servo motor

The servo motor channel in the RF module is hooked to the digital oscilloscope to determine the initial sequence. It is observed that when the RF transmitter is switched on, the RC remote sends a pwm signal which resets the servo to its starting position. This PWM signal re-centers the truck's wheels. The signal is realized by hooking the data pin from the first channel of the RF module to the digital oscilloscope. The PWM signal is shown in figure 4. The signal is having a pulse of 1.6 ms. The steering on the RC is moved left and right to determine the PWM signals. The signal values were noted from the oscilloscope. The values are tabulated below.

  • Steering PWM signal
    • Steer full right - 2 ms
    • Steer full left - 1 ms
    • Steer center - 1.6 ms

A PWM signal having a pulse width between 1.6 ms to 2 ms is used to control the steering towards right precisely. Similarly, a PWM signal having a pulse width between 1 ms to 1.6 ms is used to control the steering towards left precisely. The servo has 3 connections - Vcc, GND and PWM. The servo motor is not connected to a ESC. It doesn't get any voltage if it is not connected to the RF module. The servo motor operates at 6V. For testing, the Vcc of the servo motor is connected to the RF module. The GND from the RF module is made common with the GND from SJOne board. The PWN signal is given as an input from the SJOne board. The PWM signal values were calculated using the procedure shown above. The respective PWM signals were then sent to the servo motor using the PWM pin on the SJOne board for steering the truck.

The on-board switches on the SJOne board are used to steer the truck left and right. A sample code demonstrating this functionality is written and tested.

Servo motor demo

I/O

Liquid Crystal Display

Fig 5.LCD, Driver and SJOne interface
Fig 6.LCD displaying the values

A 20x4 LCD(CM 204-1) is used for displaying the speed, sensor values and the start and end coordinates. A LCD driver by SJValley Engineering is used for accessing the LCD through UART. The driver and LCD are soldered on to the prototype board. A USB jack is soldered on-board to power the LCD using the 5V supply from the external battery. The connections between the driver and SJOne board is shown in figure 5. As soon as the LCD is powered on, it displays to enter 0xF0 which is the command for detecting the baud rate. After 0xF0 is sent, the data can be transmitted using UART. A baud rate of 38400 is used for displaying information on the LCD. If you are getting some junk values, make sure that the baud rate is set correct and check the soldering.

The LCD with displaying the values is shown in figure 6. The following helps you to organize information on your LCD.

  • Commands for displaying information on LCD
    • urt.put displays a character on the LCD
    • urt.putlin displays a character on the LCD and moves the cursor to the next line
    • $CLR_SCR is used to clear the screen


Common Problems and troubleshooting

1. LCD is displaying only 2 lines, line 1 and line 3 when i power it on.

A. Check the connections. Make sure that the LCD is properly soldered to the driver.


2. I am getting garbage values printed on the screen when i try to transfer information over UART

A. LCD is not initialized properly. Make sure you get the detecting baudrate information displayed on screen when the LCD is powered on.


3. Is it okay to program the LCD while being connected to the SJOne board?

A. I didn't find any issues while programming the SJOne board with the LCD connected to it. However, some teams had issues with it.


4. How do i update a single field on the LCD keeping the rest static?

A. I cleared the entire screen every 100 ms and it looked like only the values are being updated!

GPS Controller

Geographical controller module plays an important role in heading and positioning of autonomous car.It consists of 20GHZ GPS module and 9-DOF RAZOR IMU interfaced to SJ-one board.

The GPS module provides Latitude and Longitude co-ordinates for current position of car.The 9DOF Razor IMU incorporates three sensors - an ITG-3200 (MEMS triple-axis gyro), ADXL345 (triple-axis accelerometer), and HMC5883L (triple-axis magnetometer) - to give you nine degrees of inertial measurement.

SPARKFUN VENUS GPS with SMA CONNECTOR

Master Controller

Bluetooth Control and Android application

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:

My Issue #1

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.