|
Oh boy, a classic
control problem. You don't see many presented so clearly. Let's
assume the problem is exactly as you presented it. I mean there
is no sticking in the mechanism, no electrical noise, the little
float is not sinking. If all that is true, we can think of the
problem and solution as a classic PID control.
The classic PID control
is a closed-loop system and has a set point as an input along
with an error signal derived from previous readings. At the
end of this you will find references to web articles that talk
about this classic PID control.
Your fuel gauge readout
is an open-loop version of those systems. Let's think of your
input signal as a combination of information (signal) and noise.
The information is the DC level of fuel in the tank. Ignoring
the noise for the momen,; how does the signal behave? Well,
the fastest it rises is when you fill the tank and the fastest
it falls is when there is a leak. The normal fall time for a
car is full to empty in 400 miles or 8 h. Very, very slow. The
fill time is about 2 to 3 min,. Still, very, very slow. A detectable
leak (or pilferage) is about the same as filling.
Next let's try to
gather some real-world data. When you drive in to fill up your
car and shut the engine off, the old reading is saved on the
gauge. After fill up when power is applied, that fuel gauge
rises ever so slowly. Let's say it goes from empty to full (0%
to 100%) in one minute. Make your own tests and change any of
my assumptions.
I believe that a simple
low-pass filter will do the job, just an 'R' and a 'C'. What
is the digital equivalent? Well, it's the average of all the
input readings. That's impossible to achieve since the total
would become a large number, as would the number of readings.
So another similar approach is:
Next Reading = Factor
×Last Reading + (1-Factor) ×New Input
Factor 0.1 is for
real slow response. I've attached a spreadsheet where I've got
a signal and I've added some noise and then I applied this filter.
spead1.xls
I plotted the results.
You can change the factor and change the noise type and see
your results. With a factor of .1, I get to a good reading in
16 samples.
The last issue is
sample rate. How fast is necessary? Well, you only need to sample
fast enough to capture your information (basically DC in this
case) and no need to go fast enough to capture the frequency
of the noise. The tradeoff is faster response on the gauge verses
more noise getting through. Faster sampling will mean a lower
factor on the filter for the same results.
Well, I didn't give
you the "'answer" but perhaps you can use these tools
to get there on your own. I think it would be interesting to
see what your testing exposed and what numbers you finally decided
upon.
The PID control is
well known and here are a number of links I found that will
explain the math in more detail than I can in this forum. A
comparison between various available controls
http://www.expertune.com/
A page posted by John
Shaw that looks informative.
http://ww.jashaw.com/
Especially this one
http://www.jashaw.com/pid/description.htm
Tutorial on PID loops
lansce.lanl.gov/lansce8/Epics/dbase/recref/Recordref-28.html
In PID loops, each
of the terms have a gain associated with them:
K(P) is the gain
for the Proportional loop.
K(I) is the gain
for the Integral loop.
K(D) is the gain
for the Derivative loop.
By adjusting the
magnitude of these gains you can extract the response you desire.
George Martin
 
|