EcoModder.com

EcoModder.com (https://ecomodder.com/forum/)
-   Instrumentation (https://ecomodder.com/forum/instrumentation.html)
-   -   ElmScan + Customized Scantool Software = data logging! (https://ecomodder.com/forum/showthread.php/elmscan-customized-scantool-software-data-logging-1781.html)

cfg83 04-09-2008 03:01 AM

ElmScan + Customized Scantool Software = data logging!
 
1 Attachment(s)
Hello -

Last year I got one of these gizmos that interfaces the OBD-II to a PC :

ElmScan VPW Scan Tool - P/N: 420300
EDIT: URL BELOW IS DEAD LINK BECAUSE PRODUCT NO LONGER OFFERED
http://www.scantool.net/products/pro...products_id=12
http://ecomodder.com/forum/attachmen...1&d=1233886788
Quote:

The ElmScan VPW Scan Tool comes mounted in a steel enclosure and can be used with our free software to turn your computer into a sophisticated auto diagnostic system. This interface supports the J1850 VPW protocol used mostly in General Motors vehicles.
Now, it took me a (long) time to get it working right. My Laptop PC (probably) had too many apps running, so the Elmscan was having connection problems. Here is what I did :

1 - Bided my time and found an obsolete 2.5" 4GB hard disk for $10. This way, if I crash the disk proving the system, I don't care because the hard disk is worthless anyway. I have an easy-to-swap hard disk, so I can pop the "base OS" hard disk in, go to work, and swap my "regular OS" back in when I am done.

2 - Installed a base XP OS on the 4GB hard disk in my laptop. That way, there is no contention for the COM1 port.

3 - Downloaded the "scantool v1.13" software that comes with it. Since it comes with source code, I could customize it after ...

4 - ... I downloaded the "allegro" game programming library for Windows/XP :

Allegro - Download - Latest version (download all422.zip)

5 - Used my trusty Visual C++ version 6.0 to compile Allego. I procastinated doing this because I expected it to be a PITA. In fact it was easier than I thought. This is the power of gamer-programmers. They are edge and MAKE IT WORK! Pssst: But, you don't need to compile it. There are also pre-compiled binaries at the URL in Step 4. Stooopeed me did it the hard way.

6 - Once I had the library, I made a Visual C++ 6.0 project for the scantool software and customized it for my SW2 :

Still working on the color pallete, :o :
http://img166.imageshack.us/img166/7...overhs3.th.jpg


These are the only variables that are available for my Saturn :
http://img528.imageshack.us/img528/1...nsw2so8.th.jpg


4 - But the really big thing is that I got it to log data. I am logging in 1 second increments. I post-processed this to be one minute increments in this example result :

Code:

YYYMMDD,HHMMSS,Absolute Throttle Position (%):,Engine RPM:,Vehicle Speed (MPH):,Calculated Load Value (%):,Timing Advance (Cyl. #1) (?):,Intake Manifold Pressure (inHg):,Short Term Fuel Trim (Bank 1) (%):,Long Term Fuel Trim (Bank 1) (%):,Intake Air Temperature (? F):,Coolant Temperature (? F):,O2 Sensor 1/Bank 1 (V):,O2 Sensor 2/Bank 1 (V):
20080407,201137,13.367,2021.100,52.533,46.817,35.150,17.542,1.088,-7.000,71.900,170.133,0.518,0.721,
20080407,201242,8.130,1952.400,54.867,30.302,37.975,11.647,-0.082,-7.367,74.783,186.950,0.537,0.621,
20080407,201348,13.787,1964.333,55.350,48.922,36.117,19.197,0.623,-7.000,80.067,190.000,0.590,0.710,
20080407,201455,11.310,1886.717,53.233,39.983,39.208,15.507,1.322,-5.495,87.533,190.000,0.481,0.732,
20080407,201601,16.863,1900.667,53.817,53.895,27.317,21.542,-1.065,-2.300,95.667,190.000,0.389,0.638,
20080407,201709,13.510,1953.183,55.133,45.238,37.333,17.980,-0.237,-2.300,103.133,190.000,0.471,0.669,
20080407,201814,8.403,1908.133,53.733,29.813,41.208,12.020,-1.097,-3.200,105.000,190.000,0.354,0.671,
20080407,201919,8.272,1777.917,50.000,31.502,35.792,12.173,-0.502,-4.167,105.000,190.000,0.346,0.718,
20080407,202023,10.620,1863.317,52.800,38.110,39.350,14.567,0.650,-2.300,105.000,190.000,0.283,0.574,
20080407,202128,7.085,1562.167,52.383,35.080,30.592,14.065,2.123,-5.700,106.533,190.500,0.517,0.616,
20080407,202234,11.227,1724.267,49.000,42.093,32.433,15.575,0.395,-5.617,105.367,190.133,0.452,0.541,
20080407,202339,8.697,1782.100,50.017,36.640,35.825,14.210,1.973,-2.640,107.000,190.000,0.461,0.551,
20080407,202446,9.245,1394.267,44.483,41.762,25.108,16.237,0.217,-6.210,106.833,191.033,0.502,0.572,
20080407,202549,10.242,1607.800,50.583,41.063,30.183,16.167,2.068,-5.530,105.567,190.500,0.352,0.396,
20080407,202653,7.198,1347.733,42.583,33.838,23.225,13.590,0.687,-7.867,106.267,191.833,0.483,0.436,
20080407,202758,8.723,1548.133,43.383,39.198,30.417,15.017,-0.398,-5.953,109.467,190.133,0.606,0.500,
20080407,202901,10.207,1615.150,45.067,38.272,30.058,15.563,0.347,-3.800,111.000,190.000,0.407,0.405,
20080407,203003,10.637,1653.900,46.233,41.332,33.733,15.853,-0.970,-2.300,111.200,190.000,0.565,0.496,
20080407,203104,8.885,1590.700,44.533,38.265,33.633,15.340,0.365,-2.300,112.000,190.767,0.559,0.539,
20080407,203207,12.003,1580.317,48.100,42.422,23.208,16.358,0.420,-5.190,113.600,191.600,0.429,0.404,
20080407,203307,13.262,1574.500,48.517,44.165,23.692,17.822,0.033,-5.460,114.333,191.500,0.488,0.551,
20080407,203409,11.132,1537.083,48.250,42.305,24.108,17.785,1.690,-4.510,112.967,190.800,0.431,0.626,
20080407,203515,17.900,1854.267,52.183,55.985,24.950,23.225,-1.523,-2.300,112.800,192.000,0.459,0.630,
20080407,203622,16.592,1829.983,54.367,49.727,25.608,21.535,-0.722,-4.170,112.000,192.000,0.464,0.731,
20080407,203724,7.418,1364.150,41.400,34.622,22.500,15.088,1.102,-5.190,111.017,191.550,0.321,0.272,
20080407,203829,13.582,1543.383,46.683,46.947,21.217,19.203,-2.012,-6.230,111.533,192.083,0.474,0.498,
20080407,203934,8.992,1511.517,48.533,38.937,23.875,16.125,1.495,-7.893,111.733,192.000,0.522,0.300,
20080407,204037,6.512,1385.333,44.033,31.723,26.550,12.637,2.392,-6.220,110.500,190.667,0.499,0.524,
20080407,204148,4.633,1420.150,48.117,26.790,26.808,11.128,2.470,-8.820,108.467,190.867,0.561,0.520,
20080407,204253,5.087,1332.000,43.350,29.773,25.800,11.532,2.833,-9.665,105.033,190.333,0.484,0.562,

Using the original 1-second increment data, I used this to make a *simple* RPM vs MPH chart that shows my engine on coasting :

http://img528.imageshack.us/img528/8...hartcj1.th.jpg


My long term goals are :

1 - Testing only. The Scangauge is still my main man. At this point, I want to see the behavior of mods like my EFIE, the IAT resistor mod, and maybe some aero mods. I wanted this gizmo because I couldn't see the fuel trim or the 02 sensor with my ScanGauge I. Also, no data logging with the ScanGauge.

2 - Get a solid state hard disk. I can get a 2GB hard disk for $60 right now. If I run the 4GB until it crashes, the price will be lower by then.

3 - Define an algorithm that uses the data I am collecting to display real time MPG (Help Me Please :o !!!!!!).

CarloSW2

.

dcb 04-09-2008 08:17 AM

Quote:

Originally Posted by cfg83 (Post 18633)
...
3 - Define an algorithm that uses the data I am collecting to display real time MPG (Help Me Please :o !!!!!!).
CarloSW2

I've been chewing on that one a little too since my elm323 showed up. Here's all I've got so far:

PID 07 -> xx Long term fuel trim Bank 1 % x*(100.0/128)-100
PID 0b -> xx Intake Manifold Pressure kPaA x
PID 0c -> xx xx Engine RPM RPM x*0.25
PID 0d -> xx Vehicle Speed km/h x
PID 0f -> xx Intake Air Temperature C X-40


lastScanTime=now (milliseconds)
onScanEvent{
time=now-lastScanTime
lastScanTime=now
distance=speed(pid0d) * time
"airMoles"=some PV=NRT thing, http://en.wikipedia.org/wiki/Ideal_gas_law
* V=rpm(pid0c)*displacement*volumetric efficiency, P=pid0b, T=Pid0f
oxygen=airMoles* 20% ?
stiochfuel=oxygen/14.7
fuel=stoichfuel*fuelTrim(pid07)

litersPer100KM= fuel converted to liters/distance converted to km

MilesPerGallon= distance converted to miles/fuel converted to gallons

}

ref: http://prj.perquin.com/obdii/
ref: http://en.wikipedia.org/wiki/Ideal_gas_law

cfg83 04-09-2008 09:43 PM

dcb -

*Arf*, that's really hard. Time to do more homework.

CarloSW2

dcb 04-10-2008 09:08 AM

Sorry. Try out the opengauge freeduino signal processor then. Let us know if it works :)


(then teach it to read your cruise control switches on an analog port)

cfg83 04-10-2008 06:43 PM

dcb -

Quote:

Originally Posted by dcb (Post 18843)
Sorry. Try out the opengauge freeduino signal processor then. Let us know if it works :)


(then teach it to read your cruise control switches on an analog port)

That's ok. Actually, I see *some* of these calculations already in the scantool source code, so it is definitely speaking the same language. I guess that's another reason why the ScanGauge is so cool. I'll need to read your "opengauge development: gunio technical considerations" thread also.

CarloSW2

dcb 04-11-2008 12:52 AM

The guino isn't going to help too much with an obd mpg effort. The guino/opengauge efforts currently look directly at the injector and the speed sensor, and bypass all the obd business. It is much easier to record how long the injector has been open than it is to get mpg out of an obd port, excepting that you have to tap some wires.

cfg83 09-02-2008 09:57 PM

1 Attachment(s)
Hello -

I noticed this commercial program from Australia. It is designed to work with the ElmScan hardware. It also claims to be able to deduce instant-MPG from OBD II data, which is what I have been looking for :

OBD 2007 - Installation Guide
http://www.glmsoftware.com/Documenta...de20080822.pdf
Quote:

Fuel Analysis (Page 15 of PDF)

Even though there is no specific pid for fuel consumption in the OBDII specification, fuel consumption can be calculated, if a vehicle supports Pid 0x0D Vehicle Speed and Pid 0x10 Mass Air Flow. All vehicles support vehicle speed and nearly all vehicles support MAF.

MAF, the mass of air moving into the engine is measured in grams per second. A petrol/gasoline engine burns the air/fuel mixture at the stoichiometric air fuel ratio of 14.64:1. The oxygen sensors in a modern vehicle are designed in conjunction with both the short and long term fuel trims to maintain this ratio. Under ideal conditions for every 14.64 grams of air an engine will consume 1 gram of petrol. We can therefore calculate FuelFlowGramsPersSec = MAF/Air Fuel ratio. We can convert the previous figure to FuelFlowLitresPerSecond by dividing FuelFlowGramsPerSec by the density of petrol/gasoline.

We can then readily convert that figure to FuelFlowLitresPerHour -- i.e. litres/hour. Fuel consumption is then simply SpeedKmsPerHour/FuelFlowLitresPerHours -- i.e. litres/kms. All the remaining figures on the OBD 2007 Fuel Analysis tab are returned by simple conversion factors -- for Metric, Imperial (US) and Imperial (UK) units.

Late model vehicles which use Oxygen sensors known as wide range linear Oxygen sensors, can also introduce another Pid 0x44, Commanded Equivalence Ratio. This pid allows fine adjustment of air fuel ratio from the constant 14.64 by modifying the air fuel ratio by a value between 0 and 1.999 which permits air fuel ratios to be measured to greater precision. If a vehicle supports Pid 0x44, OBD 2007 fuel consumption figure is modified by the effect of Commanded Equivalence Ratio.

To assist in understanding what is going on under various driving conditions, the OBD 2007 Fuel Analysis tab also includes gauges for Short and Long Term Fuel Trims. Ideally the short term fuel trims are trying to maintain the long term fuel trims at around 0%. A negative figure is an indication of leanness and a positive figure is an indication of richness.

The final components of OBD 2007’s Fuel Analysis tab are two LEDs to indicate the state of Pid 0x03, Fuel Status. The LEDs can display 5 different colours to indicate the various states of Fuel Status.

Gray -- Unused.

Red -- System is running Open loop -- has not yet satisfied conditions to go Closed loop.

Green -- System is running Closed loop -- using O2 sensors as feedback for fuel control.

Amber -- Open loop due to driving conditions -- either enrichment or enleanment.

Orange/Gray -- Fault detected.

Because the gauge is an instantaneous fuel consumption gauge, it is quite normal for the gauge to swing wildly whenever the vehicle is accelerated quickly (high fuel consumption) or decelerated quickly (low fuel consumption). You may even notice on the digital fuel consumption gauges a reading of -Err-. This doesn’t actually signify an error, but is an indication that the fuel consumption figure is greater than what the gauge can display. E.g. if the fuel consumption is greater or equal to 100mpg, that figure cannot be displayed because there is only room for two significant digits.

When the vehicle is stationary with the engine idling, fuel consumption is zero. However the fuel rates of the right hand digital gauges will show their respective fuel flow rates. The following window below displays a typical fuel consumption window.

Please note like the Dashboard tab the Fuel consumption tab is optimised for viewing in full screen mode.

Picture of "Fuel Analysis" Gauge :
Attachment 1659

Question: What do you think? Does the equation they are using look valid to you?

CarloSW2

tasdrouille 09-02-2008 10:12 PM

Using only the MAF data is an approximation of fuel economy assuming the car's always running at stoich. That's probably what the SGII does.

However, for vehicles with broad band sensors, their program supports adjustments from the equivalence ratio which should make reported fuel consumption more precise.

ChrstphrR 09-05-2008 02:55 AM

Thank you for the thread here... I think I have an idea now why my Scanguage isn't calibrating well: My MAF is failing, and thus, it's not reporting accurately, throwing the SG's tracking off.

On the A4 (or MkIV) TDI engines, the MAF sensor is notorious for failing out. I know from the slight lack of power, that mine is failing out again. So, time to sleep, so I can book more hours at work, and buy a new MAF for my car :P

cfg83 10-09-2008 07:19 PM

Hello -

(apologies in advance for some of my "custom" acronyms. I am "programming" the variable names in the post)

I am trying to determine an approximate Instant MPG calculation for my scantool software. All of the following is based on this OBD 2007 documentation blurb :

OBD 2007 - Installation Guide
http://www.glmsoftware.com/Documenta...de20080822.pdf - Page 15 of PDF
Quote:

fuel consumption can be calculated, if a vehicle supports Pid 0x0D Vehicle Speed and Pid 0x10 Mass Air Flow. All vehicles support vehicle speed and nearly all vehicles support MAF.

MAF, the mass of air moving into the engine is measured in grams per second. A petrol/gasoline engine burns the air/fuel mixture at the stoichiometric air fuel ratio of 14.64:1. The oxygen sensors in a modern vehicle are designed in conjunction with both the short and long term fuel trims to maintain this ratio. Under ideal conditions for every 14.64 grams of air an engine will consume 1 gram of petrol. We can therefore calculate FuelFlowGramsPersSec = MAF/Air Fuel ratio. We can convert the previous figure to FuelFlowLitresPerSecond by dividing FuelFlowGramsPerSec by the density of petrol/gasoline.

We can then readily convert that figure to FuelFlowLitresPerHour -- i.e. litres/hour. Fuel consumption is then simply SpeedKmsPerHour/FuelFlowLitresPerHours -- i.e. litres/kms.

Here are my inputs :

- Intake Manifold Pressure (MAP) units: inHg
- Vehicle Speed units: MPH

Here are my constants/conversions :

- AFR = Air/Fuel Ratio = 14.64
Source: http://www.glmsoftware.com/Documenta...de20080822.pdf

- "DOG" = Density of Gas (g/cm3) = (0.71 +0.77) / 2 = 0.74
Source: Gasoline - Wikipedia, the free encyclopedia

- "M2K" = Convert Miles to Kilometers = 1.609344
Source: Convert miles to km - Conversion of Measurement Units

- "KML2MPG" = Convert KM/L to MPG = 2.35214583
Source: WikiAnswers - How many km to 1 litre of gas

- "SPH" = Seconds Per Hour = 3600

- "MPL" = Milliliters Per Liter = 1000

Steps to convert with example inputs from real OBD II data logging :

- Intake Manifold Pressure (inHg) = 17.542
- Vehicle Speed (MPH) = 52.533

1 - Convert MPH to KMH
=> MPH * M2K = 52.533 * 1.609344 = 84.54366835 KMH

2 - "FFG" = Calculate FuelFlowGrams/Sec
=> MAP / AFR = 17.542 / 14.64 = 1.198224044 FFG

3 - "FFL" = Calculate FuelFlowLitres/Second
=> (FFG / DOG) / MPL = (1.198224044 / 0.74) / 1000 = 0.001619222 FFL

4 - LPH = Calculate Liters Per Hour
=> FFL * SPH = 0.001619222 * 3600 = 5.829198051 LPH

5 - KML = Calculate KiloMeters / Liter
=> KMH / LPH = 84.54366835 / 5.829198051 = 14.50348189 KML

6 - Calculate MPG
=> KML * KML2MPG = 14.50348189 * 2.35214583 = 34.11430445 MPG

The MPG number looks "ballpark" correct to me, subject to programming and testing. The most iffy part to me is step 3, where I divide by 1000 to get the "FFL". I am doing this because in step 2, it is not clear that the FFG is in Liters.

Also, the OBD 2007 algorithm calls for a MAF sensor. In my S-Series Saturn, I *think* I have a MAP sensor. My question here is, what's the difference? Do I need to convert from MAP to MAF?

Based on the steps above, here is the output I get. This is based on the data logging from thread #1 :

Code:

,,INPUT,INPUT,STEP 1,STEP 2,STEP 3,STEP 4,STEP 5,STEP 6,
YYYMMDD,HHMMSS,MAP (inHg):,Speed (MPH):,Speed (KMH),FuelFlowGrams/Sec ,FuelFlowLitres/Second,Liters per hour (LPH),KMH/LPH,MPG
20080407,201137,17.542,52.533,84.54366835,1.198224044,0.001619222,5.829198051,14.50348189,34.11430445
20080407,201242,11.647,54.867,88.29987725,0.795560109,0.001075081,3.870292424,22.81478183,53.66369394,
20080407,201348,19.197,55.35,89.0771904,1.311270492,0.001771987,6.379153744,13.96379425,32.84488043,
20080407,201455,15.507,53.233,85.67020915,1.059221311,0.00143138,5.152968542,16.62540892,39.10538626,
20080407,201601,21.542,53.817,86.61006605,1.471448087,0.001988443,7.158396101,12.09908824,28.45881994,
20080407,201709,17.98,55.133,88.72796275,1.228142077,0.001659651,5.974745237,14.85050144,34.93054504,
20080407,201814,12.02,53.733,86.47488115,0.821038251,0.001109511,3.994240142,21.64989537,50.92371111,
20080407,201919,12.173,50,80.4672,0.831489071,0.001123634,4.045081967,19.89260061,46.79029757,
20080407,202023,14.567,52.8,84.9733632,0.995013661,0.001344613,4.840607,17.55427846,41.29022288,
20080407,202128,14.065,52.383,84.30226675,0.960724044,0.001298276,4.673792645,18.03722868,42.42619223
20080407,202234,15.575,49,78.857856,1.06386612,0.001437657,5.175564909,15.2365698,35.83863412
20080407,202339,14.21,50.017,80.49455885,0.970628415,0.00131166,4.721976074,17.04679515,40.09654813
20080407,202446,16.237,44.483,71.58844915,1.109084699,0.001498763,5.395547187,13.26806099,31.20841433
20080407,202549,16.167,50.583,81.40544755,1.104303279,0.001492302,5.372286221,15.15285005,35.64171307
20080407,202653,13.59,42.583,68.53069555,0.928278689,0.001254431,4.515950377,15.17525434,35.69441122
20080407,202758,15.017,43.383,69.81817075,1.025751366,0.00138615,4.990141781,13.99121985,32.90938943
20080407,202901,15.563,45.067,72.52830605,1.063046448,0.001436549,5.171577315,14.02440718,32.98745088
20080407,203003,15.853,46.233,74.40480115,1.082855191,0.001463318,5.267944174,14.12406789,33.22186739
20080407,203104,15.34,44.533,71.66891635,1.047814208,0.001415965,5.097474524,14.05969093,33.0704434
20080407,203207,16.358,48.1,77.4094464,1.117349727,0.001509932,5.435755428,14.24078906,33.49641259
20080407,203307,17.822,48.517,78.08054285,1.217349727,0.001645067,5.922241914,13.18428797,31.01136798
20080407,203409,17.785,48.25,77.650848,1.214822404,0.001641652,5.909946832,13.13900957,30.90486658
20080407,203515,23.225,52.183,83.98039795,1.586407104,0.002143793,7.717656181,10.88159358,25.59509496
20080407,203622,21.535,54.367,87.49520525,1.470969945,0.001987797,7.156070004,12.22671176,28.75900907
20080407,203724,15.088,41.4,66.6268416,1.030601093,0.001392704,5.013735047,13.28886369,31.25734531
20080407,203829,19.203,46.683,75.12900595,1.311680328,0.001772541,6.381147541,11.7735886,27.69319733
20080407,203934,16.125,48.533,78.10629235,1.101434426,0.001488425,5.358329641,14.57661204,34.28631722
20080407,204037,12.637,44.033,70.86424435,0.86318306,0.001166464,4.199268941,16.87537649,39.69334643
20080407,204148,11.128,48.117,77.43680525,0.76010929,0.001027175,3.697828977,20.94115378,49.25664754
20080407,204253,11.532,43.35,69.7650624,0.787704918,0.001064466,3.83207798,18.20554351,42.82209326
20080407,201137,17.542,52.533,84.54366835,1.198224044,0.001619222,5.829198051,14.50348189,34.11430445
20080407,201242,11.647,54.867,88.29987725,0.795560109,0.001075081,3.870292424,22.81478183,53.66369394
20080407,201348,19.197,55.35,89.0771904,1.311270492,0.001771987,6.379153744,13.96379425,32.84488043
20080407,201455,15.507,53.233,85.67020915,1.059221311,0.00143138,5.152968542,16.62540892,39.10538626
20080407,201601,21.542,53.817,86.61006605,1.471448087,0.001988443,7.158396101,12.09908824,28.45881994
20080407,201709,17.98,55.133,88.72796275,1.228142077,0.001659651,5.974745237,14.85050144,34.93054504
20080407,201814,12.02,53.733,86.47488115,0.821038251,0.001109511,3.994240142,21.64989537,50.92371111
20080407,201919,12.173,50,80.4672,0.831489071,0.001123634,4.045081967,19.89260061,46.79029757
20080407,202023,14.567,52.8,84.9733632,0.995013661,0.001344613,4.840607,17.55427846,41.29022288
20080407,202128,14.065,52.383,84.30226675,0.960724044,0.001298276,4.673792645,18.03722868,42.42619223
20080407,202234,15.575,49,78.857856,1.06386612,0.001437657,5.175564909,15.2365698,35.83863412
20080407,202339,14.21,50.017,80.49455885,0.970628415,0.00131166,4.721976074,17.04679515,40.09654813
20080407,202446,16.237,44.483,71.58844915,1.109084699,0.001498763,5.395547187,13.26806099,31.20841433
20080407,202549,16.167,50.583,81.40544755,1.104303279,0.001492302,5.372286221,15.15285005,35.64171307
20080407,202653,13.59,42.583,68.53069555,0.928278689,0.001254431,4.515950377,15.17525434,35.69441122
20080407,202758,15.017,43.383,69.81817075,1.025751366,0.00138615,4.990141781,13.99121985,32.90938943
20080407,202901,15.563,45.067,72.52830605,1.063046448,0.001436549,5.171577315,14.02440718,32.98745088
20080407,203003,15.853,46.233,74.40480115,1.082855191,0.001463318,5.267944174,14.12406789,33.22186739
20080407,203104,15.34,44.533,71.66891635,1.047814208,0.001415965,5.097474524,14.05969093,33.0704434
20080407,203207,16.358,48.1,77.4094464,1.117349727,0.001509932,5.435755428,14.24078906,33.49641259
20080407,203307,17.822,48.517,78.08054285,1.217349727,0.001645067,5.922241914,13.18428797,31.01136798
20080407,203409,17.785,48.25,77.650848,1.214822404,0.001641652,5.909946832,13.13900957,30.90486658
20080407,203515,23.225,52.183,83.98039795,1.586407104,0.002143793,7.717656181,10.88159358,25.59509496
20080407,203622,21.535,54.367,87.49520525,1.470969945,0.001987797,7.156070004,12.22671176,28.75900907
20080407,203724,15.088,41.4,66.6268416,1.030601093,0.001392704,5.013735047,13.28886369,31.25734531
20080407,203829,19.203,46.683,75.12900595,1.311680328,0.001772541,6.381147541,11.7735886,27.69319733
20080407,203934,16.125,48.533,78.10629235,1.101434426,0.001488425,5.358329641,14.57661204,34.28631722
20080407,204037,12.637,44.033,70.86424435,0.86318306,0.001166464,4.199268941,16.87537649,39.69334643
20080407,204148,11.128,48.117,77.43680525,0.76010929,0.001027175,3.697828977,20.94115378,49.25664754
20080407,204253,11.532,43.35,69.7650624,0.787704918,0.001064466,3.83207798,18.20554351,42.82209326

Pending programming and testing, do you think I am on the right track?

CarloSW2

lyd 10-10-2008 10:01 AM

I can't comment usefully on the above, but there seems to be a number of links to information and code in this thread on gassavers.org: OBDII CarPC MPG Calculator - GasSavers.org - Helping You Save at the Pump

lyd 10-10-2008 10:32 AM

DOH! I just noticed that thread is all about you! Sorry. ;-)

mtgeekman 10-10-2008 10:56 AM

Do you know if your version will work with the ELM327 1.3 chip? I just sent my scantool in for an update (was free aside from shipping) they threw in a new chip and upped the data rate to 38000bps.

I might get a chance to test is this weekend. though I think they released the 1.14 to be compatible with it, even that one didn't work.

also some thing I noticed in the OBD2007 pdf that was posted:

Quote:

Late model vehicles which use Oxygen sensors known as wide range linear Oxygen sensors, can also introduce another Pid 0x44, Commanded Equivalence Ratio. This pid allows fine adjustment of air fuel ratio from the constant 14.64 by modifying the air fuel ratio by a value between 0 and 1.999 which permits air fuel ratios to be measured to greater precision. If a vehicle supports Pid 0x44, OBD 2007 fuel consumption figure is modified by the effect of Commanded Equivalence Ratio.

cfg83 10-10-2008 02:30 PM

mtgeekman -

Quote:

Originally Posted by mtgeekman (Post 66426)
Do you know if your version will work with the ELM327 1.3 chip? I just sent my scantool in for an update (was free aside from shipping) they threw in a new chip and upped the data rate to 38000bps.

I might get a chance to test is this weekend. though I think they released the 1.14 to be compatible with it, even that one didn't work.

also some thing I noticed in the OBD2007 pdf that was posted:

I am 85% sure that mine is based on the 1.14 version. If you can't get that version to "talk" to your ELM327, you'd probably have the same problem with mine.

Originally, I had lots of problems making it work. I found out that I needed a "vanilla clean" XP OS install to make it work. It didn't work with my XP off the bat because it was encrusted with all sorts of "barnacle-programs" that interfered with the COM1 port connection. Here's an experiment to emulate a "vanilla clean" OS that might work for you :

1 - Assuming you have Windows XP
2 - Assuming you are using COM1 or COM# port connection.
3 - Assuming COM# ports work in Safe Mode.
4 - Boot into Safe Mode
5 - Run Scantool 1.14 and see if it works.

I am also assuming that the Alegro SW graphics package won't get too upset with Safe Mode.

I will also try this experiment this weekend if I have the time (messy weekend coming up to say the least).

EDIT: No comment on the wide range linear oxygen sensor because I am narrow band. This may be a BIG help to wide band owners. Good catch!!!

CarloSW2

cfg83 10-16-2008 11:44 AM

Convert MAP to MAF?
 
Hello -

(edited multiple times to get info correct)

I have a question. If you know the following about your car :

1 - Engine displacement in Liters. For example, my engine is 1.9 liters (1901 cc).

2 - Manifold Absolute Pressure (MAP) in inHg (inches Mercury). For example, the value that my engine returns in the OBD II protocol.

3 - Compression Ratio (Optional?) . For example, my car has a compression ratio of 9.5:1.

Question : Can you *calculate* the Manifold Absolute Flow (MAF) in grams per second?

Reason : I ask because I am trying to emulate the published OBD 2007 algorithm

Thank You,

CarloSW2

lyd 10-16-2008 04:57 PM

Do you have a link to that alg, Carlo? I was looking for it the other day and couldn't track it down.

cfg83 10-16-2008 05:39 PM

lyd -

The "alg"(orithm?) is from post #10 above :

OBD 2007 - Installation Guide
http://www.glmsoftware.com/Documenta...de20080822.pdf - Page 15 of PDF
Quote:

fuel consumption can be calculated, if a vehicle supports Pid 0x0D Vehicle Speed and Pid 0x10 Mass Air Flow. All vehicles support vehicle speed and nearly all vehicles support MAF.

MAF, the mass of air moving into the engine is measured in grams per second. A petrol/gasoline engine burns the air/fuel mixture at the stoichiometric air fuel ratio of 14.64:1. The oxygen sensors in a modern vehicle are designed in conjunction with both the short and long term fuel trims to maintain this ratio. Under ideal conditions for every 14.64 grams of air an engine will consume 1 gram of petrol. We can therefore calculate FuelFlowGramsPersSec = MAF/Air Fuel ratio. We can convert the previous figure to FuelFlowLitresPerSecond by dividing FuelFlowGramsPerSec by the density of petrol/gasoline.

We can then readily convert that figure to FuelFlowLitresPerHour -- i.e. litres/hour. Fuel consumption is then simply SpeedKmsPerHour/FuelFlowLitresPerHours -- i.e. litres/kms.

CarloSW2

lyd 10-16-2008 08:06 PM

Oooohh. Right, sorry. ;-) I misunderstood what you were referring to there.

