Difference between revisions of "F15: Minion"
Proj user1 (talk | contribs) (→Project Schedule) |
Proj user1 (talk | contribs) (→Project Schedule) |
||
Line 118: | Line 118: | ||
|Completed | |Completed | ||
|12/05/2015 | |12/05/2015 | ||
+ | | | ||
} | } | ||
Revision as of 22:50, 22 March 2016
Contents
- 1 Minion
- 2 Abstract
- 3 Objective
- 4 Team Members & Responsibilities
- 5 Project Schedule
- 6 Parts List & Cost
- 7 Car Framework and Components
- 8 CAN Design
- 9 Design & Implementation of Controllers
- 9.1 Motor and I/O Controller
- 9.2 Master Controller
- 9.3 Sensor Controller
- 9.4 Geographical Controller
- 9.5 Communication Bridge Controller and Android Application
- 9.6 Common Technical Challenges
- 10 Conclusion
- 11 References
Minion
Abstract
This report is a description of how we built a prototype of a self navigating car by deploying the learnings from our graduate course CMPE- 243 Embedded System Applications. The prime motive was to navigate the car, autonomously, from a source point to destination point incorporating the following key features
- Driving and steering with the help of DC and Servo motors
- Feedback based speed control
- Obstacle detection and thereby collision avoidance
- Navigation on a user specified path
- Diagnosis of pertinent values through a display feature
The Micro-controllers- ARM Cortex3 LPC1758, FreeRTOS(operating system) and a highly reliable communication bus namely CAN constitute the basic building blocks of the car. User interaction is achieved with the help of a dynamic Android application that communicates with the controller through bluetooth. GPS and compass together aid in navigating the car.
Objective
The main objective of this project is to design and develop a self driving car capable of navigating itself from its source point to a given destination provided by an Android application. The car should follow the given path with the help of GPS and compass in the Geo controller.The car should avoid obstacles in its path with the help of ultrasonic sensors.The Master controller should make decisions to drive the motor as it receives data from Sensor controller and Geo controller in real time.The Android application should communicate with the car via a wireless medium and display sensor data in real time.The IO module should display geo controller data and sensor data on a LCD.
Team Members & Responsibilities
Sensor Controller:-
Motor & I/0 Controller:-
Communication Bridge & Android Controller:-
Geographical Controller:-
Master Controller:-
Treasurer:-
Hardware:-
Project Schedule
Sr. No | Start Date | End Date | Task | Status | Actual Completion Date | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | 9/22/2015 | 9/28/2015 | RC Car and important component buying | Completed | 9/28/2015 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
2 | 9/29/2015 | 10/6/2015 | 1) Algorithm and architecture 2) Setup of car and decision on CAN Id's |
Completed | 10/6/2015 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
3 | 10/7/2015 | 10/13/2015 | 1) Coding and final set-up of car 2) Successful communication of CAN bus. 3) Car in running position. |
Completed | 10/13/2015 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
4 | 10/14/2015 | 10/20/2015 | Controlling car via Motor Controller | Completed | 10/20/2015 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
5 | 10/21/2015 | 10/27/2015 | 1) LCD Display working and finalizing the data to be displayed on LCD module. 2) Sensor data gathering |
Completed | 10/27/2015 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
6 | 10/28/2015 | 11/30/2015 | Integration of all the modules into one | Completed | 12/05/2015 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
7 | 11/04/2015 | 11/30/2015 | Testing depending upon integrated module | Completed | 12/05/2015 |
} Parts List & Cost
Car Framework and ComponentsThe RC car, Traxxas Stampede, in its raw form consists of a Titan 12T 550 Brushed DC motor, a Servo motor, an XL-5 ESC (Electronic Speed Control) unit, battery and a pre-programmed wireless receiver and controller. The Battery used in the RC car is an 8.4 V, 3000 NiMH from Traxxas. The wireless receiver gets commands from the remote control and drives the motors accordingly, but the DC motor can be controlled only through ESC.
The ESC (Electronic Speed Control) unit is an electronic module, which receives PWM signals from the controller and varies speed and direction of the DC motor and also acts as dynamic brakes. ESCs are often used in RC models. The ESC has the capability to provide dynamic braking depending on the mode in which it is being operated. CAN DesignCAN Communication Table
CAN Message FlowDBC ImplementationBackgroundGenerally, data received from the CAN message is handled using structures. If there are 'n' CAN messages, 'n' structures will be used to handle them. Data has to be encoded at one end for CAN transmission and decoded at the other end, after CAN reception. If there are innumerable CAN messages and their respective structures, lot of effort will be spent in writing code for encoding and decoding. A better approach is to use DBC. It has a specific format and generates automatic code consisting of decoding and encoding logic and structures for CAN messages. DBC FileThe following DBC file gives the proper description of CAN messages used in our car. VERSION "" Detailed Description1)The above description shows the detailed implementation of the CAN messages used for communication between various controllers. Several types of notations are used in this DBC file. Following is the explanation of these notations which includes range of the CAN data, minimum, maximum values, and number of data bits used in the 64 bit structure. One useful feature of CAN message frame is bitwise access of data. This approach of accessing data using bits instead of bytes avoids wastage of CAN data which could otherwise be utilized properly. 2)Detailed explanation of notations used in CAN dbc file format- a. BU_: NOONE SENSOR MASTER MOTORIO ANDROID GEO The line which is starting with BU_ gives us the information about all the controllers present in the communication BUS. 3)The dbc file was created with these normal basic command and was sent as an input to the python dbc parser which decrypted it to the auto generated code. Following is the python command for the dbc parser: >python.exe dbc_parse.py -i Group2.dbc -s MASTER -a -b >generated.h Design & Implementation of ControllersMotor and I/O ControllerSchedule
Hardware DesignMotor ModuleThe motor module comprises of a servo motor for the direction control and a DC motor for speed control. The servo motor helps the car in turning left and right where as the DC motor on the other hand helps the car move forward and backward. The DC motor used in the project is a brushed motor. Conventionally, brushless motors are faster and more efficient than brushed motors. But, the reason for selecting a brushed motor over a brushless motor is that we employ a dedicated battery for the motor such that we do not have any issues with power and efficiency. Moreover, we need not operate the car at high speeds. The initial task in the motor module is to find the operating ranges of the motor so that we get to know the output signal range and frequency from the SJONE board which would be replacing the pre-programmed controller. The simplest way to find the operating ranges of the motor is to tap and analyze PWM signal that is being supplied to the motor over an oscilloscope. The results as shown in the below pictures indicate that the operating duty cycle of both the motors lie between 10% to 20% and the frequencies at which the motors operate is 100Hz.
The feedback is achieved through a shaft encoder which works based on Hall-effect. The installation of the speed sensor was pretty easy as we went with the one from Traxass, the same manufacturer as our RC car. It involves removing the DC motor casing, placing the sensor over the spur gear and the magnet holder. The sensor would sense the rotation of the axle. It produces a pulse when the magnet comes into the line of the sensor, which is then detected by the Motor controller. IO ModuleThe IO module Consists of a 4 line * 20 characters serial LCD. Data from GPS and sensor module is displayed continuously by refreshing it every second. SJ one board communicates with LCD through UART.GPS data :-
Sensor data:-
Additionally, IO module controls lighting up headlights/taillights based on the direction of the car movement. LCD unit requires 5V power supply for its working. The VCC and Ground pins are connected to common power supply lines that is used to power up all the boards. The Rx pin of LCD is connected to TXD2 (p2.8) pin on SJ one board. Two of the GPIO pins p2.6 and p2.7 controls the headlights LED’S and taillights LED’S respectively.
Usage of OnBoard LED's:
Software DesignModule FlowThe controller on boot up initializes the CAN communication, UART and also the PWM for initialization pulse required for the motor to run.The inter-controller communication is done over CAN bus. It is configured to receive and transmit messages at 100K baud-rate. The type of CAN ID is Standard. Later these are accomplished at run time using the periodic scheduler task.
The Motor controller, after sending the initialization pulse to the DC motor, waits for a start command from the Master over CAN and then controls the motors in order to reach the destination with required levels of speed and direction. The control algorithm for the Motor operation is as shown on the right. Software Implementation“Can receive” function is called in periodic scheduler 100 Hz task. This function lets the Motor/IO module receive CAN messages from other modules connected to it. CAN set up filter function has been used to accept only essential messages required by this module. Based on the CAN message identifier, corresponding action is performed. These are the CAN messages required by the motor/IO module. CAN MESSAGE ID:-
Data from sensor and GPS modules are stored in global message buffers. Sensor data is 8 bit whereas GPS data ranges between 16-32 bits. These integer values are converted into character type and then sent to LCD through UART. LCD display function is called in 1Hz periodic scheduler task. Thus Sensor and GPS data get displayed on the LCD every sec. The 3D design used as a support for mounting the LCD is shown below: Motor ControlOn receiving the CAN message(0x220) from the Master, the data is extracted and and used for specific functions as shown below. *Byte0 --> Servo Direction *Byte1 --> Servo Level *Byte2 --> DC Direction *Byte3 --> DC Level Based on this data, the first two bytes decide the direction(left/right) and the level(angle), respectively in which the car should turn using the Servo motor. Similaly, the next two bytes decide the direction(forward/backward) and the level(speed) in which the car has to move. To implement all the motor related functions, we have employed a dedicated task. Initially, the pre-scaled PWM values are fed to the motors based on the direction and level from the Master. We have a bit robust algorithm to obtain these PWM values which has offsets and level multipliers. The advantage of this is we can change the code to function for multiple levels with minimum effort. A piece of code for Motor Control: switch(DC_control) { case 0: if(DC_level==DC_level_last) { speed_offset = 0; speed_factor =0; LD.setNumber(10); } else { pwm2.set(15); vTaskDelay(25); pwm2.set(13); vTaskDelay(100); speed_offset = 0; LD.setNumber(13); speed_factor =0; } p2_pin6.setLow(); p2_pin7.setLow(); speed_offset = 0; speed_factor =0; count_rev = 1; break; case 1: speed_offset = 0.4; speed_factor = 0.2; count_rev = 1; p2_pin6.setHigh(); p2_pin7.setLow(); break; case 2: speed_offset = -0.6; speed_factor = -0.2; p2_pin6.setLow(); p2_pin7.setHigh(); break; default: speed_offset = 0; speed_factor =0; count_rev = 1; p2_pin6.setLow(); p2_pin7.setLow(); break; } PWM_value_DC = 15 + (speed_factor)*(DC_level) + speed_offset; Motor FeedbackAfter feeding the motors with the required levels, we have to check if the car is actually moving at that speed. This is ensured through feedback and control based on that. The feedback is obtained through the speed sensor collaborated with the DC motor, which triggers a pulse on every rotation and this is recorded by a rising edge based interrupt. The interrupt callback function increments the number of pulses. A separate logic is used to calculate and then compare the actual and required(from Master) speed levels. The corrective measures are enforced to achieve the desired speed. The transmit messages, except Heart beat message(sent every one second), are transmitted once every 100ms. The Motor/IO controller, on receiving a boot request from Master controller, transmits a boot reply message in order to let the Master know that it has booted successfully. The heart beat message is transmitted continuously to indicate that the controller is active and this will be acknowledged by the Master.
TestingMotor ControlThe motor operation is initially tested for its accuracy with different direction and levels such as forward, reverse, left, right. After ensuring everything is as expected, we went for refining it. Later, with the speed sensor installed, the functioning of it and the control based on it has to be checked properly. For this, we have tested the car by running it over ramp-up, ramp-down, grassy and rough paths. Then we have refined it. Finally, we made sure that the car gets back to the required speed when it deviates from the same. Technical Challenges and ResolutionMotor FeedbackThe major difficulty with motor speed feedback was getting enough number of pulses from the speed sensor in order to calculate the current speed. When we run at very low speeds, we get pulses as low as 2 0r 3 at even 10Hz. If the same value is multiplied by required factor(say 600 in 10Hz) to get the rpm, then we have a couple of issues. i) Firstly, we cannot get intermediate speed values as we get only in multiples of the the factor which will be very high. ii) Secondly, we may have some issues, at very low speeds, like we don't get a pulse every 100ms or 10ms, which means the motor is at rest but which actually is not. Solution: Never try to implement in terms of "rpm". Instead go for "rps" or "m/s". This will eliminate the first issue. And to solve the second problem, we may think of aggregating the pulse count for a greater time interval. But this will lead to a delayed feedback which in turn leads to an undesired behavior. Hence we have a trade-off between the two. Motor Control1) The first hurdle one would face with the Motor control through an ESC is starting the motor. This requires an initialization pulse, which would have been sent by the transmitter earlier. We have to realize the required pattern or PWM value for the achieving this. 2) The second difficulty with the motor comes into picture when with backward movement of the car. Due to the presence of the ESC and the residual momentum in forward direction, we cannot alter the direction of the motor suddenly. We have to manually discover the pattern required for this forward to reverse transition which takes a bit of time unless one is aware of it. Master ControllerAs the name suggests, it is main controller on the car which interacts with all other controllers over the CAN Bus to achieve real-time functionality. Basic function of the Master Controller is to receive data from Android, Geo and Sensor Modules and develop the algorithm to drive the car autonomously based on the received data through the Motor Controller. Schedule
Hardware Design
Usage of OnBoard LED's:
Software DesignThis section describes about the general algorithm used for master programming. There are a lot of cases in Master Controller which are to be handled in order to run the car properly. This includes heartbeats, boot messages, running of motor, reading of the sensor values properly and then taking proper decision. The other activities that are done in master are listed below with some fair explanations.
Software Implementation
AlgorithmGeo Processing AlgorithmFollowing is the algorithm that was implemented to process the data sent by Geo controller, which eventually navigates the car towards its destination. At first, it checks if there is any obstruction in the car’s path, if there is no obstruction it follows the further steps, And if there is an obstruction, it transfers control to the Obstruction Avoidance Algorithm. Step 1: Check if there is no obstruction. If there is no obstruction proceed to step2, otherwise proceed to step7. Following is the flow-chart of the above algorithm: Obstacle Avoidance AlgorithmThe most important part of the Master controller is to control the motors and handling other decision making factors such as when to move and when to not. The Motor/IO controller is almost entirely dependent on the Master controller to drive the motor. The Master controller is responsible for making decisions on when and where to move the car in case of any obstacle and this is where the Sensor controller comes into the bigger picture. 1)For exact precision, we are considering most accurate algorithm for Sensor Processing. We have defined three levels of obstacle zones. The exact explanation of this terminology can be understood from the gif image shown below.
2) There are three zones in which the major sensor processing for obstacle-avoidance is done. In these zones, distances were designated as the safest distance for the car in which it can move ahead though at low speeds. In addition, we also had taken the danger zone into the consideration.Within danger zone distance, the car won’t be able to move ahead and would only take reverse depending on data from rear sensor. Following is the classification of the various zones: L3 and Rt3 : We have considered all the cases for each of the zones, but during the actual running of the car, there were some cases which were only used 0.5% of the times. Just to improve the response of the algorithm, we have ignored those cases and concentrated on all the other cases. The results were fascinating since the reverse algorithm was responding very sharply. These were all the theoretical explanation about the levels. The, actual algorithm is shown using a flow diagram below. This would clearly showcase how the car would run and in what conditions. Technical Challenges and ResolutionSensor algorithmJust a straightforward algorithm is easy and short to implement. But the sensor are tested properly when there are a lot of corner cases of obstacles where the car can stuck. These corner cases were indeed a challenge that was faced. These cases were developed in step and the entire algorithm was not implemented at once. CAN Message HandlingCollaborating on the message id’s and the data in those messages. Since master is the powerhouse of the system, there are a multiple number of nodes communicating with Master. Since such a number of nodes are communicating with Master, there are a lot of cases which are to be handled in Master and that was indeed a challenging task. Integrating Sensor and Geo AlgorithmsThere were a lot of problems faced while integrating Geo controller and Sensor controller. The first and foremost problem that we faced was while implementing any new feature and synchronising other controllers with the Master controller. For example, the sensors were integrated earlier but when the Geo controller was integrated, the motor did not receive proper data. On debugging, we came to know that the problem was with the algorithm and after we changed it, everything was working on its proper way. CAN ArbitrationSince Master controller was the one with a lot number of messages, we faced some issues regarding CAN arbitration. Initially, there were a couple of messages which were high priority messages and were blocking the way of some important low priority one time messages. But after some changes in the ID’s the problem was dealt properly. Sensor ControllerSchedule
Hardware DesignSensor controller consists of sonar and ultrasonic sensors that are inter-connected to the SJOne board and CAN bus. The sensors detect if there is any obstacle around the car and report the distance of obstacle. Hardware design consists of four sensors connected to port 2 of LPC1758. The sensor in the front direction is MB1010 sonar sensor while the ones at back,right and left direction are HCSR04 ultrasonic sensors. The sensors are connected to +5V power supply to achieve the highest beam pattern that is available. Sensor Hardware Interface
MB1010 LV MaxSonar EZ1 SensorThe LV MaxSonar EZ detects objects from 0 inches to 254 inches and provides sonar range from 6 to 254 inches with 1 inch resolution. Objects from 0 to 6 inches are reported as 6 inches. Sensor operates at 42KHz. The sensor reports output formats in from of pulse width output, analog voltage output, and RS232 serial output. We have selected pulse width output.The sensor will continually measure range and output if RX data is left unconnected or held high. If held low the sensor will stop ranging. We have commanded a range reading by triggering high for 20uS.
Below are the timing diagrams for the sensor
HCSR-04 sensorHCSR-04 sensor is a ultrasonic ranging module which detects obstacle from 0 to 400 cm. It is a four pin module – Vcc, trig, echo and Gnd. It includes transmitter, receiver and control circuit. The sensor operates at 40 KHz.It Requires 5V 15mA power supply. When a short 10uS pulse is provided to the trigger input, the sensor will transmit out 8 cycle of ultrasonic burst at 40kHz and makes the echo pin high.The Echo pin is lowered to logic low when the ultrasound burst is reflected off a distant object.To obtain the distance, measure the width (Ton) of Echo pin. Time = Width of Echo pulse, in uS (micro second) Distance in centimeters = Time / 58 Distance in inches = Time / 148 Or you can utilize the speed of sound, which is 340m/s
3D Printing DesignThe 3D design used as a support for mounting the sensors is shown below:
Usage of OnBoard LED's:
Software DesignSoftware design for Sensor controller includes sensor initialization, sequential triggering of sensors, calculating distance of obstacle from the echo received and transmitting the data on CAN bus. Sensor initialization includes interrupt configuration for echo pins of sensor and configuring the trigger pins as output. A trigger of 20 us is required for MB1010 sensor and 10 us is required for HC SR-04 sensor. Algorithm
This is a piece of our Interrupt configurations and function callbacks that calculate the distance of sensor. Module Flow
Testing and Technical ChallengesSensor Triggering
Referring to the above results we can conclude that the sensor data is more accurate for MB1010 if the time interval for triggering is 50ms. Similarly for HC SR04 the readings are accurate if time interval between the trigger is 30 ms. Sensor Operating frequency
Ground Reflections
Geographical ControllerGeographical Controller consists of GPS and Compass module. GPS module tracks current position (Latitude and Longitude) of the car and compass module gives the heading of car with respect to north. With the data provided from these modules, turn angle and distance to destination is calculated. Algorithm for these calculations is explained in software section. Heading: Heading is the current direction of car, measured clockwise with respect to geographic north and ranges from 0 to 360 degrees. The compass gives the values with respect to magnetic north and the Magnetic declination is added to these values to give the actual heading. Bearing: Bearing is direction of destination point with respect to north measured clockwise and ranges from 0 to 360 degrees. This value is calculated from destination and current coordinates using Haversine formula described in software section. Turn Angle : It is a measurement in degrees that the car needs to take to head towards destination. It is calculated by using Heading and Bearing values. Direction : It is the clockwise or anti clockwise turn of the car to head towards destination. Schedule
Hardware DesignSchematicSparkFun Venus GPS with SMA ConnectorSparkFun Venus GPS uses Skytraq VENUS634FLPx IC. The Venus638FLPx outputs standard NMEA-0183 or SkyTraq Binary sentences at a default rate of 9600 bps which is adjustable to 115200 bps, with update rates up to 20Hz. We configured this module with update rate of 10Hz and 38400 bps UART rate. Module outputs GGA, GSA, GSV, GLL, RMC, VTG, ZDA NMEA standard messages which can be configures to as per our requirements. We configured it to give only GGA messages.
GGA message format is shown below.
HMC5883LHMC5883l is a triple axis digital compass IC used for heading calculation. It has magneto resistive sensors that forms the basis of the working principle of a compass. Please refer data sheet attached in reference section for specifications of the IC. Note that this IC is not tilt compensated and we need to calibrate for instrument error and for tilt. HMC5883L and I2CHMC5883L IC communicates to SJOne Board through I2C bus. Master Transmitter Mode -Slave Receiver Mode Master Receiver Mode -Slave Transmitter Mode Usage of OnBoard LED's
Software DesignCompass Heading CalculationCompass Heading = Raw values obtained from the compass module + Magnetic deviation + Magnetic declination Raw values obtained from the compass module - Of the 3 axis in compass, the x-axis and y-axis values read from the compass registers are used to calculate the heading value in radians. Due to magnetic deviations these values are not accurate and need to be calibrated for accuracy. Calibrating the values obtained as radians would be more accurate that calibrating in degrees. The calibrated values in radians are then converted to degrees. The degrees would be values from -180 to 180 degree range and this has to be scaled for 0 to 360 that forms a complete circle. Magnetic Deviation - It is the error introduced in the compass module due to local magnetic fields. The compass needs to be compensated for it. Magnetic Declination - It is the angle between the Earth's geographic north and magnetic north. The values from compass IC are with respective to magnetic north whereas the navigation is generally based on geographic north. Hence this declination has to be compensated. Declination varies from place to place and for San Jose it is 13.31 degree East and positive. This value needs to be added. Algorithm
Haversine formula: Distance = R ⋅ c c = 2 ⋅ atan2(√a, √(1−a)) a = sin²(Δφ/2) + cos φ1 ⋅ cos φ2 ⋅ sin²(Δλ/2) Module FlowImplementation
TestingAccuracy of GPS ModuleAccuracy of GPS module was tested by recording/logging coordinates received by module using LOG_INFO() function and plotting them on Google maps GPS Module Coordinates on Google Maps. GPS module was very much accurate and we did not needed it to calibrate. It is observed that accuracy depends on number of satellite locks with module, environment conditions. More number of satellite locks and sunny weather conditions, greater the accuracy of readings. You may hear that bluetooth, GPS frequencies interfere with each other reducing accuracy of GPS, but we never experienced this issue. Calibration of CompassAs any instrument has instrument error, so has the compass IC. The compass needs to be calibrated for accuracy. We undertook two levels of calibration. The deviation was not uniform for every zone. Using linear regression analysis technique, the relationship between the predictor variable - degrees and the response variable - radians was found in an ideal environment and the same was repeated several times for accuracy. The average of several such readings was taken as the final calibration value. Technical Challenges and ResolutionConfiguring GPS ModuleWe faced difficulty in configuring GPS module to sending only $GGA messages, 10Hz Position update rate and updating baud rate to 38400. Initially we were trying to configure GPS module via writing program for SJ One board and we were unable to do it. Later on we completed configuring by connecting GPS module directly to serial port and using GPS Viewer software. Through it we can directly configure GPS module without worrying about binary messages and checksum calculation. Compass module and Compass Calibration1.Initially the compass was mounted and tested on breadboard with its upper face downwards as the connecting strips are on the upper side. This made the compass produce incorrect values. Integrating Geo Module on CarIn the initial phase of integrating geo module, our car was always going in right direction but going forward towards destination. We had to put car back on track. While testing we it came to our notice that if car has closer checkpoints then it was following the track perfectly. To solve this we implemented algorithm to find midpoint between checkpoint sent by from android and current source if distance is greater than 200 feet. Mathematical formula to implement this is mentioned in software design section. Online contents are listed in references section. Communication Bridge Controller and Android ApplicationSchedule
Hardware DesignThe Communication bridge consists of establishing connection between car and the android phone which is established with the help of bluetooth module HC-05 connected to UART peripheral of SJOne Board. The UART pins on board are connected to bluetooth module in the manner shown in diagram. Once the connection is established between the car and the android phone and signals like 'Start','Stop' and 'Kill' are sent from android phone then they are received by the bluetooth and sent to SJOne board to be further broadcasted over CAN bus. Pin Configuration:
The Bluetooth module HC-05 is a MASTER/SLAVE module.The Role of the module (Master or Slave) can be configured only by AT COMMANDS.By default the mode is set to SLAVE.It has pins named KEY and 5V which we are not using because KEY pin is used to enter the Command mode.Bluetooth module when connected to SJOne board needs to be paired with any one of the external devices like android phone in our case, there is LED that blinks at different pace to indicate whether it is paired or not. Once the bluetooth module is paired indicated by slow blinking of the LED, the android phone is all ready to transmit signals to SJOne board. Usage of OnBoard LED's:
Software DesignCommunication Bridge ControllerThe purpose for Communication Bridge is mainly to facilitate communication between Android application and other controllers via Bluetooth module and CAN. The software design mainly follows the flow of data as shown in figure. The UART peripheral on SJOne is configured by using getInstance( ) on Free Rtos to either receive or transmit data through it.When the communication bridge controller receives CAN msg ids corresponding to Master,Sensor and Geo controllers over the CAN bus, it tends to send data corresponding to each msg id to Android phone through bluetooth module.Once the signals are processed by the android app, in return if it wants to send data through bluetooth over CAN bus then it can. Android Application
The entire flow of the application between android application and Communication Bridge can be showcased as follows:
TestingBluetooth ModuleWe tested the bluetooth module HC-05 using a Bluetooth chat application from app store. Using this application we could successfully send characters to bluetooth module over UART connected to SJ One board and observe the results on Hercules terminal. Android applicationAndroid application was tested for both functionality and performance.We tested all the application buttons and Map fragment with the bluetooth module and improved the performance of the app over the span of the project. CAN communicationCAN communication between bridge controller and other module was tested in an isolated fashion by setting up the connection of two SJ One board using breadboards and wires. Technical Challenges and ResolutionReading via Bluetooth
Sending via Bluetooth
Common Technical ChallengesLogging Info to Memory CardIt has been observed that if log info size is large then we cannot copy log.csv file from flash to memory card via terminal command. Command terminates with Error:2. On board flash has limited space which was causing this error to come. To solve this issue we changed file_logger.h file to log all info directly into memory card which we can directly remove and get all data directly on PC. CAN Bus HardwareRobust hardware setup of CAN bus is very much important. We faced this issue of CAN messages not being sent to other controllers. We checked voltages at every point of CAN bus and we were getting readings as expected. Later on we found that our 5v supply pins are connected to bus they were loose. After soldering supply pins properly, our CAN bus never failed till end of project. CAN Processing loopCan reception should be put in a while loop so that in one single run of the while loop all received message will be emptied.Initially, we processed the received CAN messages in an if loop. But, the effect of this on our CAN processing was that whenever we used to receive CAN messages at a particular moment, only the first CAN message was considered in processing and the other CAN messages in the queue were ignored. But, when using a while loop, all the CAN messages in the queue are processed and considered. ConclusionIn a short span of 3 months, we had an enriching experience in working for the project. We were able to implement the embedded concepts that we had learnt from our course work. Having hands on both software development and hardware interfacing is a very rare opportunity that we acquired. All essential phases of software development cycle such as design, implementation, unit testing and functional testing were mandatory steps in our project and that absolutely prepared us for the future. Besides that, some of the tools that we worked with like Gitlab for version control and Eclipse IDE as build environment are really useful as they are on par with the Industry preferences in the current scenario. Finally it was one wholesome experience and we hope we were able to share some of our learnings in this report. Project VideoProject Source CodeReferencesAcknowledgementThis project has been an amazing learning experience. We are grateful to Prof. Preetpal Kang for provision of expertise and technical support in the implementation. Without his superior knowledge and experience, project would have lagged in quality of outcomes. We would also like to express special gratitude and thanks to ISA team for the valuable inputs and timely feedback during the project development life cycle. Last but not least its the diligence and dedication of team Minion which led us to success. References Used
|