What is the best way to get fuel consumption (MPG) using OBD2 parameters?
Asked Answered
R

4

14

What is the best way to get fuel consumption (MPG) using OBD2 parameters.

Below formula is simple but not most accurate, any other formula to get an accurate estimation. The value for vehicle speed is delivered in Km/Hr, to convert to miles multiply by 0.621317. To calculate MPG divide the MPH by GPH. The final math expression for MPG will be:

For Gasoline Engine

MPG =VSS * 7.718/MAF

I would like to know for Diesel Engine to calculate instant consumption. Also I am trying to calculate it independent of car model from parameter available from obd2 standard.


Some links which might be useful for those who are looking into same topic.

Rattlesnake answered 18/6, 2013 at 13:48 Comment(3)
So you solve your problem? I'm in your same problem now and i calculate my consumption with GPS for take distance percurred and the change of the tank lvl in %... Which pids you use for your formula?Makell
Hi, how you calculate it finally?Makell
@Dario, Its not always possible to calculate fuel consumption from ODB information. As vendors provide different/no information.Rattlesnake
H
10

That's the formula for instant consumption.

If you want to work out average consumption, work out the total volume of fuel used over time and divide by the total distance traveled over the same period.

UPDATE: That is what the ratio SHOULD be. unless you want to melt pistons or lose power. The air/fuel ratio isn't supposed to change unless you change the type of fuel, e.g. to 102 octane Petrol or Ethanol. That calculation is probably the most accurate you'll get unless you want to make it horribly complex by

  1. including the readings from all six O2 sensors to verify optimal combustion took place,
  2. factoring in engine temperature (cooler engines allow better combustion because it allows denser oxygen into the intake manifold),
  3. whether or not timing advance is set properly or not (which you'll have to check against a datasheet).
  4. and whatever else I left out.

Mind you, on the off-chance you're working on a Toyota: Toyota has an extra sensor that actually measures how much fuel is being injected into the engine. So you can just read that PID. But for other cars, the given formula is the standard.

UPDATE 2: some common Air/Fuel Ratios:

  1. Natural gas: 17.2
  2. Gasoline: 14.7
  3. Propane: 15.5
  4. Ethanol: 9
  5. Methanol: 6.4
  6. Hydrogen: 34
  7. Diesel: 14.6

You'll also need to consider that when the engine is under high loads, the Air/Fuel ratio changes downward.

Hoag answered 21/6, 2013 at 10:15 Comment(7)
thanks for reply,yes i am looking for instant fuel consumption but above formula assumes air to fuel ration 14.7 and density of fuel,i am looking for is there anyother better estimation.Rattlesnake
@Nadosh could you share your calculations for each type of fuel ? By the way for is the definition of Natural gas by OBD standard ? I see all but no natural gas.Dutcher
@RustemK Hi Rustem, i had updated links based on which i tried calculating fuel consumption. But i didn't evaluate it with ground truth. And also these calculation are approximations. Only determining fuel consumption from OBD2 port is difficult. Many parameters are manufacture,model specific and differ.Rattlesnake
Do you know the special Toyota PID? I'm working on something for a Lexus and that would really help.Mafia
The PID to read fuel consumption rate is 01 5E. Note that not all cars replies to this command. You can also check the entire OBD-II PIDs table.Stratocumulus
can you post the scientific article that say what you write?Makell
The information is freely available on the internet.Hoag
C
2

If you can read injector pulsewidth and divide by speed you can get the instant consumption. If you have the total fuel used and a distance, you can get the average. Getting injector pulsewidth is the direct way to get fuel consumption. It is the actual amount of fuel injected (well, it's the time the injector is open, but calculating how much is injected is easy at that point).

Canzone answered 5/9, 2013 at 20:48 Comment(3)
i am trying to calculate instant consumption.Also i am trying to calculate it independent of car model from parameter available from obd2 standard.Rattlesnake
@Nick, How is the amount of fuel injected calculated from injector PW? You would need to know the fuel pressure, the injector pintle size and the battery voltage (higher battery voltage = faster opening time = more fuel injected). Battery voltage you can get from OBD, but what about the rest? How would you do this?Harville
First, commanded PW will already take all of those factors in to account. You would just need to know the injector size and fuel pressure. Even if not, you can get a good estimate by assuming constant battery voltage, fuel pressure, etc. As 99% of gasoline cars are using a pressure regulator to maintain constant pressure differential and battery voltage will likely be around 14.0 volts. It'd be something like this: jsfiddle.net/38db1qye/8 although I appear to have something way off.Canzone
A
2

There is an OBDII command (01 5E) that will give you fuel consumption rate per hour. I have it working with C#/Xamarin client, not sure about Java?

If that is not available then you can use the VSS and MAF values to calculate l/100km: (3600 * MAF)/(9069.90 * VSS). MPG will need further adjustment, but that's simple enough.

Additionally to make the speed value universal, implement speed as a class and expose imperial and metric properties, like so (C#):

public Class VehicleSpeed 
{
public int MetricSpeed
{
    get
    {
        return metricSpeed;
    }
}

/// <summary>
/// <para>getImperialSpeed.</para>
/// </summary>
/// <returns> the speed in imperial units. </returns>
public float ImperialSpeed
{
    get
    {
        return ImperialUnit;
    }
}

/// <summary>
/// Convert from km/h to mph
/// </summary>
/// <returns> a float. </returns>
public float ImperialUnit
{
    get
    {
        return metricSpeed * 0.621371192F;
    }
}

If you want to calculate this value over time why not just store each immediate calculation and then get average?

Hope it helps.

Alvaroalveolar answered 15/1, 2017 at 1:57 Comment(1)
Not all car models can reply to that command. For some cars, that command is unavailable. Also, AT commands are independent of the client you are using (doesnt matter if it's C# or Java, the OBD will reply in the same way.Solo
R
0

More detailed derivation of specific fuel consumption (speed over fuel flow):

SFC equation

Then, assuming a fuel density of 0.75kg/l:

enter image description here

Revoice answered 17/3, 2019 at 21:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.