Announcement

Collapse
No announcement yet.

Calculating MPG from VSS and MAF from OBD2

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Calculating MPG from VSS and MAF from OBD2

    Hi, I'd like to add instantaneous fuel efficiency (MPG - miles per gallon) to OBD Gauge for Palm. I've only been able to find a single mention of how to calculate this from an article at Circuit Cellar http://www.circuitcellar.com/adverti...ghtner-183.pdf .

    There, Bruce Lightner gives the formula:

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

    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
    4.54 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


    Is this what other software uses to calculate MPG? Are there other methods?

    I just got my OBD2 All-In-One yesterday, and have just started playing around with it and OBD Gauge. I'm going to try and add the above formula to OBD Gauge and see what it gives. I'd really appreciate any info. Thanks
    1998 Honda Civic LX
    In VERY early planning stages now
    ---------------------------------
    Awesome avatar from [email protected]

  • #2
    The software that came with the OBD reader I have, has some formulas for computing various things from the codes. One of which is instantaneous MPG, as follows:

    instantaneous Distance D = VSS * t/3600
    instantaneous Fuel F = 1 / (14.75 * 6.26) * MAF * t/60
    instantaneous MPG = D / F

    t is delta time.

    So other than the conversion constants being slightly different, I would say your formula looks good.
    *******************************
    *******************************

    Comment


    • #3
      so you can get accurate readings out of this?

      When I replace my current Dell Axim, I'm consdiering using it as a GPS/OBD tool.

      Comment


      • #4
        I haven't the slightest clue about how reliable this method is, that's what I hope to find out.

        Unfortunately, my 98 Civic does not have a MAF sensor! However, hopefuly there can be another way. Right now I'm looking at PID $04, Calculated Load Value (CLV), defined as:

        CLV = [current airflow] / [(peak airflow at [email protected] as a function of rpm) * (BARO/29.92) * SQRT(298/(AAT+273))]

        There's airflow! As for the other variables:
        peak airflow: dunno what this value is
        WOT = wide open throttle
        STP = standard temperature and pressure (25C, 29.92inHg)
        BARO = barometric pressure (maybe same as manifold air pressure MAP ?)
        AAT = ambient air temperature

        As you can see, the last two terms correct for temperature and pressure. If BARO happens to be from the MAP sensor, then we've got that. If AAT happens to be intake air temperature (IAT), then we've got that. Even if we don't have these values, the result won't be changed by a great deal.

        Peak airflow is trickier. The easy and completely inaccurate route to get peak airflow would be to just multiply the engine displacement by RPM (divided by 2, since it takes two revolutions in a 4-stroke engine). However this assumes 100% volumetric efficiency (VE), which is generally not the case. We'd need the map of VE to RPMs, which of course the ECU happily holds within its silicon.

        So we're missing a few crucial things. Perhaps we could at least get some value that's proportional to MPG. I'll try some things out.

        Anyone else here have any ideas?
        1998 Honda Civic LX
        In VERY early planning stages now
        ---------------------------------
        Awesome avatar from [email protected]

        Comment


        • #5
          Just saw this on Digg the other day...

          Fueling a Lifestyle

          In particular:

          Understanding the Engine

          Internal combustion engines are often called aspirated engines because they are "air-breathing" machines. These engines burn a combination of air and fuel mixed at the stoichiometric ratio 14.7 to 1.17 In the past, fuel and air were mixed in the carburetor, relying on the venturi effect of the pipework to render the fuel into an aerosol.18 Modern systems rely on fuel injection, a process governed by the car's engine computer unit (ECU).19 A variety of sensors feed into the ECU providing real-time information so the computer can manipulate engine performance for optimal emissions. The ECU can regulate fuel flow precisely to match air intake or even adjust the spark timing for various RPM and engine loads.

          A rough approximation of fuel use can be made through calculations on engine sensor data. Estimates on fuel consumption will be approximately equal to dividing the amount of airflow through the engine by 14.7, the stoichiometric ratio.20 Engine mass airflow may be determined either with an MAF (Mass Air Flow) sensor or through calculations on the MAP (Manifold Absolute Pressure) sensor.



          (in case the server goes down, the equations in the image are:

          Engine Mass Airflow = RPM * (Manifold Air Pressure / Absolute Temperature)

          Fuel Mass = Engine Mass Airflow / Stoichiometric Ratio
          )

          Varying Speed

          Using these equations, I can compare the fuel requirements for different driving speeds. To collect the necessary data, I configured the DigiMoto software to log data on the engine's RPM, intake temperature and manifold pressure. For the tests, I drove the Jeep at 45, 55, 65 and 75mph along the same stretch of Riverwatch Parkway. To ensure consistency, logging only took place after the appropriate speed was reached and locked into with cruise control.21 During the drive, the windows were left up for consistent aerodynamics and the air conditioning was left off to eliminate extra engine variables. The engine intake added approximately 13° of heat to the ambient air temperature resulting in 103° Fahrenheit (312.5° Kelvin).
          So there you have it. I also have a Honda Civic and was wondering how you would calculate instant MPG when you don't have an MAF sensor. From the equation above it looks like you use the RPM, MAP, and intake air temperatures instead. I haven't taken my laptop, OBD-II reader, and car out for a spin yet to test it out but it should give everyone a start...

          I'd recommend reading the entire article - it was very interesting. This guy did his research.

          Comment


          • #6
            This formula
            Fuel Mass = Engine Mass Airflow / Stoichiometric Ratio
            and also Bruce Lightner's formula, assumes a perfect stoichiometric combustion of typical gasoline.
            It will give reasonable values most of the time.
            The results may differ from the correct ones due to:
            1. Some (defective) engines may not have a perfectly Stoichiometric tuning.
            2. Some gasoline may have different octane grade and modern cars will automatically tune the mixture ratio.
            3. In the warm-up and during throttle change, the combustion is not stoichiometric.

            Problems 1. and 3. can be corrected if we have access to the Lambda factor, measured from the exhaust gas:

            Fuel Mass = Engine Mass Airflow / (Stoichiometric Ratio*Lambda)

            I still don’t know how to correct problem 2. Any ideas?

            A note on Diesel engines:
            A Diesel engine does not use stoichiometric combustion.
            So, a reasonable approach of the fuel mass can only be achieved with the Lambda correction and the value of 14.5 for the Stoichiometric Ratio.
            The density of Diesel fuel is 7.03 lbs/gal.

            JML

            Comment


            • #7
              There are 454 grams per pound, not 4.54.
              Watch out, I have a soldering iron and a ham radio license (it's worse, it's an extra class license too!) and am not afraid to use them!

              Comment


              • #8
                Originally posted by JML
                2. Some gasoline may have different octane grade and modern cars will automatically tune the mixture ratio.


                Fuel Mass = Engine Mass Airflow / (Stoichiometric Ratio*Lambda)



                JML
                The lambda sensors are used to compensate for the varying grades of gasoline (well, they compensate for everything and only look at the composition of the exhaust gases). I suspect your correction calculation would be close enough.
                Watch out, I have a soldering iron and a ham radio license (it's worse, it's an extra class license too!) and am not afraid to use them!

                Comment


                • #9
                  Let's Get the MPG Formula Right!

                  Originally posted by maeliosa View Post
                  Hi, I'd like to add instantaneous fuel efficiency (MPG - miles per gallon) to OBD Gauge for Palm. I've only been able to find a single mention of how to calculate this from an article at Circuit Cellar http://www.circuitcellar.com/adverti...ghtner-183.pdf .

                  There, Bruce Lightner gives the formula:

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

                  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
                  4.54 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


                  Is this what other software uses to calculate MPG? Are there other methods?

                  I just got my OBD2 All-In-One yesterday, and have just started playing around with it and OBD Gauge. I'm going to try and add the above formula to OBD Gauge and see what it gives. I'd really appreciate any info. Thanks
                  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.

                  Best regards,

                  Bruce D. Lightner
                  [email protected]
                  http://www.lightner.net/lightner/bruce/

                  Comment


                  • #10
                    I would suggest trying to use injector pulse width instead if it is available. Not all engines run at stoich all the time. For instance, some of the lean-burn Civics run closer to 17:1 when cruising. Also, when you floor it and your car goes into open loop, you may be running closer 12:1 to keep from popping your motor. Or before your car is warmed up in the winter, it is probably running open-loop. Wiring in a wide-band O2 sensor to accurately read the A/F ratio in realtime in conjunction with your MAF readings would be more accurate than just assuming you are running at stoich.
                    2006 Corolla S • Ex-Audio 7" • Epia MII • ATI AIW VE • 512MB • Mini-Box.com M300 Case • 100GB 2.5" HDD • Z-COM XI-325HP+ • Linksys WSB24/WRT54G w DD-WRT • Treo 755p BT Modem • Lite-On Slotload DVD • GPS • JVC AVX2 • 2x JL Audio 8" • Alpine Type-S F/R

                    Comment


                    • #11
                      I use LtFt in the equation from something I saw here a few years ago, but running a few old OBD2 logs shows Lightner's code works quite well and faster with only 2 PIDs. It's a little sensitive when my MAF reads < 0.10 once in a while, so filtering that out helps. I wouldn't display it directly though. Average it out over several seconds using a circular buffer. I actually use a 3 second and 5 minute average to show more realistic numbers. I've also decided stoplights are bad for our economy.

                      Comment


                      • #12
                        okay now how do you do it in a car without all those bells and whistles? (say a 63 Fairlane with a 221ci V-8 engine.)...some function of airflow to rpm?...

                        Comment


                        • #13
                          There are a number of senders that you can place inline. I don't have links handy, but the last time I went shopping for this, I found several options between $100-200 for kit built airplanes and marine applications. The aircraft ones are a little more expensive because they are designed not to be able to restrict fuel flow in the event of a failure. The one I spec'd sent a single pulse for every so many units of fuel that went through and cost about $180

                          I'd be going this route with my project if I hadn't found out about the OBD port. That only cost me $35 for the translator.

                          Good luck,
                          /z

                          Comment


                          • #14
                            actual fuel consumption

                            as many have posted already, the formulas given here are for stoichiometric fuel ratios. Unfortunately, modern cars don't run at stoichiometric fuel ratios. They run as lean as possible, just on the cusp of lean missing when cruising. They run rich anywhere from half-throttle to WOT. They automatically compensate for sub-standard fuels and fuel additives that affect octane.

                            My suggestion is, use the formula for calculating stoichiometric fuel consumption, but use the LTFT (Long Term Fuel Trim) to find what the vehicle is actually using. LTFT is given in +/- % (percentage). An example of the formula to use is

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

                            This formula uses the car's fuel trim value to compensate for the difference in actual AFR and stoichiometric AFR, however I'm not 100% sure that the LTFT value is % difference from stoichiometric. If anybody has any ideas as to how correct my thoughts are, please respond.

                            Comment


                            • #15
                              Originally posted by jiggersplat View Post
                              I would suggest trying to use injector pulse width instead if it is available....
                              I like this idea, and even older vehicles (like E30 BMWs) used it to calculate the MPG for the on-board computer, whilst also taking a speed reading from the speedometer (which was pulsed from the diff rather than a mechanical cable)

                              How would you measure pulse width though, if not available via OBD? wouldn't you have to build your own circuit?
                              http://sticksout.blogspot.com

                              Comment

                              Working...
                              X