Hack69.Plug into Your Car s Built-in Computer


Hack 69. Plug into Your Car's Built-in Computer

If your car is less than a decade old, you can hook into a wealth of real-time information through its on-board diagnostic port.

If you say "car computer," most auto repair shops will assume you mean one of the various electronic control units, or ECUs, built into your car. Almost all modern vehicles are computerized in the sense that they have computers that read inputs from various sensors and use that information to control the engine, transmission, and other electronic systems. Most car users are not even aware of the existence of these computers (until they break, at which point they become very aware of the expense of replacing them). However, people who modify their cars with aftermarket performance parts sometimes need to provide new software to the computers in order to take maximum advantage of the new hardware they've installed. This process, known as chipping, is often as simple as replacing a single EEPROM (Electrically Erasable and Programmable Read-Only Memory) chip.

ECUs are not monolithic computers that control everything in your car. In fact, cars have many different ECUs, such as the Electronic Control Module (ECM), which controls smog emissions through engine tuning; the Powertrain Control Module (PCM), which controls the transmission and engine; and the Vehicle Control Module (VCM), which oversees a number of non-smog-related functions, including antilock braking systems.


Almost all new consumer vehicles conform to a standard called OBD-II (On-Board Diagnostic System II). A vehicle that supports OBD-II will provide real-time readings for dozens of engine parameters, such as fuel temperature, oxygen temperature, coolant temperature, fuel pressure, RPMs, speed, and throttle position, in addition to decoding all the fault codes that cause a "check engine" light to go on or stay on.

OBD-II describes both a physical plug in your car's computer and the network protocol you can use to communicate with the car. Using the information in this hack, you will be able to connect to your car's built-in computer and have it tell you everything it is seeing and doing.

While OBD-II defines a standard set of data that has to be made available by all cars, each car manufacturer also uses the OBD-II port to access additional codes. Sometimes they also use higher-speed protocols to speak directly to (and even reprogram) the various ECUs in that car.

Entire in-car networks and related hardware standards and protocols have been developed so that the various ECUs can talk to each other. The Controller Area Network (CAN) bus is a standard used throughout Europe and in some U.S. cars to connect everything from brake systems to engine management systems to seatbelts, windows, and door locks. However, there are several standards for in-car interdevice communication, and more than one network system may be used in a particular car designone for essential real-time engine control and another for audio and lighting, for instance. A great summary of various automotive networking protocol standards can be found at http://www.interfacebus.com/Design_Connector_Automotive.html.

If you're just trying to get the standard set of OBD-II readouts, which are quite numerous, you can get a simple, inexpensive generic adapter that works with your general make of vehicle. If, however, you'd like to do exotic things such as engine tuning, you'll want to get an adapter and software designed specifically for your make and model of vehiclethese are most likely to be found on the fan sites relating to your specific car model. Before you can buy an adapter to talk to your vehicle's OBD-II port, though, you have to figure out which of the versions of OBD-II your car speaks.

On-Board Diagnostics Version II

In the 1980s and 1990s, automobile service centers started needing to employ "computer guys" to deal with the ECUs and fuel computers of modern cars. However, most shop technicians, with a little training, could still do smog inspections. All they needed was a DOS program running on a greasy Intel 286 computer wired into a long sensor stuck in the car's tailpipe and a tachometer sensor clipped to a spark plug wire. Decades later, these systems have been replaced with much more sophisticated test computers that connect directly to the car's ECU, assess its smoggyness, and then immediately phone home to the DMV mother ship. This provides more accurate and honest smog-test information to the DMV. Notably, it will also give vehicles a means of receiving orders when, in the not-too-distant future, they become self-aware and rise up against us.

As U.S. state governments worked to increase the sophistication of their tests and cut down on fraud, they pushed for a standardized interface for accessing the ECU diagnostic and engine information needed for smog-testing cars. The early version of this on-board diagnostic standard ( OBD) was not universally installed, but the second version ( OBD-II) became a requirement on all U.S. passenger cars from 1996 onward, and on most European cars from around 2000 onward.


7.2.1. The Four Flavors of OBD-II

The OBD-II port (Figure 7-1) is a 16-pin, trapezoidal-shaped connector found somewhere in the driver's-side dashboard area of modern vehicles.

If you're familiar with computers, you know that just because the plug fits, that doesn't mean it will work. The same applies to the OBD-II interface. This hardware plug is actually an interface to four different possible connection protocolsit's sort of like if you had a serial port, a USB port, and a PS2 keyboard port merged together into a single connection socket.

Figure 7-1. An OBD-II connector


The functions of the different pins in the OBD-II connector are shown in Table 7-1.

Table 7-1. The OBD-II port pinout

Pin

Purpose

2

SAE-J1850 (VPW/PWM) bus positive line

4

Chassis ground

5

Signal ground

6

CAN high (J-2284)

7

ISO 9141-2 K (data) line

10

J1850 bus negative line

14

CAN low (J-2284)

15

ISO 9141-2 L (initialization) line

16

Battery power


See http://www.obdii.com/connector.html and http://www. auterraweb.com/obdiipinout.html for more information about the pinouts.


The unassigned pins (1, 3, 8, 9, 11, 12, and 13) are all available for use by the manufacturer for things such as airbags, alarms, remotes, and so on.

OBD-II is actually a software layer on top of multiple hardware interfaces. Society of Automotive Engineers (SAE) standard J197 defines the communication protocol that runs on this hardware (sort of like how TCP/IP runs on top of Ethernet).

