F15: TopGun

From Embedded Systems Learning Academy
Revision as of 00:44, 19 December 2015 by 243 user3 (talk | contribs) (References Used)

Jump to: navigation, search

Contents

TopGun Self Driving Car

This is Top Gun - The super car that drives by itself!

Abstract

The GPS-controlled automated RC car will consistes of 5 different LPC 1758 controllers. Each controller will have a specific major tasks required to drive the car. The naming convention goes as:- Motor & I/O controller - this will control the motors of the car and will also connected with a LCD display to show the car's status, Sensor controller - It will be connected to the obstacle detecting sensors on the car, Communication Bridge - It will be connected to an Android mobile phone so as to provide co-ordinates, GEO controller - This will give the exact orientation of the car e.g., heading & bearing, etc. and finally the Master controller - This will collect the data from other controllers and will guide the motor controller. These controllers are connected using CAN bus. After the final implementation, this car will be capable of driving by itself using the destination co-ordinates set by us avoiding every obstacles, overcoming slopes thereby reaching the destination safely!

Project Diagram

Objectives & Introduction

Team Members & Responsibilities

Treasurer:

  • Anuj Korat

Five Controllers Used

Schedule

Team Schedule

SI No. Start Date End Date Task Status Actual Completion Date
1 09/15/2015 09/27/2015
  • Understanding the requirements and having initial team discussions on approach to be followed to carry out project
  • Forming sub-teams and assigning individual modules to each sub-team
Completed 09/27/2015
2 09/27/2015 10/30/2015 Following up on RC car and other component procurement through team discussions Completed 10/30/2015
3 10/30/2015 10/06/2015 Hardware design of the car including discussions on component placement, soldering and wiring. Completed 10/06/2015
4 10/06/2015 10/17/2015 CAN message ID's, priorities, data size and format proposals for all the possible CAN messages on the bus Completed 10/20/2015
5 10/20/2015 11/05/2015 Discussions and proposals on basic obstacle avoidance algorithm with sensor integration, hands on and testing Completed 11/03/2015
6 11/05/2015 11/25/2015 Integrating other modules and components to the RC car, development of autonomous driving algorithm and finalize on hardware layout of the car Completed 12/1/2015
7 11/25/2015 12/7/2015 Testing the RC car in real world environments Completed 12/5/2015

Parts List & Cost

Item# Part Desciption Vendor Qty Cost
1 RC Car From Preet 1 Free
2 RC Car Battery Amazon 1 $24.72
3 Core CPU Supply Amazon 1 $12.70
4 CAN Transceiver MCP2551 Microchip 15 $20.00
5 Printed Circuit Boards Amazon 1 $12.25
6 M-F,F-F,M-M Jumper Wires Amazon 120 $8.75
7 Ultrasonic Parallax Ping Sensor Fry's Electronics 1 $63.99
8 Ultrasonic Sensors Amazon 5 $10.45
9 9 DOF Razor IMU module SparkFun 1 $74.95
10 FTDI Basic Breakout SparkFun 1 $14.95
11 LCD Display uLCD-32PTU 4D systems 1 $111.00
12 Bluetooth Module Amazon 1 $9.99
13 Wire Cutter Amazon 1 $2.99
14 GPS Sensor Adafruit 1 $39.95
Total Cost $450

DBC File Implementation

  • This section explains DBC file implementation of the project. The DBC implementation contains the python based DBC file parser, a DBC file and auto generated C code for the five CAN nodes. These five nodes include driver(master), sensor, motor, geo and bluetooth node. The DBC file is a input to the python DBC parser script. The python script will generate a C file for the specific node given by the user at the command line argument. The python script goes through this DBC file and generates code to marshal (covert to raw CAN) and unmarshal (convert from raw CAN) using the provided API that you can enclose in a header file.
  • The following is the DBC file of the project.


BU_: NOONE SENSOR DRIVER MOTORIO BLUETOOTH GEO
BO_ 0 DRIVER_KILL_SWITCH: 0 DRIVER
 SG_ DRIVER_KILL_SWITCH_cmd 		: 0|0@1+ (1,0) [0|0] "" SENSOR,MOTORIO,BLUETOOTH,GEO
BO_ 1 DRIVER_RESET: 0 DRIVER
 SG_ DRIVER_RESET_cmd 				: 0|0@1+ (1,0) [0|0] "" SENSOR,MOTORIO,BLUETOOTH,GEO
BO_ 2 DRIVER_SYNC_ACK: 0 DRIVER
 SG_ DRIVER_SYNC_ACK_cmd 			: 0|0@1+ (1,0) [0|0] "" SENSOR,MOTORIO,BLUETOOTH,GEO
BO_ 3 MOTORIO_SYNC: 0 MOTORIO
 SG_ MOTORIO_SYNC_cmd 				: 0|0@1+ (1,0) [0|0] "" DRIVER
BO_ 4 SENSOR_SYNC: 0 SENSOR
 SG_ SENSOR_SYNC_cmd 				: 0|0@1+ (1,0) [0|0] "" DRIVER
BO_ 5 BLUETOOTH_SYNC: 0 BLUETOOTH
 SG_ BLUETOOTH_SYNC_cmd 			: 0|0@1+ (1,0) [0|0] "" DRIVER
BO_ 6 GEO_SYNC: 0 GEO
 SG_ GEO_SYNC_cmd 					: 0|0@1+ (1,0) [0|0] "" DRIVER
BO_ 7 MOTORIO_HEARTBEAT: 0 MOTORIO
 SG_ MOTORIO_HEARTBEAT_cmd 			: 0|0@1+ (1,0) [0|0] "" DRIVER
BO_ 8 SENSOR_HEARTBEAT: 0 SENSOR
 SG_ SENSOR_HEARTBEAT_cmd 			: 0|0@1+ (1,0) [0|0] "" DRIVER
BO_ 9 BLUETOOTH_HEARTBEAT: 0 BLUETOOTH
 SG_ BLUETOOTH_HEARTBEAT_cmd 		: 0|0@1+ (1,0) [0|0] "" DRIVER
BO_ 10 GEO_HEARTBEAT: 0 GEO
 SG_ GEO_HEARTBEAT_cmd 				: 0|0@1+ (1,0) [0|0] "" DRIVER
BO_ 11 MOTORIO_RUNMODE: 1 DRIVER
 SG_ MOTORIO_RUNMODE_cmd 			: 0|8@1+ (1,0) [0|3] "" MOTORIO
BO_ 12 SENSOR_SONARS: 6 SENSOR
 SG_ SENSOR_SONARS_front_left 		: 0|8@1+ (1,0) [0|4] "" DRIVER,MOTORIO
 SG_ SENSOR_SONARS_front_right 		: 8|8@1+ (1,0) [0|4] "" DRIVER,MOTORIO
 SG_ SENSOR_SONARS_front_center 	: 16|8@1+ (1,0) [0|4] "" DRIVER,MOTORIO
 SG_ SENSOR_SONARS_left 			: 24|8@1+ (1,0) [0|4] "" DRIVER,MOTORIO
 SG_ SENSOR_SONARS_right 			: 32|8@1+ (1,0) [0|4] "" DRIVER,MOTORIO
 SG_ SENSOR_SONARS_back 			: 40|8@1+ (1,0) [0|4] "" DRIVER,MOTORIO
BO_ 13 MOTORIO_DIRECTION: 2 DRIVER
 SG_ MOTORIO_DIRECTION_speed_cmd 	: 0|8@1+ (1,0) [0|4] "" MOTORIO
 SG_ MOTORIO_DIRECTION_turn_cmd 	: 8|8@1+ (1,0) [0|5] "" MOTORIO
BO_ 14 DRIVER_CHECKPOINT_REQ: 1 DRIVER
 SG_ DRIVER_CHECKPOINT_REQ_cmd 		: 0|8@1+ (1,0) [0|3] "" BLUETOOTH,MOTORIO
BO_ 15 BLUETOOTH_CHECKPOINT_SEND: 1 BLUETOOTH
 SG_ BLUETOOTH_CHECKPOINT_SEND_cmd 	: 0|8@1+ (1,0) [0|3] "" DRIVER,MOTORIO
BO_ 16 BLUETOOTH_CHECKPOINT_DATA: 1 BLUETOOTH
 SG_ BLUETOOTH_CHECKPOINT_DATA_cmd 	: 0|8@1+ (1,0) [0|3] "" DRIVER,MOTORIO
BO_ 17 DRIVER_LOC_UPDATE: 8 DRIVER
 SG_ DRIVER_LOC_UPDATE_LAT_cmd 		: 0|32@1+ (0.0001,0) [0|0] "" GEO,MOTORIO
 SG_ DRIVER_LOC_UPDATE_LONG_cmd 	: 32|32@1+ (0.0001,0) [0|0] "" GEO,MOTORIO
BO_ 18 GEO_SPEED_ANGLE: 5 GEO
 SG_ GEO_SPEED_cmd 					: 0|8@1+ (1,0) [0|0] "" DRIVER,MOTORIO
 SG_ GEO_ANGLE_heading_cmd 			: 8|16@1+ (1,0) [0|0] "" DRIVER,MOTORIO
 SG_ GEO_ANGLE_bearing_cmd 			: 24|16@1+ (1,0) [0|0] "" DRIVER,MOTORIO
BO_ 19 GEO_LOC_DATA: 8 GEO
 SG_ GEO_LOC_LAT_cmd 				: 0|32@1+ (0.0001,0) [0|0] "" DRIVER,MOTORIO
 SG_ GEO_LOC_LONG_cmd 				: 32|32@1+ (0.0001,0) [0|0] "" DRIVER,MOTORIO
BO_ 20 SENSOR_LIGHT_BAT: 2 SENSOR
 SG_ SENSOR_LIGHT_cmd 				: 0|8@1+ (1,0) [0|1] "" DRIVER,MOTORIO
 SG_ SENSOR_BAT_cmd 				: 8|8@1+ (1,0) [0|1] "" DRIVER,MOTORIO
