# ## Forums

#### Guest Welcome Guest, posting in this forum require registration.

 Pages: Author Topic: Fuel level
rsfjr87
Member
Posts: 15  Fuel level on: November 30, 2017 (GMT)

Hello all,

The thing that I love about Torque is the ability to add custom pids and formulas.

One thing that I miss or I just don’t know how to do, is related to the fuel level.

The fuel level button only allows us to fill or empty the tank by 25% steps.

At least, whenever I go to the gas station, I fill my tank in liters (or gallons), not percentage.

So I am wondering, is there any way, by using OBD commands or a virtual PID to solve that issue?

For example,
R = Fuel remaining in my Tank. (% from [ff1271])

T = Total capacity of my Tank. (liters, from the profile or user input)

F = filled volume at gas station. (liters, user input)

Whenever I fill the gas, I would enter the gas volume, F, so that:

R = 100*((((T*R)/100) + F)/T)
Or
R = (100*F + R*T) / T (%)

So that the PID is updated with the filled volume.

Another interesting thing is to update the fuel costs, also.

C = current fuel cost per volume (pid?, the one that provides the \$/mile)

N = Filled gas cost (eg. I spent when I went to the gas station)

C = (C*(R*T/100)^2 + N*F)/(R*T/100)
(so that the program calculates the actual gas price inside the tank)

For example:
My tank has 40 liters of capacity.
I have 20 liters of gas, that I have paid

T=40
R =50%
C= 15/20 = 0.75 \$/liter

Then I stopped by another gas station,
and filled 10 more liters at the cost of (yes I was dumb)

N = 25\$
F = 10 liters

Cnew= (0.75*20*20 + 10*25)/30
Cnew = 18.33 \$/liter

As for the R
Rnew = (100.10 + 50*40)/40 = 75%, after filling the gas

 Pages: 
WP-Forum by: Fredrik Fahlstad, Version: 2.4