Author Topic: capacitive fuel gauge for petrol  (Read 2522 times)

Offline angus

  • Jr. Member
  • **
  • Posts: 57
  • Country: gb
capacitive fuel gauge for petrol
« on: January 21, 2018, 08:14:52 AM »
hi
i am trying to make a better fuel gauge for my weekend car
it currently uses 9 reed switches, and a floating magnet, with an arduino controller damping out the sloshing
its not the best

have stolen the idea from here for a capacitive probe
http://www.instructables.com/id/Paramotor-Fuel-Sensor-and-Gauge/


have built a rough prototype of the probe

3/4" bore tube with an 8mm rod

roughly 9" long

get according to my one multimeter with capacitance, about 16pf empty and 32pf full

dunno why but i expected the cap to go down as the fuel level went up

do you think  thats a big enough change ?

if i go larger on the center rod, the values will increase, but will the percentage change (give me a larger swing ?)


eskoilola

  • Guest
Re: capacitive fuel gauge for petrol
« Reply #1 on: January 21, 2018, 01:05:44 PM »
The capacitance change is big enough.

What is the challenge here is the capcitance itself - it is a  fairly low value. You better put the arduino right on top of that capacitance tube to eliminate any stray capacitances as far as possible.

And yes, the capacitance should go up as the gasoline replaces air as dielectric. Actually that is not air, it is saturated gas vapor.

The capacitance is also affected by tempearature at some degree. The author recommends using a parallel capacitor that has the opposite temperature coefficient. This works but at the same time it makes the capacitance change that much smaller. A better solution is to measure the temperature and programmatically correct the reading. A simple NTC can be used for temperature measurement.

The mechanical construction is a little bit wobbly. The capacitance is affected by the distance of the electrodes and if the middle rod bends, You will get a different reading. It might be a good idea to have some support for the rod in between as well. The construction shows support only at the ends.

Making the capacitor larger will not impact the relative capacitance change. However it will increase the base capacitance. The base capacitance is diretrly proportional to the surface area of capacitor electrodes. If You double the area You will double the capacitance.

Offline angus

  • Jr. Member
  • **
  • Posts: 57
  • Country: gb
Re: capacitive fuel gauge for petrol
« Reply #2 on: January 21, 2018, 02:47:38 PM »
Mine is a lot more mechanically robust.  I did have another go with a larger center tube of 15m. That gave me roughly 50 to 130pf
The arduino will be right on top of the probe.

I had considered temperature compensation with  an ntc  that will depend how much it changes. It may be useable without, time will tell

Offline PK

  • Sr. Member
  • ****
  • Posts: 369
  • Country: au
Re: capacitive fuel gauge for petrol
« Reply #3 on: January 21, 2018, 04:57:54 PM »
Might be easier to build an oscillator that uses the sensor then count cycles..... (if you're not already doing that).

Offline angus

  • Jr. Member
  • **
  • Posts: 57
  • Country: gb
Re: capacitive fuel gauge for petrol
« Reply #4 on: January 22, 2018, 11:36:06 AM »
to be honest, am not entirely sure how the arduino is doing its black magic!!
about to start soldering now!

Offline AdeV

  • Madmodder Committee
  • Hero Member
  • *****
  • Posts: 2071
  • Country: gb
Re: capacitive fuel gauge for petrol
« Reply #5 on: January 22, 2018, 01:38:56 PM »
I'm not 100% sure with the library he's using, but it will probably work like this:

The fuel sensor pin D5 is driven high. This starts to charge the capacitor (actually the sensor) through the 1MOhm resistor (i.e. slowly). After a certain period of time, it's full, and current starts to flow to the other pin it's connected to, D6. The Arduino counts the number of times it goes around in a tight loop before D6 goes high. The count is effectively a period of time. This time is then divided/multipled/whatever to produce a range 1-10 which the Arduino then displays on the LEDs. After each "read", the pin goes low, and the charge in the capacitor is dumped to earth.  All of this happens so quickly, he's actually taking 200 readings & averaging them, for both sensor & compensator, this in theory gives a more stable reading (in practice, I've found the readings don't jump about too badly; but that's on a deskbound setup, not in a moving vehicle).

