S15: Real Time Brake Assist (RTBA)
Contents
- 1 Grading Criteria
- 2 Real Time Brake Assist (RTBA)
- 3 Abstract
- 4 Objectives & Introduction
- 5 Schedule
- 6 Parts List & Cost
- 7 Design & Implementation
- 8 Hardware Interface
- 9 Interface to Lidar Laser Distance Sensor
- 10 CAN interface to OBDII Connector
- 11 Bluetooth/Android Bridge
- 12 Testing & Technical Challenges
- 13 Issues Found
- 14 Conclusion
- 15 References
Grading Criteria
- How well is Software & Hardware Design described?
- How well can this report be used to reproduce this project?
- Code Quality
- Overall Report Quality:
- Software Block Diagrams
- Hardware Block Diagrams
- Schematic Quality
- Quality of technical challenges and solutions adopted.
Real Time Brake Assist (RTBA)
Abstract
Real time brake assist is an automotive application that helps the user in calculating a safe braking distance with respect to the car in the front. The system makes use of a LiDAR sensor for judging the car’s proximity to the car ahead of it and uses the diagnostic port (OBDII) to pull up the car’s current speed from the ECU. Based on the collected data, it will calculate the safe braking distance and will provide visual indicators for the same.
Objectives & Introduction
What we would like to accomplish is the following:
- Provide a user friendly solution to brake assistance by analyzing car's data through OBD-II.
- Lidar to detect distance.
- OBD-II interface with SJSU One Board.
- Special I2C circuitry for wiring the lidar from the front of the car to inside of the car.
- Provide a simple mobile application which reads the OBD-II data through bluetooth as additional feature to the braking solution. It would provide the following indicators:
- Car Speed(mph)
- Braking Distance(ft)
- Proximity(ft)
- Safety Warning
- Additional Features:
- TBD
Team Members & Responsibilities
- Sahil Kataria
- Architecture Design, Hardware & Software Development, Integration
- Julio Fuentes
- I2C Communication, Hardware Development
- Shaw Ken Chang
- Android App/Bluetooth bridge, System Integration, brake algorithm, new features.
- Naghma Anwar
- CAN Communication, Software Development
Schedule
Show a simple table or figures that show your scheduled as planned before you started working on the project. Then in another table column, write down the actual schedule so that readers can see the planned vs. actual goals. The point of the schedule is for readers to assess how to pace themselves if they are doing a similar project.
Week # | Start Date | End Date | Task | Status | Result |
---|---|---|---|---|---|
1 | 03/10/15 | 03/16/15 |
|
Completed |
|
2 | 03/17/15 | 03/23/15 |
|
Completed |
|
3 | 03/24/15 | 03/30/15 |
|
Completed |
|
4 | 03/31/15 | 04/06/15 |
|
Completed |
|
5 | 04/07/15 | 04/13/15 |
|
Completed |
|
6 | 04/14/15 | 04/20/15 |
|
Ongoing |
|
7 | 04/21/15 | 04/27/15 |
|
Completed |
|
8 | 04/28/15 | 05/04/15 |
|
Ongoing |
|
9 | 05/05/15 | 05/11/15 |
|
Ongoing | |
10 | 05/12/15 | 05/25/15 |
|
Scheduled |
Parts List & Cost
Give a simple list of the cost of your project broken down by components. Do not write long stories here.
Item# | Part Desciption | Vendor | Part Number | Qty | Cost |
---|---|---|---|---|---|
1 | LIDAR Lite | sparkfun.com | SEN-13167 | 1 | $89.95 |
2 | SJOne Board | SCE | 1 | $80.00 | |
3 | I2C Diff Buffer | NXP | PCA9615DPJ | 2 | $2.99 |
4 | CAN Trasceiver | Philips | TJA1050T | 1 | $1.03 |
5 | 12V-5V DC-DC REG | Murata | 7805SR-C | 1 | $9.90 |
6 | 3.3V LDO REG | ON Semiconductor | NCP4683DSQ33T1G | 1 | $0.92 |
7 | Prototype board | Twin Industries | 800-45 | 1 | $12.99 |
8 | Bluetooth Module | Sparkfun | RN41-XV | 1 | $29.99 |
Design & Implementation
The design section can go over your hardware and software design. Organize this section using sub-sections that go over your design and implementation.
Hardware Design
The Real Time Break assist hardware consists of the three boards. The SJ-ONE board provides the LPC1758 ARM based CPU with the integrated CAN and I2C interface controllers used for communication. The second board referred as “Board #1” in the hardware diagram provides the CAN PHY, 12V to 5V voltage regulation and the I2C differential driver. The third board is located in the front of the car and provides power and proper I2C connectivity to the Linder laser distance sensor. The user interface is implemented through an android based device that connects to the SJ-ONE board through a Bluetooth module.
Hardware Diagram
Hardware Interface
Interface to Lidar Laser Distance Sensor
The Linder laser distance sensor requires 5V and I2C interface operating at a maximum rate of 100Kbps for communication. To provide a reliable and low cost communication to the sensor, a PCA9615 differential driver was chosen. The PCA9615 provides the noise immunity and capability to drive long cables necessary for this application. For cable connectivity, a standard CAT5 RJ45 cable was used because of its low cost and twisted pair connectivity for differential signals. The diagram below shows the connectivity of the differential pairs. In order to provide the maximum differential swing, VDDB1 and VDDB2 should be connected to 5V and use 120ohms for R1 and 60 ohms for R2. VDDA1 and VDDA2 should be pulled up to 3.3V as required by the I2C interface. The PCA9615 provides separate voltage pins for the I2C interface which should be 3.3V and for the differential signaling which should be 5V.
The RJ45 cable and connections should be selected so that each of the differential signals is connected to a corresponding twisted pair. Also, 5V power and ground should be connected so that they use a twisted pair and therefore keep the capacitive coupling through the cabling.
The figure below shows the RJ45 pin assignment, as well as the twisted pair cable coloring found in traditional CAT5 cables.
CAN interface to OBDII Connector
Bluetooth/Android Bridge
For this project we chose RN41XV Bluetooth module. This is a Bluetooth module with Zigbee footprint and it fits SJSUone board perfectly. This is one of the main reason why we use this module. We can easily access the Bluetooth module through UART 2 or UART3 – depending on the board setting. Features of RN41XV:
- Fully certified Bluetooth® version 2.1 module, supports version 2.1 + Enhanced Data Rate (EDR)
- Backwards-compatible with Bluetooth version 2.0, 1.2, and 1.1
- Pin compatible with widely used 2 x 10 (2mm) socket typically used for 802.15.4 applications
- Low power: 30 mA connected, < 10 mA sniff mode
- UART (SPP or HCI) and USB (HCI only) data connection interfaces
- Sustained SPP data rates: 240 Kbps (slave), 300 Kbps (master)
- HCI data rates: 1.5 Mbps sustained, 3.0 Mbps burst in HCI mode
- Embedded Bluetooth stack profiles included (requires no host stack): GAP, SDP, RFCOMM, and L2CAP protocols, with SPP, HID and DUN profile support
- Bluetooth SIG certified
- Chip antenna on-board
Since we are using android to connect to the module, having SPP support is important. There are many projects on the web describing how to connect android to a Bluetooth module and they are more or less similar. The things that differs are only hardware specifications such as the range and what types of protocols and profiles it can support. Based on the specification sheet, RN41XV has range up to 100 meters, this is plenty for our application. We expect that users will use an android phone to connect to the main embedded device within 1m-2m distance.
Testing Bluetooth Bridge
Test Strategy:
- Functionality test1: Using PC terminal app and android terminal app, check the range and see if data can be transferred as expected.
- Functionality test2: Setup the module to communicate with SJSUone board through UART3 port and then connect the module to android phone using android terminal app.
- Functionality test3: Do the same thing as test2 but use our own android app instead.
Android Application Design
The objective for our application UI is to be make it simple and easy to use. The following screen captures shows different modes of UI:
This application has the following components:
- Initial page to select a bluetooth module to connect to.
- Bluetooth communication manager to read and parse bytes of data when there are data on the buffer ready to be read.
- Indicators to show the car speed in mph, calculated safe braking distance in ft based on the current speed, and the proximity sensor reading in units of ft.
- Indicator to warn the user when the car's distance is less than the safe braking distance. The indicators include a warning image telling the user to slow down and also sound alert to warn the user with beeping sounds
Android Application Implementation
To get started with bluetooth programming on android, we consult the official developer website (http://developer.android.com/guide/topics/connectivity/bluetooth.html). Essentially we picked and choose the code we need from the tutorials and examples as a base framework for a bluetooth capable application. In this application we only have two source java files, MainActivity.java and DeviceListActivity.java. At launch, the MainActivity class will call the DeviceListActivity class to display a list of discovered device and prompt users to select a bluetooth device to connect to, if successful, the application will jump to the indicator page where it shows the speed, safe distance, and proximity values. Those values was fetched using SJSUone board from the OBDII CAN port then outputted to android through UART/Bluetooth communication.
General steps to bluetooth enable android program :
- Add bluetooth permission in the application manifest file.
- Setup bluetooth.
- Get the BluetoothAdapter.
- Enable Bluetooth - first check if bluetooth is enabled and if it's not then we will create an Intent to request for enabling bluetooth.
- Discover Bluetooth and Manage Connection
- Fetch the data bytes from bluetoothsocket streams.
Other feature added:
- The warning part of this application uses imageView and View API's setvisibility to display a warning sign and vice versa.
- The font of the speed, safe braking distance, and proximity data was changed to a digital font that looks like 7 segment display. This is done by downloading a 7 seg digital font and place it in the resource file and then declare the following code in the onCreate method of the MainActivity: Typeface tf = Typeface.createFromAsset(getAssets(),"fonts/digital-7.ttf"); carSpeedDataTextView.setTypeface(tf); brakingDistDataTextView.setTypeface(tf); proximityDataTextView.setTypeface(tf);
- The warning alert sound was added to the android application as an additional feature. This is made possible by calling mediaPlayer library and play the sound only when warning should happen(safe distance < proximity distance).
Implementation
Steps to communicate from SJSUone Board to the Android App
-steps to communicate to OBDII/CAN -braking Algorithm implementation
This section includes implementation, but again, not the details, just the high level. For example, you can list the steps it takes to communicate over a sensor, or the steps needed to write a page of memory onto SPI Flash. You can include sub-sections for each of your component implementation.
Testing & Technical Challenges
Describe the challenges of your project. What advise would you give yourself or someone else if your project can be started from scratch again? Make a smooth transition to testing section and described what it took to test your project.
Include sub-sections that list out a problem and solution, such as:
Issues Found
CAN Broadcast Address
The broadcast address of 0x7DF referred on the Wikipedia (http://en.wikipedia.org/wiki/OBD-II_PIDs) is for 11 bit communication and is outdated. This broadcast address does not work. We could not find information on broadcast address for 29 bit communication. To bypass this blocking issue, we used an OBDII reader and examined what it was sending to find the particular broadcast and response address of our test cars.
Flooding of CAN Messages (TBD)
After establishing communication with the car, we noticed that we were receiving only a couple of replies from the car. This appears to be due to the fact that we do not have the hardware filter implemented. The CAN controller is flooded with messages from the car and is dropping most of the packets. We are currently investigating how to implement the hardware filter.
Incorrect Value Displayed on Android Application
This happens in the beginning when we first try to integrate all of the components together. The output was incorrect with our initial SJSUone firmware because the software was sending floating point values to the android when android was expecting integer bytes. Later we change the output to unsigned integer char and that solved the issue. Other solutions could be done on the android end where we can convert the floating point values to strings. Another problem we see with our initial firmware is that we thought a value was passed correctly but it was not. We were supposed to assign a value to a variable but we didn't so we got a value of 0 for the proximity value. This is fixed by simply assigning the value fetched from freeRTOS queue correctly.
Sound Stops Playing on Android Application When Not Expected to
The warning sound was supposed to play forever as long as proximity distance is less than safe distance. This is because a new mediaPlayer object was programmed to be called and started every single time we get a valid message on the bluetooth connection stream buffer. After some researching, the problem and solution was found. Basically this problem is caused by instantiating too many mediaPlayer object without releasing the object from the memory. The garbage collector will come in and kill the mediaPlayer process to free up memory. The fix is basically to actually release the object after starting the mediaPlayer object. But we need to have some delay in order for a beep sound to come out. If the delay is too short, the object would be released before the beep sound can be outputted to the speaker.
Conclusion
Conclude your project here. You can recap your testing and problems. You should address the "so what" part here to indicate what you ultimately learnt from this project. How has this project increased your knowledge?
Project Video
Upload a video of your project and post the link here.
Project Source Code
References
Acknowledgement
Any acknowledgement that you may wish to provide can be included here.
References Used
List any references used in project.
Appendix
- CAN Transceiver File:S15 244 Grp9 TJA1050.pdf
- I2C Differential Buffer File:S15 244 Grp9 PCA9615.pdf
- Laser Distance Sensor File:S15 244 Grp9 Laser.pdf
- Bluetooth Module File:S15 244 Grp9 RN41XV.pdf