CM_ BU_ NOONE "No node, used to indicate if it's a debug message going to no one"; 
CM_ BU_ DRIVER "The driver controller driving the car";
CM_ BU_ SENSOR "The sensor controller of the car";
CM_ BU_ MOTORIO "The motor_io controller of the car";
CM_ BU_ BLUETOOTH "The bluetooth controller of the car";
CM_ BU_ GEO "The geo controller of the car";
CM_ BO_ 2 "Sync message used to synchronize the controllers";
BA_DEF_  "BusType" STRING ; 
BA_DEF_ SG_ "FieldType" STRING ;
BA_DEF_ BO_ "GenMsgCycleTime" INT 0 0;
BA_DEF_DEF_ "BusType" "CAN";
BA_DEF_DEF_ "FieldType" "";
BA_ "GenMsgCycleTime" BO_ 7 	          1;
BA_ "GenMsgCycleTime" BO_ 8 	          1;
BA_ "GenMsgCycleTime" BO_ 9 	          1;
BA_ "GenMsgCycleTime" BO_ 10              1;
BA_ "GenMsgCycleTime" BO_ 11 	          1;
BA_ "GenMsgCycleTime" BO_ 12              10;        
BA_ "GenMsgCycleTime" BO_ 13              10;
BA_ "GenMsgCycleTime" BO_ 17              10;
BA_ "GenMsgCycleTime" BO_ 18              10;
BA_ "GenMsgCycleTime" BO_ 19              10;

  • Let's understand the above DBC file. The line which contains BU_:... tells the python parser that the user has five nodes in the CAN implementation. In the TopGun project, we have total five nodes -> SENSOR, DRIVER(master), MOTOR, BLUETOOTH, GEO.
  • The second important thing in the DBC file is the lines starting from BO_ message_id. These lines define the different message ids for the CAN implementation of the TopGun project. Here, the project includes total 20 message ids. So, The DBC file contains separate BO_ message_id line for each and every message id. Now, let's see what these lines are indicating to the python parser. What the BO_ line contains is given below:
    • BO_ 4 SENSOR_SYNC: 0 SENSOR --> BO_ "message_id" "message_id_name" "number_of_bytes_transmitted_on_CANbus" "transmitter_node"
  • Now, there are lines which start from SG_. The format of the line contains SG_ is given below. It will contain the variable name that we want to marshal and unmarshal for the CAN bus message data. It also contains the size of that variable and from where it is placed in the 8 bytes of total data. This line will also decide the range of the value held by this variable. User needs to define this max and mim range according to the application. If it is [0|0], then the the parser will consider this as a default and will give the maximum and minimum value of that variable according to its size and the sign information of the variable. Information in the (1,0) will define the multiplier of the value of the variable which in this case is 1. The second value of this bracket is 0 which indicates the offset for the value of the variable.
  • Execute the following commands in the command line argument to generate the API for the motor controller node.
    • $python dbc_parse.py -i TopGun_12_38am_11_16_2015.dbc -s MOTORIO > generated_code_MOTORIO.c
  • The above command will generate the code for the generated_code_MOTORIO.c file
  • Sample implementation of CAN dbc for sensor message.
  • Sensor message encode code:
    can_msg_t sensor_can_msg;
    SENSOR_TX_SENSOR_SONARS_t sensor_msg;
    sensor_msg.SENSOR_SONARS_front_center = sen_front_center.szone;
    sensor_msg.SENSOR_SONARS_front_left = sen_front_left.szone;
    sensor_msg.SENSOR_SONARS_front_right = sen_front_right.szone;
    msg_hdr_t sensor_msg_header = SENSOR_TX_SENSOR_SONARS_encode((uint64_t*)&sensor_can_msg.data, &sensor_msg);
    sensor_can_msg.msg_id = sensor_msg_header.mid;
    sensor_can_msg.frame_fields.data_len = sensor_msg_header.dlc;
    transmit_data(sensor_can_msg);
  • Sensor message decode code:
    SENSOR_TX_SENSOR_SONARS_t sensor_msg;
    can_msg_t received_msg;
    msg_hdr_t hdr;
    hdr = { received_msg.msg_id, (uint8_t)received_msg.frame_fields.data_len };
    SENSOR_TX_SENSOR_SONARS_decode(&sensor_msg,(uint64_t*)&received_msg.data,&hdr);


CAN Message ID Table

Message ID Task associated with ID Data bit-fields
0x00 Kill Switch No Data
0x01 Reset
  reset_motorio:8;   // Acknowledge motorio controller
  reset_sensor:8;    // Acknowledge sensor controller
  reset_geo:8;       // Acknowledge geo controller
  reset_bluetooth:8; // Acknowledge bluetooth module  
0x02 Master Sync Ack
 ack_motorio:8;		// Acknowledge motorio controller
 ack_sensor:8;		// Acknowledge sensor controller
 ack_geo:8;			// Acknowledge geo controller
 ack_bluetooth:8;		// Acknowledge bluetooth module
0x03 MotorIO Controller Sync No Data
0x04 Sensor Controller Sync No Data
0x05 Bluetooth Controller Sync No Data
0x06 Geo Controller Sync No Data
0x07 MotorIO controller Heart-beat No Data
0x08 Sensor controller Heart-beat No Data
0x09 Bluetooth controller Heart-beat No Data
0x0A Geo controller Heart-beat No Data
0x0B Run mode mode:8;
0x0C Distance Sensor Data
 front_left:8;		// Front left sensor reading
 front_right:8;		// Front right sensor reading
 front_center:8;	        // Front centre sensor reading
 left:8;			// Left sensor reading
 right:8;			// Right sensor reading
 back:8;			// Back sensor reading
0x0D MotorIO Direction Data
 speed:8;			// Indicate speed for DC motor
 turn:8;			// Indicate turn angle for servo motor
0x0E Check-point Request Message No Data
0x0F Check-point Start Message
 num_of_points;	// Number of check-points to be loaded
0x10 Check-point Data
 float latitude;
 float longitude;
0x11 Geo-Controller New Destination Data
 float latitude;
 float longitude;
0x12 Geo-Controller Speed and Angle message
 speed:8;		// Speed as measured by the GPS sensor
 heading:16;		// Heading from the Geo controller
 bearing:16;		// Bearing calculated by the Geo controller
0x13 Geo-Controller Location Data
 float latitude;
 float longitude;
0x14 Light and Battery Sensor Data
 light_sensor:8;	// Light sensor reading
 batt_sensor:8;	// Battery level sensor reading

Sensor Controller

Team Members:

Divya Dodda
Dhruv Kakadiya

Sensor Controller Schedule

SI No. Start Date End Date Task Status Actual Completion Date
1 09/20/2015 09/27/2015 Researching and ordering the sensors to be used in the project Completed 9/27/2015
2 09/27/2015 10/03/2015
  • Studying sensor data sheets and preparing code sketch to be used after components are procured
  • Interface ADC ultrasonic sensor to SJOne board(available spare sensors), reading sensor values and filtering the readings
Completed 10/03/2015
3 10/03/2015 10/10/2015 Interfacing ADC ultrasonic sensor to SJOne board, reading sensor values and filter the readings Completed 10/10/2015
4 10/10/2015 10/20/2015 Understanding inertial measurement unit sensor, interfacing it to SJOne board to get filtered readings Completed 10/20/2015
5 10/20/2015 11/05/2015 Integrating multiple sensors to the SJOne board, testing the sensors and debugging issues Completed 11/02/2015
6 11/05/2015 11/15/2015 Preparing sensor values to be sent over CAN bus and testing out the correctness of sensor can messages Completed 11/10/2015
7 11/25/2015 11/30/2015 Testing of code during final phases, modifying code in cooperation with other teams and optimization of code Completed 12/1/2015

Sensor Testing

Front Sonar Visualization

Simple Sensor ping operation

Sensor Ping Operation

HCSR04 Sensor Testing

  • As shown in the figure below, HC-SR04 ultrasonic sensor requires an external 5V DC supply.
  • When in the initial testing stage we just connected one sensor for testing the accuracy and the range of the sensor.
  • The values we received were very stable and neat.
HC-SR04 sensor

Parallax Ping Sensor Testing

  • As shown in the figure below, Parallax ping ultrasonic sensor requires an external 5V DC supply.
Parallax ping sensor

Finalizing distance sensors

  • Both sensors being pretty accurate, we were confused while finalizing one. So we were using both sensors, for front we were using Parallax and for left,right and back sensors we were using HCSR04 sensor.
  • HCSR04 sensor was better option because as it was much cost efficient than the Parallax Ping Sensor (Where one Parallax Ping costs $30, one HCSR04 costed us only $2)
  • Its only drawback is, the cheaper one sensor needed good filter to remove some spikes and Parallax sensor was working pretty good without any filtering.

Switching to Hardware Timer

  • Previously, all sensor were triggered using software timers. We declared a soft timer for each sensor which kept track of the time between trigger and echo for that particular sensor.
  • If we see the declaration of software timer as shown below, we come to know that the timer returns a value in milliseconds.
   SoftTimer limit_time;    
   limit_time.reset(25);
   limit_time.restart();
   if(limit_time.expired()){
       break;
   }
  • If we apply the before mentioned distance formula to this timer value in milliseconds, we will always get the distance in multiples of 17.
  • Let's work out an example for better understanding;

F15 243 TG IMG SoftTimerCalculation.jpg

  • As the return return type of this function is an integer, we always get the distance in multiples of 17, which compromises the accuracy by a large factor.
  • Because of this reason we switched to hardware timers.
  • The declaration of hardware timer is as shown below, and this return value of time is in micro-seconds.
   lpc_timer_enable(lpc_timer0,1);
   lpc_timer_set_value(lpc_timer0,0);
  • Let's work out the same example for the return value being 1usec.

