PDA

View Full Version : Fuel_Economy calculated pid?



Zeus
January 3rd, 2006, 04:28 PM
Anyone know of something like this, or a way to do it? It seems like it would be super easy to divide vehicle speed by the amount of fuel being delivered (through injector pulse widths?). Alas I know nothing of programing Live so I'm wondering if anyone can help out.

I for one think it would be cool to have a gauge or graph that shows how your fuel economy varies based on tuning/hardware changes or driving habits.

Blacky
January 3rd, 2006, 05:13 PM
Tricky to do, because there is no PID (as far as I know) to retrieve actual fuel flow. There is a PID that returns injector pulse width in milliseconds but how to convert from pulse width to actual fuel flow (i.e. liters per hour, or gallons per hour) is not trivial. The conversion would need to be based on fuel pressure (not available on LS1) and injector characteristics.

Regards
Paul

Zeus
January 3rd, 2006, 05:35 PM
I guess if your VE table was dialed in so your BEN was right around 1 you could calculate it based on the VE, cylinder volume, and AFR couldn't you?

joecar
January 3rd, 2006, 06:03 PM
You can calculate approximate fuel consumption using airflow, AFR, VSS, density of fuel, and some imperial/metric conversions:

fuelflow (g/s) = airflow (g/s) / AFR

then use density of gasoline (petrol) (737.22 g/L found on web) to convert fuelflow to from g/s to L/s,
then convert to L/hour,
then convert to gallon/hour,
and then divide this into VSS (miles/hour), giving miles/gallon.

Tordne
January 3rd, 2006, 06:11 PM
You can calculate approximate fuel consumption using airflow, AFR, VSS, density of fuel, and some imperial/metric conversions:

fuelflow (g/s) = airflow (g/s) / AFR

then use density of gasoline (petrol) (737.22 g/L found on web) to convert fuelflow to from g/s to L/s,
then convert to L/hour,
then convert to gallon/hour,
and then divide this into VSS (miles/hour), giving miles/gallon.

There you go Paul, simple as that. So there will be a new calc PID in the next patch right :muahaha:

ace68
January 4th, 2006, 08:01 AM
or you could just divide the miles driven by the gal used :notacrook:

dc_justin
January 4th, 2006, 09:41 AM
Couldn't you also use GM.INJFLOW to get the injector flow rate, rather than using airflow (g/s) / AFR? Assuming you're not using a wideband, the AFR would only be commanded and not dead on, no?

Blacky
January 4th, 2006, 10:33 AM
Couldn't you also use GM.INJFLOW to get the injector flow rate, rather than using airflow (g/s) / AFR? Assuming you're not using a wideband, the AFR would only be commanded and not dead on, no?

Riiiiiiiiiiiiiiight (in my best Dr Evil voice). Don't I feel stupid now. I had forgotten about that fuel flow PID :nixweiss:

I'm sure the maths gurus among us can come up with a formula to convert {GM.INJFLOW} and {SAE.VSS} into a fuel economy value...

Regards
Paul

dc_justin
January 4th, 2006, 10:49 AM
Riiiiiiiiiiiiiiight (in my best Dr Evil voice). Don't I feel stupid now. I had forgotten about that fuel flow PID :nixweiss:

I'm sure the maths gurus among us can come up with a formula to convert {GM.INJFLOW} and {SAE.VSS} into a fuel economy value...

Regards
Paul

I created one that I am going to try on my drive home today to see if it works. Would be nice to see what the best combo for driving my T/A is for milage :)

{SAE.VSS}/({GM.INJFLOW}/737.22*3.785412)

Not sure if it is right, been a long time since I did "garbage problems" in high school physics, but I followed joecar's advice.

Blacky
January 4th, 2006, 11:26 AM
One thing to remember when creating calculated PID expressions that use PIDs with both metric and imperial units, is to append the units to the PID name, like this:

If the speed is in mph and the flow is in pound per minute then use:
{SAE.VSS.mph}/({GM.INJFLOW.lbpm}/737.22*3.785412)

If the speed is in km/h and the flow is in grams per second then use:
{SAE.VSS.kph}/({GM.INJFLOW.gps}/737.22*3.785412)

Otherwise EFILive won't know which units to use when computing the expression.

The units are listed in
\Program Files\EFILive\V7\Configuration\sae_generic.txt
in the *UNITS section.
The first entry in the "Code" column is the one you need to append to the PID name.

Regards
Paul

dc_justin
January 4th, 2006, 11:38 AM
One thing to remember when creating calculated PID expressions that use PIDs with both metric and imperial units, is to append the units to the PID name, like this:

If the speed is in mph and the flow is in pound per minute then use:
{SAE.VSS.mph}/({GM.INJFLOW.lbpm}/737.22*3.785412)

If the speed is in km/h and the flow is in grams per second then use:
{SAE.VSS.kph}/({GM.INJFLOW.gps}/737.22*3.785412)

Otherwise EFILive won't know which units to use when computing the expression.

The units are listed in
\Program Files\EFILive\V7\Configuration\sae_generic.txt
in the *UNITS section.
The first entry in the "Code" column is the one you need to append to the PID name.

Regards
Paul

Yeah, I screwed that one up. :rockon:

emarkay
January 4th, 2006, 11:43 AM
Jeez, this was an old request I made way back in the V6 days... Easier way would be VSS and inverted MAP. Vacuum in In/Hg is an easy and close "instant" MPG figure, and when VSS gets to zero MPG also goes to "0"...

What about it, programmers? :)

dc_justin
January 4th, 2006, 01:12 PM
Welp, Calculated Injector Flow Rate doesn't work properly. My whole 30 minute drive home it stayed in the narrow range of 0.48lb/min to 0.52lb/min. Time for another idea.

Blacky
January 4th, 2006, 01:47 PM
That value is the value looked up by the PCM from {B4001}*{B4002}.
You would need to multiply that by injector base pulse width and then by RPM and some constants thrown in as well.

Maybe something like this:
{GM.INJFLOW.gps}*({GM.INJBPW}/1000)*({SAE.RPM}*4/60)

