Some of you may have seen my previous thread about my CarPC, things are going well and I am ready to start working on the code to get MPG calculated out of the sensor data from my OBDII port.
HERE is a link to the other thread if you want to know what I am working with here.
The important part is the scanner, which is an ElmScan 322 from
www.scantools.net. This device is for my 2000 Saturn SL.
I have found a perl program that was last updated in 2003 which should do basic polling of data from the port (I don't really know what is going on, just guessing here). This program and source can be found
HERE I will also attach the zip in case the site goes down.
This program does not appear to pull any data involving injector pulses. I am going to try and hook up to my obdII port while running a program like Hyperterminal to see if I can tell what all data is coming out of it. I have not had much of a chance to mess with it yet but I am hoping to get some support on the programming side as this is quite new to me
.
Also, if you think I should start with a different program let me know. I could change.
Another I had considered was JDash, it is based on Java but the programmer said that his program did not do anything but look at realtime data so calculating values off of the data that came in was beyond it. Not sure if that is a limitation of Java or just his program or what. I am not knowledgeable enough to know.
Something cross platform would be great in case someone else here wanted to run something on a Windows machine and could put to use some of what we figure out here.
Here is a section of the code, this is what appears to be the extent of the data that this perl script is programmed to grab, this is from the .ini file:
Code:
# Enable PID = 1, Disable PID = 0
$PID01 = 1; # Number of trouble codes and test information
$PID03 = 1; # Fuel system status
$PID04 = 1; # Engine load %
$PID05 = 1; # Coolant temp
$PID06 = 1; # Short term fuel trim %, Bank 1
$PID07 = 1; # Long term fuel trim %, Bank 1
$PID08 = 1; # Short term fuel trim %, Bank 2
$PID09 = 1; # Long term fuel trim %, Bank 2
$PID0A = 1; # Fuel Pressure
$PID0B = 1; # Intake manifold pressure
$PID0C = 1; # Engine RPM
$PID0D = 1; # Vehicle speed
$PID0E = 1; # Timeing advance degrees
$PID0F = 1; # Intake air temp
$PID10 = 1; # MAF air flow
$PID11 = 1; # Absolute trottle position
$PID12 = 1; # Sec. air status
$PID14 = 1; # Oxygen sensor voltage, Bank1, sensor 1
$PID15 = 1; # Oxygen sensor voltage, Bank1, sensor 2
$PID16 = 1; # Oxygen sensor voltage, Bank1, sensor 3
$PID17 = 1; # Oxygen sensor voltage, Bank1, sensor 4
$PID18 = 1; # Oxygen sensor voltage, Bank2, sensor 1
$PID19 = 1; # Oxygen sensor voltage, Bank2, sensor 2
$PID1A = 1; # Oxygen sensor voltage, Bank2, sensor 3
$PID1B = 1; # Oxygen sensor voltage, Bank2, sensor 4
My main goal here is to get instant/trip/tank etc. MPG figures. Of course once instant and trip is figured out everything else should be just moving code around I would think. Of course a nice front end would be nice but something that showed up in a terminal window is just fine for now
.
Google findings
http://www.circuitcellar.com/avr2004/wabstracts
MPG = VS * 71.07 / MAF
where VS = vehicle speed in kph (mode 01 PID 0D)
and MAF = air flow rate (mode 01 PID 10)