# Math function for fuel consumption and Distance to Empty?

## Recommended Posts

So I have been thinking about this for a while:  I would love to be able to output to a CAN gauge instantaneous MPG as well as some averaging of such, as well as possibly with inputing a tank size variable provide a calculated value of distance to empty.  It is these little things that make new cars feel new and adding something like this to an old car would be fantastic.

Given:
Driven wheel speed in MPH
Inst. Fuel consumption in cc/min
1 gallon = 3785.41 cc
1 Hour = 60 min

(Driven wheel speed/Inst. Fuel cons.)*(3785.41/60)= mile/gallon = mpg

or

It would be nice to provide some accumulated average MPG as well, but I'm not sure the averaging function would work well for that.  Any thoughts?

Also distance to empty once you know miles per gallon seems fairly straight forward or even instantaneous fuel consumption given a know fixed volume of fuel.  Perhaps fuel level sensor input would automate this value....

##### Share on other sites

Have a look at the current firmware, most of that is already in the virtual fuel tank functionality (chassis and body menu)

##### Share on other sites

• 3 years later...
On 12/9/2020 at 9:33 AM, koracing said:

So I have been thinking about this for a while:  I would love to be able to output to a CAN gauge instantaneous MPG as well as some averaging of such, as well as possibly with inputing a tank size variable provide a calculated value of distance to empty.  It is these little things that make new cars feel new and adding something like this to an old car would be fantastic.

Given:
Driven wheel speed in MPH
Inst. Fuel consumption in cc/min
1 gallon = 3785.41 cc
1 Hour = 60 min

(Driven wheel speed/Inst. Fuel cons.)*(3785.41/60)= mile/gallon = mpg

or

It would be nice to provide some accumulated average MPG as well, but I'm not sure the averaging function would work well for that.  Any thoughts?

Also distance to empty once you know miles per gallon seems fairly straight forward or even instantaneous fuel consumption given a know fixed volume of fuel.  Perhaps fuel level sensor input would automate this value....

How did you get on with this, im wanting to do something with the virtual fuel tank and distance to empty that i can stream to a powertune digital display

##### Share on other sites

It is fairly well explained in the help file.  What do you need help with?  How do you want to set or reset the amount of fuel in the tank when filled?

##### Share on other sites

i

I managed to get the fuel tank level in litres from virtual tank into the display. I reset it via direct input 3 which is connected to ignition on button ( power hold system) and when tps is over 98 percent.

Effectively hold pedal down and turn it on. which resets the fuel to full tank.

Any pointers to get the distance to empty to work in power tune display?

i have speed in the lf wheel speed,  a custom math block?

##### Share on other sites

If you are wanting to do the distance to empty maths yourself it would be something like the below:

Note that it will be distance in km unless you change the 0.01 to 0.0062 to get miles.

##### Share on other sites

@Vaughan,

In a Real Wheel Drive application with a single speed sensor, the Helpfile indicates to configure - at least for a Front Wheel Drive with single input - the following:

To calculate the Accumulated Fuel/Distance above, the Helpfile indicates a Driven Wheel Speed input is required:

Can I configure Driven Wheel Speed to the same GP Input as Driving Wheel Speed..? or no..
With the above Math Block the ECU is currently calculating 'INF' due to the Accum Fuel/Distance calculating 0L/100km

Thanks

##### Share on other sites

Driven and driving can both be assigned to the same DI input yes.

##### Share on other sites

@jdniss did you get it to work?

##### Share on other sites

On 6/10/2024 at 8:30 PM, HarryBeron said:

@jdniss did you get it to work?

hey @HarryBeron, it looks to have worked, yes - thanks @koracing.

I forgot to enable the ECU log parameter and I only verified the Math value output on the Dash - however there was no value output at all prior to enabling Driven Speed - so the change looks to have worked as intended.

Still unsure whether the setting change will cause any adverse effects elsewhere as its not mentioned in the Helpfiles - but no issues so far.

##### Share on other sites

20 minutes ago, jdniss said:

Still unsure whether the setting change will cause any adverse effects elsewhere as its not mentioned in the Helpfiles - but no issues so far.

no issue with having driven and driving set to same speed input unless you are using features like traction control which require the two to be differentiated

##### Share on other sites

On 6/11/2024 at 10:33 AM, jdniss said:

hey @HarryBeron, it looks to have worked, yes - thanks @koracing.

I forgot to enable the ECU log parameter and I only verified the Math value output on the Dash - however there was no value output at all prior to enabling Driven Speed - so the change looks to have worked as intended.

Hey, just to follow this up @Vaughan, @HarryBeron - Distance to Empty isn't really working as expected - I suspect I have a calculation error somewhere.

The ECU is still reporting a calculated '0' value after 2-3 days (just to rule out the "Math Blocks only show historic data" question), despite the other parameters being populated.

On 6/6/2024 at 2:10 PM, Vaughan said:

If you are wanting to do the distance to empty maths yourself it would be something like the below:

Note that it will be distance in km unless you change the 0.01 to 0.0062 to get miles.

Oddly the Dash is showing a fixed '75' value for Math Block 8 regardless of the Fuel Left and Accum Fuel/Distance values - so suspecting this is also a divider or multiplier issue on my CAN stream.
~ Though with the Math Block 8 reporting a '0' value at least in the Log, I'm not entirely sure what RealDash thinks is being transmitted..

##### Share on other sites

Is it possibly a resolution issue where you're commanding only 1 decimal place, but multiplying by .01 in your equation?  Anything resulting in a/b being less than 1 would be 3 decimal places out.

##### Share on other sites

Got my maths wrong, just tested it on the bench and should be 100*a/b

or 62*a/b if you want it in miles till empty

##### Share on other sites

Hi i had tryed this one, using math block 4.

Tell me if im wrong??

##### Share on other sites

All working here now - both in PCLink and output to RealDash via Math Block 8 - thanks @Vaughan @koracing.

The updated math calculation sorted the Distance to Empty value,
and I'd stuffed up the CAN Stream output which was why Math Block 8 was reporting a weird parameter in RealDash last week.

I'd upload a picture, but I'm out of Storage Space on the account

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.