The temperature compensation works the same way. In theory, the capacitor in free air should always charge in the same number of cycles. If the temperature drops & therefore the charge takes longer (assuming it's that way around), then the % difference can be applied to the fuel sensor, thus removing any temperature change error from the sensor reading.

I've done something similar for a touch-sensitive doorbell; that uses the fact that the human body is effectively a big capacitor, and when you touch the panel, its natural capacitance jumps up. This is a much easier application (since I'm only looking to detect the presence or absence of a human-sized capacitance), rather than trying to accurately read tiny differences...
Cheers!
Ade.
--
Location: Wallasey, Merseyside. A long way from anywhere.
Or: Zhengzhou, China. An even longer way from anywhere...
Skype: adev73

Offline awemawson

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 6424
  • Country: gb
  • East Sussex, UK
Re: capacitive fuel gauge for petrol
« Reply #6 on: January 22, 2018, 04:23:18 PM »
To improve the stability to eliminate the sloshing effect it's only necessary to average the last N readings, adjusting N to meet the practical circumstances.
Andrew Mawson
East Sussex

Offline Noitoen

  • Full Member
  • ***
  • Posts: 135
  • Country: pt
Re: capacitive fuel gauge for petrol
« Reply #7 on: January 22, 2018, 06:28:36 PM »
Long ago, I did some experiments on a RV a plastic  water tank. I used a couple of aluminium tape strips on the outside and the tank and to simplify the capacitance measurements, I used a NE555 chip as a variable oscilator dependant on the level and to read the frequency, a PIC microcontroller. It worked ok.

Offline PK

  • Sr. Member
  • ****
  • Posts: 369
  • Country: au
Re: capacitive fuel gauge for petrol
« Reply #8 on: January 23, 2018, 02:31:44 AM »
I'm not 100% sure with the library he's using, but it will probably work like this:
I concur.
The good systems have some kind of calibration routine too.

The challenge may be that the value of C is so small that the library struggles for resolution and is swamped by noise.

