The Design
Here is my solution to Scopeman's Jeep Fuel Gauge question. I present it here to show the technique of using EXCEL for modeling the fuel tank sender, and using LTSpice to test a proposed circuit to drive the gauge from the sender.
Look at the EXCEL Spread sheet.
Column A is the voltage across the Sender with the Sender connected to an 1126 Ohm resistor fed from a 10.0V DC power supply. Scopeman posted the voltage out of this circuit as fuel was added one gallon at a time. The Row number in the spread sheet is gallons added, 1 - 13. As was pointed out, the voltage vs gallons plot is quite non-linear, and is not useful for driving the Fuel Gauge directly.
I know from previous experience that most automotive fuel gauges are just a DC milli-amp meter wired in series with the fuel tank sender. Such a fuel gauge is usually fed from a regulated DC voltage derived from the car's battery voltage. This suggests that the current through the sender and meter is proportional to the float position, so I set about to determine the sensor current vs gallons added from Scopeman's posted data.
First, I used the spreadsheet to calculate the Sender resistance (Rs) vs gallons. The Rs is calculated this way:
Vs = 10.0*(Rs/(1126+Rs)) [the familiar voltage divider equation]
Rearranging:
1126*Vs + Vs*Rs = 10*Rs
1126*Vs = Rs(10 - Vs)
Rs = 1126*Vs/(10-Vs)
Col. B is Rs calculated from each measured Vs (col A).
Next, I wanted to know what the current through Rs would be if it were fed from a constant voltage. Wanting to keep the current through the sender to a low value, like less than 10mA, I choose 0.1V as the applied voltage. In col C. I calculate the current through Rs with 0.1V applied across Rs, so Is = E/Rs = 0.1/colB.
Next, I plotted the calculated sender current Is vs gallons, and as I expected, the data points are quite linear. I used the TRENDLINE feature in EXCEL (least square error regression) to fit a
y=mx+b straight line through those points. This is shown as the
black line in the plot. Also shown are the
m and
b coefficients of the fitted line as reported by EXCEL.
I then created col. E which is the linearized calculated current LIs through the sender based on the
y=mx + b line as determined above. Finally, the linearized sender resistance is LRs = E/I = 0.1/LRs. The final equation simplifies to:
LRs=100/(gal*0.4516+0.9337)
The calculated sensor resistance (
blue trace) and the linearized sensor resistance (
purple trace) are superimposed on the plot.
Since I want to simulate Scopeman's circuit in LTSpice, I need a parameterized model of Rs vs gallons that I can use in the schematic. To validate the model derived above, I created this simple circuit (SenderI.asc) to simulate and compare the derived model for the sender to the calculated sender resistances derived from measurements.
For you LTSpice fans, note the use of the parameter "gal" to sweep the two versions of Rs. No surprise that these look just like the EXCEL plots.
So, if the current through the sensor is proportional to gallons in the tank, how do you make a circuit which makes a voltage proportional to the current, which is what we need to drive Scopeman's B17 fuel gauge?
He previously posted data which shows that the gauge reading is more-or-less proportional to the voltage input to the gauge. If we can make the gauge input 3.74V it will display full (430gal).
SenderV.asc is a simplified schematic of an op-amp current-to-voltage converter which does this. A fixed bias voltage of 0.1V is applied to the non-inverting input of the op-amp. Because the op-amp drives its output so as to make the voltage difference between the non-inverting input and the inverting input close to zero, this applies the assumed 0.1V to the sender, too. The sender current (created by the 0.1V across it) also flows in R2, making
Vout = 0.1 + R2*Is.
Look at the plot. Note that with R2 = 650 Ohm, V(out) is almost ready to apply to the gauge. Note that the R2 determines the slope, so we can tweak R2 to fit the full end of the range. However, there is an offset that must be dealt with.
Because of the way I modeled Rs, Is can never go to zero, so the offset is slightly more than the 0.1V implied by the equation above.
The solution to the zero offset is to inject a small current into the inverting input, adjusted to get the desired gauge reading at 1 gallon, and then tweak R2 a bit more to get the 3.74V into the gauge when tank is full.
The circuit depends on having a fixed voltage of 0.1V across the sender, and having a a fixed offset current into the inverting input on the op-amp. To create these from the Jeep's Battery, which will vary from ~12V to 14.5V depending on how fast the engine is running, I include a LM431 shunt-regulator.
Two trim-pots set the 1 gallon and 13 gallon indication on the meter, respectively. First, preset both pots to the middle of their range. Substitute a 70 Ohm resistor for Rs, and set the ZERO pot to get a 50 gal reading on the gauge. Then substitute a 15 Ohm resistor for Rs and adjust the GAIN pot to get 430 gal on the gauge. The adjustments will interact a bit, so go back and forth between the two resistors/adjustments a couple of times. You are effectively fitting the circuit output to the gauge at two points, full and nearly empty.
Note, as shown, the gauge is being operated directly off the battery voltage. If normal battery voltage fluctuations cause a problem, then I have a design for an ultra-low drop-out voltage regulator to run it off a fixed 12.0V. Scopeman, You will have to determine if that is necessary.