Notes:
divide INJBPW by 1000 to convert from ms to seconds.
divide RPM by 60 to convert RPM to RPS (revs per second).
multiply by 4 to convert RPS to injector openings per second (8 injectors, each one opens every 2 revolutions)That's just off the top of my head, I have not checked it for accuracy.

Regards
Paul

Blacky
January 4th, 2006, 01:49 PM
Jeez, this was an old request I made way back in the V6 days... Easier way would be VSS and inverted MAP. Vacuum in In/Hg is an easy and close "instant" MPG figure, and when VSS gets to zero MPG also goes to "0"...

What about it, programmers? :)

I thought of your original request... I was about to send you an email.
Paul

dc_justin
January 4th, 2006, 02:29 PM
That value is the value looked up by the PCM from {B4001}*{B4002}.
You would need to multiply that by injector base pulse width and then by RPM and some constants thrown in as well.

Maybe something like this:
{GM.INJFLOW.gps}*({GM.INJBPW}/1000)*({SAE.RPM}*4/60)

Notes:

divide INJBPW by 1000 to convert from ms to seconds.
divide RPM by 60 to convert RPM to RPS (revs per second).
multiply by 4 to convert RPS to injector openings per second (8 injectors, each one opens every 2 revolutions)That's just off the top of my head, I have not checked it for accuracy.

Regards
Paul

Thanks, I'll play with that some more. I couldn't find any documentation or anything that was able to help me with determining just how to use that calculated injector flow rate.

dc_justin
January 4th, 2006, 03:29 PM
OKAY, I worked this one all out on paper first to make sure all units cancel out properly and whatnot, and it looks like you nailed it there Paul.
I've got this expression set up:
{SAE.VSS.mph}/({GM.INJFLOW.lbpm} *{GM.IBPW1}* {SAE.RPM} * 4 / 6250 )

and it looks to be pretty close. :D

joecar
January 4th, 2006, 06:54 PM
If the speed is in mph and the flow is in pound per minute then use:
{SAE.VSS.mph}/({GM.INJFLOW.lbpm}/737.22*3.785412)

If the speed is in km/h and the flow is in grams per second then use:
{SAE.VSS.kph}/({GM.INJFLOW.gps}/737.22*3.785412)

Both equations have mismatched units...! :bawl:

Edit: Oh, I didn't see page 2.

joecar
January 4th, 2006, 07:15 PM
I've got this expression set up:
{SAE.VSS.mph}/({GM.INJFLOW.lbpm} *{GM.IBPW1}* {SAE.RPM} * 4 / 6250 )
The units don't match up (fails to convert lb->gal and min->hr or sec->hr)...! :bawl:

What are the units of 4 and 6250...?

dc_justin
January 5th, 2006, 01:56 AM
The units don't match up (fails to convert lb->gal and min->hr or sec->hr)...! :bawl:

What are the units of 4 and 6250...?

4 and 6250 accomplish that. :notacrook:

I don't have my notepad in front of my that accomplished all of this, but the only constant you need (I think) is the weight of gasoline at 6.25lb/gal (thanks google).

joecar
January 5th, 2006, 07:29 AM
4 and 6250 accomplish that. :notacrook:

I don't have my notepad in front of my that accomplished all of this, but the only constant you need (I think) is the weight of gasoline at 6.25lb/gal (thanks google).
Ah, I see it now, thanks... :cheers:

So, is this what you got (where "rev" is unitless):

VSS[mile/hr] / ( INJFLOW[lb/min] / 60[s/min] * IBPW[ms] / 1000[ms/s] * 4[1/rev] * RPM[rev/min] * 60 [min/hr] * 1/6.25[lb/gal] )

dc_justin
January 5th, 2006, 07:37 AM
Ah, I see it now, thanks... :cheers:

So, is this what you got (where "rev" is unitless):

VSS[mile/hr] / ( INJFLOW[lb/min] / 60[s/min] * IBPW[ms] / 1000[ms/s] * 4[1/rev] * RPM[rev/min] * 60 [min/hr] * 1/6.25[lb/gal] )

Yep, that looks how I did it. And the resulting values in the scanner are legit. :rockon:

emarkay
January 5th, 2006, 08:55 AM
Paul, shall we test this one out and add it to the "sample set" of calc pids in the next release?

ringram
January 5th, 2006, 09:14 AM
Ok post up the full PID then bud and we can all try it out, compare it to our trip computers, manual calc etc and give feedback and see if it needs tweaking etc.

Tordne
January 5th, 2006, 09:18 AM
Ok post up the full PID then bud and we can all try it out, compare it to our trip computers, manual calc etc and give feedback and see if it needs tweaking etc.

Me too. I'd be keen to give this a go. Would need to convert to work with metric units also :rockon:

kbracing96
January 5th, 2006, 09:21 AM
Paul, shall we test this one out and add it to the "sample set" of calc pids in the next release?

I would vote yes to this.

I would like to use this pid, but I haven't yet figured out how to create custom pids. I did a little searching and didn't come up with what I was looking for. If some one had a little time, could you do a brief write up for use newbees to learn form on how to create a custom pid like this? Or point me to where I need to look.:thankyou2:

dc_justin
January 5th, 2006, 09:57 AM
Here's my pid file. My first one, hope it is right, the instructions were pretty easy to follow.

eboggs_jkvl
January 5th, 2006, 10:57 AM
Oh crap. searching for how to add a manual pid! Hm...

eboggs_jkvl
January 5th, 2006, 11:24 AM
Ahhh. Search is good. Turn a couple PIDs on and I got's me a MPG gauge!

I can't wait to try it!

Elmer

emarkay
January 5th, 2006, 12:33 PM
Greetings Elmer! Glad to see you. I remember the good old days at LS1.com!
BTW, Since you found it, care to post the link for those searchingly and PIDDingly challenged. (Not I of course...):)

eboggs_jkvl
January 5th, 2006, 12:42 PM
Copy the entire cal_pids.txt into your memory buffer (Ctrl C) that DC shows above in his file attachment.
Open Scan tool
Click Edit
Click Open Notebook
Click File/open
Search down in My documents/EFILive/V7/User Configuration/calc_pids.txt
Open the file
Highlight the entire text file and paste in the calc_pid you have in memory (Ctrl V)
Save the file
Close Scantool
Open scan tool
Look at your PIDs there is an MPG there.