With a 16pF cap you can make a fairly stable oscillator in the 250KHz to 1MHz range, the counter input on a micro should easily run at those speeds. Gate it with an interrupt (if the uC doesn't have a gated counter) and you'll get good resolution...
All armchair speculation of course....

Offline AdeV

  • Madmodder Committee
  • Hero Member
  • *****
  • Posts: 2071
  • Country: gb
Re: capacitive fuel gauge for petrol
« Reply #9 on: January 23, 2018, 05:33:03 AM »
Long ago, I did some experiments on a RV a plastic  water tank. I used a couple of aluminium tape strips on the outside and the tank and to simplify the capacitance measurements, I used a NE555 chip as a variable oscilator dependant on the level and to read the frequency, a PIC microcontroller. It worked ok.

I found a circuit in an ancient Everyday Electronics magazine (well... 1980s anyway) which measured water level using 2 probes, to give you 3 readouts: Low, Medium and High.

My version of it is here: http://meddlingmonk.blogspot.com/2010/05/electronics-or-why-didnt-i-use-green.html

I presume, if one were skilled with analogue electronics, one could add intermediate levels as well to improve the resolution.
Cheers!
Ade.
--
Location: Wallasey, Merseyside. A long way from anywhere.
Or: Zhengzhou, China. An even longer way from anywhere...
Skype: adev73

Offline Bluechip

  • Madmodder Committee
  • Hero Member
  • *****
  • Posts: 1503
  • Country: england
  • Derbyshire UK
Re: capacitive fuel gauge for petrol
« Reply #10 on: January 23, 2018, 07:52:00 AM »
Not having spent much time sussing out this particular application, but there is a bargraph display ic which is essentially just a string of comparators with a variable set point.

LM3914

http://www.ti.com/lit/ds/symlink/lm3914.pdf

Dave
I have a few modest talents. Knowing what I'm doing isn't one of them.

Offline awemawson

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 6424
  • Country: gb
  • East Sussex, UK
Re: capacitive fuel gauge for petrol
« Reply #11 on: January 23, 2018, 08:34:34 AM »
That's the chip I used when I made the fuel gauge for my JCB 803 described here:

https://madmodder.net/index.php/topic,10749.150.html

Still working well  :thumbup:
Andrew Mawson
East Sussex

Offline angus

  • Jr. Member
  • **
  • Posts: 57
  • Country: gb
Re: capacitive fuel gauge for petrol
« Reply #12 on: January 23, 2018, 11:27:12 AM »
the display that is used in the kink i originally posted, wont be used.. the dashboard display already runs on 0-5 volt, and will continue to do so.... i will just be using the 0-5v output of the arduino

eskoilola

  • Guest
Re: capacitive fuel gauge for petrol
« Reply #13 on: January 23, 2018, 12:32:31 PM »
Another thing I have some doubts with these sort of applications are high impedances. One MEGA ohm (million ohms) resistance which is supposed to be charging a capacitor. There is also the input impedance of the analog comparator of the microcontroller which being in parallel with the capacitor adds up in a bad way. It does not take much moisture to make this circuit defunkt. Especially in a harsh environment.

An oscillator based circuit is much better as the impedance of it can be made really low - in the milliohm range. From my (foil)hat I draw a figure around 100Mhz. With this one could get very low impedance and convert all nearby radios into whistle boxes. Maybe better in the 16Mhz range. I suppose the counters in microcontrollers can handle that. Using overflow interrupt and another interrupt as reference it should be fairly simple thing to convert the frequency into a figure and go on from there.

Further more I do not understand the need for another IC for the leds. Most microcontrollers have enough IO pins to be able to light the needed leds as wanted.

Offline Noitoen

  • Full Member
  • ***
  • Posts: 135
  • Country: pt
Re: capacitive fuel gauge for petrol
« Reply #14 on: January 23, 2018, 03:28:49 PM »
After a little digging, I found a dedicated chip for the job. Maybe you cold get a sample  :thumbup:http://www.analog.com/en/analog-dialogue/articles/liquid-level-sensing-using-cdcs.html

Offline angus

  • Jr. Member
  • **
  • Posts: 57
  • Country: gb
Re: capacitive fuel gauge for petrol
« Reply #15 on: January 27, 2018, 09:20:03 AM »
Been looking into this more couple of the commercial versions of this seem to use a second capacitive tube as the reference... same dimensions but obviously no holes to let the fuel in
This is easily done for me mechanically, and would obviously keep the ref at the same temp and therefore the same amount of  drift
Thoughts?
This probe should be useable even if the arduino circuit proves unreliable

Offline hermetic

  • Sr. Member
  • ****
  • Posts: 299
Re: capacitive fuel gauge for petrol
« Reply #16 on: January 28, 2018, 02:09:49 PM »
  KIS?

Offline angus

  • Jr. Member
  • **
  • Posts: 57
  • Country: gb
Re: capacitive fuel gauge for petrol
« Reply #17 on: January 28, 2018, 04:00:33 PM »
No room as its a baffled tank, too deep for the swing on a conventional sender

Offline awemawson

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 6424
  • Country: gb
  • East Sussex, UK
Re: capacitive fuel gauge for petrol
« Reply #18 on: January 28, 2018, 04:25:52 PM »
JCB 803 sender is a long thin tube giving a varying resistance so should fit i'd think but there must be many available in this  style

Andrew Mawson
East Sussex

Offline hermetic

  • Sr. Member
  • ****
  • Posts: 299
Re: capacitive fuel gauge for petrol
« Reply #19 on: January 29, 2018, 03:40:49 PM »
Right, now I see the problem, I have seen one with a float that rose vertically on a shaft, twisting the shaft as it went, and operating a variable resistor, what about a vertical tube with reed switches inside and a rising magnetic float. alternately, could you not take a tapping from the bottom of the tank and read pressure  as contents? I am intrigued, what sort of car?

Offline angus

  • Jr. Member
  • **
  • Posts: 57
  • Country: gb
Re: capacitive fuel gauge for petrol
« Reply #20 on: January 31, 2018, 11:34:51 AM »
the one i have removed is a magnetic float and 9 reed switches, just as you decribed... problem is 2 fold, the float is not as buoyant in fuel as it would be in water, so only just floats, and i suspect sink on harsh cornering, even though it is in a dip tube with small hole top and bottom
also 9 reed switches leaves gaps between them, there isnt physical room in the tube for more, and it is sometimes a few miles before i sees the first switch on the journey
the arduino that currently runs it, has damping programmed in for corners, but obviously isnt so good on first switch on...

its in a lotus 7 style kit, so is quite often subject to harsh cornering, hence the baffled tank
 

Offline hermetic

  • Sr. Member
  • ****
  • Posts: 299
Re: capacitive fuel gauge for petrol
« Reply #21 on: January 31, 2018, 02:04:38 PM »
I think I would go for a better float, or see what you can find available to read fuel pressure (weight) in the tank as tank contents.
Phil

Offline AdeV

  • Madmodder Committee
  • Hero Member
  • *****
  • Posts: 2071
  • Country: gb
Re: capacitive fuel gauge for petrol
« Reply #22 on: January 31, 2018, 04:47:35 PM »
IMHO the problem with floats is they can end up not floating (which is not TOO bad, at least they end up reading "empty" all the time; worse if the mechanism jams & it reckons you have fuel when you don't... Plus, it's an electromechanical system, and on cars, anything mechanical will eventually break...

Weight's no good, because the weight transfer as the car moves around on the road, goes up/down hills and bumps, will always be throwing off the readings. Hit a big bump with a 1/2 full tank and one moment it'll read full, the next empty, then full again until all the oscillations in the suspension and the fuel itself damp down...

Nah, I have to say, I like the idea of a capacitive sensor. No moving parts, once the capacitance range is determined, and any temperature offset compensated for; it should be extremely reliable, long lasting, high resolution and very accurate. The 2nd tube idea is great, if there's room in the tank for it, but it should still be possible to use an arbitrary off-the-shelf capacitor which, once the circuit is tuned, should be just as good as a 2nd tube, and also much cheaper and smaller.
Cheers!
Ade.
--
Location: Wallasey, Merseyside. A long way from anywhere.
Or: Zhengzhou, China. An even longer way from anywhere...
Skype: adev73

Offline awemawson

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 6424
  • Country: gb
  • East Sussex, UK
Re: capacitive fuel gauge for petrol
« Reply #23 on: January 31, 2018, 05:18:58 PM »
Another approach is is sonar technology as used in domestic central heating oil tanks . The Watchman Sonic is an example.

A sonic burst is transmitted towards the oil surface and the reflected sound is detected. The transit time is a function of tank level. Now obviously a lot of averaging would be needed in an automotive application  but the technology works (I have three oil tanks here on the farm monitored by them)

The averaging could simply be a tube with only a small hole at the bottom, and having the sonic sender in the top

Andrew Mawson
East Sussex

Offline angus

  • Jr. Member
  • **
  • Posts: 57
  • Country: gb
Re: capacitive fuel gauge for petrol
« Reply #24 on: February 01, 2018, 03:22:18 PM »
Trouble with sonic devices, they need as gap between the liquid level and the sensor head... the ones we use at work need 12"

Offline angus

  • Jr. Member
  • **
  • Posts: 57
  • Country: gb
Re: capacitive fuel gauge for petrol
« Reply #25 on: February 25, 2018, 07:35:21 AM »
right then, the mechanicals of the probe have been built, as have the electronics and a calibration has been done
i have discovered a problem
the code allows the fuel value to exceed the maximum 255 for the output pin, and allows it to go below zero
- this could happen in real life with variations in fuel, and temperature

this causes the naon to go full scale on under empty, and zero on over full

i intend to add these lines of code to hopefully stop this

but if i add after the fuel calibration bit of code

if (fuel > 255) fuel=255;
if (fuel < 0) fuel=0;

it compiles ok, just got to brave the cold garage with my laptop and a can of fuel and have anothe rgo