F15 243 TG IMG HardTimerCalculation.jpg

  • Hence, even if the timer value is an integer, as it is in microseconds, we have improved the accuracy.
  • As there are only three hardware timers in LPC 1768 we cannot allot individual timer for each sensor. Hence, we use just one hardware timer which runs regardless any individual sensor.
  • All sensors get the current timer value during trigger and echo from this single timer, and do the further processing individually.

Sequentially Triggering of Sensors

  • We used to trigger all the sensors at the same time, which caused interference between adjacent sensors, which in turn caused mis-firing of echo.
  • This resulted in incorrect distance values from all the sensors.
  • Thus to solve this issue, we implemented sequential triggering.
  • Under this logic, each sensor will be triggered only when the previous sensor receives an echo or exceeds the maximum echo reception wait time which is 60msec.
  • This implementation solved the issue at hand but gave rise to a new issue which is mentioned in the next section.

Limiting the Scope to Improve Frequency

  • As discussed in the previous section, if we implement sequential triggering for each sensor, if there is no obstacle, then the worst case delay would be 360 msec(60msec*6sensors) to update all sensor values to the master.
  • Means the frequency of communicating these values to the master will be, 2.8Hz.
  • For proper obstacle avoidance, we need to provide the sensor data to the master atleast 10 times per second, i.e. at 10Hz.
  • Which means data from all six sensors must be calculated within 100msec.
  • Even if we consider limiting the time allotted to a sensor to time required for maximum distance (400cms), we will require 23.5msec each sensor i.e. 141msec to update the values of all six sensors. This increases the frequency to 7.1Hz.
  • This led is to the solution to this problem, if we limit the scope of each sensor then we can update the sensor values more frequently to the master.
  • To overcome this issue, we limited the maximum scope of the sensor to 170 cms, limiting the time required to get the echo to 10msec. Which makes the total time required to calculate all six sensors' data about 60msec.
  • Hence, as shown in the flowchart, each sensor waits 10msec for an echo. If we get an echo within 10msec, we calculate the distance; if we don't, we assume the obstacle is at 170cms or further.

Misfiring of Sensor

  • At times the sensor used to mis-fire. Which means; in a stable condition, if the obstacle is at a constant distance of 150cms, 1 out of 50 continuous values will be 60cms.
  • This value being false, misguides the master.
  • To overcome this issue, we introduced a threshold value called DELTA (say, 10cms). Which defines the acceptable range from the previous value.
  • In this algorithm, an abrupt change in the distance value should be constant for at least two consecutive reads to be considered genuine.
  • If the current value from the sensor is in the range of the previous value's +/- 10cms, then this value is considered to be correct, and is provided to the master. Then this current value will be copied in the previous value register.
  • If the current value is not is the previous value's +/- DELTA range then it is considered as a misfire and hence is not provided to the master. But this sudden change might be because of a sudden obstacle; hence, the value is copied in the previous value register, and if the same value repeats, it will be considered genuine and provided to the master.
  • The code for this algorithm is as shown below;
       if(temp-DELTA<current && current<temp+DELTA){
           distance = current;
       }
       temp = current;
  • Hence, this algorithm will overcome the abrupt mis-firing of the sensor and make the data provided to the master more reliable.

Sensor Software Design

Sensor Controller Team Software Design

  • Sensor software design is composed of three crucial tasks, which are to read GPIO based sonar, read ADC based sonar, and CAN TX.

Operation Sequences

GPIO based read
ADC based read
CAN Frame write

Tasks

Sensor Controller Tasks
Task Name Purpose
Period Init Can bus initialization
Period Register telemetry Register sensor_data can message
Periodic 1Hz Callback Check can bus off
Periodic 10Hz Callback Get and Send Sensor Data

Sensor Zones

Each sensor can detect obstacles at a maximum range of 400cm. We have divided this range into 3 zones as shown in the figure.

Sensor Zones

Sensor Pin Connections

Line Item# Node A Source Node A Pin Node B Source Node B Pin Description
1 3.3V Power Supply 3.3V SJOne Board 3V3 SJOne Power
2 3.3V Power Supply GND SJOne Board GND SJOne Ground
3 CAN Transceiver Tx SJOne Board P0.1 (Tx) SJOne - CAN Tx
4 CAN Transceiver Rx SJOne Board P0.0 (Rx) SJOne - CAN Rx
5 CAN Transceiver 3.3V 3.3V Power Supply 3.3V SJOne - CAN Power
6 CAN Transceiver Ground 3.3V Power Supply GND SJOne - CAN Ground
7 Parallax Ultrasonic Sensor (Front Left) Vcc 5V Power Supply +5V Front Left Sensor Power
8 Parallax Ultrasonic Sensor (Front Left) GND 5V Power Supply GND Front Left Sensor GND
9 Parallax Ultrasonic Sensor (Front Left) Echo/Trig SJOne Board P2.0 Front Left Sensor Echo
10 Parallax Ultrasonic Sensor (Front Right) Vcc 5V Power Supply +5V Front Right Sensor Power
11 Parallax Ultrasonic Sensor (Front Right) GND 5V Power Supply GND Front Right Sensor GND
12 Parallax Ultrasonic Sensor (Front Right) Echo/Trig SJOne Board P2.2 Front Right Sensor Echo
13 Parallax Ultrasonic Range Sensor (Front Middle) Vcc 5V Power Supply +5V Front Middle Sensor Power
14 Parallax Ultrasonic Range Sensor (Front Middle) GND 5V Power Supply GND Front Middle Sensor GND
15 Parallax Ultrasonic Range Sensor (Front Middle) Echo SJOne Board P2.4 Front Middle Sensor Echo
16 Parallax Ultrasonic Range Sensor (Front Middle) Trig SJOne Board P2.5 Front Middle Sensor Trig
17 CAN Transceiver CANL CAN BUS CANL CANL to CAN BUS
18 CAN Transceiver CANR CAN BUS CANR CANR to CAN BUS

Sensor Implementation Using Interrupts

  • We implemented interrupt based code for 3-pin and 4-pin ping sensors.

Implementation of 4-pin Sensors With Interrupt

  • Initially a class for the 4-pin sensor was developed. Three instances of this class were declared for front, right and left sensors with GPIO pin numbers for trigger, echo with trigger being the input to the sensor and echo being the output of the sensor to the board.In addition to the pin numbers an unique index for each sensor.
  • First task was to assign the pin numbers to set as input and output pins which were interrupt based GPIO pins.
  • From the file "eint.h", we inferred the ports 0 and 2 were interrupt based pins.
Interrupt On The Echo Pin
  • To set an interrupt on echo pin, we used the API "eint3_enable_port2(pin, edge_type, callback_function)". The respective echo pin number was provided as the first parameter for front, right and left sensors. The edge type was rising and falling edge on the echo pin of each sensor. Two callback functions were implemented for rising and falling edge. When the echo pin went high,we captured the time using the API "sys_get_uptime_us()" in the rising edge callback function. When the echo pin went low, we captured the time using the same API in the falling edge callback function. The difference between uptime and downtime obtained from these callbacks functions, was used to calculate the distance using the formula "distance(in cms) = (downtime-uptime) * (1.0 / 58.0)."
Design Flow
  • The function for pinging the sensors followed the order front,right and left with indexes 0,1, and 2 respectively. The function was called from 1000Hz periodic callback function. The design flow for the function was as follows:
  • 1. Check the index of the pinged sensor.
  • 2. Send the pulse to the trigger pin for the indexed sensor.
  • 3. Calculate uptime, downtime, distance for the current instance sensor.
  • 4. Add the latest calculated distance value to a dedicated filter for the respective sensor.
  • 5. The filter would update and return the latest average distance.
  • 6. Calculate the zone for the distance obtained.
  • 7. The data to be sent onto the can bus involves the zone information for all the three sensors for every 1000Hz. This meant the zone information of the pinged and the un-pinged sensor values are needed out to be sent over the bus.
  • 8. We concluded that at a given point of time, the can bus would receive the previously calculated values for all the sensors. What this meant is if we calculated the values for current instance of the front sensor, we would push the values of the previous instance of front,right and left sensors on the bus. This would keep the master updated with all the sensor data.
Sensor Implementation with Interrupts Pin Connections
Line Item# Node A Source Node A Pin Node B Source Node B Pin Description
1 3.3V Power Supply 3.3V SJOne Board 3V3 SJOne Power
2 3.3V Power Supply GND SJOne Board GND SJOne Ground
3 CAN Transceiver Tx SJOne Board P0.1 (Tx) SJOne - CAN Tx
4 CAN Transceiver Rx SJOne Board P0.0 (Rx) SJOne - CAN Rx
5 CAN Transceiver 3.3V 3.3V Power Supply 3.3V SJOne - CAN Power
6 CAN Transceiver Ground 3.3V Power Supply GND SJOne - CAN Ground
7 4-pin Ultrasonic Sensor (Front) Vcc 5V Power Supply +5V Front Sensor Power
8 4-pin Ultrasonic Sensor (Front) GND 5V Power Supply GND Front Sensor GND
9 4-pin Ultrasonic Sensor (Front) Trig SJOne Board P2.0 Front Sensor Trigger pin
10 4-pin Ultrasonic Sensor (Front) Echo SJOne Board P2.1 Front Sensor Echo pin
11 4-pin Ultrasonic Sensor (Right) Vcc 5V Power Supply +5V Right Sensor Power
12 4-pin Ultrasonic Sensor (Right) GND 5V Power Supply GND Right Sensor GND
13 4-pin Ultrasonic Sensor (Right) Trig SJOne Board P2.2 Right Sensor Trigger pin
14 4-pin Ultrasonic Sensor (Right) Echo SJOne Board P2.3 Right Sensor Echo pin
15 4-pin Ultrasonic Sensor (Left) Vcc 5V Power Supply +5V Left Sensor Power
16 4-pin Ultrasonic Sensor (Left) GND 5V Power Supply GND Left Sensor GND
17 4-pin Ultrasonic Sensor (Left) Trig SJOne Board P2.4 Left Sensor Trigger pin
18 4-pin Ultrasonic Sensor (Left) Echo SJOne Board P2.5 Left Sensor Echo pin
19 CAN Transceiver CANL CAN BUS CANL CANL to CAN BUS
20 CAN Transceiver CANR CAN BUS CANR CANR to CAN BUS