Select it
Select Vss
Select IBPW Bank 1

You should be golden


Oh, Hi! Nice to see you! Why aren't you posting on www.ls2.com? (http://www.ls2.com?)

Elmer

eboggs_jkvl
January 5th, 2006, 12:50 PM
I used to write instructional material for AT&T. Pretty specific instructions huh?

kbracing96
January 5th, 2006, 01:23 PM
WOW that worked great. To bad I don't have GM.INJFLOW.lbpm loged in any of my logs. :( This is some thing I have wanted for a long time and now I have it. I was allways going to ask how to do it, but never got around to doing it. Thanks guys :rockon:

emarkay
January 5th, 2006, 03:31 PM
Oh, Hi! Nice to see you! Why aren't you posting on www.ls2.com? (http://www.ls2.com?)
Well about this time last year, I just sort of got burned out, I stupidly wrecked the car (it's fixed), had an addition to the family, picked up a nice low mileage GM boat (that demands attention at random times), realized that I know a LOT about a specific few years of the F-Platform, but that I am not up to speed on trucks all the rest, and, really could care less about the then (and immediate future) crop of GM product. But I may pop on over just to see what's going on someday...



I used to write instructional material for AT&T. Pretty specific instructions huh?
Ah, yes, "Your world. Delivered." Glad you missed out on the $16.9 billion merger?
Looks fine to me!
...And yes, I have been known to dabble in some technical writing myself... ;)

Zeus
January 5th, 2006, 05:36 PM
yeah! good idea me.... lol


thanks dc_justin, I think I might have to try this out.

ringram
January 5th, 2006, 11:01 PM
Dont forget to back your cacl_pids.txt up if you want to use the other ones in it.

Also you can just add the lines in the calc_pids above into your existing file and retain all the current ones. You just have to make sure the slot numbers are unique.

I guess you can make a map to give you an average mpg over your trip as well. Plus even average mpg at each vss so you can see best cruising speed for economy.

row vss, data mpg and column mpg, or for overall average, make everything mpg.

Rich

dc_justin
January 6th, 2006, 02:49 AM
I drove the Silverado into work today which has the instant MPG display in the DIC. And it matched what this PID calculates! :D

Extinct
January 6th, 2006, 03:07 AM
Was thinking about this myself the other day.

I was thinking that with a PID such as this, you could use the bi-directional controls to quickly zoom in on the optimum AFR for fuel economy, especially here in the Midwestern US where there are plenty of flat roads.

Find long flat road - set cruise control, vary AFR via Bi-directional controls while logging fuel economy - voila' - best AFR arrived at !

OK, who wants to be the first to do it (mine is currently on stands undergoing gearing adjustments) ?

dc_justin
January 6th, 2006, 03:13 AM
I'll be moving from VA to CA in the next month (THANK GOD) and will more than likely have the wideband still hooked up to my truck running in open loop. I'll definitely be playing with the AFR a bit to see if I can save some cash on gas. 2800 miles at anticipated 12mpg towing the trailer... :Eyecrazy:

Zeus
January 6th, 2006, 07:59 AM
wait you think moving to California is a "THANK GOD" moment? Maybe for your job it is but even though I was born and raised in this state I HATE IT. I used to think it was the best state in the Union, but we've effectively enacted laws that take all risk, all danger, all reward, all fun, and all uniqness out of life. Every part of daily life is legislated to death here. This is especially true with vehicles and it's why I'm glad I spend 80% of the year in another state. Hope it works out better for you.

....btw, on a lighter note, thanks again for the PID :D

Zeus
January 6th, 2006, 08:05 AM
Was thinking about this myself the other day.

I was thinking that with a PID such as this, you could use the bi-directional controls to quickly zoom in on the optimum AFR for fuel economy, especially here in the Midwestern US where there are plenty of flat roads.

Find long flat road - set cruise control, vary AFR via Bi-directional controls while logging fuel economy - voila' - best AFR arrived at !

OK, who wants to be the first to do it (mine is currently on stands undergoing gearing adjustments) ?

I don't know if setting the cruise control to do this is the best method. I know of other people who have done this while tuning, say to hit a particular cell in an autoVE tune, but they found out the CC varies engine conditions super rapidly and their graphs almost look like those of O2 sensors chasing stoich in closed loop. I don't think it should be too hard to just hold the throttle manually.

dc_justin
January 6th, 2006, 08:09 AM
wait you think moving to California is a "THANK GOD" moment? Maybe for your job it is but even though I was born and raised in this state I HATE IT. I used to think it was the best state in the Union, but we've effectively enacted laws that take all risk, all danger, all reward, all fun, and all uniqness out of life. Every part of daily life is legislated to death here. This is especially true with vehicles and it's why I'm glad I spend 80% of the year in another state. Hope it works out better for you.

....btw, on a lighter note, thanks again for the PID :D

I lived in CA for 22 years before moving out here. 18 in rural Fresno county, 4 in Davis. At the time I felt that there were some bad things about the state, which there still are, but compared to aspects of life that affect me regularly, it's a notch well above Northern VA in every aspect. And as an auto enthusiast and someone who enjoys driving, I'm certain that you would be just as annoyed as I have been out here in a matter of minutes. Vehicle modifications are much, much more heavily legislated here than in CA, other than CARB. I'd say less than 10% of the people on the road have any idea whatsoever that bad driving habits on a road will affect literally tens of thousands of people during a given commute... Gas and brakes pedals should not be used like on/off switches! :Eyecrazy:


As for the PID. Thank Paul for the bulk of the explanation, I was just the first to put it to use and post it. :rockon:

mistermike
January 6th, 2006, 12:06 PM
What parameters do they crunch in the Holden / GTO DIC to express Instantaneous MPG? I know the smarts are in the cluster, but they start with info from the PCM.

