2
\$\begingroup\$

I have a fuel tank sensor that reports the remaining fuel with a resistance between 10 ohms (empty) and 180 ohms (full). I want to read this value using the Analog In of an Arduino (or ADS1115, not a big difference). The voltage range of the digital input is 0-5V. The obvious solution I came up with is the following:

schematic

simulate this circuit – Schematic created using CircuitLab

Now this has two big problems: First, the measured range is only between 5V/190 * 180 = 4.7V and 5V/20 * 10 = 2.5V, which uses less than half of the resolution of the ADC. And second, when the tank is empty, the resistance chain has only 20 ohms, resulting in a 250mA leak current. If my math isn't completely rusted, using a larger value for R1 solves problem two, but worsens problem 1.

How do I read the value of the sensor, so that the range of the analog in has the best possible resolution, and avoid heating everything up?

Notes:

  • It appears that the sensor must measure to ground, so one end must be at GND. If helpful, this could eventually be relieved.
  • I do have a bunch of resistors, capacitors and even transistors available if that helps. I do not have any op-amps (and getting one would be difficult at this time).
\$\endgroup\$
12
  • 1
    \$\begingroup\$ This really isn't that big of a deal: which uses less than half of the resolution of the ADC \$\endgroup\$
    – Andy aka
    Sep 26, 2021 at 13:32
  • \$\begingroup\$ Maybe yes, but if I use 1k (which reduces the current to 5mA), the range is reduced to about 0.7V. \$\endgroup\$
    – PMF
    Sep 26, 2021 at 13:39
  • \$\begingroup\$ The more important part is what's your expected fuel tank level resolution? Maybe, half the resolution of the ADC will suffice for you. \$\endgroup\$
    – Long Pham
    Sep 26, 2021 at 13:44
  • 2
    \$\begingroup\$ Ditching ADC and using RC time constant (fixed C, variable sensor R) might solve both resolution, and power dissipation problems. Some clever, innovative software is likely required. Microcontrollers are very adept at measuring time spans. \$\endgroup\$
    – glen_geek
    Sep 26, 2021 at 15:22
  • 1
    \$\begingroup\$ If you can get it to output a proper signal-conditioned 4-20mA that would be far preferable since most of the hard work will be done for you. \$\endgroup\$ Sep 26, 2021 at 17:14

3 Answers 3

4
\$\begingroup\$

Typically for this sort of thing you might want to pick a resistor value somewhere near the middle of the range, perhaps 100 ohms. That will limit the current to about 45mA and the dissipation in the 100 ohm resistor to about 200mW.

That will give you an ADC input from 9.1% of range to 64% or about 55% of the full scale range,which is probably more than good enough even with the on-chip Arduino ADC let alone the TI 16-bit outboard ADC, considering the crude nature of such sensors, with a 180 ohm resistor. The crudeness is masked by slow indicator response on the dashboard and a lack of fine divisions on the meter scale. Using a resistor near mid-range will also make the nonlinearity as a function of resistance less pronounced (the nonlinearity as a function of fuel tank contents may be another matter- depending as it does on the mechanical construction and shape of the fuel tank).

If you are insistent on using more ADC range you can buffer, filter and offset/add gain with an op-amp but I doubt it has much merit.

However there is an unstated issue here- unless there is a separate wire back from the sensor for ground (requiring a more complex differential measurement), the ground potential may vary significantly from ground at your circuit due to various return currents such as tail lights, rear wiper motor, turn signals etc. passing through the chassis. This is perhaps not so serious with crude measurements on a 12V circuit but at 5V is worse and it gets worse again for reduced sensor current.

Presumably you're rather more interested in the reading as the sensor resistance approaches 10\$\Omega\$, which is where the effect will be more significant.

\$\endgroup\$
3
  • 3
    \$\begingroup\$ Yes, absolutely the most important thing is that I don't run out of fuel. The ground wire is separate. This is a boat with a fiberglass hull, pretty bad to use as a common ground :) \$\endgroup\$
    – PMF
    Sep 26, 2021 at 16:37
  • 1
    \$\begingroup\$ I'm +1 this answer because it addresses the question about approaching the low-end fuel value. I think this is very important. In this case, the better idea is to let the resistance determine a collector current and to use the base-emitter voltage (after gain and offset adjustment) as the means by which the gauge operates, linearly. \$\endgroup\$
    – jonk
    Sep 27, 2021 at 5:25
  • \$\begingroup\$ Voting for this solution because 55% of 10 bits should be plenty enough, specially if using proper software filtering. You could also throw in a capacitor to filter out electrical noise and have a cleaner ADC input. \$\endgroup\$ Apr 20, 2022 at 8:57
