# Calculating MPG from VSS and MAF from OBD2

Show 40 post(s) from this thread on one page
Page 13 of 13 First ... 345678910111213
• 01-03-2013, 04:09 PM
Quote:

Originally Posted by lude-de
I've worked on this for two days now, and I've gotten to the point that I'm going to post my questions.

My situation is unusual. I am working with the ODB1 Honda ECU that is chipped and has a data port installed. From this I can poll for information that the ECU is using to manage the engine.

I am getting IAT in Fahrenheit , MAP in PSI, RPM and VSS in MPH.

Here's an example of the numbers

IAT = 88.39
MAP = -16.97
RPM = 3094
VSS = 60.89

IAT F to K = 304.3
MAP PSI to kPa = -117.06
RPM = 3094
VSS = 60.89

I plug that into the first formula to get IMAP:

IMAP = RPM * MAP / IAT
1190.218994413408 = 3094 * -117.06 / 304.3

Then I plug that into the MAF formula:
MAF = (IMAP/120)*(VE/100)*(ED)*(MM)/(R)
MAF = (1190.218994413408/120)*(80/100)*(2.056)*(28.97)/8.314
MAF = 9.918491620111732 * .8 * 2.056 * 28.97 / 8.314
MAF = 56.84564559003256

Then I plug that into the MPG formula with adjustments because I'm in MPH and not KPH:
MPG = (14.7 * 6.17 * 454 * VSS) / (3600 * MAF / 100)
MPG = (14.7 * 6.17 * 454 * 60.89) / (3600 * 56.84564559003256 / 100)
MPG = 2507288.59794 / 2046.443241241172
MPG = 1225.19332440382

Now, as much as I'd like this to be true... it sadly isn't. I'm getting around 30 - 31.5 MPG on a tank of gas. I've checked my conversions several times and I'm sure they are correct.

Can someone please put a second set of eyes on these equations to help me figure out what's wrong here. Unfortunately, I don't have an ODBII car to compare numbers with.

Try #2 for posting...don't know where the first reply went...Here's the short version...

#1 - MAP value figured wrong. You're reading manifold vacuum, not manifold pressure. Subtract your reading from ambient baro pressure (use 29.92 for starters) and work with that instead.

#2 - F to K is off slightly.

#3 - There's an extra /100 in the final solution.

When I do the calculation the right way, I get about 31-ish MPG.
• 02-25-2014, 10:29 AM
lightner
On-Line Gasoline MPG Calculator (Using MAF and/or MAP/IAT/RPM)
For those that want to calculate MPG using MAF (and/or MAP/IAT/RPM) for gasoline vehicles I've put together a Webpage with a Javascript-based air/fuel flow calculator...

http://www.lightner.net/obd2guru/IMAP_AFcalc.html

You may find this useful for "checking your work".

As many of you have discovered---based on comments here and email that I regularly receive---getting all the units and calculations exactly right can be hard. And, in an embedded system without floating-point support, avoiding integer overflow errors can proved difficult.

Best regards,

Bruce D. Lightner
[email protected]
http://www.lightner.net/lightner/bruce/
• 05-22-2015, 03:00 PM
lightner
Usiing LOAD_ABS (OBD-II Mode 1 PID 0x43) to Estimate Vehicle MPG
:ohwell:
Quote:

Originally Posted by lightner
There seems to be at least two different interpretations of the OBD-II parameter called "engine load" (i.e., LOAD, in the range of 0-100%), as reported over the OBD-II bus by modern engine computers. One version gives a LOAD value with is directly proportional to MAF (i.e., mass air flow). The other version seems to show that MAF is proportional to (LOAD x RPM).

So, if you want to solve for MAF using LOAD, first you need to determine which LOAD algorithm is being used by the vehicle in question, then you need to determine the appropriate constant scaling factor to derive MAF. Of course in one case you need to read RPM along with LOAD.

Given a calculated MAF, plus a periodic VSS (i.e., vehicle speed) reading, integrating these gets you incremental fuel consumed and distance traveled. Divide one by the other and you get MPG.