ringram
January 6th, 2006, 12:38 PM
Yes, Id like to know. Mine are so far out of whack its not funny. This is on a 00 R8 HSV Model that has been messed with to change kmph to miles and an attempt to get the l/100km working properly and has failed miserably, its about 30% out.

kbracing96
January 6th, 2006, 12:59 PM
I have ScanGuage by liner logic and it does MPG. I know it used the MAF, because when i unhooked it to do SD tuning, it stoped working.

Blacky
January 6th, 2006, 02:56 PM
Yes, Id like to know. Mine are so far out of whack its not funny. This is on a 00 R8 HSV Model that has been messed with to change kmph to miles and an attempt to get the l/100km working properly and has failed miserably, its about 30% out.

You can adjust the fuel flow used by the trip computer in the cluster.
You can also change the speedo needle in the cluster (Bad for EFILive because then the PCM internal calculations are out).
Instructions in the vehicle handbook under trip computer (page 1-20 in my VT book).

Regards
Paul

ringram
January 6th, 2006, 11:50 PM
Thanks Paul, yes I saw you can do 250L -> 500L of fills then check the calibration and adjust. I went way over like 600L and forgot the book to remind me how to get into the mode... So Im starting again. I just wasnt sure that would help. Needle is bang on now, VSS seems a little slow though... work in progress.

ringram
January 8th, 2006, 11:53 AM
Ok ran this map and pid up and it looks good.
50mph looks to be the most economic.. Though my right foot was rather heavy I managed to get into the 40's in this area on my 10min drive.

Ive got 250miles tomorrow so Ill report back on how things go then.

emarkay
January 8th, 2006, 04:05 PM
Works great for me! Got values from 0 to 110 MPG, with an average on a constant run of 31.5 MPG. I did get about 30 once, on a long 55MPH full tank of fuel (calculated with miles used and gallons added to top of filler), so this is truly in line with reality.

THANKS!

Extinct
January 9th, 2006, 02:49 AM
I don't know if setting the cruise control to do this is the best method. I know of other people who have done this while tuning, say to hit a particular cell in an autoVE tune, but they found out the CC varies engine conditions super rapidly and their graphs almost look like those of O2 sensors chasing stoich in closed loop. I don't think it should be too hard to just hold the throttle manually.

Well, I haven't done it on an OBDII vehicle, but on my OBDI truck it worked great. The CC varies throttle very little if at all, and is much better at holding a constant speed than I am. Remember, even if you hold the throttle motionless, the speed could go up or down depending on grade, wind conditions, and current speed (whether you are at equilibrium hp=drag).

Just thought CC is an easy way to get to that equilibrium, although as stated works best on level roads, or at least roads with a long constant grade where you can adjust fueling with Bi-directional controls.

Several roads like that here in the Midwest, and in the San Joaquin valley Ca., lots of other roads in the west too !

dc_justin
January 9th, 2006, 02:58 AM
San Joaquin valley Ca.

Exactly where I plan to do a bit of my tuning in three weeks. Perfectly straight, flat roads for miles and miles. :rockon:

Extinct
January 9th, 2006, 03:17 AM
Exactly where I plan to do a bit of my tuning in three weeks. Perfectly straight, flat roads for miles and miles. :rockon:

Great, be sure to report back the optimum AFR, OK ?

dc_justin
January 9th, 2006, 03:20 AM
Great, be sure to report back the optimum AFR, OK ?

Will do. Both with my LQ9 and LS1.

ringram
January 9th, 2006, 04:13 AM
Ive tuned to 15.4:1 on a motorway cruise, it would be interesting to see what looks ideal. I think it will also depend on your drag coefficient. CD.
Trucks will need more grunt to keep going I recon. Anyway be interesting to see..

oztracktuning
February 4th, 2006, 05:31 PM
I have installed the MPG pid and modified it to get it to display L/100km as thats how we describe fuel economy here now in Australia.

I found it to be about 35% out - so i have calibrated it to my trip computer which i know is accurate as i have checked it many times.

Does someone know where that sort of an error could come from. I have SVO 30 injectors with the right IFR values for them and my car initially had the original LS1 injectors which are the 24 (26.4) ones. SV0 30s are 36.1 so 36.1/26.4 is near the 35% error i was seeing ??

bK
February 5th, 2006, 01:27 AM
I have installed the MPG pid and modified it to get it to display L/100km as thats how we describe fuel economy here now in Australia.

I found it to be about 35% out - so i have calibrated it to my trip computer which i know is accurate as i have checked it many times.

Does someone know where that sort of an error could come from....

Are you able to post up your calc_pids.txt or the calculation?

oztracktuning
February 5th, 2006, 01:31 AM
Its not tidy but the formula that works accurately for my car is
in the expression section. I just did another log and its now saying the same as what my trip computer says when cruising.

"95.6/(0.35363*{SAE.VSS.mph}*1.367/({GM.INJFLOW.lbpm} * {GM.IBPW1} * {SAE.RPM} * 4 / 6250 ))"

Garry
June 17th, 2006, 08:24 AM
Sorry if this is a stupid question, but what do I actually have to change where to add the MPG calculated PID? I've looked at the manual as well as the different files, but can't seem to figure out what to enter ... !?

purrvert
June 24th, 2006, 05:50 AM
The formula is burried some where in my C5 software, I can watch instant or average consumption on my DIC.

joecar
June 24th, 2006, 07:53 AM
Sorry if this is a stupid question, but what do I actually have to change where to add the MPG calculated PID? I've looked at the manual as well as the different files, but can't seem to figure out what to enter ... !?Garry,

Find the calc_pids.txt in My Documents/EFILive/V7/User Configuration on your PC;

