Making a non-linear resistance look linear

Jan 31, 2010 29 Replies

Hi,



I'm planning to fit a fuel tank with a contents gauge. The sender that the tank manufacturer will put in is essentially a variable resistor, which reads 180 ohms when the tank is full, and 0 ohms when it is empty with, presumably, a linear resistance in between. There is a gauge that connects to this - presumably an ammeter and a means of passing current through the sender?



My problem is that the tank is not square, and so the height of the sender float is not directly proportional to the amount of fuel actually remaining. More unfortunately, it's actually "the wrong way round", so that when the gauge reads half-full there will actually be significantly less than half a tank of fuel left - perhaps a quarter or less.



I've wired up a couple of PICs and so on in my time, but have very little experience with basic analogue electronics. Is it possible to build a passive circuit (perhaps a network of resistors?) that will "convert" the resistance of the sender so that it's proportional to the amount of fuel remaining rather than the height of the sender float?



Some sketches of the tank here:

formatting link
Note that the lame attempt at isometric projection actually makes the tank seem squarer than it is - the slope is in fact very pronounced indeed, it's basically wedge-shaped in all three dimensions, plus a sneaky little change of gradient in one side.



This shape means the perfect correction is probably quite complex - but all I really want to do is pin 3/4, 1/2, 1/4 in their right places. I can pour water through the tank before installing it, to measure the "observed" resistance at those points.



Note the "orientation" of the sender is indeed 0 ohms when empty - I believe the other way round is normal in the US but I haven't made a mistake! I could special-order the American sender if required, but it would then make my gauge read backwards unless flipped again as part of the circuit.



Thanks for any help or suggestions,



Pete


On a sunny day (Sun, 31 Jan 2010 23:09:51 +0000) it happened Pete Verdon wrote in :

sender -> [PIC, ADC in, lookup table, PWM DAC out] -> analog meter.

"Pete Verdon" wrote in message news:hk52k0$e7g$ snipped-for-privacy@news.eternal-september.org...

You need to do a little curve fitting, maybe X^2 or something similar. Calculate the volume of the tank at 4 or 5 levels and plot the volume on a graph (Excel). Then plot the output of the sensor, etc... You may not need a pic, but it does make a lookuptable easy. A log amp comes to mind, as does Temperature stability.

Cheers

If you can generate a graph of resistance versus liquid volume, some sort of circuit could likely be created.

What sort of meter will be used to display the contents?

John

Calculate? Naaaah! Use alcohol as a test fluid and add a quart at a time, plotting the sensor output. Then curve fit, mostly likely easily done piece-wise-linear. Analog piece-wise-linear can easily be done with NO TC effects. ...Jim Thompson

| James E.Thompson, CTO | mens | | Analog Innovations, Inc. | et | | Analog/Mixed-Signal ASIC's and Discrete Systems | manus | | Phoenix, Arizona 85048 Skype: Contacts Only | | | Voice:(480)460-2350 Fax: Available upon request | Brass Rat | | E-mail Icon at http://www.analog-innovations.com | 1962 | I love to cook with wine. Sometimes I even put it in the food.

Yes, I plan to do this once I've had the tank manufactured, hopefully in the next couple of weeks. Using water though - I don't have access to 40 or 50 litres of alcohol! (The tank will have an inspection hatch, so I can dry it out afterwards and avoid contaminating my diesel.)

I don't quite understand this, but do you mean that a simple analogue circuit is feasible for this problem? If so, that's good news!

Pete

Thanks, but I'm hoping to avoid using a PIC. It would be possible, but I don't own a programmer, and it's a very long time indeed since I did any C or Assembler. Having a processor running continually just to make the fuel gauge work also seems like overkill to me.

Pete

Thanks - I guess I'll do a test when the tank arrives, and report back with some numbers to work from.

I don't really know - I plan to reuse the gauge from the old (square) tank. I presume it's an ammeter, and measures the current that's flowing through the sender resistance at a known (or more likely, assumed with varying accuracy) voltage.

Pete

Old meters probably are already nonlinear to compensate for the old tank and sender. You'll have to characterize the meter, too!

John

The old bi-metal gauges were like that, EXCEPT that many GM products used two-coil gauges (orthogonal drive, no springs)... but then that makes them sinusoidal, still needing correction for a (substantially) linear sensor ;-) ...Jim Thompson