As I have noted before, using MAF to derive a fuel flow measured in gallons assumes a constant air-fuel (A/F) ratio and a fixed, known fuel density. Given that modern fuel injected engines are designed to run with a fixed, "stoichiometrically ideal" air fuel ratio of 14.7:1 almost all the time, using a constant A/F ratio for the MPG calculation makes good sense.

SAE J1979 defines a new OBD-II parameter, LOAD_ABS (i.e., Mode 1 PID 0x43) which is the normalized value of air mass per intake stroke displayed as a percent. This value is directly proportional to air flow rate which, as we know, is directly proportional to fuel flow (almost 100% of the time). Therefore integrating this percentage and then multiplying it by a constant---which will be unique for a given vehicle make/model/engine, will provide a good estimate of fuel consumed. With that and distance traveled---derived from integrating vehicle speed readings---we can calculate fuel consumption in miles per gallon (MPG). Q.E.D. :)

The absolute load value has some different characteristics than the LOAD_PCT defined in Mode 1 PID 0x04. Vehicles which utilize spark or compression ignition engines for propulsion shall use the following definition for calculating LOAD_ABS:

LOAD_ABS = [air mass (g / intake stroke)] / 1.184 (g / litre) * cylinder displacement (litres / intake stroke)]

Derivation:

- air mass (g / intake stroke) = [total engine air mass (g/sec)] / [rpm (revs/min)* (1 min / 60 sec) * (1/2 # of cylinders (intake strokes / rev)],
- LOAD_ABS = [air mass (g)/intake stroke] / [maximum air mass (g)/intake stroke at WOT@STP at 100% volumetric efficiency] * 100%.

where:

- STP = Standard Temperature and Pressure = 25 oC, 29.92 in Hg (101.3 kPa) BARO
- WOT = wide open throttle.

The quantity (maximum air mass (g)/intake stroke at WOT@STP at 100% volumetric efficiency) is a constant for a given cylinder swept volume. The constant is 1.184 (g/litre) * cylinder displacement (litres/intake stroke) based on air density at STP.

- Ranges from 0% to approximately 95% for naturally aspirated engines, 0% to 400% for boosted engines,
- Linearly correlated with engine indicated and brake torque,
- Often used to schedule spark and EGR rates,
- Peak value of LOAD_ABS correlates with volumetric efficiency at WOT.,
- Indicates the pumping efficiency of the engine for diagnostic purposes.

NOTE At engine off and ignition on the LOAD_ABS = 0 %.

All vehicles with spark ignition engines used for propulsion are required to support PID 0x43.

See Mode 1 PID 0x04 for an additional definition of engine LOAD.
• 06-22-2015, 06:55 AM
washburn_it
Hi to all,

first of all I'm new with "OBD-stuff" so I apologize for my beginner questions.
I'm an electronic enthusiast and a software developer and I'm trying to develop a "trip computer" (with a Raspberry PI) for my car that is not equipped with it.
My car is a Renault Kangoo 1.5 DCI (turbocharged diesel, 82 hp) equipped with an OBDII port and through one of the various OBD scanner (USB) I'm able to read PIDs from the ECU but, unfortunately, the engine is not equipped with a MAF meter.
Then using the published formulas I'm trying to calculate the instant consumption (in km/liter) but, after some conversion (I use km/h for the speed and grams/liter for the petrol density), I'm obtaining strange values (surely it's my fault somewhere but I can't figure it out !)
The following are some values extracted from a file where I wrote all the PIDs values during a run with the car (a sort of "log" file):

Engine Displacement= 1461 cc (or 1.461 liters)
RPM=3339
IAT=83 °C (356.15 K degree)
MAP=199 kPa (the value used in the formula is the MAP subtracted 101.3 as stated in a post above)
VSS=49 km/h
VE= 1.64 (I derived it from a graph that I found on the net)

then

IMAP= (3339*97.7)/356.15/2= 457.98
MAF= (457.98/60)*1.64*1.461*28.97/8.314= 63.73
KPL= (14.5*830*49)/(3600*63.73)= 2.57 km/l

where "830" is the (average) density of petrol in grams/liter (my car is diesel).
As you can see the KPL value is a bit worrying, if my car were a Ferrari maybe I could consider that value valid (actually it would be too much also for a Ferrari at 49 km/h).
The average consumption of my car (calculated by tank fill and distance) is about 19 km/l.
So where is the mistake?
Thank you, regards.

Roberto
• 06-22-2015, 07:18 AM
washburn_it
Hi to All,

I'm trying to develop a trip computer for my car (it's not equipped with it) using a Raspberry PI and an OBD scanner.
I was able to read all the available PIDs but unfortunately my car is not equipped with a MAF meter (it's Renault Kangoo 1.5 DCI 82 hp, turbocharged diesel).
So I've used the published formulas to calculate the MAF and then the instant consumption (that is what I'm interested to) but values that I'm obtaining are strange (surely it's my fault somewhere but I can't figure it out!).
I developed a little program to register all the PIDs values in realtime saving the read values into a file.
Then I considered a group of values and tried to calculate the consumption (in km/l):

Engine Displacement= 1461 cc (or 1.461 in liters)
RPM=3339
VSS=49 km/h
IAT=83 °C (thus 356.15 K degrees)
MAP=199 kPa (then as staded in a previous post I subtracted 101.3)==> 97.7 kPa
VE= 1.64 (derived from a graph that I found on the net)

then

IMAP= (3339*97.7)/356.15/2= 457.98
MAF= (457.98/60)*1.64*1.461*28.97/8.314= 63.73
KPL= (14.5*830*49)/(3600*63.73)= 2.57 km/l (where "830" is the average petrol density in grams/liter)

as you can see according with the above result my car should be a Ferrari (actually that consumption would be too much also for a Ferrari I think) !
The calculated average consumption (using the "tank fill and distance" method) is around at 19 km/l.
Where's the mistake?
Thank you, regards.

Roberto
• 07-25-2015, 01:54 AM
hittheskids
Quote:

Originally Posted by lightner
:ohwell:

SAE J1979 defines a new OBD-II parameter, LOAD_ABS (i.e., Mode 1 PID 0x43) which is the normalized value of air mass per intake stroke displayed as a percent. This value is directly proportional to air flow rate which, as we know, is directly proportional to fuel flow (almost 100% of the time). Therefore integrating this percentage and then multiplying it by a constant---which will be unique for a given vehicle make/model/engine, will provide a good estimate of fuel consumed. With that and distance traveled---derived from integrating vehicle speed readings---we can calculate fuel consumption in miles per gallon (MPG). Q.E.D. :)

I found this thread several months ago because I needed to write some code to track fuel consumption and fuel economy, and with hints from this thread, I was able to write an unexpectedly accurate MAF-based approach. ~120 gallons and ~4000 miles later, my code is only off by about -4.5% compared to manual hand calculations over the same period.

But today I was surprised to find a 2011 Ford that doesn't have a MAF sensor. So I revisited this thread to get some suggestions for calculating fuel consumption/economy using the MAP sensor. I had worked through the the math involved, but I wasn't excited about having to 'calibrate' over a tank of gas to figure out the volumetric efficiency because I just don't think my users will be willing to put in the effort to do this.

But this most recent post about absolute load sounds very promising. I think I've worked out the general math, but I'm a little uncertain about the 1.184g/liter density of air constant. It sounds like 1.184g/liter for the density of air is built into the definition of the ABS_LOAD parameter, so if I'm at altitude where the atmospheric pressure is lower, is it fair to say that my engine will simply report a lower ABS_LOAD to account for the fact that the air is less dense at altitude and my engine will not be able to fit as much air mass into the cylinders? I don't actually need to correct for atmospheric pressure in this calculation, right?
Show 40 post(s) from this thread on one page
Page 13 of 13 First ... 345678910111213