look in the attached calc_pids.txt and find the 2 lines containing CLC-00-090;
this is the CALC.MPG pid from showpost.php?p=15435&postcount=17 (http://forum.efilive.com/showpost.php?p=15435&postcount=17) on page 2 of this thread;

this is how you modify the calc_pid.txt file to enter the CALC.MPG pid (copy/paste those lines).

Joe :cheers:

macca_779
April 13th, 2007, 06:56 PM
Hi guys I know i'm draging up an old topic here but here goes. I've read this entire thread and the informating has been informative. I'm not the best at decifering all the info in the calc_pids file and how it all works, but I can see the maths and work from there. I've had some success in getting the MPG Pid to work using Joecar's attached file. But the numbers just don't look right compared to my trip computer. I think the 6250 value in the calculation corelates to how the Holden Trip computers offer calibration via the diagnostic page. All this is theory though as it's hard for me to convert MPG to L/100km while driving. I know roughly that 30MPG is 7.5L/100km, but the numbers going up and down in the opposite direction makes my head hurt. hehe

What I'm after is a PID to log fuel economy in L/100km like the Holden trip computers. Being able to select between Metric (L/100km) and Imperial (MPG) would be great and I'm sure a lot of guys would use it. Including this PID in the Core set of PID's in the Scan Tool would be even better.

So if anyone would like to help me out by creating a calc_pids file with L/100 included in it I would be greatly appreciate it. Once I have that I can work out exactly where the Holden calculation and the PID differ. I'll see if I can confirm the Holden cal number in the PID calculation too.

joecar
April 14th, 2007, 07:31 AM
I think you need a new pid...

The conversion from X [mile/gallon] to Y [L/100km] is: Y [L/100km] = 235.2146 / (X [mile/gallon])

The MPG pid is:
{SAE.VSS.mph} / ({GM.INJFLOW.lbpm}*{GM.IBPW1}*{SAE.RPM}*4/6250)

Your VSS would be in km/h, so a conversion to mile/h is required, so the MPG pid based on VSS.kph would be:
({SAE.VSS.kph}*0.6214) / ({GM.INJFLOW.lbpm}*{GM.IBPW1}*{SAE.RPM}*4/6250)

That gives fuel usage in mile/gal from your speed in km/h.

Now, divide this pid into 235.2146, like this:
235.2146 / (({SAE.VSS.kph}*0.6214) / ({GM.INJFLOW.lbpm}*{GM.IBPW1}*{SAE.RPM}*4/6250))

This can be rewritten as:
235.2146 / ({SAE.VSS.kph}*0.6214) * ({GM.INJFLOW.lbpm}*{GM.IBPW1}*{SAE.RPM}*4/6250)

See attached calc_pid.txt (I haven't tried it yet).

macca_779
April 14th, 2007, 12:52 PM
thanks mate. It works a treat. I overlooked the speed value thats where I was going wrong. I'll test it out later to calibrate it to car trip computer.

DMaxME
April 18th, 2007, 01:18 PM
what about diesel guys?

SSpdDmon
April 19th, 2007, 08:45 AM
Did anyone ever verify the accuracy of this? I ask because my H/C car averaged 27mpg on the way into work this morning according to the scan tool. The problem is, I was in some pretty heavy stop and go traffic on the highway going from 50-0-65-15-35-70.... for a while and even had a quick WOT pull in 4th up to 4,500rpm (someone slowass was pissing me off - so I gave 'em an ear full :D). I'm wondering if the DFCO is throwing it off. When it kicks on, I see some insane mileage numbers and didn't know if they are skewing the average too much or not. It makes sense that they be high, but we're talking 200+mpg here while DFCO is on. :lol:

dc_justin
April 19th, 2007, 08:53 AM
Did anyone ever verify the accuracy of this? I ask because my H/C car averaged 27mpg on the way into work this morning according to the scan tool. The problem is, I was in some pretty heavy stop and go traffic on the highway going from 50-0-65-15-35-70.... for a while and even had a quick WOT pull in 4th up to 4,500rpm (someone slowass was pissing me off - so I gave 'em an ear full :D). I'm wondering if the DFCO is throwing it off. When it kicks on, I see some insane mileage numbers and didn't know if they are skewing the average too much or not. It makes sense that they be high, but we're talking 200+mpg here while DFCO is on. :lol:

Yeah, the PID fairly closely matches the actual mileage I get. DFCO DEFINITELY skews the numbers, so you really can't trust it without filtering DFCO out.

kbracing96
April 19th, 2007, 09:03 AM
Instant seems to be close for me, but the average is generally way off, something is missing to this equation, cuz DFCO really skews it off and even turning it off, average still reads higher then my actual, buy quite a bit. I think part of it is that sitting still at 0 mph, it does not lower the average, there something that we are missing here, but I'm not smart enough to figure it out.

dc_justin
April 19th, 2007, 09:10 AM
Instant seems to be close for me, but the average is generally way off, something is missing to this equation, cuz DFCO really skews it off and even turning it off, it still reads higher then my actual, buy quite a bit. I think part of it is that sitting still at 0 mph, it does not lower the average, there something that we are missing here, but I'm not smart enough to figure it out.

Well, it's based on injector pulse widths... Those are assumed to be correct, but if the correct turn on and turn off times aren't accounted for with the injectors you're using, then the numbers will be off, especially at shorter pulse widths. B3701 wouldbe a good tool to getting that nailed down, but hard to get exact without proper injector information. Racetronix fortunately has the information for mine. :master:

kbracing96
April 19th, 2007, 09:18 AM
Well, it's based on injector pulse widths... Those are assumed to be correct, but if the correct turn on and turn off times aren't accounted for with the injectors you're using, then the numbers will be off, especially at shorter pulse widths. B3701 wouldbe a good tool to getting that nailed down, but hard to get exact without proper injector information. Racetronix fortunately has the information for mine. :master:

I agree with you on that part, but what I'm saying is with this equation, it is flawed in that when you are stopped, you are still using fuel, but are at 0 mph, but the average doesnt reflect that, or subtract for that. That the point I'm trying to make.

kbracing96
April 19th, 2007, 09:39 AM
Thinking about this a little more, here is what I come up with. This PID calculates instant MPG and average instant MPG, but average instant MPG is NOT the same as average MPG, lol.

To get average mpg we need a PID that takes MPH and converts that in to distance traveled, and then take injector pulse withs and convert that in to gallons used and then divide the two. That would give use a average MPG. Make any since?

dc_justin
April 19th, 2007, 09:51 AM
I agree with you on that part, but what I'm saying is with this equation, it is flawed in that when you are stopped, you are still using fuel, but are at 0 mph, but the average doesnt reflect that, or subtract for that. That the point I'm trying to make.

When you're stopped it should show 0mpg, which is correct. :)

kbracing96
April 19th, 2007, 09:56 AM
When you're stopped it should show 0mpg, which is correct. :)

It does :), but the average doesn't drop ;) Like i said, it shows instant, but not average MPG. I'm more interested in total average for fuel mileage tuning :D

dc_justin
April 19th, 2007, 09:56 AM
Thinking about this a little more, here is what I come up with. This PID calculates instant MPG and average instant MPG, but average instant MPG is NOT the same as average MPG, lol.

To get average mpg we need a PID that takes MPH and converts that in to distance traveled, and then take injector pulse withs and convert that in to gallons used and then divide the two. That would give use a average MPG. Make any since?

Yep, I'll work on that tonight...

dc_justin
April 19th, 2007, 09:57 AM
It does :), but the average doesn't drop ;) Like i said, it shows instant, but not average MPG. I'm more interested in total average for fuel mileage tuning :D

Need a 3d map.. MPG mapped on RPM x MAP x AFR :rockon:

kbracing96
April 19th, 2007, 09:59 AM
Need a 3d map.. MPG mapped on RPM x MAP x AFR :rockon:

Yep that would be awesome:rockon:, lol. Paul, get to work on that ;) haha

redhardsupra
April 19th, 2007, 01:20 PM
Need a 3d map.. MPG mapped on RPM x MAP x AFR :rockon:

if you just log IFR, AFR and IPW, you pretty much got fuel mass per cycle, then just integrate it across RPM and through time and you got real fuel consumption, i dont see a problem here.

DMaxME
April 20th, 2007, 09:01 AM
I got a diesel pid working for instant mpg, what i am looking into is the distance, maybe for quartermile times

kbracing96
April 20th, 2007, 12:48 PM
I got a diesel pid working for instant mpg, what i am looking into is the distance, maybe for quartermile times

Mind posting the code :)