3
\$\begingroup\$

Consider feeding the meter with a constant current source. This will give you a linear voltage relationship with the pot angle (but remember that the tank cross-section may not be uniform so this has to be taken into account).

schematic

simulate this circuit – Schematic created using CircuitLab

Figure 1. A constant current source consisting of Q1, Q2, R1 and R2. (The meters are only to display the simulation results.)

How it works:

  • R1 biases Q1 on and current starts to flow through R2, Q1 and R3 (the level sensor).
  • When the voltage across R2 reaches about 700 mV Q2 starts to turn on and steals the bias from Q1. This prevents it turning on any further and so limits the current to 0.7/R2.

The simulation shows that with R2 = 47 Ω you'll get about 15 mA through the sender across the full range and that you'll get > 2.5 V for the ADC. You can play with the simulator above to vary R2 but give yourself some safety margin for reliable operation.

\$\endgroup\$
3
  • \$\begingroup\$ I'll consider this, but need some time to actually implement it. \$\endgroup\$
    – PMF
    Sep 26, 2021 at 16:31
  • \$\begingroup\$ Hit the simulation link below the schematic. You can do a DC sweep while varying R3's resistance from 10 ohms to 180 ohms to satisfy yourself that it will work. The PNP transistors are the CircuitLab defaults. Any small PNP should work at 15 mA collector current. \$\endgroup\$
    – Transistor
    Sep 26, 2021 at 17:34
  • \$\begingroup\$ @MathKeepsMeBusy I've found a workaround and updated this question with the workaround that keeps the meters intact. I've also answered the [electronics.stackexchange.com/q/588720/268467](question) you referred to. Feel free to delete the comments relating to this as they are somewhat outdated now. \$\endgroup\$ Apr 19, 2022 at 8:05
1
\$\begingroup\$

I do have a bunch of resistors, capacitors and even transistors available if that helps. I do not have any op-amps [...]

Your wish is my command :)

Not the swiftest op-amp in the world, and not particularly exciting, but does the job. Breadboarded, seems to work. The discrete implementation could benefit from either higher supply voltage or a cascode on Q3, Q7, Q8 to boost the DC gain. Input current is a couple or dozen nA. V2 is a LED + a top-side 100uA current source. Current consumption on the breadboard is below 4mA even when hot.

The sensor is driven with 1mA. Voltage gain is 18x, and internal compensation seems unnecessary at this gain. Output range is about 0.3V to 4.2V.

I didn't check anything else - that will depend somewhat on layout, transistor choices, etc. Generally, any jellybean transistors will work, but there's a benefit to higher gain and lower gain spread. Since there are many operating currents, for super precise DC operation it's necessary to match at least some transistors at their operating current. Q20/Q23 are at a slight disadvantage since their current depends on the beta of Q21/Q22 - matching them pairwise would be beneficial for offset voltage tempco. The cascode current source is not particularly match-sensitive by design. The cascode pair Q31 and Q32 would benefit from matching. The output stage is LM358 flipped upside down.

schematic

simulate this circuit – Schematic created using CircuitLab

\$\endgroup\$
4
  • \$\begingroup\$ Wow, thanks. That's an interesting approach. I'm not able to test anything here by now (since the boat is still in the yard), but I'll need to get this done when the season begins. \$\endgroup\$
    – PMF
    Apr 20, 2022 at 4:55
  • \$\begingroup\$ @PMF If you actually want to use this discrete implementation for real, I'll tweak it a bit to make it more worthy of boating, get a PCB for it and assemble two pieces, one for me, one for you, just for the fun of it :) Keeping in mind that it's absolutely ridiculous not to use a chip op-amp and call it a day - but hey, this is how they'd have done it in the late 60s probably if they had to. I don't have Rubylith but just for this will do the layout using dot-and-tape. Back then they'd have just slammed 15-20 mA through the sender and called it a day. I'm not that kind of a person, lol. \$\endgroup\$ Apr 20, 2022 at 5:06
  • \$\begingroup\$ The last I tried was an approach mentioned in the comments at the top using a current source, but the results where not so good. However I first need to find out how much resolution that sensor actually provides to estimate the required effort for the ADC. \$\endgroup\$
    – PMF
    Apr 20, 2022 at 6:03
  • \$\begingroup\$ Besides, a breadboard works surprisingly well. I have a large breadboard full of electronics with different ICs and sensors installed in a box and that has not made me the slightest problems so far. The connections in a breadboard are probably more stable than what my soldering joints would be.... \$\endgroup\$
    – PMF
    Apr 20, 2022 at 6:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.