| James E.Thompson, CTO | mens | | Analog Innovations, Inc. | et | | Analog/Mixed-Signal ASIC's and Discrete Systems | manus | | Phoenix, Arizona 85048 Skype: Contacts Only | | | Voice:(480)460-2350 Fax: Available upon request | Brass Rat | | E-mail Icon at http://www.analog-innovations.com | 1962 | I love to cook with wine. Sometimes I even put it in the food.

A cut trick is to use an LM324 or other op-amp that doesn't mind being crammed against the rails and having a large input voltage. I will use a simple case as an example:

Input ----+--------------------------/\/\--------- ! ! ----!+\ ! ! >---+-------------------/\/\----+---- ---!-/ ! ! ! 2V--/\/\----+---/\/\---

All resistors 10K

From 0 to 1V the gain of the system is 1/2. Above 1V the gain increases to 1.5

If you use a rail to rail op-amp, you can have the gain decrease again at some higher voltage. The result can be a nice straight line estimate of the curve you need.

I doubt it - the gauge is a standard part not meant for any particular tank. The old tank was custom-made (but a rectangular shape, so without the linearity issue) and the gauge would have been bought off the shelf.

I think most people using these just tolerate any minor non-linearity, but the shape of my new tank means the effect would be pretty extreme.

Pete

You are absolutely right. An 8051 would be much better. :)

You can make interesting PWM actions with a CMOS 555 chip too.

You'll still need to measure the meter's coil resistance and the full-scale deflection voltage or current. As long as you're doing that, you may as well take a few more points.

John

"Pete Verdon" wrote in message news:hk54j9$u1c$ snipped-for-privacy@news.eternal-september.org...

Other constraints may come in. How big can it be? How much power? An op-amp running constant is going to burn more than a few mA. CMOS amp less (use big resistors in the feedback circuit!). PIC will consume somewhere inbetween. The analog solution will use at least an op-amp and a big mess of diodes and resistors -- complexity-wise, it's simpler, but it sure ends up taking a lot of board space. On the other hand, you can drop in a PIC and use basically no support hardware.

Tim

Deep Friar: a very philosophical monk. Website: http://webpages.charter.net/dawill/tmoranwms

Table lookup on the digital side, of course.

Zero cost and accuracy beyond analog.

Many thanks, Don Lancaster voice phone: (928)428-4073 Synergetics 3860 West First Street Box 809 Thatcher, AZ 85552 rss: http://www.tinaja.com/whtnu.xml email: don@tinaja.com Please visit my GURU's LAIR web site at http://www.tinaja.com

Is it practical for you to re-scale the meter face?

Aside from that, if the tank makes the sensor resistance severely non-linear, you might want to use comparators to switch in/out resistors, depending on the tank content level.

Ed

A cut trick is to use an LM324 or other op-amp that doesn't mind being crammed against the rails and having a large input voltage. I will use a simple case as an example:

Input ----+--------------------------/\/\--------- ! ! ----!+\ ! ! >---+-------------------/\/\----+---- ---!-/ ! ! ! 2V--/\/\----+---/\/\---

All resistors 10K

From 0 to 1V the gain of the system is 1/2. Above 1V the gain increases to 1.5

If you use a rail to rail op-amp, you can have the gain decrease again at some higher voltage. The result can be a nice straight line estimate of the curve you need.

This is indeed a very cute circuit, because no diodes need to be used, but it puts a sharp knee, which would be more appropriate for a step in diameter, not the continuous function he describes. Anyway, maybe the meter itself is already non linear for the original tank, and together it can be twiddled to a satisfying fit, doesn't need to be too accrate. Ciao Ban Apricale, Italy.

On a sunny day (Sun, 31 Jan 2010 23:46:16 +0000) it happened Pete Verdon wrote in :

PIC programmers can be made with about 3 $ in parts, I use one like that. A small PIC uses less then 1.5 mA for an application like this. Any analog solution will cost more parts then the programmer + PIC together.

What about a non-electric gauge, such as a pneumatic system with a 'U' tube?

In case you have not come across the system, I have drawn a diagram at:

formatting link

A hand-operted air pump is used to fill the tubing with air until it bubbles out from the dip tube in the tank. If the fluid in the manometer is the same density as that in the tank, the height 'h2' will be equal to the height 'h1'. If the two fluids have different densities, 'h2' and 'h1' will be related by the density ratio.

When you fill the tank for the first time, calibrate the manometer as you go. The calibration will hold good for all time and the system will work with no need for batteries until the pump washer needs replacing (about once every 25 years and cheaper than a battery).

~ Adrian Tuddenham ~ (Remove the ".invalid"s and add ".co.uk" to reply) www.poppyrecords.co.uk

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required