Implementation 3-pin Sensors With Interrupt

Design flow
  • The design flow for the 3-pin ping sensors with interrupts was same as the 4-pin ping sensors with interrupts.
  • 3-pin sensor has a single pin for Echo and Trigger.
  • 1. In the sensor function, first the Trigger pin is set as output. A high to low pulse is provided.
  • 2. Once the low pulse is provided on the trigger pin, the same pin is configured as input pin to the board.
  • 3. The echo pin is monitored for rising and falling edge. Once the falling edge is detected, the distance calculation, can data transfer takes place following the same logic as 4-pin sensor.
  • The pin connections for this implementation are same as Sensors pin connections mentioned in 7.2.3.

Geographical Controller

Team Members:

Chitrang Talaviya
Navjot Singh

Geographical Controller Schedule

SI No. Start Date End Date Task Status Actual Completion Date
1 09/20/2015 09/27/2015 Researching and ordering the parts Completed 9/27/2015
2 09/27/2015 10/05/2015 Studying module data sheets and writing code sketches to be used when modules are procured(GPS and IMU) Completed 10/05/2015
3 10/05/2015 10/15/2015 Interfacing GPS module and compass to SJOne board and get consistent filtered readings Completed 10/17/2015
4 10/15/2015 10/30/2015 Proposals for heading and distance calculation, unit testing and integrating modules Completed 10/30/2015
5 10/30/2015 11/10/2015 Calibration of compass and GPS readings, CAN bus communication from geo controller to other boards. Completed 11/10/2015
6 11/10/2015 11/25/2015 Android application connection with data reception and transmit Completed 11/25/2015
7 11/25/2015 12/15/2015 Final phase testing and optimization, collaborating with android team to get better reliable outcomes Completed 12/12/2015

Geographical Controller H/W Design

  • Below figure represents the block diagram of Geo Controller. Geo-controller uses GPS and IMU module for its working. Uart3 and Uart2 are used for interfacing IMU and GPS with SJ One board at baud rate 9600bps.
H/W Interface of GeoController

Geographical Controller Hardware Design Components

Adafruit MTK3339 GPS:

This GPS unit is interfaced via UART with build in antenna. The GPS provides latitude and longitude accurately up to 5-10 meters with a strong satellite fix with update rate of 10Hz. By default, the baud rate is 9600bps. Power usage for this module is 20mA during navigation.

The GPS module comes with following capabilities:

  • -165 dBm sensitivity, 10 Hz updates, 66 channels
  • 5V friendly design and only 20mA current draw
  • Breadboard friendly + two mounting holes
  • RTC battery-compatible
  • Built-in datalogging
  • PPS output on fix
  • Internal patch antenna + u.FL connector for external active antenna
  • Fix status LED

We chose this part because it provided the base functionality we needed along with many other functions that would be fun to play with and try to include in the project. The antennae options and voltage regulator were also very enticing. We gets raw GPS "NMEA sentence" output from module. The most important NMEA sentences include the GGA which provides the current Fix data, the RMC which provides the minimum gps sentences information, and the GSA which provides the Satellite status data. We are filtering the data for RMC, Recommended Minimum, which will look similar to:

    $GPRMC,123519,A,4807.038,N,01131.000,E,022.4,084.4,230394,003.1,W*6A
where:-RMC          Recommended Minimum sentence C
     123519       Fix taken at 12:35:19 UTC
     A            Status A=active or V=Void.
     4807.038,N   Latitude 48 deg 07.038' N
     01131.000,E  Longitude 11 deg 31.000' E
     022.4        Speed over the ground in knots
     084.4        Track angle in degrees True
     230394       Date - 23rd of March 1994
     003.1,W      Magnetic Variation
     *6A          The checksum data, always begins with *


GPS_Module

9 Degrees of Freedom- Razor IMU:

In our project, we used IMU module to get the heading of the device. The 9DOF Razor IMU provides nine degree of inertial measurement by incorporates three sensors - an ITG-3200 (MEMS triple-axis gyro), ADXL345 (triple-axis accelerometer), and HMC5883L (triple-axis magnetometer).The outputs of all sensors are processed by an on-board ATmega328 and output over a serial interface. UART interface is used for interfacing with SJ One board and it is connected via UART3 with LPC board and is operated at 3.3V.

Features:

  • 9 Degrees of Freedom on a single, flat board:
    • ITG-3200 - triple-axis digital-output gyroscope
    • ADXL345 - 13-bit resolution, ±16g, triple-axis accelerometer
    • HMC5883L - triple-axis, digital magnetometer
  • Outputs of all sensors processed by on-board ATmega328 and sent out via a serial stream
  • Autorun feature and help menu integrated into the example firmware
  • Output pins match up with FTDI Basic Breakout, Bluetooth Mate, XBee Explorer
  • 3.5-16VDC input
  • ON-OFF control switch and reset switch
9DOF-IMU

Geographical Controller H/W Interface

  • Below table shows the Pins connection of GPS and IMU module with SJ One Board. Both the h/w's are interfaced with Controller using UART interface. The operating volatge of GPS and IMU is 3.3V.
Geographical Controller Pin Connection Table
Description Interface Device Port SJOne Board Port
Supply Voltage N/A Vcc 3.3 V
Ground N/A GND GND
GPS Module UART2
Channel 1 -> Rx
Channel 2 -> Tx
Channel 3 -> EN 
Channel 1 -> Tx P2.8
Channel 2 -> Rx P2.9
Channel 3 -> Vcc
IMU Module UART3
Channel 1 -> Rx
Channel 2 -> Tx 
Channel 3 -> DTR
Channel 1 -> Tx P4.28
Channel 2 -> Rx P4.29
Channel 3 -> GPIO P2.2

Geographical Controller S/W Design

Geographical controller uses two modules to get GPS data and headings. These are:

  • GPS module
  • IMU module


Tasks

Geo Controller Tasks
Task Name Purpose
IMU Task To get IMU reading over UART3.
GPS Task Read the GPS data string via UART2 Interrupt Handler.
Periodic 1Hz Callback Receive Checkpoint from Master.
Periodic 10Hz Callback Send GPS data over CAN BUS

Send IMU heading,bearing,speed and distance data over CAN Bus


In the below sections, one will see the methods used to get the values from the modules. Both of the modules are interfaced using UART.

GPS

  • Initialization: GPS data is retrieved using Interrupts for UART2. Before using Interrupts for receiving GPS string that contains data,UART2 is initialized with Receiving Interrupts Enabled. The code for UART init is as below. The UART init is done once, so is called in main().
void uart2init()
{
   // In our inter-board communication we have used UART 2 for transmission and reception. So, We will unable UART 2.
   LPC_SC->PCONP |= (1<<24);  // We have to Power on the UART 2 peripheral. To do so we have to enable bit 24 of PCONP register.
   LPC_SC->PCLKSEL1 &= ~((1<<16)|(1<<17));    // Peripheral Clock = CPUClock/4. (48 Mhz/4= 12 Mhz)
   LPC_PINCON->PINSEL4 &= ~((1<<19)|(1<<18)|(1<<17)|(1<<16)); 
   LPC_PINCON->PINSEL4 |= ((1<<19) | (1<<17));  // We have to set this bits to meet the requirements of selection lines.
   LPC_UART2-> LCR  |= 0xFFFFFF83;    // To access DLL and DLM we have to set 7th bit of the LCR. We are enabling Dlatch by setting this bit.
   // 0 and 1 bits of LCR is 11. 8 bit data format. 1 stop bit. No parity.
   LPC_UART2 -> DLL = 71;         // To set the baud rate 9600 bps we have to set divisor latch least significant bits to 96.
   LPC_UART2 -> DLM = 0;// and most significant bits to 0.
   LPC_UART2-> FDR = 0xA1;
   LPC_UART2-> LCR &=~(1<<7) ;    // We have to reset the Dlatch bit before starting the communication.
   LPC_UART2->FCR = (1 << 0) | (1 << 6);
   LPC_UART2->FCR |= (1 << 1) | (1 << 2);
   LPC_UART2->IER = (1 << 0);
}
  • Getting GPS data from Interrupt Handler: The reason we used Interrupt handler was to get the data from GPS without any delay. Interrupt handler on getting all the string, will send over 'Queue'. To get data from the GPS module, we need to send raw data over UART bus :

char dataTobeSenttoGPS[] = "$PMTK314,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*29\r\n"; char dataTobeSenttoGPS_1[] = "$PMTK220,100*2F\r\n"; After sending this, we will be getting GPS string after every 100ms, which is read by interrupt handler as:

extern "C"
{
   void UART2_IRQHandle()
   {
       static  char GPS_buffer1[100];
       static int i_new=0;
       while(!(LPC_UART2-> LSR & 0x01));
       GPS_buffer1[i_new]= LPC_UART2 -> RBR;
       if(GPS_buffer1[i_new]=='\n') {
          GPS_buffer1[i_new]='\0';
          flag_received = true;
          if(xQueueSendFromISR(gps_queue1, &GPS_buffer1 , 0)) {
          }
          else{
          }
          i_new=0;
       }
       else{
       i_new++;
       }
   }
}
  • Sending data over CAN bus: In GeoController, we are using can1 for transmit and receive can messages. Latitude and longitude values are getting updated by GPS task using global structure. 'CAN send' function which is getting called every 100hz is using memcpy function to copy the structure data to CAN message and send over can bus.
       gps_msg.msg_id = GEO_LOC_DATA_ID;
       gps_msg.frame_fields.is_29bit = 0;
       gps_msg.frame_fields.data_len = sizeof(gps_data_dec);
       memcpy(&gps_msg.data.qword, &gps_data_dec, sizeof(gps_data_dec));
       CAN_tx(GEO_CNTL_CANBUS, &gps_msg, GEO_CNTL_CAN_TIMEOUT);

