{"id":1347,"date":"2018-02-02T17:57:21","date_gmt":"2018-02-02T22:57:21","guid":{"rendered":"http:\/\/www.circuitcrush.com\/?p=1347"},"modified":"2021-06-30T17:44:48","modified_gmt":"2021-06-30T21:44:48","slug":"how-obd-ii-works","status":"publish","type":"post","link":"https:\/\/www.circuitcrush.com\/how-obd-ii-works\/","title":{"rendered":"How OBD-II Vehicle Diagnostics Work"},"content":{"rendered":"<p>Since January 1<sup>st<\/sup>, 1996 all vehicles have been required to have On-board Diagnostics II, also known as OBD-II.<\/p>\n<p>On-board diagnostics existed before then, but the process for reading diagnostic data varied from manufacturer to manufacturer.<\/p>\n<p>If you knew the \u201csecret\u201d sequence, you could use your car key to turn the ignition switch a certain way and hopefully get the check engine light to blink out the error code. Not only did you need to know the correct sequence for the ignition switch, you had to then be able to decode the blinks.<\/p>\n<p><!--more--><\/p>\n<p>The Society of Automotive Engineers (SAE) pulled it all together by defining OBD-II. This made it much easier to read error codes and troubleshoot vehicles.<\/p>\n<p>In fact, it\u2019s so easy that many auto parts stores offer this service for free and will read your check engine light code (in hopes that they can sell you some parts, of course).<\/p>\n<p><strong>So why should electronics enthusiasts care?<\/strong><\/p>\n<p>These days, cars are literally <em>loaded<\/em> with electronic gadgets and makers can build some interesting automotive related projects. To do this, an understanding of OBD-II is often necessary.<\/p>\n<p>As a side note, I\u2019m also a sort of gearhead and do all my own work on our two cars. And I find the way things work — both electrical and mechanical \u2013 very interesting. I suspect I\u2019m not alone.<\/p>\n<h2><strong>But This is an Electronics Blog, Not a Car Blog\u2026<br \/>\n<\/strong><\/h2>\n<p>True.<\/p>\n<p>But because cars are loaded with electronic gadgets, it\u2019s easy to see why someone would want to embark on an automotive related electronics project. If you\u2019re one of those people, you will need to know about OBD-II, CAN, and the myriad of other electronics stuffed into today\u2019s vehicles.<\/p>\n<p>If you\u2019re old enough, you may remember a time when you could pop the hood of your car open, gaze into it, and see a lot of the ground underneath. The only electronics in the car were the ignition system, headlights and tail lights, battery and alternator, and maybe a simple AM\/FM radio.<\/p>\n<p>Those were the good ol\u2019 days.<\/p>\n<p>Personally, I have never owned a car like this. My current car (the newest one I\u2019ve had) is from 1999. But don\u2019t scoff — in addition to all the fuel and emissions controls, the car boasts distributorless ignition, power everything, heated mirrors, anti-lock brakes, and a CD\/MP3 player. The dash even alerts me when a tail light or headlight is out. I Like not having a car payment, but I\u2019ll be looking at buying a new car this year – likely something 2015 or newer.<\/p>\n<p>Due to pressure to reduce toxic emissions and improve gas mileage, manufacturers eventually started putting more electronics into cars.<\/p>\n<p>In the 1980\u2019s electronic fuel injection was showing up on more and more cars, eventually replacing carburetors all together. Along with it came the need for a computer to control it and talk to the other various emissions and fuel system related components. Most of us left these things buried under the hood and gave them very little thought, if we even knew they were there in the first place.<\/p>\n<p>Enter the 1990\u2019s.<\/p>\n<p>Things like power locks and windows, higher quality sound systems, anti-lock brakes, keyless entry, and electronic climate control were becoming standard in many vehicles. Even technology such as navigation, traction control, TV screens in headrests, and \u201cRun Flat\u201d tires were showing up (along with their control circuitry) in some cars later that decade.<\/p>\n<p>Electronic devices were now creeping out from under your hood and into your vehicle\u2019s cabin.<\/p>\n<p>Modern hybrid vehicles became available to the general public around the turn of the millennium.<\/p>\n<p>I remember my parents (who are generally afraid of technology and not early adopters of anything) buying a 2001 Prius. I was shocked. It wasn\u2019t the prettiest car, but later models made the Prius more aesthetically pleasing.<\/p>\n<p>Of course, with the introduction of hybrid cars came the need for more electronics: batteries, electric motor\/generator, and all the associated control circuitry.<\/p>\n<p>Later in the 2000s, Bluetooth connectivity, USB ports, and other technologies started showing up in cars. My wife\u2019s 2009 Fusion comes with all the above and Ford\u2019s Sync (with software by Microsoft), so she can make and receive cell phone calls on the car\u2019s audio system, which \u2013 even for a factory system sounds nice, sans any amps or subwoofers in the trunk.<\/p>\n<p>In the current decade we have cars that parallel park themselves and apply the brakes for you to avoid a potential collision. Many vehicles come standard with back-up cameras and internet connectivity, along with all the other goodies that were introduced in previous decades.<\/p>\n<p>It\u2019s official: electronics in vehicles are here to stay and will only increase. Pretty soon, cars will be driving themselves while we sit back and relax. There are a few technical, political, and legal hurdles to surmount before this happens, but it\u2019s coming.<\/p>\n<p>Enough about why we <em>should<\/em> care about OBD-II, let\u2019s get into some nitty gritty!<\/p>\n<h3 style=\"text-align: center;\">Become the Maker you were born to be. Try <a href=\"https:\/\/learnarduinonow.com\">Arduino Academy<\/a> for FREE!<\/h3>\n<p><img decoding=\"async\" class=\"aligncenter wp-image-4238\" src=\"https:\/\/www.circuitcrush.com\/wp-content\/uploads\/FB_Cover2.png\" alt=\"\" width=\"318\" height=\"121\" srcset=\"https:\/\/www.circuitcrush.com\/wp-content\/uploads\/FB_Cover2.png 828w, https:\/\/www.circuitcrush.com\/wp-content\/uploads\/FB_Cover2-300x114.png 300w, https:\/\/www.circuitcrush.com\/wp-content\/uploads\/FB_Cover2-150x57.png 150w, https:\/\/www.circuitcrush.com\/wp-content\/uploads\/FB_Cover2-768x292.png 768w\" sizes=\"(max-width: 318px) 100vw, 318px\" \/><\/p>\n<h1><strong>OBD-II Basics<br \/>\n<\/strong><\/h1>\n<p>The OBD-II connector has the shape of a trapezoid and resides underneath the driver\u2019s side dashboard. Figure 1 depicts a picture of the connector and the pinout.<\/p>\n<p>OBD-II is an odd standard in that it is made up of four different main \u201csub\u201d standards in and of itself. The OBD-II connector supports all of these. You\u2019ll see what I mean soon.<\/p>\n<p><img fetchpriority=\"high\" decoding=\"async\" class=\"size-full wp-image-1350 alignnone\" src=\"http:\/\/www.circuitcrush.com\/wp-content\/uploads\/OBD-II-Pinout.jpg\" alt=\"OBD-II pinout\" width=\"432\" height=\"550\" srcset=\"https:\/\/www.circuitcrush.com\/wp-content\/uploads\/OBD-II-Pinout.jpg 432w, https:\/\/www.circuitcrush.com\/wp-content\/uploads\/OBD-II-Pinout-118x150.jpg 118w, https:\/\/www.circuitcrush.com\/wp-content\/uploads\/OBD-II-Pinout-236x300.jpg 236w\" sizes=\"(max-width: 432px) 100vw, 432px\" \/><\/p>\n<p><strong><em>Figure 1: OBD-II connector and pinout.<\/em><\/strong><\/p>\n<p>You\u2019ll notice that some of the pins in figure 1 are specific to the make and model of the car. We won\u2019t worry about those. The standard is the same and works with or without those make\/model specific pins.<\/p>\n<p>This single connector contains all the networks in use today as well as the controller area network (or CAN) standard. All vehicles from January 1<sup>st<\/sup>, 2008 or later use the CAN standard. If your vehicle was made before 2008, it may use CAN, or it may use one of the other standards.<\/p>\n<p>What do I mean by all the networks in use today?<\/p>\n<p>Earlier, I said OBD-II was composed of other standards.<\/p>\n<p>These standards are:<\/p>\n<ul>\n<li>ISO 9141-2<\/li>\n<li>SAE J1850 variable pulse width (VPW)<\/li>\n<li>SAE J1850 pulse width modulation (PWM)<\/li>\n<li>And the newer CAN standard (ISO 15765)<\/li>\n<\/ul>\n<p>While all cars made since January 1<sup>st<\/sup>, 2008 use the CAN version, there are still a fair share of older vehicles on the road today that use one of the other three standards.<\/p>\n<p>Quick research suggests the average lifespan of a vehicle in the U.S. today is about 12-13 years. Given this information, it\u2019s easy to see why OBD-II includes the older standards. We\u2019ll go into some detail on each one in part 2 of this series.<\/p>\n<p>When you plug a code scanner into an OBD-II port, the scanner automatically discovers which standard to use. It then communicates using the correct pins, ignoring all the other pins.<\/p>\n<h2><strong>OBD-II Passive vs Active States<br \/>\n<\/strong><\/h2>\n<p>Throughout this series you\u2019ll see the words passive and active. This has to do with OBD-II bus arbitration. The passive state of a bus can always be over-ridden by an active state by any node. A node is just something that connects to the bus.<\/p>\n<p>This creates a priority where logic 0 (active) wins out over logic 1 (passive). Since nodes always listen to the bus as they send data, if any node detects an active state while it\u2019s sending a passive state, it will stop sending and wait for the bus to become idle.<\/p>\n<p>Because of this, important messages, such as those pertaining to critical engine parameters, can get through while messages of lesser importance must wait.<\/p>\n<h2><strong>OBD-II Data Packet Structure<br \/>\n<\/strong><\/h2>\n<p>All OBD-II standards us the same basic format for their data packets, though there are some slight differences for each protocol.<\/p>\n<p>The basic structure is a packet beginning with a start of frame (SOF) pulse. Then comes the header which includes a priority, a destination, and a source. After the header comes the data. After that, a CRC or checksum. Finally, there is the end of data (EOD). Note that all buses will go idle if there has been no activity for a certain amount of time.<\/p>\n<p>Header bytes direct the data. The priority byte within the header enables arbitration of the bus. Lower values have a higher priority. The priorities are used in arbitration to ensure important messages get first dibs on the bus. Destination and source bytes help direct the request to the right node and also show where the response needs to go.<\/p>\n<p>The data field generally can contain up to 7 bytes. A running checksum (or CRC in the case of CAN) helps with data corruption.<\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"96\"><strong>Mode<\/strong><\/td>\n<td width=\"525\"><strong>Description<\/strong><\/td>\n<\/tr>\n<tr>\n<td width=\"96\">0x01<\/td>\n<td width=\"525\">Show current data<\/td>\n<\/tr>\n<tr>\n<td width=\"96\">0x02<\/td>\n<td width=\"525\">Show freeze frame data<\/td>\n<\/tr>\n<tr>\n<td width=\"96\">0x03<\/td>\n<td width=\"525\">Show stored Diagnostic Trouble Codes<\/td>\n<\/tr>\n<tr>\n<td width=\"96\">0x04<\/td>\n<td width=\"525\">Clear Diagnostic Trouble Codes and stored values<\/td>\n<\/tr>\n<tr>\n<td width=\"96\">0x05<\/td>\n<td width=\"525\">Test results, oxygen sensor monitoring (non-CAN only)<\/td>\n<\/tr>\n<tr>\n<td width=\"96\">0x06<\/td>\n<td width=\"525\">Test results, other component\/system monitoring (Test results,<br \/>\noxygen sensor monitoring for CAN only)<\/td>\n<\/tr>\n<tr>\n<td width=\"96\">0x07<\/td>\n<td width=\"525\">Show pending Diagnostic Trouble Codes<\/td>\n<\/tr>\n<tr>\n<td width=\"96\">0x08<\/td>\n<td width=\"525\">Control operation of on-board component\/system<\/td>\n<\/tr>\n<tr>\n<td width=\"96\">0x09<\/td>\n<td width=\"525\">Request vehicle information<\/td>\n<\/tr>\n<tr>\n<td width=\"96\">0x0A<\/td>\n<td width=\"525\">Permanent Diagnostic Trouble Codes (DTCs)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong><em>Figure 2: OBD-II modes.<\/em><\/strong><\/p>\n<p>Most requests consist of a mode byte and a parameter ID (PID) byte. OBD-II also requires a \u201cfunctional address\u201d that all nodes must respond to. This is sort of like a roll-call or public shouting of \u201chere I am!\u201d for the nodes.<\/p>\n<p>The figure above shows the 10 OBD-II modes. Note that not all manufacturers support all nodes.<\/p>\n<p>There are too many PIDs to list here, but Wikipedia provides an extensive list of PIDs with different modes. Just search OBD-II PIDs.<\/p>\n<p>Figure 3 depicts a graphical representation of a typical OBD-II data frame.<\/p>\n<p><img decoding=\"async\" class=\"size-large wp-image-1351 alignnone\" src=\"http:\/\/www.circuitcrush.com\/wp-content\/uploads\/OBD-II-Data-Frame-1024x306.jpg\" alt=\"OBD-II Data Frame\" width=\"1024\" height=\"306\" srcset=\"https:\/\/www.circuitcrush.com\/wp-content\/uploads\/OBD-II-Data-Frame-1024x306.jpg 1024w, https:\/\/www.circuitcrush.com\/wp-content\/uploads\/OBD-II-Data-Frame-600x180.jpg 600w, https:\/\/www.circuitcrush.com\/wp-content\/uploads\/OBD-II-Data-Frame-150x45.jpg 150w, https:\/\/www.circuitcrush.com\/wp-content\/uploads\/OBD-II-Data-Frame-300x90.jpg 300w, https:\/\/www.circuitcrush.com\/wp-content\/uploads\/OBD-II-Data-Frame-768x230.jpg 768w, https:\/\/www.circuitcrush.com\/wp-content\/uploads\/OBD-II-Data-Frame.jpg 1126w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/p>\n<p><strong><em>Figure 3: OBD-II data frame structure.<\/em><\/strong><\/p>\n<p>The actual codes you would see on your code scanner are five characters long. To use the scanner, you simply plug it into your vehicle\u2019s OBD-II port under the driver\u2019s side dash, turn the key to \u201con\u201d position, hit the appropriate button on your scanner and wait for the codes to come rolling in.<\/p>\n<p>Figure 4 shows a breakdown of the structure of a typical diagnostic trouble code (DTC). Note that you should not get any codes unless your check engine light is on. You can also clear the codes with your scanner and turn that annoying light off. However, it will simply come back on unless the problem is fixed.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1352 alignnone\" src=\"http:\/\/www.circuitcrush.com\/wp-content\/uploads\/DTC-Anatomy.jpg\" alt=\"Diagnostic Code Anatomy\" width=\"416\" height=\"319\" srcset=\"https:\/\/www.circuitcrush.com\/wp-content\/uploads\/DTC-Anatomy.jpg 416w, https:\/\/www.circuitcrush.com\/wp-content\/uploads\/DTC-Anatomy-150x115.jpg 150w, https:\/\/www.circuitcrush.com\/wp-content\/uploads\/DTC-Anatomy-300x230.jpg 300w\" sizes=\"(max-width: 416px) 100vw, 416px\" \/><\/p>\n<p><strong><em>Figure 4: anatomy of a DTC.<\/em><\/strong><\/p>\n<h2><strong>Coming up: OBD-II, Part II<br \/>\n<\/strong><\/h2>\n<p>So far, we\u2019ve talked about why you should care about OBD-II, a brief history of electronics in cars, OBD-II basics, passive and active states, and we dissected an OBD-II data frame.<\/p>\n<p>In part 2, we\u2019ll dissect each of the four protocols or standards in OBD-II and delve into how they work.<\/p>\n<p>Meanwhile, comment and let me know if you\u2019re into automotive related projects (electrical, mechanical or both). If so, tell me a bit about your latest endeavor.<\/p>\n<h2 style=\"text-align: center;\">Become the Maker you were born to be. Try <a href=\"https:\/\/learnarduinonow.com\">Arduino Academy<\/a> for FREE!<\/h2>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4238\" src=\"https:\/\/www.circuitcrush.com\/wp-content\/uploads\/FB_Cover2.png\" alt=\"\" width=\"828\" height=\"315\" srcset=\"https:\/\/www.circuitcrush.com\/wp-content\/uploads\/FB_Cover2.png 828w, https:\/\/www.circuitcrush.com\/wp-content\/uploads\/FB_Cover2-300x114.png 300w, https:\/\/www.circuitcrush.com\/wp-content\/uploads\/FB_Cover2-150x57.png 150w, https:\/\/www.circuitcrush.com\/wp-content\/uploads\/FB_Cover2-768x292.png 768w\" sizes=\"(max-width: 828px) 100vw, 828px\" \/><\/p>\n<a target=\"_blank\" href=\"https:\/\/www.drpeterscode.com\/index.php\"><img src=\"https:\/\/www.circuitcrush.com\/wp-content\/plugins\/dpabottomofpostpage\/apixel1x1.jpg\" ><\/a><table><\/table>","protected":false},"excerpt":{"rendered":"<p>Since January 1st, 1996 all vehicles have been required to have On-board Diagnostics II, also known as OBD-II. On-board diagnostics existed before then, but the process for reading diagnostic data varied from manufacturer to manufacturer. If you knew the \u201csecret\u201d sequence, you could use your car key to turn the ignition switch a certain way […]<\/p>\n","protected":false},"author":1,"featured_media":1355,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_genesis_hide_title":false,"_genesis_hide_breadcrumbs":false,"_genesis_hide_singular_image":false,"_genesis_hide_footer_widgets":false,"_genesis_custom_body_class":"","_genesis_custom_post_class":"","_genesis_layout":"","_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[104],"tags":[105],"class_list":{"0":"post-1347","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-obd-ii","8":"tag-obd-ii","9":"entry"},"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"https:\/\/www.circuitcrush.com\/wp-content\/uploads\/Hack-Your-Car-With-OBD-II.jpg","_links":{"self":[{"href":"https:\/\/www.circuitcrush.com\/wp-json\/wp\/v2\/posts\/1347","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.circuitcrush.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.circuitcrush.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.circuitcrush.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.circuitcrush.com\/wp-json\/wp\/v2\/comments?post=1347"}],"version-history":[{"count":2,"href":"https:\/\/www.circuitcrush.com\/wp-json\/wp\/v2\/posts\/1347\/revisions"}],"predecessor-version":[{"id":4310,"href":"https:\/\/www.circuitcrush.com\/wp-json\/wp\/v2\/posts\/1347\/revisions\/4310"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.circuitcrush.com\/wp-json\/wp\/v2\/media\/1355"}],"wp:attachment":[{"href":"https:\/\/www.circuitcrush.com\/wp-json\/wp\/v2\/media?parent=1347"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.circuitcrush.com\/wp-json\/wp\/v2\/categories?post=1347"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.circuitcrush.com\/wp-json\/wp\/v2\/tags?post=1347"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}