You practically need an R2D2 unit to speak all the different languages, protocols, and electrical standards that this innocent-looking port can speak. The following list describes the four different wire protocols crammed into the OBD-II port (and thus the four types of adapters you might have to purchase):


ISO (International Organization for Standardization) 9141-2 and ISO 1430

ISO 9141-2 is the electrical connection method used by European, Asian, and Chrysler vehicles and is electrically similar to a serial port. ISO 1430, or KWP2000 (Key Word Protocol 2000), uses the same physical interface but speaks a different language. The ISO protocols use pins 5, 7, 16, and sometimes 15.


VPW (SAE J1850)

Variable Pulse Width (describing the electrical communication method) is used by most General Motors vehicles. This uses pins 2, 5, and 16.


PWM (SAE J1850)

Pulse Width Modulation (describing the electrical communication method) is used by most Ford vehicles. This uses pins 2, 5, 10, and 16.


CAN (SAE J2284)

Controller Area Network (described in ISO documents 11898/11519/ 15765) is slowly replacing the three buses above, and it should be the one standard OBD-II interface method by 2008. This uses pins 4, 6, 14, and 16.

There are dozens more acronyms where those came from, but this list should allow you to wade through some of the morass and figure out what kind of adapter you'll need to connect your PC to the OBD-II port in your car. A good list of car makes and the protocols they support for each year of manufacture can be found at http://www.etools.org/files/public/generic-protocols-02-17-03.htm.

7.2.2. Access Your Car's OBD-II Data

Some vendors make standalone devices that plug into the OBD-II port and are primarily designed to read vehicle fault codes. To use your computer to take readings, you will need an OBD-to-serial or OBD-to-USB adapter.

There are too many OBD-II adapters out there to mention them all, but a couple of popular adapters used by car PC hackers are the BR-3 from http://www.obddiagnostics.com and the Elmscan from http://www.scantool.net. While both have free software available for Windows and Linux, the Elmscan has more third-party application support (http://www.scantool.net/ software/scantool.net/). You can download the software for both of these units and check them out before you buy.

Once you get one of these adapters, you're going to need to figure out where to plug it into your car. Depending on your vehicle, the physical interface may be with the fuses, under the steering wheel to the left or right, or in some other inconspicuous and car-specific location. A great resource for finding this location is at http://www.autocenter.weber.edu/OBD-CH/vehicleoems.asp. If your port is right under the steering wheel, you may want an adapter that folds over nicely. Since you're probably going to be leaving your OBD-II interface plugged in all the time, you don't want to have a big plug hitting your knees as you try to drive.

Once you have plugged the unit into your OBD port, you'll simply need to plug the serial connector into your car PC or laptop, and inform the OBD-II software which COM port you've connected it to.

One of the most popular uses of live OBD-II data is for a computerized dashboard display. The software that comes with the BR-3 has a built-in gauge function, which you can see in Figure 7-2.

Although the Elmscan software does not come with a gauge display, I went onto the OBD-II forums at http://www.mp3car.com and found a skinnable real-time gauge designed to use the Elmscan hardware (Figure 7-3).

As I write this, both FrodoPlayer [Hack #75] and CENTRAFUSE [Hack #73] are adding support for OBD-II data streams directly into their applications.

7.2.3. Going Beyond OBD-II

OBD-II will give you an interesting set of data and may even help you diagnose engine troubles, but it's only the beginning of in-car interfacing. Beyond the sub-$100 hobby interfaces (which are perfectly adequate for most users), there are professional scan tools that understand the unique dialect of your make of vehicle and can interface more intimately with your car than ordinary OBD-II can.

There are aftermarket products dedicated to the specific make (or even model) of most popular vehicles. Some of these products are designed for tuning the vehicle and improving its racing performance, and to facilitate this they can tap into the car's real-time sensor networks (as opposed to the slower, once-a-second readouts of OBD-II). Examples include http://www.tweecer.com (for Mustangs), http://www.ecutek.com (for Subarus), and so on for every other make of car you can think of. Combining the OBD-II data with other sensors can allow for some very accurate measurements of engine performance. For example, for $239 Auttera (http://www.auterraweb.com) offers a unit that combines all four OBD protocol standards, and also includes an accelerometer. Combining the speed and RPM measurements from the OBD-II with the accelerometer readout, the device can accurately estimate horsepower and torque, acceleration times (060, quarter-mile, and so on), and fuel mileage.

Figure 7-2. BR-3 gauges


Figure 7-3. OBD-II gauge from MP3Car.com forums


You have to spend a bit more for the ultimate in ECU measurement and interfacing. Vehicle Spy (http://www.intrepidcs.com/vspy/), which uses a highly sophisticated (and very expensive) hardware interface, can simultaneously record information from a number of your car's ECUs in real time and correlate them to location data from a GPS unit. Designed primarily for engineers at auto manufacturers, it has APIs and programming interfaces so you can get at the data any way you want. Although this tool is total overkill for most car PC hacking, I've listed it here because there's little it can't do.

7.2.4. See Also

  • http://www.obdii.comThis site provides a great introduction to OBD-II and is sponsored by AutoTap (http://www.autotap.com).

  • http://www.andywhittaker.com/ecu/obdii_software.htmThis site provides a good tutorial, sells OBD interface hardware, and links to other useful OBD programs.

  • http://www.mp3car.comThe MP3Car.com forums are the best place to see what cheap, open, functional adapters are most popular amongst car PC hackers.



    Car PC Hacks
    Car PC Hacks
    ISBN: 0596008716
    EAN: 2147483647
    Year: 2005
    Pages: 131

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net