DMaxME
April 25th, 2007, 11:31 AM
good point...

here it is, just copy and paste the parts you want.. the MPG only works for diesel.



# ================================================== ============================
# File details
# ------------
#
# This section defines various details about the file format.

*FILE

#Parameter Value Description
#---------- ---------------- ---------------------------------------------------
VERSION 7.1.1 File version
DECSEP . Decimal separator used in this file



# ================================================== ============================
# Units
# -------------------
# See sae_generic.txt for more information on the *UNITS section

*UNITS

#Code System Abbr Description
#-------- ---------- -------- -------------------------------------------------------------
mpg None "mpg" "Miles per gallon"
None None "" "No units"


# ================================================== ============================
# Add slot definitions here
# --------------------------------
# See sae_generic.txt for more information on "SLOT" formats
#
#Units Low High Fmt Expression
#------------ ------------- ------------- ---- --------------------------------------------------------------

*CLC-00-010
factor 0.5 1.5 0.3 "14.63 / {GM.AFR}"

*CLC-00-011
factor 0.5 1.5 0.3 "14.63 / {CALC.AFR_WBOS1}"

*CLC-00-012
factor 0.5 1.5 0.3 "14.63 / {CALC.AFR_WBOS2}"

*CLC-00-021
V 0.0 5.0 0.2 "{EXT.AD1}"
AFR 10.0 20.0 0.2 "({EXT.AD1} - 0.8) * 1.995 + 10.0"

*CLC-00-022
V 0.0 5.0 0.2 "{EXT.AD2}"
AFR 10.0 20.0 0.2 "({EXT.AD2} - 0.8) * 1.995 + 10.0"

*CLC-00-031
factor 0.5 1.5 0.2 "{CALC.AFR_WBOS1.AFR} / {GM.AFR}"

*CLC-00-032
factor 0.5 1.5 0.2 "{CALC.AFR_WBOS2.AFR} / {GM.AFR}"

*CLC-00-041
factor -20.00 20.00 0.2 "1 + {SAE.LONGFT1} / 100"

*CLC-00-042
factor -20.00 20.00 0.2 "1 + {SAE.LONGFT2} / 100"

*CLC-00-090
mpg 0.0 100000.0 0.1 "{SAE.VSS.mph} / ((({GM.MAINRATE.mm3}+{GM.PILOTRATE.mm3})*0.0000002 641720512)*480*({SAE.RPM}/2))


# ================================================== ============================
*PRN - Parameter Reference Numbers
# --------------------------------
# See sae_generic.txt for more information on the *PRN section
#
#Code PRN SLOT Units System Description
#------------------------- ---- ------------ ---------------- ---------------- ------------------------------------------

CALC.EQ F010 CLC-00-010 factor Fuel "Commanded EQ"
CALC.EQ_WBOS1 F011 CLC-00-011 factor Fuel "Wideband EQ 1"
CALC.EQ_WBOS2 F012 CLC-00-012 factor Fuel "Wideband EQ 2"

CALC.AFR_WBOS1 F021 CLC-00-021 "AFR,V" Fuel "Wideband AFR 1"
CALC.AFR_WBOS2 F022 CLC-00-022 "AFR,V" Fuel "Wideband AFR 2"

CALC.BEN_WBOS1 F031 CLC-00-031 factor Fuel "Wideband BEN 1"
CALC.BEN_WBOS2 F032 CLC-00-032 factor Fuel "Wideband BEN 2"

CALC.BEN_LONGFT1 F041 CLC-00-041 factor Fuel "LTFT BEN 1"
CALC.BEN_LONGFT2 F042 CLC-00-042 factor Fuel "LTFT BEN 2"

CALC.MPG F090 CLC-00-090 mpg Fuel "Calculated miles per gallon"

DMaxME
April 25th, 2007, 11:33 AM
the only thing i haven't figured out is how to make it not go to zero when the DFCO kicks in. other than that it works great. also i't not damped, i didn't need it to be for the charting i was doing.

ace68
April 25th, 2007, 12:05 PM
so how can I make this work on my ford super duty?

