The Shop > Electronics & IC Programing

capacitive fuel gauge for petrol

<< < (2/6) > >>

AdeV:
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...

awemawson:
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.

Noitoen:
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.

PK:

--- Quote from: AdeV 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:

--- End quote ---
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....

AdeV:

--- Quote from: Noitoen 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.

--- End quote ---

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.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version