IMU

  • Initialization: IMU is initialized using Singleton Class pattern. UART3 is being used for IMU interface with board.
   readYawCommand{'#', 'f'} // string is used to get Yaw reading from IMU module.
   if(IMUInterface.sendYawReadCommand(IMUInterface.readYawCommand))
   {
       // Waits for a response from IMU
       if(IMUInterface.getYawReadingString())
       {
           CUSTOM_DEBUG("IMUTask : Read success");
       }
       else
       {
           CUSTOM_DEBUG("IMUTask : Read fail");
       }

The Yaw data we received from getYawReadingString() is used later to calculate heading value.

  • Sending data over CAN bus: CAN1 is used for sending can messages. Following code shows, how the structure for IMU is filled by calling respective functions such as : calculateBearing(), getHeading(), calculateDistance() and then send over CAN bus.
void geo_send_heading()
{
   can_msg_t geo_msg;
   geo_spd_angle geo_data;
   if(a == GEO_DATA_TO_SEND)
   {
       static imu& imu_handle = IMUInterface;  // Handle to singleton IMU object
       geo_data.bearing = calculateBearing(current_checkpoint_data);   // put bearing here
       geo_data.heading = imu_handle.getHeading();
       if(geo_data.heading < HEADING_OFFSET2 && geo_data.heading >= 0)
       {
           geo_data.heading = 360 - HEADING_OFFSET2 + (geo_data.heading);
       }
       else
       {
           geo_data.heading = geo_data.heading - HEADING_OFFSET2;
       }
       geo_data.speed = speed_gps;
       geo_data.distance = (uint16_t)calculateDistance(current_checkpoint_data);
   }
   if(a == GEO_DO_NOT_SEND)
   {
       geo_data.bearing = 0;   // put bearing here
       geo_data.heading = 0;
       geo_data.speed = 0;
       geo_data.distance = 0;
   }
   geo_msg.msg_id = GEO_SPEED_ANGLE_ID;
   geo_msg.frame_fields.is_29bit = 0;
   geo_msg.frame_fields.data_len = sizeof(geo_data);
   memcpy(&geo_msg.data.qword,&geo_data, sizeof(geo_data));
   CAN_tx(GEO_CNTL_CANBUS, &geo_msg, GEO_CNTL_CAN_TIMEOUT);
}
  • Updating Firmware on IMU:
    • For updating the firmware on IMU, we used FTDI basic breakout which uses USB mini cable to connect to PC. The board comes programmed with the 8MHz Arduino bootloader (stk500v1) and some example firmware that demos the outputs of all the sensors. UART connection are made to interface IMu with breakout board at 57600bps.
    • Connections between IMU and FTDI breakout :-
FTDI BREAKOUT      RAZOR
GND           <--> GND
CTS           <--> CTS
3.3V          <--> 3.3V
TXO           <--> RXI
RXI           <--> TXO
DTR           <--> DTR 

The details are given at: https://github.com/ptrbrtz/razor-9dof-ahrs/wiki/Tutorial. Firmware provides the readings Yaw, Pitch and Roll readings. As in the project we only need the Yaw data, so firmware is been updated to provide only the Yaw readings.

  • Sensor Calibration:
    • Sensor calibration include calibrating the accelerometer, gyroscope and magnetometer. Sensor calibration in our project is done twice, once in the beginning and then at the end when all the boards are mounted on the car. As the magnetic field of motor can effect the gyroscope readings so we did the calibration again. The details can be found on the link given above.


Software Flow Diagram


S/W Interface Flow Diagram of Geo-Controller

Motor I/O Controller

Team Members:

Anuj Korat
Dhruv Kakadiya

Motor & I/O Controller Schedule

SI No. Start Date End Date Task Status Actual Completion Date
1 09/20/2015 09/27/2015 Researching and ordering the LCD module to be used in the project Completed 9/27/2015
2 09/27/2015 10/05/2015
  • Studying data sheets(LCD and motor) to get understanding of basic concepts and working of components
  • Understanding and proposing driving mechanisms for LCD and motors(DC and servo)
Completed 10/05/2015
3 10/05/2015 10/12/2015
  • Interfacing motors to SJOne board and developing drivers for the same
  • Interfacing LCD module to SJOne board and developing drivers to display basic texts and symbols
Completed 10/12/2015
4 10/12/2015 10/30/2015
  • Implementation of basic power on RC car run with motors(DC and servo) interfaced to SJOne board
  • Collaborating with other teams to develop basic obstacle avoidance and testing it
Completed 11/5/2015
5 10/30/2015 11/12/2015 Proposals related to speed controls and sensors for the same and integration of LCD module(with data display) Completed 11/12/2015
6 11/12/2015 11/25/2015 CAN bus communication from motor and I/O controller to other boards Completed 11/15/2015
7 11/25/2015 12/15/2015 Debugging issues during trial runs and testing out fault cases Completed 12/8/2015

Motor/IO Controller Software Design

Tasks

Motor/IO Controller Tasks
Task Name Purpose
Period Init Can bus initialization, Motor and LCD initialization
Period Register telemetry Register Motor_data can message and dc_speed counts for different speeds
Periodic 1Hz Callback Check can bus off and Print data on LCD
Periodic 10Hz Callback Drive car according to received data from Master controller
Periodic 100Hz Callback Receive CAN bus data
Periodic 1000Hz Callback Receive touch data from LCD and check RPM sensor

DC Motor

Our car came installed with the motor which needs 7.4V of power supply to work. This motor has the power to run the car at the maximum speed of the 35mph.

The table below contains information about PWM (duty cycle) given to the motor and the corresponding speed of the car on the flat surface.

S.R. Duty Cycle Speed(mph)
1 15.80 2
2 16.00 4
3 16.20 6
4 16.40 8
5 16.60 10
6 16.80 11

Table3: DC Motor Duty Cycle v/s Speed

F15 243 TG DC Motor.gif
DC Motor

DC motor is controlled with the help of three wires coming out of the ESC. The wires are Vcc, Gnd and Speed control. The Vcc is not used as required voltage is directly given to motor through battery via ESC. The Gnd is connected with Gnd pin and Speed control is connected to the PWM pin of SJOne board.

S.R. ESC Wire Pins SJOne Board Pins
1 Vcc -
2 GND GND
3 Speed Control P2.1

DC Motor Pin Connections

For DC motor we are using pwm2 i.e. pin P2.1 of the SJOne board, the pwm function is the in-build function which requires two parameters, one is pwm that we are using and the second parameter is the frequency of the pwm. To set the duty cycle in-build set function is used in which we are passing the duty cycle at which we want DC motor to work.

F15 243 TG motor cnt.png
DC Motor Connector

F15 243 TG Motor init.png

Servo Motor

Our car came with waterproof digital servo motor. This motor works without ESC. We can directly control this motor by giving PWM signal from our SJOne board. The below table contains information about PWM (duty cycle) given to the motor and the corresponding turns taken by the car.

S.R. Duty Cycle Turn
1 10.41 Full Left
2 12.35 Half Left
3 13.53 Slight Left
4 15.39 Straight
5 16.00 Slight Right
6 17.37 Half Right
7 20.03 Full Right

Servo Motor Duty Cycle v/s Turn

F15 243 TG Servo motor.gif
Servo Motor

Servo motor is controlled with the help of three wires coming out of the servo motor. The wires are Vcc, Gnd and Direction control. The Vcc is connected to the 3.3v, Gnd is connected with Gnd pin and direction control is connected to the pwm pin of SJOne board.

S.R. Servo Motor Pins SJOne Board Pins
1 Vcc Vcc
2 GND GND
3 Direction Control P2.0

Servo Motor Pin Connections

For Servo motor we are using pwm1 i.e. pin P2.0 of the SJOne board, the pwm function is the in-build function which requires two parameters, one is pwm that we are using and the second parameter is the frequency of the pwm. To set the duty cycle in-build set function is used in which we are passing the duty cycle at which we want servo motor to work.

Motor cnt1.png
Servo Motor Connector

F15 243 TG MotorControl Singletone.png
Motor PWM Singleton implementation

I/O Software Design

The I/O Software is based off of two tasks: The Event Handler Task and the RX Task.

Event Handler Task (High Priority):

This Task receives any immediate messages sent from the uLCD, processes the message, and sends the message to the CAN BUS.

This task enables the system to: Turn On/Off the Vehicle and Change Vehicle Modes.

RX Task (Low Priority):

This task receives all messages from the CAN BUS, and outputs message data onto the uLCD

High Level IO Software Logic -- Event Handler Task Logic -- RX Task Logic

HighLevel
EventHandlerTaskLogic
RXTaskLogic

Different screens on LCD

Locked Screen
Home Screen
Geo Screen
Sensor Screen
Motor Screen

The Displays on LCD were well thought of according to its application in our project. We wanted to test the sensor and the magnetometer readings while we were testing out car along with testing the algorithm of navigation. This would enable us to not connect the LPC controller with a Laptop to check any readings. The LCD we bought is from 4D systems and is very convenient and efficient to use. It has its own software which enables us to work in 4 different modes. We chose the mode which gave us different tools to build the compass, buttons and the angularometer. A bluetooth to serial converter is used to program the LCD with the software. After we had used the tools on to picturize our LCD screens. We burned the program down to LCD's memory card. The program that we burned on LCD will use the data bytes we send from our microcontroller and will print those bytes appropriately on different elements that we had created. For example, there are 360 degrees values to show on angularometer. The microcontroller will give a value from 0-360 based on the CAN frame which consists of car speed, heading and bearing values broadcasted by the Geo controller. In this way each and every item is driven.

Master Controller

Team Members:

Hemanth Konanur Nagendra
Akshay Vijaykumar

Master Controller Schedule

SI No. Start Date End Date Task Status Actual Completion Date
1 10/10/2015 10/20/2015
  • Establishing powerup sync and acknowledgement between master controller, sensor controller and Bluetooth controller
  • Implement heart beat monitoring on the master controller.
Completed 10/20/2015
2 10/21/2015 10/31/2015
  • Get sensor readings from the sensor controller and start/stop commands from Bluetooth controller to control the car
  • Send driving commands to the motor controller over the CAN bus
Completed 10/25/2015
3 10/26/2015 11/01/2015
  • Decide the obstacle avoidance algorithm based on sensor readings from sensor controller.
  • Implement and test the avoidance algorithm.
Completed 11/01/2015
4 11/10/2015 11/20/2015
  • Get route co-ordinates from Bluetooth controller and setup infrastructure to send checkpoint updates to Geo-controller.
  • The master controller should be able to receive new routes in between navigation.
Completed 11/20/2015
5 10/21/2015 11/30/2015
  • Get heading, bearing and speed information from Geo-controller
  • Decide on the navigation algorithm
Completed 11/24/2015
6 12/01/2015 12/07/2015
  • Test obstacle avoidance along with Navigation algorithm
Completed 12/12/2015
7 12/08/2015 12/15/2015 Extensive testing and smoothing out speed, turning, etc In Progress


The Master Controller receives obstacle information from the Sensor Controller, navigation data from the Geo Controller and routing information from the Bluetooth Controller, collates all this information and provides driving directions to the Motor Controller.

Design

Master Controller Team Hardware Design

F15 243 TG masterCANconnections.png

Master Pin Connections

Line Item# Node A Source Node A Pin Node B Source Node B Pin Description
1 3.3V Power Supply 3.3V SJOne Board 3V3 SJOne Power
2 3.3V Power Supply GND SJOne Board GND SJOne Ground
3 CAN Transceiver CAN Tx SJOne Board P0.1 (Tx) SJOne - CAN Tx
4 CAN Transceiver CAN Rx SJOne Board P0.0 (Rx) SJOne - CAN Rx
5 CAN Transceiver CAN 3.3V 3.3V Power Supply 3.3V SJOne - CAN Power
6 CAN Transceiver CAN Ground 3.3V Power Supply GND SJOne - CAN Ground
7 CAN Transceiver CANL CAN BUS CANL CANL to CAN BUS
8 CAN Transceiver CANR CAN BUS CANR CANR to CAN BUS

Control Flow

On boot-up, Master Controller first attempts to sync with all the other controllers through a power-up sync and acknowledgement handshake mechanism. Once sync is established with all the controllers, it periodically monitors the heart-beat signals from all the controllers till the end of power cycle. If any controller goes out of sync, the master requests that controller to reset itself.

The Master Controller now enters the ‘stopped’ state where no driving takes place. It continuously monitors the CAN bus for any routes from the Bluetooth Controller. Once all the navigation check points have been received, the Master Controller starts driving the car by directing the Motor Controller based on the Geo controller data. While driving, the Master Controller continuously listens for the obstacle data from the Sensor Controller and avoids any obstacles, if necessary. Once obstacle avoidance has been completed, Master makes any necessary course corrections and proceeds towards the destination as per the route.


Communication between Controllers

Power-up Sync and Acknowledgement

Once master boots up, it continuously monitors the CAN bus for a “Power up Sync” message from each of the other controllers. Once it receives the Sync message from all the controllers it acknowledges all of them at once by sending the “Master Sync Ack” message. This should prompt the other controllers to spawn their periodic tasks and start their respective functionalities.


Heart Beat Implementation

After sending the ACK message the master proceeds to spawn its own periodic scheduler and starts monitoring the heartbeat signals from all the controllers at a rate of 1Hz.

Every 1Hz, all the controllers are expected to send their respective “Heart-beat” message over the CAN bus. If this message fails to arrive, the master controller will wait for a specific period of time for the other controller to sync again. The sensor controller and motorIO controllers are very critical components for driving the car. So, they are not allowed to skip any heart-beats. The other controllers have varying thresholds of wait time, allowing them to sync with the master again. Once the threshold time is crossed, the master controller issues a “Reset” message for the controller that went out of sync. The receiving controller is expected to reset and sync again at this point.

If the sensor controller or motor controller go out of sync, the master stops issuing driving directions to the motorIO controller, hence stopping the car.

Data Communication

The master controller performs the following data transactions over the CAN bus.

Bluetooth controller signals to the master controller that a new route has been requested from the Android application through “Check-Point Send” message. In this message, the Bluetooth controller also specifies the number of check-points that are present along the route. The master acknowledges this signal through “Check-point Request” message. The Bluetooth controller starts sending the check-points periodically, at 10Hz, after it receives the ack. The master stores all these check-points in an array and switches to navigation mode.

In navigation mode, master controller issues the next immediate check-point to the Geo controller through “Geo location update” message and expects the current heading, current bearing, current speed and current GPS location information from the Geo controller with respect to this new checkpoint. Master controller continuously calculates the distance between the current GPS location and the current checkpoint location to determine if the checkpoint has been reached. Once reached, the next checkpoint co-ordinates are issued to the Geo controller. This cycle is repeated till the destination has been reached.

All through the navigation mode, master controller directs the motor controller to drive (speed and direction to turn) based on heading and bearing information from the Geo controller. The obstacle information is also being continuously received from the sensor controller. If an obstacle is detected, the master controller stops navigating to the checkpoint and avoids the obstacle. Once obstacle has been avoided the master goes back to navigation.

Driving Algorithm

Overview

Driving algorithm has two parts to it. One is the obstacle avoidance algorithm and the other is the navigation algorithm. Obstacle avoidance has a higher priority. Navigation algorithm drives the car as long as no obstacles are present.

Obstacle Avoidance Algorithm

The primary obstacle avoidance algorithm is based on the front three sensors. The algorithm is based on the truth table below. The near obstacles have higher priority than obstacles in the mid range, which has a higher priority than the obstacles in the far range. The tables below depict the action taken by the master controller when obstacles are in the near and mid-range. A ‘1’ in the table represents that a particular sensor has an obstacle within the range being evaluated. A ‘0’ represents that a particular sensor has no obstacle within the range being evaluated. The last two columns show the command sent from the master controller to the motorIO controller.

Obstacle avoidance in the Near range

Front Left Sensor Front Center Sensor Front Right Sensor Motor Speed Motor turn
0 0 0 Normal Straight
0 0 1 Slow Hard Left
0 1 0 Stop Straight
0 1 1 Slow Hard Left
1 0 0 Slow Hard Right
1 0 1 Stop Straight
1 1 0 Slow Hard Right
1 1 1 Stop Straight

Obstacle avoidance in the Mid range

Front Left Sensor Front Center Sensor Front Right Sensor Motor Speed Motor turn
0 0 0 Normal Straight
0 0 1 Slow Slight Left
0 1 0 Normal Straight
0 1 1 Slow Slight Left
1 0 0 Slow Slight Right
1 0 1 Stop Straight
1 1 0 Slow Hard Right
1 1 1 Stop Straight

Navigation Algorithm

As stated before, the Master Controller receives all the necessary parameters for navigation viz, current GPS co-ordinates, heading and bearing from the Geo-Controller. The heading and bearing are angles that are measured from 0 degrees to 360 degrees from the true North. Heading specifies the direction in which the car is currently oriented in. Bearing specifies the direction in which the car has to be oriented so as to reach the next check point. The current navigation algorithm divides the entire 360 degree orientation space of the car into 30 zones of 12 degrees each. The difference between the bearing and heading values is used to correct the direction of the car. This correction value would lie between 0 degrees to 360 degrees, falling into one of the 30 zones. As seen in the diagram, If the correction lies between 0 degrees to 12 degrees, the car should travel straight at normal speed. If the correction lies between 97 degrees to 180 degrees, the car should take a U-turn from the right direction at a slow speed. Similar behaviors of the car in terms of the direction and speed of movement of the car are specified for each zone and are sent as commands to the Motor Controller.

A few examples to test the correctness of the algorithm are discussed. If the heading is 50 degrees and the bearing is 90 degrees, the correction is 40 degrees. The behavior specified for the zone in which this correction will fall into is for the car to perform a hard right turn at slow speed. Similarly, if the heading is 70 degrees and the bearing is 10 degrees, the correction is -60 degrees. Converting this to a value in between 0 degrees and 360 degrees, we have 300 degrees ( 360 degrees - 60 degrees ). The behavior specified for the zone in which this correction will fall into is for the car to perform a slight left turn at normal speed.

Calculate Distance between two points
Zones used in the Navigation Algorithm

Bluetooth/Bridge Controller

Team Members:

Anush Shankar
Aditya Devaguptapu

Bluetooth/Bridge Controller Schedule

SI No. Start Date End Date Task Status Actual Completion Date
1 09/20/2015 09/30/2015 Getting familiarized with Android SDK, Java, Bluetooth API and Google Maps API Completed 09/30/2015
2 09/31/2015 10/10/2015
  • Placement of buttons on the app activity page to switch on and off bluetooth on the phone
  • Marker placement on Google maps for source and destination
Completed 10/10/2015
3 10/10/2015 10/22/2015
  • Creating input and output streams for bluetooth for sending and receiving data
  • Performing straight line routing between source and destination on google maps
Completed 10/22/2015
4 10/22/2015 10/30/2015 Interfacing bluetooth module to SJOne board through UART and receive data on SJOne board sent by the bluetooth application Completed 11/05/2015
5 10/30/2015 11/10/2015 Relay commands and CAN messages from SJOne to android application and test correctness of data Completed 11/15/2015
6 11/10/2015 11/22/2015 Performing correct routing between source and destination, have a complete working application, basic testing of application and bridge interface Completed 11/22/2015
7 11/22/2015 12/15/2015 Extensive Testing of application during final phases, modifying code in cooperation with other teams and optimization of android application Completed 12/13/2015

Bluetooth Controller

The Bluetooth Controller is responsible to help the RC car navigation by providing it with route information between source and destination as selected on the Android application. It communicates with the Android application over Bluetooth channel to obtain the route and way-point data between two points on the google map. The route and way-point information once received is parsed to get latitude and longitude for all way-points. This information is then communicated to the Master Controller via CAN bus.

HC-06 Bluetooth Module

HC-06 Bluetooth Module

The HC-06 is a bluetooth controller with slave only configuration used to communicate to and from a master Bluetooth module. The master Bluetooth module is capable to initiating a connection with other Bluetooth module, while slave is not able to do that. The slave can only communicate with the master module over a connection established by the master. The HC-06 by default is in slave configuration as per factory settings.


Some of the features of HC-06 which make it apt for the RC car are as follows:


  • Can work at the low voltage (3.1V~4.2V). The current in pairing is in the range of 30~40mA. The current in communication is 8mA.
  • Has a 2.4GHz digital wireless transceiver.
  • Small (27mm×13mm×2mm)
  • Peripherals circuit is simple.
  • Low power consumption
  • Has high-performance wireless transceiver system
  • Low Cost

Bluetooth Controller Hardware Design

Bluetooth Controller Interface Diagram

Bluetooth Controller Pin Connections

Line Item# Node A Source Node A Pin Node B Source Node B Pin Description
1 Power Supply 3.3V SJOne Board 3V3 SJOne Power
2 Power Supply GND SJOne Board GND SJOne Ground
3 CAN Transceiver CAN Tx SJOne Board P0.1 (Tx) SJOne - CAN Tx
4 CAN Transceiver CAN Rx SJOne Board P0.0 (Rx) SJOne - CAN Rx
5 CAN Transceiver CAN 5V Power Supply 5V SJOne - CAN Power
6 CAN Transceiver CAN Ground Power Supply GND SJOne - CAN Ground
7 CAN Transceiver CANL CAN BUS CANL CANL to CAN BUS
8 CAN Transceiver CANH CAN BUS CANH CANH to CAN BUS
9 Bluetooth Module TXD SJOne Board RXD3 SJOne RX3- Bluetooth module TXD
10 Bluetooth Module RXD SJOne Board TXD3 SJOne TX3- Bluetooth module RXD
11 Bluetooth Module Bluetooth module VCC(3.3V) Power Supply 3.3V Bluetooth module - Power supply 3.3V
12 Bluetooth Module Bluetooth module GND Power Supply GND Bluetooth module - Power supply GND

Control Flow

On boot-up, Bluetooth Controller first attempts to sync with the Master controller through a power-up sync and acknowledgement handshake mechanism. Once sync is established with the Master Controller, the Bluetooth controller periodically sends heart-beat signals to master controller till the end of power cycle. If any Bluetooth controller goes out of sync, the master requests the controller to reset itself.

Once all initial handshaking procedures are completed and heart beat signal is established, the Bluetooth Controller waits for data from the On board HC-06 Bluetooth module on the UART port. When Bluetooth connection is established between the Android application and the On board HC-06 Bluetooth controller, routing data is sent from the Android app to the SJOne board. The SJOne board receives the data on UART port via interrupts and parses the data to extract 6 point precision floating point values for each way-points latitude and longitude. The way-point latitude and longitude is stored in a array to be sent out on CAN bus.

Once all way-point data is parsed and ready, the SJOne board first sends out the number of way-points to the master controller and waits for acknowledgement from the master controller. One reception of the acknowledgement from the master and intent to receive the way-point data, the data is sent on the CAN bus periodically till all the data is exhausted.

Communication between Bluetooth and Other Controllers

Power-up Sync and Acknowledgement

Once Bluetooth controller boots up, it continuously sends "Power up Sunc" on the CAN bus to the master using "BLUETOOTH_SYNC_ID" can message id. The controller then polls on the sync function to receive an acknowledgement from the master towards "Power on Sync". Once an acknowledgement is received from master with message id "MASTER_SYNC_ACK_ID", the Bluetooth controller starts the FreeRtos scheduler. Only after this will all tasks run on the controller.

Heart Beat Implementation

Once Bluetooth controller starts the scheduler, it starts sending out heart beat messages on can bus directed towards the master controller using message id "BLUETOOTH_HEARTBEAT_ID" every 1 Hz. If the master does not receive heart beat message it asks Bluetooth controller to reset.

Data Communication

The Bluetooth controller performs data transactions over the CAN bus with the master controller and Geographical controller. The Bluetooth controller receives the geo coordinates every 1 hz using "GEO_LOC_DATA_ID" to get current car location and send it to the android application for dynamic location update. Bluetooth controller signals to the master controller that a new route has been requested from the Android application through “CHECKPOINT_SEND_ID” message id. In this message, the Bluetooth controller also specifies the number of check-points that are present along the route. The Bluetooth Controller waits on master's acknowledgement through “CHECKPOINT_REQ_ID” message id. The Bluetooth controller starts sending the check-points periodically, at 10Hz, after it receives the ack. Once all the way-points are sent to the master, the Bluetooth Controller goes to listening to UART interrupts for any changes in the route.

Flow Chart

The flow chart for the Bluetooth Controller is as follows:

Bluetooth Controller Flow Chart

Android Application Design

Problem Definition

At the end of the day, an autonomous vehicle is built so as to usher in a new era of transport where the user need not be concerned with driving the vehicle. With this basic idea in mind, we can thus define our problem- how does one communicate with an autonomous vehicle to perform the tasks he/she desires? On further contemplation, it could even be argued that we are able to accomplish the task of navigating from source to destination in a normal vehicle because the user is able to manually control the vehicle. We will hence require an interface by means of which we can specify a source and a destination. With the ubiquity of smart phones, it makes perfect sense for us to leverage the availability of the Android platform to make an application that would augment the user’s ability of accomplishing objectives with the autonomous vehicle.

A Basic Mock Up of the App based on the Problem Definition

Design

The objective of the Android App is to be able to let the user control the car by issuing commands from a smartphone- the most fundamental commands being the ability to issue a source and a destination for the Car to traverse. Providing the car with autonomy ensures that we need to be able to specify location information to the car in a form that it can understand. We will thus use Google’s comprehensive mapping solution to look up places on the map. We shall also use their services to get the best route available between the source and the destination. Google’s Android OS is a very popular OS for smartphones. Its proliferation in the smartphone market, very comprehensive documentation and open-source nature make it a natural choice for the platform on top of which the application will be developed. Android Studio is Google’s IDE for developing applications on the Android platform. Their Maps API will be used to implement a Map fragment and to specify travel points while the Directions API works in the background to provide a route from source to direction. The user will be provided with buttons to connect with the car, to issue Start/Stop Commands, to send a route if a travel needs to be performed and to determine the location of the car.


Android application design and sequence of operations

Implementation

App Template and Using Google Maps within an App

Android Studio comes with some default templates which lets the user have a basic app up and running within no time. The project has a .java file to program the logic of the app while the user interface can be modified using the .xml(extended markup language) file. The user can test the app using the in-built emulator or by running it on an Android phone. To use Maps within your application, you will first have to get a API key on Google’s Developer Console online. This API key lets Google track statistics related to the app usage. If the Map loads when the App starts up, then its a sign that you’ve successfully implemented a Map fragment.

Using Maps and Implementing the Directions API

A Maps Fragment comes with several features that let the user specify input to the App. We use Markers (Pin shaped images) to denote locations on the map. Every Marker on the map has its own latitude and longitude which is a necessary value for calculating a route. We essentially want to calculate a route from a source, which in this case, is the location of our car. The CarLocation Button gets us the location of the Car and places a marker on the map at the location of the Car. The App has a OnClickListener function in the background, waiting for a tap input from the user. This tap places a marker that denotes the destination that the user, or in this case, the car will navigate to. On placing the destination marker, the Directions API calculates a route between the source and the destination based on how the parameters for the API are defined. The Directions API returns intermediate points (with latitudes and longitudes of their own) that form a route between the source and the destination. The Polylines function defined within the map can be used to plot a line that connects these points from the source to the destination.

Using Bluetooth and Bluetooth API

Android provides a robust and well defined Bluetooth API as part of application development support. The API provides functions to query devices, pair with devices, connect to devices and send/receive data. In our application pairing, connection and send/receive API functions are used to talk to HC-06 Bluetooth module on the RC car. The application has a bunch of buttons at the bottom which are used to establish Bluetooth communication and used to control markers on the Google Map. The functionalities of the Buttons are as follows:

SI No. Button Functionality
1 ON User is prompted to Turn on Bluetooth device on the phone. User can "allow" or "deny" the request. Application displays message if no bluetooth support on phone.
2 CONNECT Establishes a communication channel with a slave Bluetooth. Connection is done to a Predefined Bluetooth MAC address.
3 DISCONNECT Disconnects communication channel with an already connected Bluetooth module
4 START CAR Sends string 0 over Bluetooth channel to indicate to the SJOne Board start of car.
5 STOP CAR Sends string 0 over Bluetooth channel to indicate to the SJOne Board to kill the car(Wireless Kill switch).
6 CLEAR Clears markers on the Google Map.
7 CAR LOC Places a marker on Google Map based on cars coordinates received from the HC-06 Bluetooth module on-board the car.
8 SEND ROUTE Send route from source to destination selected on map after filtering way-points.

Our Modifications

  • The number of points returned was filtered to obtain an accurate route with sufficient points, enough to not overwhelm the SJOne Board during processing.
  • The first point was ignored because it nearly coincides with the location of the car and it made sense for the car to ignore this first point in order to preserve time and power.
  • We also place a limit on the maximum number of points that can appear. For a real world scenario, this limit wouldn’t make sense. However for a tiny RC Car which runs on battery to possess so much information and not be able to navigate through vast paths, it wouldn’t make sense for so much information to be filtered.
Workflow

On starting the app, the user first uses the ON button to switch the phone’s bluetooth On. The next step is to Connect to the Bluetooth module that is present on the RC Car. This is accomplished using the Connect button, which toasts a “Connected” notification once this connection happens. The Start Car Button then polls for the location of the car and places a marker on the map. The User may then tap the map and place the destination marker. Placing the destination marker triggers the Directions API to create a route and plot it from the location of the Car till the Destination Marker. The Send Route button sends the route to the controller on the car which lets the car travel from source to destination.

Testing & Technical Challenges

Issue #1 (Motor I/O)

The Motor I/O controller is the only controller which accepts all the CAN messages sent on the bus. This is because the LCD needs to print values from the different controllers like Sensor controller, Master controller and Geo controller. It was decided mutually to use the CAN transmit receive function on the bus at same speed, which was 100 Hz. As our controller had to receive more than one frame in one cycle of 10 ms, the hardware CAN rececive queue kept on enlarging. We were dequeueing at a lower speed than expected. So the data received by the software was not fast enough as the data received by the hardware which slowed down our operation. So, a tip for the future, always make sure that you receive the CAN data frame at the same speed as the transmitter's and dequeue your CAN receive queue so as to make sure you are getting all the latest data bytes. We had used while(CAN_RX) condition to keep receiving until we have emptied the queue. And YES! always remove all the printf functions in the periodic scheduler running at 100 HZ frequency or more. This will really help your board not to crash!

Issue #2 (Project Hardware)

We were required to establish CAN communication at an earlier stage itself. In order to do so, we rushed into soldering the CAN bus on the PCB. At a later stage we realized some difficulty as we had soldered the bus in a compact manner. And now, arranging all the LPCs together with all the jumper wirings with the CAN bus truly messed up any debugging that we could do. We had to rearrange the whole hardware and set the arrangements strictly according to the soldered CAN bus which made the task a little unconvenient. TIP - When it comes to hardware, always discuss with your teammates about all the aspects of arranging your car and always keep some space for future use.

Issue #3 (Project Hardware)

Perhaps the most common problem for all the groups, the car crashed at all the initial testing phases. Even if you think your code is perfect and your car will do exactly what you think it will do, it will crash for sure at start and may wreck something here or there(Trying to save your car and not disappoint you!). Install a kill switch at the earliest that will instantly stop the car whenever you want. Atleast implement a kill button in your Mobile App. Also try to cover the front of your car with multiple layers of cardboard, thermocol or a sponge material which will really help the car absorb the shock.

Issue #4 (Geo controller software)

  • Geo controller was crashing randomly and that problem was happening because of too much log messages were written to SPI flash memory and memory was full with messages, so we have solved that issue by clearing flash memory and removed unnecessary log messages from the code.
  • Initially when we were testing IMU with raw data then it was not giving proper data values so we have calibrated Gyrometer and Magnetometer parameters to get exact angle with precision of +/- 2 degrees, but still as magnetometer's readings were changing with taking any soft/hard iron object near to sensor. So to remove electromagnetic interference generating from DC motor we have put our IMU far from DC Motor.
  • Even after electromagnetic interference calculation, still the heading was deviating a lot than the true heading. So we calibrated IMU sensors with the help of IMU calibration Software provided by manufacturer.
  • Some times in the string, we received from GPS module contains some void data. So to get rid of that we started using UART interrupts and getting all data at once. Which is later sent to the GPS task over Queue. Here the GPS tasks validated the data and in case if Data is not valid, GPS task sets GPS structure to NULL.
  • By using volatile keyword inside the Interrupt handler , avoid the compiler optimization as the string which we are sending over the Queue was getting data when there was interrupt. In the beginning, we were not using the volatile and due to which there was no update in the string we read from Queue at the GPS task.

Issue #5 (Motor Controller software)

  • When we were trying to initialize ESC(Electronic Speed Controller), we didn't know what exact sequence would have to be sent for initialization of DC motor, so we have tried to figure out that thing from Oscilloscope but still somehow we could not able to detect exact sequence of pulses but we hacked the ESC for driving DC motor in Forward and Reverse direction what pulse width is needed and that pulse should be sent in how much frequency. Then to figure out initialization sequence we have done some trial and error case with pre-knowledge of waveforms, we figured out initialization sequence and it was very simple like just we need to send stop motor signal for 1 second and that's it.
  • But here main thing was that, give at least 20ms(miliseconds) time to send each pulse proper, otherwise if anyone tries to send pulses less than 20ms then that pwm pulse value can't set properly as DC pwm's frequency was itself 20ms(Frequency - 50Hz).
  • And we spent lots of time to figure out this issue and that is, we were trying to have different pwm objects to set DC and Servo motor's pwm values. But we couldn't able to set those values properly. So we thought that our object is destroying somehow so then we tried global pwm objects still we failed, then we tried Static objects still we failed, then finally we made pwm object as Singleton object and problem was solved. So yes applications like this, when we are going to use single channel/resource for different purposes again and again then better to have singleton object of that resource.

Issue #6 (Sensors using Interrupt on the 4-pin sensor's Echo pin)

Sequential Pinging

  • Initially, we tested the code for front, right and left 4-pin ping sensors. We got decent readings for all the 3 sensors . For some angles, the distance value would be very large. We concluded that at some instances the echo pin was not reaching the low edge, meanwhile we were triggering the trig pin for the next sensor. This was obviously affecting the distance value calculated. We solved this issue by checking for the echo pin, and proceed with further functions only when the echo pin was low. We also provided a macro which was the maximum limit on the distance value. If the distance value exceeded the maximum range, returning the maximum distance.
  • Once this was resolved, the obtained output readings matched the expected output readings. All the zones and distance values were a match for the obstacle provided for the sensors. Preet reviewed the code and suggested to use pointer for any instance of the pinged sensor. We implemented the code using the pointers for each instance of the sensor.

Inline resistors

  • The testing was a success on the breadboard. When we loaded the code onto the sensor controller on the car, the readings were not accurate. We realized, on the breadboard we tested using inline resistors between the echo pin of the sensor and the GPIO pin(set as input pin to the board). Once we introduced the inline resistors while testing on the sensor controller, we obtained the accurate readings. We initially had introduced the inline resistors as we were providing 5V supply to the sensors. So we figured the output voltage from the sensors should be in the acceptable voltage range of the GPIO pins. The inline resistors provided the required voltage drop. Thus, we solved the issue of inaccurate readings and unresponsive input to the board by introducing the 1K inline resistors for each echo pin of the three sensors. If you plan to work with the ping sensors, do us the inline resistors as it was very obvious with the readings we experienced, inline resistors made a huge difference.

Issue #7 (Sensors using Interrupt on the 3-pin sensor's Echo pin)

  • Once the interrupt algorithm worked for 4-pin sensors, we implemented the same algorithm for 3-pin sensors with changes in the configuration of input and output pins. We tested for a single 3-pin sensor and obtained readings were 100% accuracy. Later we introduced the second sensor for testing the algorithm with 2 sensors. This created an issue. The front sensor was being triggered and the same pin was configured as echo pin. Reading was obtained on the echo pin of the front sensor. In the next cycle, the index was incremented to the right sensor. The algorithm was struck on the second sensor triggered. Each time the function was called from the periodic callback the index did not increment as required by the algorithm. We suspected the echo pin of second sensor was not going low at the required time, which would increment the index according to the algorithm. We could not debug this issue in time for demo. We hope to debug the issue and get the algorithm running for 3-pin sensors too.

Conclusion

Altogether, we really enjoyed being in this class and do this project. We faced many difficulties throughout the semester including understanding the requirements for the project, planning and executing it. But each time we faced a problem, we got to learn many new things. The difficulties led to the deeper knowledge. All of us were stuck at our individual tasks at some point or the other, but we helped each other and finally made our project up and running. Not to mention, Preet was always easily approachable. Our project is running from top to bottom, -> Sending a source, a destination and checkpoints between them from Android app to the Bridge controller -> Sending these co-ordinates to the Geo controller through CAN bus -> Calculating heading and bearing at Geo and giving those back to Master -> Sensor controller sending its reading from sensors in front, sides and back of the car to master -> Deciding where and how much to turn using Geo and Sensor data at Master and sending commands to Motor controller -> Motor I/O controller driving the car and displaying on LCD all the values required for debugging.

Some tasks were very tough to debug. But if you really put your mind into it, you will be able to see the solution right in front of you. One final tip - Do not get frustrated. Always have a bigger picture in mind that what you are getting out of it! We have uploaded everything regarding this project on this page. We honestly appreciate your interest in reading it. Thank you and best of luck!

Project Video

Project Source Code

References

Acknowledgement

We would like to thank Preet for teaching the concepts in a very practical sense in the class. It really helped us in the implementation and the testing of the project. We would also like to thank Rutwik who was always ready to help and who also gave us many ideas of what we can do in the project. All the team members worked really hard towards this project and this motivated us in accomplishing the team goals every week. All in all, a great course which required us not to memorize, but to think in a practical way. Thanks again Preet to introduce this course to the major. This will surely be a major benefit in building our career!

References Used

[1] Preetpal Kang's lecture notes of CMPE 243, Computer Engineering, San Jose State University, Aug-Dec 2015. 
[2] Wiki Projects
[3] LPC17XX datasheet
[4] Parallax Ultrasonic Sensor
[5] CAN Transceiver
[6] Razor IMU
[7] Adafruit Ultimate GPS Breakout - 66 channel w/10 Hz updates - Version 3
[8] GPS data calculation accuracy
[9] GPS Longitude Latitude distance calculator
[10] Calculate distance between two points
[11] GLCD with Touchscreen
[12] HCSR04 Ultrasonic Sensor
[13] GPS Datasheet
[14] Learning Git Tutorials

Appendix

You can list the references you used.