DMaxME
April 25th, 2007, 12:19 PM
it depends, but the calculation is simple if you break it down. Diesels are fuel throttled, no AF to worry about. so basically you need to get down to fuel consumption.

for example, on my duramax the first thing i did was add the Pilot and Main injection quantities, which gave me x volume. the volume was reported as mm3 or cubic millimeters per stroke.

so now we need to turn this volume into a rate.

first i converted int gallons per stroke (just multiply a conversion factor), then used 4 * RPM for the rate. as I have 8 cylinders drawing fuel every fourth stroke or every other rotation. When i wrote the code i was rather tired and did this the "late night way" 480*({SAE.RPM}/2 basically means (8cylinders*60minutes/1hour)*(RPM/2) no biggie it works either way.

the 60 minutes converts it to gallons/hour. divide Miles per hour by Gallons per Hour and your left with Miles per gallon... yay.

As for your powerstroke, replace the GM mainrate and pilotrate with the names of the pids representing your injection rates. you can add a gauge for it and play a recorded file to check your work. it's a calculated file so it dosen't have to be recorded initially.

If you have any further questions post your pid list and i'll try and help you further.

Best of luck

joecar
April 25th, 2007, 12:31 PM
DMaxME,

I added tags around your calc_pids text to disable the 8) smilies that show up from "8)" combinations.

Cheers,
Joe
:)

DMaxME
April 25th, 2007, 12:33 PM
Looks great, Thanks

joecar
April 25th, 2007, 12:38 PM
DMaxME,

Here is your file with the pertrol/gasoline stuff trimmed out...



# ================================================== ============================
# File details
# ------------
#
# This section defines various details about the file format.

*FILE

#Parameter Value Description
#---------- ---------------- ---------------------------------------------------
VERSION 7.1.1 File version
DECSEP . Decimal separator used in this file


# ================================================== ============================
# Units
# -------------------
# See sae_generic.txt for more information on the *UNITS section

*UNITS

#Code System Abbr Description
#-------- ---------- -------- -------------------------------------------------------------
mpg None "mpg" "Miles per gallon"


# ================================================== ============================
# Add slot definitions here
# --------------------------------
# See sae_generic.txt for more information on "SLOT" formats
#
#Units Low High Fmt Expression
#------------ ------------- ------------- ---- --------------------------------------------------------------

*CLC-00-090
mpg 0.0 100.0 0.1 "{SAE.VSS.mph} / ((({GM.MAINRATE.mm3}+{GM.PILOTRATE.mm3})*0.0000002 641720512)*480*({SAE.RPM}/2))"


# ================================================== ============================
*PRN - Parameter Reference Numbers
# --------------------------------
# See sae_generic.txt for more information on the *PRN section
#
#Code PRN SLOT Units System Description
#------------------------- ---- ------------ ---------------- ---------------- ------------------------------------------

CALC.MPG F090 CLC-00-090 mpg Fuel "Calculated miles per gallon (diesel)"




lol... I made the high limit 100.0 so that when displayed on a chart it won't look flat/zero.

Cheers
Joe
:cheers:

DMaxME
April 25th, 2007, 01:38 PM
so that's how to make it not 0 out during DFCO? technically it's a math error, fuel goes to 0 and then you have a devide by zero condition, the gauge jumps past 600 and then reads 0, rather than the upper limit. oh well it's just a querky thing, i can live with it.

joecar
April 25th, 2007, 02:01 PM
My understanding is that the low/high limits are used only for setting the min/max chart axis values or the min/max gauge pegs...

so I'm not sure that this will prevent displaying zero when a divide-by-zero occurs.

DMaxME
April 28th, 2007, 10:56 PM
yea that's what i guessed, oh well no biggie

kbracing96
June 1st, 2007, 03:29 AM
Thinking about this a little more, here is what I come up with. This PID calculates instant MPG and average instant MPG, but average instant MPG is NOT the same as average MPG, lol.

To get average mpg we need a PID that takes MPH and converts that in to distance traveled, and then take injector pulse withs and convert that in to gallons used and then divide the two. That would give use a average MPG. Make any since?


Yep, I'll work on that tonight...
Any one come up with anything on this??

redhardsupra
June 1st, 2007, 06:15 AM
if you have a bunch of instant values, just sum them up and divide by the number of them. numerical integration at it's simplest.

how to do it in hpt? umm... make a histogram with ONE cell, that grabs all values, so make it on like scale of 0-512 g/sec of airflow, and then use the instant milage pid as the data. the average in that histogram is going to be your integral of instant milage values across time.

kbracing96
June 1st, 2007, 07:03 AM
if you have a bunch of instant values, just sum them up and divide by the number of them. numerical integration at it's simplest.

how to do it in hpt? umm... make a histogram with ONE cell, that grabs all values, so make it on like scale of 0-512 g/sec of airflow, and then use the instant milage pid as the data. the average in that histogram is going to be your integral of instant milage values across time.

Like I was telling Justin, the problem with instant MPG PID is then when you not moving instant is 0, but the engine is still running, but average instant is not changing, where your actual MPG would be getting lower as you are still burning fuel, but your not going anywhere. That the problem with this pid and what I want to do.

joecar
June 1st, 2007, 07:08 AM
To get miles from MPH, need to integrate VSS over time (mulitply each instant VSS by the time since the previous frame, sum all these up, divide by the number of samples, mulitply by some constant to account for hr->sec).

Same thing with injector flow -> gallons.

This will be easy to do when Paul puts the integrate function back into the software.

dc_justin
June 1st, 2007, 07:08 AM
Like I was telling Justin, the problem with instant MPG PID is then when you not moving instant is 0, but the engine is still running, but average instant is not changing, where your actual MPG would be getting lower as you are still burning fuel, but your not going anywhere. That the problem with this pid and what I want to do.

I started to work some more on this, but stopped short due to time constraints. Basically, I was coming up with a "fuel used per frame" PID, which, when summed, would give you the total fuel used. Could then create a distance traveled per frame PID and calculate out an MPG PID from a combination of the two.

Justin

DMaxME
June 3rd, 2007, 10:38 AM
Typically I dump it in Excel and spit out large regions for MPG estimation. I like the instant on my computer, as it reminds me to take my foot off it while driving.