cfg83 07-25-2010 05:00 PM

Hello -

I was toodling around the scantool website and looking at their "OBDWIZ" MPG feature. Look at it's configuration inputs :

ScanTool.net LLC - OBDwiz Automotive Diagnostic Software
http://ecomodder.com/forum/member-cf...fuel-setup.jpg

It looks like they have three "Fuel Calculation Method" algorithms. Is the "Volumetric Efficiency" of one's engine easy to find?

The above led me to some other interesting (to me) places :

METHOD FOR ON-LINE ADAPTATION OF ENGINE VOLUMETRIC EFFICIENCY USING A MASS AIR FLOW SENSOR - Patent application
Calculating MPG from VSS and MAF from OBD2 - Page 4 - MP3Car.com
http://www.mympgtracker.com/

CarloSW2

cfg83 08-08-2010 09:24 PM

Hello -

Ok, I now have a workable formula, thanks to post #9 :

Calculating MPG from VSS and MAF from OBD2 - MP3Car.com
Quote:

... For the record, the first "one-line" MPG formula above, taken from my Circuit Cellar article, is off by 100! The "4.54" should in fact be "454". The correct formula is:

MPG = (14.7 * 6.17 * 454 * VSS * 0.621371) / (3600 * MAF / 100)
MPG = 710.7 * VSS / MAF

