Windmill Software Ltd
Windows Engineering Software

Garmin GPS Receiver
June 2007

Interfacing a vehicle's On Board Diagnostics

Home
Newsletters
Catalogue
Search

Regularly Logging a Vehicle's Fuel-Consumption, Emissions, Location, etc

With Windmill you can use your laptop to log and display your vehicle's fuel consumption, emissions, location and other parameters.

Recently manufactured vehicles will have an On Board Diagnostics (OBD) system. This monitors vehicle conditions and components that are related to vehicle emissions. The US and Canada has the OBDII system, Europe the EOBD system and Japan the JOBD system. You can interface this system to your PC and use Windmill to automatically collect the data at regular intervals.

To connect your OBD system to the PC you need an interface. Although the On Board Diagnostics are standard across cars, the interface isn't: you need to buy an interface that matches your vehicle. You connect the interface between the car's 16-pin diagnostic port and, if you plan to use the free Windmill software, to the computer's COM port. (There are interfaces that connect to other PC ports - the USB port for example - but the free software reads the PC's COM port.)

You now need some software to request data from the OBD system, read the response and log and display the data. If you wish to perform real-time calculations on the data, for example to see current fuel consumption, the software needs to be able to channel the data to a spreadsheet or similar program. Windmill software can do all these things. You can choose either the free Windmill 4.3 software or the more recent Windmill 6 COMIML.

With Windmill you can interface several different devices, so you could add a GPS receiver to record location alongside your fuel consumption and emissions data.

Using Windmill 4.3 Software | Getting the data into Excel | Application Story: Real-Time Fuel Consumption Monitoring | Understanding PIDs and the OBD Message Structure


Using Windmill 4.3 Software

  1. Run the Windmill ConfIML program and enter the settings needed to communicate with your On Board Diagnostics interface.
  2. Run the Windmill SetupIML program and choose names and units for your data.
  3. Run the Windmill DDE Panel and Logger programs to send the data to Excel or log it to disk.

After you have entered your configuration settings with ConfIML and SetupIML, you don't need to use these again and can go straight to the logging and display programs. More details on entering the configuration settings are below.


Run the Windmill ConfIML program

This detects and saves a record of the hardware you want to use. You need to add the LabIML ASCII instrument handler and enter your instrument's communication settings. To do this

  1. Press the Add button.
     
  2. Select LabIML RS232 ASCII Instrument Handler and press Add again.
     
  3. Type a name and a description, for example Fuel and Fuel consumption. The name and description can be anything you like. Decide how many types of data you want to collect, and enter this as the number of channels. For example, if you wanted to read vehicle speed this would be stored in one channel.
     
  4. Enter your interface's settings. These depend on exactly what you want from your system, but these settings should get you started.
    • Reading Protocol: Request/Response - Background
    • Timeout: 1000 milliseconds
    • Data Persistence: 5000 milliseconds (assuming you are taking readings more often than once every 5 seconds)
    • Returned Message Length: 40
    • Instrument Initialisation String: Leave blank.
       
    The "Request/Response – Background" sets the device to request data and respond while working in the background. Windmill will "timeout" if no response is received in 1 second. The data persistence is how long the data will remain active. This must be longer than the rate at which you plan to read data.
     
  5. Enter your communication settings. These should work but check they are the same as your interface is using.
    • Com port: Set this to the port to which you have attached the interface
    • Baud rate: 9600
    • Data bits: 8
    • Parity: None
    • Flow control: None
       
  6. You now need to define how to extract data. To do this press the Channels button. Each channel will have a specific task to request a specified piece of data from the interface. For each channel Windmill needs to send a command to request a reading, and extract that reading from the data string returned.
    • Make sure that "Read Channel" is checked. This tells Windmill that the channel will be collecting data.
    • Prompt String: enter the command needed to request a reading. For example, to request a vehicle speed reading from an ELM interface you would enter 010D\C013. 01 is the request for current data, 0D identifies you want the speed value and \C013 is a carriage return. (The 0D identifier is the PID or parameter identification number. See below for details of commands and PIDs.)
    • Reply Parse String: this is where you tell Windmill how to extract data from the response. In our vehicle speed example, the response would be in this format: 41 0D 37. We can ignore 41 0D as this just tells us that the speed value has been returned. The value we want is 37. So to extract 37 we could use ignore first 6 characters then extract next 2. (The value is in hexadecimal so for one byte readings will always be two characters. See below for details of how many bytes are returned for each reading.) In ConfIML this would look like \I06\E02.
    • Click OK and repeat for the other channels.
      Configuring the OBD device
  7. Save your settings and close ConfIML.

Run the Windmill SetupIML program