When i make my estimations i cruise control it at a fixed speed for about 1/2hr or so. I also am sure to take notice of my altitude on my GPS, as it is important to limit absolute elevation changes. I export the data, and run a macro to average all columns. It's the overall average data i'm interested in, so I copy the averages to my active spreadsheet, and delete the logged data for computer space conservation.

oztracktuning
June 3rd, 2007, 11:43 AM
Do you notice how much fuel economy drifts with changes in intake temperature. warmer is better - but it would be interesting to know some figures.

I love playing with fue economy tuning. We are putting a small 206 212 112 comp cam in a Statesman and hope to see it improve overall fuel economy. I have seen heads, UDP and TB, extractors all help improve economy.

kbracing96
March 6th, 2008, 11:08 AM
I started to work some more on this, but stopped short due to time constraints. Basically, I was coming up with a "fuel used per frame" PID, which, when summed, would give you the total fuel used. Could then create a distance traveled per frame PID and calculate out an MPG PID from a combination of the two.

Justin

I'm gona bump this. Did you ever come up with anything Justin? I still want to make an actual, MPG gauge, not instant.

joecar
March 6th, 2008, 01:52 PM
For gasoline, use post #17 of this thread: showthread.php?t=1667&page=2 (http://forum.efilive.com/showthread.php?t=1667&page=2)

For diesel, use the same equation but replace the pids GM.INJFLOW.lbpm and GM.IBPW1 with their diesel equivalents.

Oh, but this gives the MPG based on vehicle speed ("instant MPG") and not on distance travelled ("actual MPG").

dc_justin
March 6th, 2008, 04:48 PM
I'm gona bump this. Did you ever come up with anything Justin? I still want to make an actual, MPG gauge, not instant.

Nope, I haven't played with it since then. I'll think about it some more and see what I can come up with.

Justin

Extinct
January 24th, 2009, 04:01 PM
Bump

Justin, did you ever do that fuel economy tuning out near fresno ? Just wondering what you came up with as optimum AFR ?

dc_justin
January 26th, 2009, 05:43 AM
Bump

Justin, did you ever do that fuel economy tuning out near fresno ? Just wondering what you came up with as optimum AFR ?

You know, I never got around to it. Spent more time using the straight flat roads for other purposes. :angel_innocent:

Coincidentally, I'm in the area right now, but don't have any of my vehicles with me to test out. Perhaps the Chevy HHR from Hertz would be a good test subject.

rennoc442
November 17th, 2009, 07:01 PM
Hey guys Ive tried doing this,and it wouldnt work. Said the pid I have selected is n/a, and wouldnt display it since it is n/a. Any ideas? I can see the mpg pid in the data, but it reads n/a?

ferocity02
May 16th, 2013, 04:54 AM
Has anyone used the MPG calc pid with big injectors? The equation should account for the injector size, but some people are saying the pulse width might be too low with big injectors. I cruise at 3.2ms and idle at 2.1ms. They are 72# @ 3bar Bosch injectors from FIC. According to the calc pid, my cruise fuel economy went from 19-20mpg with stock 25# injectors to 12-13mpg with the 72# injectors. The actual fuel economy appears to be much lower as well. Just trying to figure out if an error in the calc pid is partially to blame. Here is mine:

MPG(mi/gal) = {SAE.VSS.mph}/({GM.INJFLOW.lbpm}*(({GM.IBPW1}+{GM.IBPW1})/2)*{SAE.RPM}*4/6073)

joecar
May 16th, 2013, 08:45 AM
Hey guys Ive tried doing this,and it wouldnt work. Said the pid I have selected is n/a, and wouldnt display it since it is n/a. Any ideas? I can see the mpg pid in the data, but it reads n/a?On the PIDs tab, on the MPG pid do rightclick->More Info and take note of all the pids mentioned... then go and select all those pids.

EagleMark
May 20th, 2013, 03:06 PM
On the PIDs tab, on the MPG pid do rightclick->More Info and take note of all the pids mentioned... then go and select all those pids.:hihi:
November 18th, 2009

Your slipping joe...

I found this thread couple weeks ago and the MPG PID works great, but have to check and see if you have your liters and gallons mixed up.

bimbleuk
June 3rd, 2013, 03:10 AM
4 and 6250 accomplish that. :notacrook:

I don't have my notepad in front of my that accomplished all of this, but the only constant you need (I think) is the weight of gasoline at 6.25lb/gal (thanks google).

I was about to log some data and as I'm using imperial gallons (not US) I think I just need to change 6250 in the equation to 7500 to account for the bigger gallon measurement used here? Imperial gallon being 20% more volume.

EagleMark
June 3rd, 2013, 04:00 AM
What is the purpose of this PID and 2 "GM.IBPW1" then divide by 2?
"MPG(mi/gal) = {SAE.VSS.mph}/({GM.INJFLOW.lbpm}*(({GM.IBPW1}+{GM.IBPW1})/2)*{SAE.RPM}*4/6073)"

Also looks like the weight of fuel has changed from 6250 to 6073? Could this be an E fuel adjustment?

ferocity02
June 3rd, 2013, 04:07 AM
What is the purpose of this PID and 2 "GM.IBPW1" then divide by 2?
"MPG(mi/gal) = {SAE.VSS.mph}/({GM.INJFLOW.lbpm}*(({GM.IBPW1}+{GM.IBPW1})/2)*{SAE.RPM}*4/6073)"

Also looks like the weight of fuel has changed from 6250 to 6073? Could this be an E fuel adjustment?

It averages the two injector pulse widths because they may not be the same. As for the fuel density, not sure where that value came from. But you'll find a wide range of values depending on where you look.

EagleMark
June 3rd, 2013, 04:16 AM
Shouldn't that be "(({GM.IBPW1}+{GM.IBPW2})" notice 1 and 2... the origianl is 1 and 1... ?

ferocity02
June 3rd, 2013, 04:23 AM
Shouldn't that be "(({GM.IBPW1}+{GM.IBPW2})" notice 1 and 2... the origianl is 1 and 1... ?

Good catch, typo :)