Note that OBD-II VSS reading is in kilometers/hour and MAF reading is grams/sec times 100.

This formula works very well in a modern automobile because the engine computer spends almost 100% of its time managing the fuel-air-ratio to 14.7, which it can do very well because of the "closed loop" feedback from the O2 sensor(s).

In fact, the accuracy of this method has been proven in literally tens of thousands of gasoline-powered vehicles. Accuracy within a few percent is typical, often limited by the accuracy of the vehicle speed reading (i.e., VSS).

As for other ways of doing this, especially if you don't have a MAF sensor, by knowing the displacement of the engine, and after a simple "calibration" using fuel tank "fill-up" data to find the only unknown, namely the "volumetric efficiency" (VE) of the engine, MAF can be calculated from RPM, MAP and IAT. With VE, one can use the following formulas to calculate a synthetic "mass air-flow" (MAF) in grams per second, all without a MAF sensor, using the "Ideal Gas Law", as follows:

IMAP = RPM * MAP / IAT
MAF = (IMAP/120)*(VE/100)*(ED)*(MM)/(R)

where manifold absolute pressure (MAP) is in kPa, intake air temp (IAT) is in degrees Kelvin, R is 8.314 J/°K/mole and the average molecular mass of air (MM) is 28.97 g/mole. Note that, in the above formula, the volumetric efficiency of the (4-cycle!) engine is measured in percent and the engine displacement (ED) is in liters.