Here you can name your channel, set its units, enter a scale and offset, and so on.

  1. Select "Create new setup" and give it a name and a description.
  2. From the Device menu select LabIML.
  3. Your data channels will be shown as numbers like 10000, 10001, 10002. Double click a channel.
  4. Type name for your channel, eg Speed, and make sure Enable for Input is checked.
  5. Many OBD readings need a scale and offset to be applied to them. See the table below for details. You can do this in SetupIML. You can also use SetupIML's scale and offset to change the units of a reading.
  6. Save your settings in a *.ims file and close SetupIML.

Open Windmill DDE Panel

  1. From the File menu select Load Hardware Setup and choose the *.ims file you just saved.
  2. Connect your channels (eg Speed). You should see your data in DDE Panel.
  3. Proceed similarly for the Logger and Chart programs.

Getting the data into Excel

The data collected is in hexadecimal format which you need to convert to decimal. To do this you will need a spreadsheet like Excel. You can use the Windmill Logger program to collect data, and after collection has finished import it into Excel. Alternatively, you can collect data with Excel in real-time (detailed on our Excel page). Use Excel's HEX2DEC command to convert to decimal.


Application Story: Real-Time Fuel Consumption Monitoring

Download the Step-by-Step Guide.

Robert Kwiatkowski designed a real-time fuel consumption monitoring system for his truck. He connected his laptop to the On Board Diagnostics system of his Ford Expedition, used Windmill to collect data from the truck and Excel to calculate and display his current fuel consumption.

Most vehicles do not have a fuel flow sensor, therefore he used the Mass Air Flow (MAF) sensor and the Vehicle Speed Sensor (VSS) to calculate miles per gallon (MPG).
1. Mass Air Flow - The mass of Air in grams per second consumed.
2. Vehicle Speed Sensor - The actual speed of the vehicle.

Vehicles use the oxygen sensors to feedback data to the vehicle's electronic control module (ECM) and control the air to fuel ratio. This ratio is set at the chemically ideal value of 14.7 grams of air to every gram of gasoline. He could use the known values to convert the MAF to Gallons of fuel per hour (GPH) and then calculate miles per gallon (MPG).

Here are the steps to make the conversion:

  1. Divide the MAF by 14.7 to get grams of fuel per second
  2. Divide result by 454 to get Lbs fuel per second
  3. Divide result by 6.701 Gals fuel per second
  4. Multiply result by 3600 to get gallons per hour

The expression for GPH is: MAF * 0.0805
To calculate MPG divide the MPH by GPH.
The final expression for MPG will be: VSS * 7.718

Robert Kwiatkowski has produced a step-by-step guide to replicating his system which he has kindly made available here.


Understanding PIDs and the OBD Message Structure

PID stands for parameter identification number. It is a hexadecimal number. For most PIDs (including all listed below) the value returned is also a hexadecimal number. One hexadecimal number is contained in each byte returned. So for a 1-byte message 2 characters would be returned, for a 2-byte message 4 characters would be returned.

PID Description                  Number of bytes  Scale   Offset   Units
                                 returned
05  Engine Coolant Temperature   1 byte           1       -40      oC
0A  Fuel Pressure                1 byte           3                kPa
0B  Intake Manifold Pressure     1 byte           1                kPa
0C  Engine RPM                   2 bytes          0.25             rpm
0D  Vehicle speed                1 byte           1                km/h
0E  Timing advance               1 byte           0.5     -64      degrees  
0F  Intake air temperature       1 byte           1       -40      oC
10  MAF air flow rate            2 bytes          0.01             g/s
11  Throttle position            1 byte           0.3922           %
1F  Run time since engine start  2 bytes          1                s
23  Fuel Pressure (diesel)       1 byte           3                kPa
2F  Fuel Level Input             1 byte           0.3922           %
33  Barometric pressure	         1 byte           1                kPa
46  Ambient air temperature      1 byte           1       -40      oC

For a full list see an OBDII PID table.

Commands to Reqest Data: The Prompt String
The command to request data is made up of at least two components. The first specifies the mode of operation. There are nine modes of operation in the OBD standard, but for data logging you will generally use Mode 1: Show Current Data. The next component is the PID of the data you want. If you wanted to request the current mass air flow rate you would use: 0110 (01 for Mode 1, 10 for the PID). Depending on you interface you may need to add an end-of-message character. With ELM interfaces you would add a carriage return.


Need More Information?

Try these pages.


Home | Windmill Programs | Monitor | On-Line Shop | Free Literature and Software Demos | Contents | Search

Copyright Windmill Software Ltd 2007
PO Box 58, North District Office, Manchester, M8 8QR, UK.
E-mail: sales@windmill.co.uk, Tel: +44 161 833 2782
http://www.windmill.co.uk/library.html
Data Acquisition News Feed (RSS) Free measurement news feed...
Designed by Studholme.net