Difference between revisions of "F15: Fury"
(→Testing & Technical Challenges) |
(→Testing & Technical Challenges) |
||
Line 1,070: | Line 1,070: | ||
=== Testing & Technical Challenges === | === Testing & Technical Challenges === | ||
− | [[File:F15_Fury_GEO_Controller_10Hz_update.png| | + | [[File:F15_Fury_GEO_Controller_10Hz_update.png|270px|left|thumb|During 10Hz update of GPS]] |
− | [[File:F15_Fury_GEO_Controller_5Hz_update.png| | + | [[File:F15_Fury_GEO_Controller_5Hz_update.png|270px|right|thumb|During 5Hz update of GPS]] |
'''For Debug purpose:''' | '''For Debug purpose:''' | ||
Revision as of 05:31, 19 December 2015
Contents
Project Title
Fury a self driving RC car
Abstract
This project implements a self-driving car with the ability to have programmable routes and do obstacle avoidance. Programmable routes are implemented through an Android application, while precise motion to a programmed destination is implemented by using an electronic compass and GPS. Also, the self-driving car provides an RPM speed controlled motor for constant speed in different terrains as well as a master controller with obstacle avoidance algorithms and steering control to direct the car to its final destination.
Schedule
Sl. No | Start Date | End Date | Task | Actual End date |
---|---|---|---|---|
1 | 09/20/2015 | 09/27/2015 | Buy RC Car | 09/26/2015 |
2 | 09/27/2015 | 10/3/2015 | Divide the modules among team members | 10/2/2015 |
3 | 10/3/2015 | 10/10/2015 | Decide the pins used by each module | 10/15/2015 |
4 | 10/10/2015 | 10/25/2015 | Get the main board ready which connects all SJOne boards | 10/20/2015 |
5 | 10/3/2015 | 10/30/2015 | Work on individual modules | 11/15/2015 |
6 | 10/31/2015 | 11/13/2015 | Sensors, motors and master controller are integrated and tested.
GPS, android and master are integrated and tested |
12/05/2015 |
7 | 11/14/2015 | 12/10/2015 | Integration, testing and tweaking | 12/16/2015 |
8 | 12/16/2015 | 12/16/2015 | Final testing | 12/16/2015 |
Parts List & Cost
Introduction
The Controllers
- Master Controller
- Motor and I/O controller
- Sensor Controller
- Geographical Controller and Compass
- Android & Communication Bridge Controller
Design & Implementation
CAN Interface
The CAN interface was implemented by using the MPC2562 transceiver. The MPC2562 transceiver supports data rates up to 1Mbps and also provides a separate I/O supply pin to support 1.8-5V signaling on the controller side. Below is a diagram of the CAN interface implemented on Fury.
A very useful tool for debugging CAN bus. The CAN BUS Analyzer Tool is intended to be a simple-to-use, low-cost CAN Bus monitor which can be used to develop and debug a high-speed CAN network. The CAN Analyzer tool supports CAN 2.0b and ISO 11898-2 (high-speed CAN with transmission rates of up to 1 Mbit/s). The tool can be connected to the CAN network using the USB connector.
CAN 11-bit ID Format
DST | SRC | MSG |
---|---|---|
3 bits (11-9) | 3 bits (8-6) | 5 bits (5-0) |
Controller ID Table
Controller ID | Controller Type |
---|---|
000 | Motor and LCD Controller |
001 | Master Controller |
010 | Sensor Controller |
011 | GPS and compass Controller |
100 | Communication Bridge + Android Controller |
Master Controller
Group Members
- Bhargava Sreekantappa Gayathri
- Thiruparan Balachandran
Schedule
Sl.No | Start Date | End Date | Task | Status | Actual Completion date | Problems Encountered |
---|---|---|---|---|---|---|
1 | 9/27/2015 | 10/4/2015 | Decide on Node address and message ID's for CAN controller. | Completed | 10/1/2015 | |
2 | 10/4/2015 | 10/11/2015 | Research and decide on the tasks, priorities and scheduling. | Completed | 10/12/2015 | |
3 | 10/11/2015 | 10/18/2015 | Come up with a kill switch mechanism with the existing remote control and complete building the car. | In Progress | ||
6 | 10/18/2015 | 10/30/2015 | Set up inter board communication with CAN and test specific messages sent to a module and broadcast messages. | |||
5 | 10/25/2015 | 10/30/2015 | Get the car running by integrating with the motor controller and Implement logging. | |||
6 | 10/31/2015 | 11/13/2015 | Integrate GPS module and implement the algorithm for the car to travel to the destination with a hard coded Destination co-ordinates. | |||
7 | 11/13/2015 | 11/21/2015 | Integrate sensor module and implement obstruction avoidance mechanism. | |||
8 | 11/21/2015 | 11/25/2015 | Integrate the Bluetooth bridge and get co ordinates from hone as well as send vehicle parameters to the phone for displaying in the app. | |||
9 | 11/26/2015 | 12/15/2015 | Testing and fine tuning as required. |
Hardware Design
To stop the car during an emergency we need a wireless kill switch which would kill the power to the motors. For the kill switch we will be using a 4 channel remote control from gearbest.com. The module has the following properties:
- Working voltage: DC 12V, relay excitation voltage of 5V
- Static current: Less than 7mA
- Relay output: Controllable AC / DC select-able
- Working frequency: 315MHz, 433.92MHz, can customize special frequency
- Control modes: Latch (L4), Unlatch (M4), Self-latching (T4)
- Channel: 4 channels
- Working range: 200 meters
- High-security, stable performance, low power consumption, and easy to use
The main battery which will power the motors will be having the kill switch in its path, when ever the kill switch is armed main battery will not be fed to the motors.
Software Design
- The Master Controller is responsible for any action the car performs.
- To control the actions of the car, the Master Controller relies upon the periodic scheduler of the FreeRTOS.
- The periodic scheduler ensures that the Sensor, geo-controller messages are read periodically and the actuation command is sent out to the motor controller.
- To read and send messages to the other controllers, the Master Controller makes use of the CAN bus. The controll signal to the motor controller is sent out every 100ms.
- Since the master controller receives a huge number of messages, the Full CAN feature of LPC 1758 is made used. Enabling Full CAN will ensure that the Master Controller will not check for the CAN messages periodically but will directly read a memory location in the RAM which will havr the CAN message.
- For debuggin puposes, the Telemetry module provided by Preet is used. The Telemetry module logs the pre-decided variables in memory and the values of those variables can be read out via the telemetry viewer. This method is better than the printing the values or logging those values in a file as it is realtime and runs in the background.
- Additionally, there are 4 LEDs at the back of the car. The 2 red LEDs light up when ever the car is braking or is stopped. The 2 green LEDs on the either sides of the car blinks when the car is taking a turn. If the car is taking a left turn then the left green LED will blink and vice versa.
- Apart from the LED indications. The Master controller also sends useful debug information to the IO controller to be displayed on the App.
Controller Communication Table
S.R. | Message Number | Destination | Message Name (MSG_FUNCTION) | Data Layout of Data Sent over CAN (byte[0] = total number of data bytes) |
---|---|---|---|---|
1 | 0x020 | Motor Controller | RESET |
- |
2 | 0x220 | Sensor Controller | RESET |
- |
3 | 0x221 | Sensor Controller | HEART BEAT |
- |
4 | 0x320 | Geo-controller | RESET |
- |
5 | 0x420 | Communication Bridge | RESET |
- |
6 | 0x021 | Motor Controller | STEERING |
8 bytes steering data |
7 | 0x321 | Geo controller | DESTINATION |
8 bytes destination latitude and longitude data |
8 | 0x421 | Communication Bridge | DISPLAY DATA |
8 bytes data to be displayed on the LCD |
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.
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.
Motor and I/O controller
Group Members
- Sin Yu Ho
- Nimmi Bhatt
Schedule
Sl.No | Start Date | End Date | Task | Status | Actual Completion date | Problems Encountered |
---|---|---|---|---|---|---|
1 | 9/27/2015 | 10/3/2015 | Decide and purchase rpm sensor and LCD screen module | Completed | 10/1/2015 | |
2 | 10/4/2015 | 10/11/2015 | Research and understand servo/throttle motor and issue command from terminal to control it. | Complete | 10/25/2015 | Programming throttle motor backward rotation |
3 | 10/11/2015 | 10/18/2015 | Understand LCD module programming and RPM sensor, and create a speed monitoring | Complete | 10/18/2015 | |
4 | 10/18/2015 | 10/25/2015 | Design CAN message and implement CAN infrastructure. | Complete | 10/30/2015 | Delay due to full can implementation |
5 | 10/25/2015 | 10/30/2015 | Design and create display for monitoring sensor, gps, connection bridge, and master on LCD module | Complete | 11/2/2015 | |
6 | 10/31/2015 | 11/13/2015 | Integrate with master, testing and debug | Complete | 11/20/2015 | |
7 | 11/14/2015 | 12/10/2015 | Integrate with the whole system, testing and debug | In progress | 12/15/2015 |
Hardware Design
The motor-IO controller consists with four modules: LCD modules, Servo motor module, DC motor module, and speed sensor module. Steering motor module controls steering of the car; DC motor module controls movement; Speed sensor module reports the rpm of a wheel.
- LCD: : 4D Systems- uLCD-35DT-AR
- Servo motor: : Arrma ADS-5 Steering Servo motor, which comes with the car
- DC motor: : Arrma 6 cell 2000mAh 7.2 volt NiMh battery pack, Arrma mega waterproof 35A ESC, and a 15T mega brushed motor, which come with the car
- Speed Senor: :Traxxas 6520 RPM Sensor and magnets
Hardware Interface
CAN - Master controller makes decision for motors’ behavior. The decision is sent to motor controller through CAN bus with options that provided by each module. Full can is enabled in motor/IO controller board, which means when the module receives CAN messages, messages are put into ram memory by hardware. Since LCD provides information display screen for each controller on this car, many CAN messages are received. Using normal CAN in this case accumulates the queue in CAN easily and messages with the same message id most likely occurs more than once but only the last one matters. Therefore, full can is a better option since the software can read from the ram for the most recent messages. For motor controller, software reads and analyzes motor messages (message ID 0x20, 0x21 and 0x22) every 0.01s, and send 2 messages to CAN bus every 1s. Following is the DBC file for CAN.
BO_ 20 RESET_MOTOR: 1 DRIVER SG_ RESET_MOTOR_cmd : 0|1@1+ (1,0) [0|0] "" MOTOR BO_ 21 STEER: 1 DRIVER SG_ DRIVER_STEER_dir : 0|4@1+ (1,0) [0|4] "" MOTOR BO_ 22 THROTTLE: 1 DRIVER SG_ DRIVER_THROTTLE_stop : 0|1@1+ (1,0) [0|1] "" MOTOR SG_ DRIVER_THROTTLE_forward : 1|1@1+ (1,0) [0|1] "" MOTOR SG_ DRIVER_THROTTLE_usecustom : 2|1@1+ (1,0) [0|1] "" MOTOR SG_ DRIVER_THROTTLE_custom : 3|2@1+ (1,0) [0|3] "" MOTOR SG_ DRIVER_THROTTLE_incr : 5|1@1+ (1,0) [0|1] "" MOTOR
BO_ 100 MOTOR_HEARTBEAT: 8 MOTOR SG_ MOTOR_HEARTBEAT_cmd : 0|64@1+ (1,0) [0|0] "" DRIVER BO_ 102 SPEED: 1 MOTOR SG_ MOTOR_SPEED_speed : 0|8@1+ (1,0) [0|0] "" DRIVER SG_ MOTOR_SPEED_rpm : 8|8@1+ (1,0) [0|0] "" DRIVER
PWM (Pulse Width Modulation)- This is an analog signal that micro-controller sends to different module to control the motor speed or a motor rotation. Since we would like to build a self-driving car with a similar performance as its original performance, we used an oscilloscope to measure the base frequency from the wireless receiver, which comes with the car to control the motors. 54.24Hz is measured, and we round it up to 55Hz in the software. Therefore, all the calculation is based on 55Hz in this project.
Software Design
Displaying on LCD
In 1Hz task, LCD will update the display as following.
Speed Sensor
When hall sensor detects a magnetic field difference, an interrupt is generated. This interrupt will increment a counter. In every 0.5s, RPM will be calculated with the counter, and the counter will be cleared.
void speed_pulse_start(void)
{
SpeedMonitor::getInstance()->addRpmCounter();
}
SpeedMonitor::SpeedMonitor()
{
int port2_5 = 5;
eint3_enable_port2(port2_5, eint_rising_edge, speed_pulse_start);
m_rpmCounter = 0;
}
Setting Steering Direction/ Speed
In 100Hz task, RAM will be checked if steer/throttle CAN message is updated. When a message is received, the PWM to control motor will be updated.
Self Tuning
Based on CAN message from master, custom speed is set. This feature is to make sure the car is running under the custom speed all the time.
Implementation
LCD - To be edited
Speed Sensor - This sensor detects magnetic field and outputs a pulse to the microcontroller. In this project, five magnets are attached to the wheel. When the wheel rotates, the magnet gets closer to the sensor and the sensor would generate a pulse. With this pulse, software in the microcontroller can calculate time difference between one pulse and another to get the RPM(rotation per minute). The car should maintain in a certain speed selected by the master, and RPM implies the speed. When run speed is lower than selected speed, PWM is increased gradually in order to run with the rpm that master selected.
Servo Motor - For this motor, 10% of duty cycle provides the furthest left rotation, 20% duty cycle provides the furthest right and 15% put the wheel to go straight. Five options are provided according to this data for master controller:
Options | PWM |
---|---|
Far Left | 5.5 |
Far Left | 6.875 |
Center | 8.25 |
Right | 9.625 |
Far Right | 11 |
ESC (Electronic Speed Controller) - This module receives PWM from microcontroller and outputs a DC signal to DC motor to control speed and rotation direction. To reduce the complexity of the speed control for the master controller, 7 options are provided. 3 levels for moving forward and for moving backward respectively and a stop option. Each level is defined by rpm of a wheel.
Options | Target Rpm |
---|---|
Stop | 0 |
Forward/Backward Custom 1 | 120 |
Forward/Backward Custom 2 | 160 |
Forward/Backward Custom 3 | 200 |
Testing & Technical Challenges
- Backward - We did not know how to control the car goes backward. After quite a bit of research and experiment with the car, we found out that the ESC requires two clicks from the remote to change direction. As a result, we simulates it by sending 2 different close-to-base PWM values.
- Brake - Our car does not have a brake. When the base PWM is sent to the ESC. The car will still move forward due to momentum. Master controller may need to take this into calculation. We will suggest to pick a car with a brake option.
- Speed sensor - At first, we stick 1 magnetic on the right back wheel and target rpm is 120. This also means about 2 pulses per second is received. Since number of data is too little for each second, the analysis/tuning of speed only can happen every 1 second. To increase the number of data, we stick 5 magnetic in total on the wheel, which means about 10 pulse per second. Now, the analysis/tuning of speed will happen every 0.5 second.
- Computer program - One of our teammates' computer, was used to program the flash all the time, all of a sudden, causes the board rebooting after loading the program. We tried to load the exact same hex with another computer to the same board, and the board works fine.
Sensor Controller
Group Members
- Christopher Laurence
- Julio Fuentes
Schedule
Sl.No | Start Date | End Date | Task | Status | Actual Completion date | Problems Encountered |
---|---|---|---|---|---|---|
1 | 9/27/2015 | 10/3/2015 | Order ultra sonic sensors and read data sheets | Completed | 10/2/2015 | N/A |
2 | 10/4/2015 | 10/10/2015 | Connect ultra sonic sensor to LPC board & see if LDAR is an option | Completed | 10/10/2015 | N/A |
3 | 10/11/2015 | 10/17/2015 | Read data value from sensor and send in CAN bus | Completed | 10/17/2015 | N/A |
4 | 10/18/2015 | 10/24/2015 | Integrate and test proximity sensors | Completed | 10/30/2015 | N/A |
5 | 10/25/2015 | 10/31/2015 | Develop battery sensor code | Completed | 10/31/2015 | N/A |
6 | 11/01/2015 | 11/07/2015 | Integrate and test battery sensor | Completed | 11/07/2015 | N/A |
7 | 11/08/2015 | 11/21/2015 | Complete hardware testing | Completed | 12/12/2015 | N/A |
Hardware Design
For the Sensor team, we decided to use three ultrasonic sensor and a LIDAR sensor for the front. We also use a voltage dividing circuit to bring down the voltage of the batteries, so we can monitor the voltage using two ADC pins. Lastly, our voltage regulator comes with a flag bit that indicates that the voltage has dropped below 5% of 5 volts. Below are the schematics and pin layout for our design.
Hardware Interface
Ultrasonic Sensor
The ultrasonic sensor that we used for this project came with three interface methods. The XL-MaxSonar EZ are a highly senstive sensor that is capable of detecting object up to 725 cm away with a 5V power supply. However, this ultrasonic sensor will not be able to give you the actual distance of an object less than 20 cm away but it will detect it. The sensors allowed reading from ADC, UART, and PWM. The sensor group decided to use PWM because there would not be enough ADC available to do the battery sensor. The UART interface would take approximately 100 ms per a reading but the PWM could read a value between 18ms and 52 ms. Another reason we used PWM was because there are several pins that support PWM available on the SJSU board.The method to use the PWM is to trigger a 20 us high signal to the RX pin and read the value back from the PWM. The PWM will have an rising edge and falling edge and the time held high indicate the distance to the object.
Lidar Lite Laser Distance Sensor
The Lidar laser distance sensor requires 5V and I2C interface operating at a maximum rate of 100Kbps for communication. The Lidar Lite has a maximum acquisition time of 20ms. For reliability, the sampling interval was set to 40ms. The maximum distance measuring capability of the sensor is 60 meters or 196 feet. Testing showed a blind spot of 1-2 inches which was avoided by installing the sensor back a little over two inches.
Battery Sensor
The Battery sensor interface was provided by the 12 bit ADC on the SJ One Board. The ADC has the reference voltage connected to 3.3V and any voltage to be sensed has to be brought down to 3.3V using a resistor divider circuit. The design for the Fury RC car has a 5V source for digital power and a 7.2-7.4 source to power the motor. Both voltages had to be scaled down to 3.3V to interface to the ADC. There are two options to provide a voltage source for the digital circuits. Option 1 was from a NCP59300 LDO Voltage regulator which provides a FLAG output to signal that the 5V wa10% below the nominal 5V. This FLAG signal as well as the reading on the ADC was reported to the master controller. A local LED also provided visual indication that the battery was draining. The second option was to provide the 5V from a USB battery power source which turned out to be the preferred choice since it lasted a long time. Below is a diagram of the power with battery sensing options.
Sensor Controller Pin Mapping
Pin Name | Function |
---|---|
P2_0 | PWM for left Sonic Sensor |
P2_1 | RX trigger for left Sonic Sensor |
P2_2 | PWM for right Sonic Sensor |
P2_3 | RX trigger for right Sonic Sensor |
P2_4 | PWM for back Sonic Sensor |
P2_5 | RX trigger for back Sonic Sensor |
P2_6 | 5V Regulator Flag bit |
P1_30 | ADC from RC Battery |
P1_31 | ADC from 5V source for all Boards |
SDA 2 | LIDAR I2C data |
SCL 2 | LIDAR I2C clock |
Software Design
For the sensor, we created two tasks to complete the sensor software design. The first task was to initialize the pins for the sonic sensor and create the interrupts for each of the sonic sensors. In the run phase of the task, we trigger the reading pin and use interrupts to get the length in us on the PWM pin. We repeat for each of the three sonic sensors which will have a 45 ms delay between the next triggering of the sonic sensor. The LIDAR is sampled through I2C at the same time as the first sonic sensor it sampled. After all three sonic sensor have data, we applied a simple filter to eliminate bad values. Finally we values from all the sensor are put into a queue that the periodical function will check every 10 Hz and send out a CAN message.
For the Battery sensor was in a separate task that would be sent out everyone 1 Hz. This task initialized the ADC pins and an interrupt for the flag bit from the voltage regulator. In the run phase we read the value of each ADC and place them in a queue with the flag bit value. To get the voltage level of the battery we took the percentage based on the max ADC value and multiple it by the battery's original value. For debug purpose, we had the voltage level displayed on the SJSUOne board.
BattSen.MotorBattery = ((adc0_get_reading(4)*7.4 * 10) / 4096);
BattSen.BoardBattery = ((adc0_get_reading(5)* 5 * 10) / 4096);
BattSen.BatteryFlag = BoardBatteryFlag;
xQueueSend(battery_data_q, &BattSen, 0);
return true;
Implementation
The communication method for the sonic sensors is to use a PWM pin with and interrupt to find the distance. The LIDAR used I2C to send a 16 bit distance value and the battery sensor used ADC. To communicate with the other boards, we used the below CAN messages. Below is each of the CAN messages in DBC format.
BO_ 140 HEARTBEAT: 1 SENSOR SG_ DRIVER_HEARTBEAT_cmd : 0|8@1+ (1,0) [0|0] "" DRIVER
BO_ 142 SONARS: 8 SENSOR SG_ SENSOR_SONARS_left : 0|16@1+ (1,0) [0|0] "" DRIVER,IO SG_ SENSOR_LIDAR_middle : 16|16@1+ (1,0) [0|0] "" DRIVER,IO SG_ SENSOR_SONARS_right : 32|16@1+ (1,0) [0|0] "" DRIVER,IO SG_ SENSOR_SONARS_rear : 48|16@1+ (1,0) [0|0] "" DRIVER,IO
BO_ 144 BATTERY: 3 SENSOR SG_ SENSORS_Motor_BATTERY : 0|8@1+ (1,0) [0|0] "" DRIVER, IO SG_ SENSORS_Board_BATTERY : 8|8@1+ (1,0) [0|0] "" DRIVER, IO SG_ SENSORS_Flag_BATTERY : 16|8@1+ (1,0) [0|0] "" DRIVER, IO
Sr. No. | Message Number | Destination | Message Name (MSG_FUNCTION) | Data Layout of Data Sent over CAN (byte[0] = total number of data bytes) |
---|---|---|---|---|
1 | 0x140 | Master | HEARTBEAT |
- |
2 | 0x142 | Master | SONIC SENSOR DATA |
Msg : byte[0:1] : (uint16_t) middle (LIDAR) Msg : byte[0:1] : (uint16_t) left Msg : byte[2:3] : (uint16_t) right Msg : byte[4:5] : (uint16_t) back |
3 | 0x144 | Master & I/O Controller | BATTERY DATA |
Msg : byte[0] : (uint8_t) Motor battery * 10 Msg : byte[1] : (uint8_t) Board battery * 10 Msg : byte[2] : (uint8_t) Board battery Flag |
Testing & Technical Challenges
- For the sonic sensor the biggest challenge was preventing the sensor from interfering with each other. While testing the sensor would get incorrect values if the time between triggering was too short. I notice with a 30 ms delay that the sensor seemed to be working correctly but when an object was placed on the right side of the car the left sensor would react. By placing a delay of 45 ms I was able to only see the right sensor react and the left remain the same.
- The next issue during testing was getting value from the sensor that were greater than the device was capable of having. By applying a simple filter to weed out bad value allows the master only to receive good values.
- During the last stages of testing, we notice that the sensors were receiving low value because it was picking up the ground. To fix the issue we raised the sensors 3 inches and slightly angled them back to increase the range.
- The Lidar sensor sends a value of 0 when it is out of range. Also, it sends 0 if an object is very close like 1 inch away. To solve this problem, the Lidar sensor was moved back so that it will never read 0 for an object that was too close. For the out of range case, the 0 value was replaced with 600.
Geographical Controller and Compass
Group Members
Schedule
Sl.No | Start Date | End Date | Task | Status | Actual Completion date | Problems Encountered |
---|---|---|---|---|---|---|
1 | 9/23/2015 | 10/2/2015 | Researched and decided upon the GPS module and Compass module. | Completed | 10/1/2015 | None |
2 | 10/3/2015 | 10/3/2015 | Ordered GPS module and compass module. | Completed | 10/2/2015 | None |
3 | 10/5/2015 | 10/14/2015 | Interface GPS module and
compass module to SJOne board. |
Completed | 10/20/2015 | The delivery of GPS and compass module was delayed. |
4 | 10/15/2015 | 10/25/2015 | Parse GPS data and format the data to be transmitted
Test code to get compass reading information |
Completed | 10/25/2015 | None |
5 | 10/26/2015 | 10/30/2015 | Calibrating the compass module.
Integration of GPS and compass module. Interfacing of GPS and compass module to Android. |
Completed | 11/25/2015 | Testing of the module is taking time.
Burnt GPS module, had to order another one. |
7 | 11/1/2015 | 11/13/2015 | Integration with Master through CAN bus. | Completed | 12/05/2015 | Had to filter the data |
8 | 11/15/2015 | 12/10/2015 | Testing and calibrating with other modules. | Completed | 12/16/2015 | Tuning |
Hardware Design
GPS Module
GPS module used in our project is Sparkfun Venus GPS - (Model: GPS-11058) and embedded antenna from Sparkfun - (Model: GPS-00177). We were able to configure this module at 10Hz and communicate at 38400bps through UART. Skytraq has developed a Graphical User Interface to check Latitude, Longitude and every possible information this GPS module provides. GPS can also be configured to operate and communicate at various speed though the provided Graphical User Interface. This module has got an on-board flash to store these configuration. There are three modes in which this module can operate,
1. Cold start: Cold Start is performed every time when the GPS module is turned off without backup power supply connected. It is the longest starting time out of the three. It usually took around 15 to 20 minutes to get a GPS fix indoors.
2. Hot start: GPS module will perform Hot Start if the GPS module is provided with backup power and is powered on any time within the 2-hour time frame after GPS was previously turned off, the required fix is still stored inside the its flash memory and will not be changed. The Hot start time is typically around 10 to 15 seconds.
3. Warm start: Warm Start is performed if the module is switched on after the 2-hours of time, since satellite data has to be refreshed. Warm start time is typically around 2 to 3 minutes.
Compass Module
Compass module used for our project is CMPS 11 by Devantech Ltd(Robot Electronics). It is tilt compensated module which made life easier for us. There are two ways to establish communication between CMPS 11 and SJ-ONE board. UART and I2C are the two ways and we choose to do use I2C for communication. Since, it is faster.
1. First thing to do before calibrating the compass module is to make sure that there is proper I2C communication established between the compass module and SJ-ONE board. Once we have communication setup we can got ahead and find out the bearing degree of the compass and verify it with an actual analog compass.
2. Once the communication is setup and working as desired, then we can calibrate the compass. Calibration is done by sending 3 commands for every 20ms. The purpose of calibration is to remove sensor gain and offset of both magnetometer and accelerometer and achieves this by looking for maximum sensor outputs.
Hardware Interface
GPS module
Communication between GPS and SJOne board is through UART2. GPS was configured to communicate at 38400bps and operate at 10Hz. A coin battery of 3.3V was connected between Vbat and Gnd of GPS. The coin battery helped in hot start of GPS module.
Compass module
CMPS 11 module provides two ways of communication. First option is I2C and second option is UART. We chose I2C communication since it is faster when compared to UART. Since GPS uses UART2 and Seven segment display uses UART3 we decided to use I2C. The operating voltage range is from 3.3v to 5v.
Software Design
GPS module
A task is created to read the GPS values from the module. This task starts reading GPS coordinates when there is some data on UART, the received data is then checked if it is valid. If valid, then the data is pushed onto queue which is basically every 200ms, since the GPS module is configured to work at 5Hz. GPS module transmits data in NMEA format and we are following the $GPRMC data. GPS module was configured for pedestrian mode. Module was configured through the software provided by skytraq. Coordinates from communication module is received at the start of code which contains checkpoint details. The GPS data and the checkpoint data is used to calculate the distance to next checkpoint, distance to final destination and angle in which the car has to head by using Haversine formula. Once a checkpoint is reached, the checkpoint is updated and continues till final destination is reached. Once the final destination is reached, master is informed about the same. Present GPS data is transmitted back to communication bridge.
Compass module
All of compass calculation is done in 10Hz periodic task. Initial bearing is calculated and compared with the desired heading. The desired heading is calculated using the longitude and latitude values provided by the GPS module. Based on this value a turn decision is made and sent to the master to handle it.
- For entering into the calibration mode, switch 1 on SJ- One board has to be pressed.
- Switch 2 to come out of calibration mode back to heading mode.
- Switch 3 to do the factory reset setting.
Algorithm to calculate distance using longitude and latitude values.
- The distance is calculated between 2 geographical points.
- It is used to calculate to distance between two checkpoints in our project.
- We use ‘haversine’ to calculate the distance of two points over a sphere i.e the earths surface.
Haversine formula: a = sin²(Δφ/2) + cos φ1 ⋅ cos φ2 ⋅ sin²(Δλ/2) c = 2 ⋅ atan2( √a, √(1−a) ) d = R ⋅ c
where φ is latitude, λ is longitude, R is earth’s radius (mean radius = 6,371km) (assuming earth to be a sphere and ignoring ellipsoidal effects)
Algorithm to calculate desired heading using longitude and latitude values.
- This algorithm is used to calculate the desired heading direction between two geographical locations. This helps in navigating car to reach the destination.
- The algorithm calculates the heading between present checkpoint and the next checkpoint by taking the present latitude and longitude values and the next checkpoint's latitude and longitude values.
- The final heading direction may change when we travel towards the destination because of the shape of earth. Hence, the forward azimuth formula is used to calculate the initial direction.
- To get the final direction, take bearing from the end point to the start point and reverse it as follows, θ = (θ+180) % 360
Formula: θ = atan2( sin Δλ ⋅ cos φ2 , cos φ1 ⋅ sin φ2 − sin φ1 ⋅ cos φ2 ⋅ cos Δλ )
where φ is latitude, λ is longitude
Since this formula generates a negative value (-180 to 180), we need to normalize the value to get a compass bearing (0 - 360). We have divided the compass into 12 zones of 30 degrees each. This allows the car to remain in one zone and only turn if a heading / turn of more than 30 degrees is to be performed. This provides stability to the car thereby avoiding heading correction every time the algorithm computes a heading.
Controller Communication Table
Sr. No. | Message Number | Destination | Message Name (MSG_FUNCTION) | Data Layout of Data Sent over CAN (byte[0] = total number of data bytes) |
---|---|---|---|---|
1 | 0x160 | Master | HEARTBEAT |
- |
2 | 0x162 | Master and I/O | COMPASS HEADING DATA |
Msg : 8 bits : turn angle Msg : 7 bits : checkpoint Msg : 1 bit : isFinal Msg : 16 bits : distance to final destination Msg : 16 bits : distance to next checkpoint |
3 | 0x461 | Communication Bridge | GPS DATA |
Msg : 8 bits : latitude_decimal_part Msg : 20 bits : latitude_float_part Msg : 8 bits : longitude_decimal_part Msg : 20 bits : longitude_decimal_part Msg : 7 bits : checkpoint Msg : 1 bit : isFinal |
4 | 0x47F | Communication Bridge | CHECKPOINT RECEIVED |
- |
Testing & Technical Challenges
For Debug purpose:
On board LED 3 is toggled every time there is an error to push the data onto queue.
On board LED 4 is toggled every time the data is not read from gps.
Different numbers were displayed on the 7 segment display of SJOne board to debug the compass modes.
FURY was displayed on 7 segment display of SJOne board on a rolling basis to indicate the destination was reached.
Testing Procedure
- The checkpoints were added once, manually at the start of the code. The checkpoint data was collected from the android app at different locations.
- Distance calculations(next checkpoint distance and final distance) were tested by using these test values of latitude and longitude.
- Desired heading angle was also calculated on similar lines.
- GPS was carried along with the SJOne board to these checkpoints and was checked for the update of checkpoint data in software.
- Compass heading angle and desired angle was also mapped similarly.
- SJOne board was connected to CAN bus and was checked if the messages were sent through CAN bus by using a CAN analyzer tool from microchip.
Challenges:
- Initial fix for GPS used to take a lot of time. At first, it took around 1 hour and 30 minutes to get a fix. Then understood that GPS wont fix to a satellite if it is in a closed environment. Then tried to get a fix outside and it took around 30 minutes which is better but still not good. After reading a lot about the working of hot start mode in GPS module, we figured out that Vbat of around 3V has to be connected. This improved the time to get a satellite fix and it reduced to around less than 2 minutes.
- When the car was carried around the update of GPS was correct and car worked as desired, the problem was when the car was let lose on road. The car never used to go straight. To avoid this, kalman filter was implemented and then tested. There was no much changes since IMU was not used and many other factors was not considered to factor in kalman filter. The GPS was then slowed down by configuring it to update at 5Hz, this stabilized the car. The figures provide the movement of car with GPS update rate of 5Hz and 10Hz.
- Don't use 5v supply because for us it somehow created more than expected offset and our initial testing failed because of it. Later we switched back to 3.3v and offset was in expected range and testing went well too.
- If any objects such as laptop or mobile was taken near compass, the calibration would be lost and compass had to be re-calibrated. Since there was no software calibration available on the board, we had to manually remove the compass from the car, send calibration commands and then calibrate it. After few days, we tried factory reset commands which brought back the compass to correct readings, this was integrated in our code to reset the compass through android app by send messages through CAN bus. This reduced a lot of work for us.
Android & Communication Bridge Controller
Group Members
- Chinmayi Divakara
- Praveen Prabhakaran
Schedule
Sl.No | Start Date | End Date | Task | Status | Actual Completion date | Problems Encountered |
---|---|---|---|---|---|---|
1 | 9/30/2015 | 9/30/2015 | Decide and purchase Bluetooth Module | Completed | 9/30/2015 | None |
2 | 9/30/2015 | 10/14/2015 | Develop Basic Android App with Bluetooth Sensor Communication | Completed | 10/14/2015 | |
3 | 10/15/2015 | 10/20/2015 | Interface Bluetooth Module with SJSU Dev Board | Completed | ||
4 | 10/12/2015 | 10/26/2015 | Be able to send bi-directional arbitrary messages between Android App and Dev Board via Bluetooth | Completed | ||
5 | 10/14/2015 | 11/21/2015 | Interface Bluetooth Module with CAN | |||
6 | 10/26/2015 | 11/30/2015 | Integration with GPS module testing and fine tuning. | |||
7 | 11/01/2015 | 11/13/2015 | Integration with Master through CAN bus | |||
8 | 11/15/2015 | 12/10/2015 | Android App GUI enhancements (Google Maps, Google Drive) |
Hardware Design
- For wireless communication between the SJSU One Board and a Android device, a Bluetooth (RN-421) module is used. This module was chosen because it can connect and mount directly onto the SJSU One Board's XBee breakout socket.
- To give a longer range communication, we used wireless mesh network (Nordic) which was available in SJOne board.
1. Bluetooth Module (RN-421):
Features:
- Fully qualified Bluetooth version 2.1 module, support version 2.1+Enhanced Data Rate (EDR)
- Backwards compatible with Bluetooth version 2.0, 1.2 and 1.1.
- Low power (26uA sleep, 3mA connected, 30mA transmit)
- UART (SPP or HCL) and USB (HCI only) data connection interfaces.
- Sustained SPP data rates: 240 Kbps (slave), 300Kbps (master).
- HCI data rates: 1.5 Mbps sustained, 2.0Mbps burst in HCI mode.
- Bluetooth SIG certified.
- Castellated SMT pads for easy and reliable PCB mounting.
- Certifications: FCC, ICS, CE
2. Nordic Wireless:
Features:
- Worldwide 2.4GHz ISM band operation.
- Common RX and TX interface.
- Low power 1.9 to 3.6V supply range.
- 250kbps, 1 and 2Mbps air data rate.
- 1 to 32 bytes dynamic payload length.
- 3 separate 32 bytes TX and RX FIFOs
Hardware Interface
Bridge between Nodic wireless and bluetooth:
Since Nodic wireless cannot communicate with regular android cell phone, we would need one device/module that common accepted for both configurations. Bluetooth is one of the best devices for this purpose. In order to create a platform for these two device, SJ One board has been used as the medium to make communication bridge them. On the SJ One board, we have chosen UART 2 as communication connector among UART 2 or UART 3. There is no logic stored on the SJ One board but the initialization for the UART port. The logic for the communication for Bluetooth and Nodic module is simple. The baud rate has to set to 38400 for both module Tx of Bluetooth has to connect with Tx of Nodic while Rx of Bluetooth has to connect with Rx of Nodic. Besides, both Vcc(3.3V) and Ground of Bluetooth module and Nodicmodule are connected to the Vcc and ground on SJ One board respectively.
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.
S.R. | Message Number | Destination | Message Name (MSG_FUNCTION) | Data Layout of Data Sent over CAN (byte[0] = total number of data bytes) |
---|---|---|---|---|
1 | 0X180 | Master | HEARTBEAT |
No DATA |
2 | 0X181 | Master | DRIVE MODE |
No DATA |
3 | 0X182 | Master | STOP |
No DATA |
4 | 0x382 | Master | LOCATION POINTS |
Msg : 8 bits : latitude_decimal_part Msg : 20 bits : latitude_float_part Msg : 8 bits : longitude_decimal_part Msg : 20 bits : longitude_decimal_part Msg : 7 bits : checkpoint Msg : 1 bit : isFinal |
5 | 0X385 | Master | Compass Factory Reset (Debug) |
No DATA |
Implementation
S.R. | Command | Code |
---|---|---|
1 | Start | start$ |
2 | Checkpoints | check <Lattitude> <Longitude> <Checkpoint Number> <IsFinal>$ |
S.R. | Command | Code |
---|---|---|
1 | Acknowledgement | a~ |
2 | Location Values from Car | l<Lattitude> <Longitude>~ |
3 | Compass Values from Car | c<Heading Angle> <Desired Angle> <Turn Direction>~ |
4 | Distance Values from Car | c<Next Checkpoint Distance> <Final Distance >~ |
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.
Integration
Testing & Technical Challenges
Issue 1:
Full CAN was implemented to receive the required data. During CAN communication, when a particular message intended to receive for one particular module was received, the SJOne board of that module used to get stuck, there was no watchdog timer reset as well.
Solution - The Full CAN messages had to be added in ascending order. Once this was implemented, the working was smooth.
Issue 2:
The car used to turn even if the destination was straight ahead. There was a bit of difficulty to debug this issue. We could not figure out if it was due to GPS, compass or sensors. The front left and right sensors were mounted a bit low on the car and the readings from the sensors were low, due to reflections from ground, and hence there was difficulty in tuning threshold levels for obstacle avoidance.
Solution - The sensors were mounted a bit higher and was tilted backwards which gave a good range. The issue was debugged through LCD display and android app. All the important values were displayed on LCD and the android app provided better visualization of the GPS position.
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?
Word of advice:
- Invest time in debugging tools and options, it will save a lot of time while testing.
- Use Telemetry to check variable values than printf statement.
- Use LCD to display all important messages/values.
- Try to develop an android device such that all the messages are update on the app, it will be handy to check the updated values and for debugging.
- Start testing early to figure out the problems and tune your car for better results.
- CAN analyzer was a great tool to check the CAN messages on CAN bus. This helped in resolving on which board the problem resided.
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
- Laser Distance Sensor File:F15 243 Fury Lidar spec.pdf
- Sonic Sensor File:CmpE243 F15 Fury XL-MaxSonar-EZ Datasheet.pdf