The VE of my 1999 7.4L Chevy Suburban is about 65%. Smaller, higher performance engines can have VE's of 85% or higher.

...

That led me to this code :

Code:

//
// For signalling when one of the critical input variables has been received from the ECU/PCM
//
typedef struct
{   
    // 32 bits
    int    mph:1;
    int    map:1;
    int    iat:1;
    int    rpm:1;
    int  _PADDING:28;
} accessbits32;

//
// MPGData is global data structure for calculating MPG
//
typedef struct
{
    union
    {
        int          accessbit32:32;
        accessbits32 accessed;
    };

    double speed_kmh;
    double speed_mph;
    double map_inHg;
    double map_kPa;
    double rpm;
    double iat_c;
    double mpg_instant;
    double fuel_instant;
    double miles_instant;
    int    mpg_count;
    double mpg_avg;
    double imap;
    double maf_gs;
    double total_miles_travelled;
    double total_fuel_consumed;
} MPGData;

MPGData m;

//
// Drivetrain specific variables that can be loaded from a file
//
typedef struct
{
    double ed;            // Engine Displacement
    double ve;            // Volumetric Efficiency
    double odo_correction; // odometer correction
} DriveTrain;

DriveTrain dt;

//
// calc_mpg_formula
//
int calc_mpg_formula()
{
    int ret;
    double iat_k;
    int kmh_zero;

    iat_k = m.iat_c + 273.15;
   
    if ( iat_k == 0.0)
        iat_k = ALMOST_ZERO;

    // IMAP =  RPM  * MAP:kPa    / IAT:K
    m.imap  = (m.rpm * m.map_kPa) / iat_k;

    // MAF = (IMAP/120)*(VE/100)*(ED)*(MM)/(R)
    // MAF  = ((  IMAP / 120  )*(VE:% /100)*(ED:liters)*(MM)  )/(R)
    m.maf_gs = (( m.imap / 120.0)*(dt.ve/100)*(dt.ed)    *(28.97))/(8.314);
   
    if ( m.maf_gs == 0.0)
        // then protect against divide by zero later on
        m.maf_gs = ALMOST_ZERO;
             
    // where manifold absolute pressure (MAP) is in kPa,
    // intake air temp (IAT) is in degrees Kelvin,
    // R is 8.314 J/°K/mole and
    // MM is the average molecular mass of air (MM) = 28.97 g/mole.
    // Note that, in the above formula, the volumetric
    // efficiency of the (4-cycle!) engine is measured in
    // percent and the engine displacement (ED) is in liters.
   
    if ( m.speed_kmh == 0.0)
    { // Not a good solution for 0 MPH, but lets give it a try
        m.speed_kmh = 0.161 / 1000.0;
        m.speed_mph = 0.10  / 1000.0;
        kmh_zero = 1;
    }
    else
    {
        kmh_zero = 0;
    }

    // miles travelled in 1 second
    m.miles_instant = m.speed_mph / 3600.0;
   
    if (( m.rpm < 100) && (kmh_zero == 1))
    { // then EOC
        m.mpg_instant = 9999.0;
        m.fuel_instant = 0.0;
    }
    else
    {
        // MPG - miles per gallon
        // 14.7 grams of air to 1 gram of gasoline - ideal air/fuel ratio
        // 6.17 pounds per gallon - density of gasoline
        // 454 grams per pound - conversion
        // VSS - vehicle speed in kilometers per hour
        // 0.621371 miles per hour/kilometers per hour - conversion
        // 3600 seconds per hour - conversion
        // MAF - mass air flow rate in 100 grams per second
        // 100 - to correct MAF to give grams per second => NOT NEEDED

        //MPG = (14.7*6.17*454*KPH*0.621371)/((3600*MAF)/100)
        //            => 710.7335739 * KPH          / MAF
        //            => 7.107335739 * KPH          / MAF_gs
        m.mpg_instant = (7.107335739 * m.speed_kmh) / m.maf_gs;

        // GPH / 3600 = GPSecond = ( MPH        / MPG          ) / 3600.0
        m.fuel_instant    = ( m.speed_mph / m.mpg_instant) / 3600.0;
    }

    m.mpg_count++;
    m.total_miles_travelled += m.miles_instant;
    m.total_fuel_consumed  += m.fuel_instant;

    if ( m.total_fuel_consumed != 0.0)
    {
        m.mpg_avg = m.total_miles_travelled / m.total_fuel_consumed;
    }
    else
    {
        m.mpg_avg = 0.0;
    }

    ret = m.accessbit32;
    m.accessbit32 = 0;
    return (ret);
} // END calc_mpg_formula()

There are lots of limitations to what I am calculating. I need to get IAT, MAP, MPH, and RPM in one second in order to be able to datalog. This sounds like plenty of time for a computer, but my standing theory is that the ECU/PCM communicates in it's own good time.

Also, I don't know the Volumetric Efficiency (VE) of my engine. This doesn't address the knowledge that VE changes under different loads.

However, I *am* datalogging MPG numbers that are very very very similar to what a Scangauge displays. This has always been my goal, to have a formula that can give me the same *relative* MPG changes as the ScanGauge.

Me Happy, :) .

CarloSW2


All times are GMT -4. The time now is 02:13 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Content Relevant URLs by vBSEO 3.5.2
All content copyright EcoModder.com