Obd2 Pid Reader
Obd2 Pid Reader
2013
CPE Senior Project
Andrew Fong
Table of Contents
Table of Contents .......................................................................................................................................... 2
List of Tables and Figures .............................................................................................................................. 3
Acknowledgements....................................................................................................................................... 4
Abstract ......................................................................................................................................................... 5
I. Introduction ............................................................................................................................................... 6
II. Background ............................................................................................................................................... 7
III. Requirements ........................................................................................................................................... 8
IV. Design ...................................................................................................................................................... 9
VI. Development ......................................................................................................................................... 10
V. Testing and Results ................................................................................................................................. 12
VI. Conclusion and Recommendations ....................................................................................................... 16
VII. Bibliography .......................................................................................................................................... 18
VIV: Appendixes .......................................................................................................................................... 19
Appendix A: Analysis of Senior Project Design ....................................................................................... 19
Appendix B: Parts List ............................................................................................................................. 21
Appendix C: Hardware and Connections ................................................................................................ 21
Appendix D: How to Manual ................................................................................................................... 21
Appendix D: OBD Visual Basic Code........................................................................................................ 23
Page 2
Page 3
Acknowledgements
I would like to thank Dr. Dolan for his insight and guidance throughout the project. In addition,
he provided the Bluetooth ELM327 device as well as a Chevy Volt to test the project on.
Sincerely,
Andrew Fong
Page 4
Abstract
The most current standard on automobiles for monitoring data is OBD-II. Using On board
diagnostic Parameter ID (OBD PID) codes hobbyists and mechanics have the ability to monitor, chart,
and obtain data on cars by communicating to the ECU. The OBD-II connector is often located under the
drivers side inside of the car. The hardware will consist of a generic Bluetooth OBD2 connector and a
laptop running windows. The software will be an program exe created by visual basic. The software
created in visual basic will allow the user to examine PID codes in order to record and discover new data
on the OBD bus.
Page 5
I. Introduction
General Knowledge
An OBD-II standard was mandated for all automobiles sold in the United States since 1996 [2].
The port is often located on the drivers side of the car underneath the steering wheel on the left or
right side. This data is read-only so it can in no way cause harm to the car as it is merely a diagnostics
tool. A connector is hooked up to this port and is usually interfaced with by Bluetooth, usb, or a
connected display. Reading this port gives the user access to data to monitor the chasis, body, and
accessories of the car as well as other diagnostic data [2].
The device that this project uses in particular is the ELM327 chip. Its peripheral interface is
either Bluetooth or usb, in this project a Bluetooth connection was used. This chip is able to read five
different signaling interfaces: SAE J1850 PWM, SAE J1850 VPW, ISO 9141-2, ISO 14230 KWP2000, ISO
15765 CAN [5]. However, the CAN interface has become a requirement on vehicles in the US starting
from the year 2008 [5]. Using this interface, allows for a higher possible range of data as it is a 11-bit
BUS. The ELM327 Bluetooth device handles all the interfaces by using its onboard commands to select
the protocol. The device pre-handles the headers and format. For instance, if one wants to send the a
Parameter-ID, the user just has to enter the mode and then a supported OBD2 PID [5]. The result is then
responded in a hex message string which one needs to use a program to decode it into human readable
data.
The goal of the project is to read custom and standard (Mode 01) On-Board Parameter-IDs for
OBD2 vehicles. Using the ELM327, the user will be able to use the program to monitor and poll for new
codes later being able to chart the hex strings to determine what the code represents exactly. In
addition, the operator can simply use draw from the standard PID list that is supported on all vehicles to
access known data.
Page 6
II. Background
Hardware
A 16 pin J1962 connector is standard for all cars to interface with. There are five communication
types using this layout: J1850 VPW, ISO-9141-2, KWP2000, J1850 PWM, and CAN are set by the metal
contacts that the connector touches [5]. At the start of 2008 cars in the United States were required to
have a new standard on top of this which was using a CAN bus [3].
In all cases pins 4 and 5 are both tied to ground and 16 is to the 12V battery. Based on what
interface is used, two other pins are used for the data lines. In the CAN implementation, 6 and 14 are
used. The advantages of CAN are that it supports a higher bit transfer rate and 2 buses support by a
CANH (Pin 6) and CANL(Pin 14) [5].
The device used in this project is a generic Bluetooth ELM327. The Bluetooth connectivity allows
for freedom to place the device accessing the ELM327, but at the cost of some speed. This connector
allows for the user to monitor data through a computer or phone and potentially could be added to
onboard GPS navigation systems. The ELM327 software addresses the CAN implementation by
preloading the message header with 0x7DF and formats the hex string appropriately to a 7 byte CAN
message [6]. Elm Electronic Incs ELM327 microchip handles the detection of the proper protocol used
by the car as well as sets up the header for the protocol to be used this is hidden by default and can be
shown with the command AT H1 [1].
Page 7
III. Requirements
Marketing
Requirements
Engineering
Specifications
Justification
2, 3
2, 3, 4
Bluetooth ELM327
1,2,3, 4
Marketing Requirements
1. Low cost.
2. Easy to use
3. Support all protocols
4. User input
5. Portability
Page 8
IV. Design
Hardware
See Hardware connection in Appendix C.
Software
After connecting the ELM327, the device is to be connected using Bluetooth from a computer
using windows. A program will be devised in visual basic to allow users to check for standard PIDs as well
as monitor non-standard PIDs such as manufacturer specific codes that are unreleased to the public. A
visual basic program was constructed to allow the user to examine data. The device is to be interfaced
using serial and the com connection created by the Bluetooth device. After connecting to the COM port
the code will the initialize an array that corresponds to the standard PID table [6]. When initialization is
finished, the user will be able to select to look at the standard PIDs or enter their own (Figure 2). The
standard PID populates the list in Figure 4 and then pushes the checked list to the readPID tab shown in
Figure 5/6. The other two modes allow the user to input their own custom PID and receive results.
Initialize
Single
Tri-PID
Page 9
Standard PID
VI. Development
The development was done using Microsoft Visual Studio to create visual basic code to connect
to the hardware. Using the ELM327 device and a laptop with both Bluetooth and a windows operating
system, initial tests were done using a terminal client to read data from the ELM327. After sending this
data, bytes of data were returned at monitored to understand the data collection process. Tests were
done using a terminal application and reading data from the program.
To initialize the ELM327 chip for use, the program first connected to the serial COM port
created by the Bluetooth link. First, an AT Z command is sent to reset the settings on the ELM327 [1].
Next, the command AT L1 sets up the output for terminal style feeds [1]. The code also toggles off
programmable parameters, turns echo on, and turns on headers [1]. While testing on the Chevy Volt, an
issue occurred as Flow Control was also enabled by default. As opposed to the previous CAN vehicle I
tested on it ran a loop reading multiline input that would not stop, this hindered the results of my
program. As a fix, I turned flow control off allowing for single line input feeds using the command AT
CFC0 [1].
After making comparisons, a standard PID calculation list was constructed to support the 101
PIDs for Mode 1 for PIDs 0x00 to 0x64 [6]. A successful response to a mode 01 PID would be for example
41 00 to a 01 00 query would be followed by 4 bytes of data [6]. In Figure 9, the section above the single
line PID entry (1) generates a header that shows the connected status of the device. Looking at Figure 7,
information on the ELM327 device is shown in the top section. Next, the OBD protocol the ELM327 uses
to connect to the vehicle is specified. Finally, the manufacturer of the device is listed at the end.
The other functionality is to allow users to attempt to read custom PID codes. As shown in
Figure 9, the design to add the option to input up to 3 custom PIDs was added. For the tests on the
Chevy Volt, it was noted that GM vehicles use mode 22 [6]. This section sends the PID entered into the
Page
10
textbox from left to right, first sending the hex string to the ELM327 and waiting on the response then
sending the next PID. After completing the loop, the thread for then loops on itself, and will continue to
print until it is cancelled by the button. The cancel button for the tri-line PID also stores the data into the
file C:\EngineMonitoring\CPID.txt. The single line PID sends the PID only once but still requires the
user to cancel the string in order to be run again. The standard PID is used in the same method where
the ReadPID in Figure 5 starts the thread. After this, the overhead for the program generates the
supported PID list for the vehicle and updates it in Figure 4. The user then selects the PIDs they wish to
monitor using the check boxes and presses refresh to push the ids to the screen in Figure 5. The data in
Figure 5 automatically updates after a loop of reading values is completed.
Page
11
Testing was initially done using HyperTerminal as shown in Figure l. After connecting to the
Bluetooth device in windows, the Bluetooth manager was opened to detect that the device used COM
ports 3 and 4. PIDs 00, 20, and 40 were read in mode 1 to determine which standard PIDs were
supported by the vehicle. In figure, the responses after the requests for the available pids returns 41 to
confirm a valid response to mode 1 followed by the pid entered [6]. After that the following, data is a
bitmap to which PIDs in mode 1 are supported. In the 4 byte string response for the code 01 20, the last
bit of the hex string means that PID 0x40 is available. Bit masking is done to check the status of
supported bits for these PIDs.
Page
12
Next, I began to construct my program in which I constructed a table to convert the hex string
responses into human readable data. After using others code to connect to the Bluetooth using the
serial COM port, the code read in the strings into a function. At first, work was done to determine the
bitmap and determine which PIDs were supported by the vehicle, this turned on or off elements in my
array. In Figure 4, shows the program determining which PIDs were supported and creating a list. After
generating this list, the user is able to select what PIDs to monitor.
Page
13
In tab 3 shown in Figure 5/6, the user is reading the data select by the boxes in the previous tab
(PID List). Testing was done on the custom program created in visual basic and a reference program.
After verifying consistent data, tests were done on the all supported PIDs for the vehicle [6].
Page
14
Finally, the next step involved testing custom PIDs (Figure 7). The final tests were done a Chevy
Volt. On GM cars, there is a special pid mode 22 the valid response for this query would have 62 then
the PID[6]. Using discovered data users would try to poll through the mode 22 and a 2 byte PID to
discover new PIDs that are not required by the government via the standard PID list [6]. These
manufacturer specific codes have much more data and information. In this case, the program wants to
monitor 22 2414 and 22 2429, which are the Hybrid Voltage discharge amps and voltage respectively. In
this mode, valid responses show 62 to confirm the mode 22 followed by the custom pid in this case
which is 2 bytes. The string responded with 62 24 29 58 04. To convert this, the formula was described
to be (Signed(A)*256 + B)/64. The result for the string would be approximately 352V. A is multiplied by
256 since theres multiple bytes in the calculation, the string is merely converted into its decimal value.
After polling the data, users have to then convert the hex string into decimal and understandable data.
Page
15
Page
16
standard PIDs. Furthermore, smartphone could be implemented to minimize on spatial and increase
portability.
Page
17
VII. Bibliography
[1] "ELM327 Datasheet." ELM Electronics
URL: http://elmelectronics.com/DSheets/ELM327DS.pdf
[2] "OBD-II Background Information." OBD-II Background Information. B&B Electronics, 2011.
URL: http://www.obdii.com/background.html
[3] "Control of Air Pollution From New Motor Vehicles and New Motor Vehicle Engines; Modification of
Federal On-Board Diagnostic Regulations For: Light-Duty Vehicles, Light-Duty Trucks, Medium Duty
Passenger Vehicles, Complete Heavy Duty Vehicles and Engines Intended for Use in Heavy Duty Vehicles
Weighing 14,000 Pounds GVWR or Less." EPA. Environmental Protection Agency, 19 Dec. 2005.
URL: http://www.epa.gov/fedrgstr/EPA-AIR/2005/December/Day-20/a23669.htm
[4] Chevy Volt Mode 22 PIDs "VPIDs-labeled Spreadsheet." Professor at UCCS via GM-Volt Forums.
URL:
https://docs.google.com/spreadsheet/ccc?key=0AvK9F6VeA7dvdFUwSjBzR2FQM1BJTWZoLW43ZFdoTF
E#gid=0
[5] "OBD-II PIDs." Wikipedia. Wikimedia Foundation, 28 May 2013.
URL: http://en.wikipedia.org/wiki/OBD-II_PIDs
[6] "On-board Diagnostics." Wikipedia. Wikimedia Foundation, 06 Dec. 2013.
URL: http://en.wikipedia.org/wiki/On-board_diagnostics#OBD-II
Page
18
VIV: Appendixes
Appendix A: Analysis of Senior Project Design
Project Title: OBD2 PID Reader
Students Name:
Andrew Fong
Advisors Name:
Dale Dolan
Students Signature:
Advisors Initials:
Date:
Page
19
Sustainability
The project is sustainable since it uses existing technology for the ELM327. This device can also
features a low power mode (AT LP) and sleep functionality. Other than this hardware device, the
software is stored in memory and has little issue with real world resources besides a small amount of
memory on a computer. Since the OBDII standard has existed for over a decade its a reliable and
consistent format that may not be upgraded for a while.
The requirement of a laptop with windows is not exactly the most sustainable device to always
lug around for monitoring a vehicle, thus upgrades can be made to convert the project over to a
smartphone, tablet, or possibly integrated into a navigation system changing the portability of the
system. Issues with this design may arise depending on how the Bluetooth stack is integrated.
Ethical
Since the device acts as a read-only connection to the ECU (Central computer for cars) the code
cannot harm the cars digital circuits or reroute information. However, users can still clear diagnostic
troubleshooting codes on the car or access the cars VIN number. These are minor changes that in reality
wont harm the vehicle.
Health and Safety
There are no health and safety issues with the project.
Social and Political
There are no major social issues associated with this project. Political issues associated with
reverse engineering non-standard PID codes and selling them may arise with conflict to the Equipment
and Tool Institute and manufacturers. Not much data if any, has been leaked from these sources,
however an online community online seeks to discover the information so far not making any changes
to affect stakeholders stance. Stakeholders of the ELM Electronics and other stakeholders may have
issues regarding the creation of fake ELM327s created for profit since they created both the circuit and
software for the device.
Development
New tools for development were learned from this project in the coding language of Microsoft
Visual Basic. For example, it was learned how to create forms to display and buttons for an executable in
which the data for the project was shown.
Page
20
Page
21
Page
23
In OBD Class
This Function turns off FlowControl by sending the command AT CFC0
Public Function FlowControlOff() As Boolean
Page
24