Fuel Gauge for RC airplanes

#1
Typically RC airplane pilots that fly combustion engines have no clue how much fuel they have left.
They fill the tank at start of the flight, take off, and use a timer to tell them when to land the plane.
On a nice sunny day when life is easy they land the plane and discover the tank is still 3/4 full.
On a windy day, when adrenaline rushes through the pilot, an in air motor out (fuel empty) is not uncommon.
And recovery of that plane is sometimes hard.....

How different is that with RC planes that fly electro (battery) powered. Modern transmitters have telemetry (even the USD 50 ones) that show
actual battery status, and you can put an alarm to that.

I set out to find a solution to that problem. The result is this circuit.

This circuit is a PICAXE 08M2 based interface that measures the fuel level in the airplane tank, and translates it into a voltage.
The voltage level is proportional with the fuel level in the tank.

This first first post will show the circuit diagram, successive posts will contain an explanation, and implementation, and the code.
 

Attachments

Last edited:
#2
The fuel in the airplane tank is a mixture of methanol, oil, and nitro. It is quite an aggressive mixture.
Putting electrodes or sensors inside the fuel is risky, corrosion is to be expected.
Therefore a solution was engineered to place electrodes outside the (plastic) tank, and measure the tanks capacitance.

How does that work:
Left and right side of the tank are equipped with thin conductive plates (in my case copper), forming a capacitor (see picture).
An empty tank is filled with air, and the capacitance (ignoring the thin plastic tank walls) is based on the relative permeability of air (=1).
The math behind it can be found on

what its a capacitor

Look at the section on parallel plate capacitor. C = eA/d
If the tank is filled with methanol (relative permeability = 33) the capacitance is 33 times as high.
If the tank is half full, the capacitance is in between these 2 values.

From experiments (later confirmed by calculation) the location of the plates determines the exact relation between fuel level and capacitance.
If the 2 conductive plates are place top and bottom, the relation is highly un-linear. But if the conductive plates are places at the sides of the tank the relation is linear.

The attached picture shows a fuel tank with top (and bottom) plates.
Best results are with plates at the sides.
 

Attachments

Last edited:
#3
The fuel tank is placed in the airplane hull, that typically is made of foam, glass fiber, or balsa covered with foil.
These material do not shield electrical fields at all (carbon fiber does though).
That means that the capacitive plates are also sensitive to the world outside the airplane.
Putting your hand on the airplane hull can totally invalidate the fuel meter reading.

Typical method of shielding the outside world from the fuel measuring system is by putting a conductive shield around the whole measuring system.
Since weight is an issue in model airplanes a proper shielding material is kitchen foil (aluminum foil). It is thin, lightweight, and conducts on both sides.
To be honest, it is a challenge to get a good cover of thin aluminium foil inside an airplane hull since access is generally narrow.
You only need to apply the foil in the section where the tank is located.
It is not necessary to make the shield out of one piece, since (with sufficient overlap) the foil pieces will conduct - or - form a large capacitance. Many times bigger that what we are measuring with the capacitive plates at the tank, so it will still work as a shield.

First test where performed with a all foil shielding connected to the battery (minus pin).

What appears obvious happened: the capacitance change from filling the tank was only a small percentage of the total capacitance.
This makes the system inaccurate (measuring a small change on a large value).

Explanation: in my airplane, the plates in the tank are 5 cm apart. But the shield was less than 1 cm away, forming an additional capacitor that is 5x larger in value (5x closer). (formula C=eA/d where d=distance)

A friend of mine suggested to connect the shield to a low impedance (so it will work as a shield) replica signal off the signal at the capacitor plate. In that case there will still be a capacitor, but the electrical field between the shield and capacitive plate is 0. This was engineered, and proves to be the solution.
 

Attachments

#4
Now we come to the moment the PICAXE comes into play.
The M2 series of pickaxe chips have a function that is called "capacitive touch" using the TOUCH and TOUCH16 commands.
It is designed for capacitive touch buttons (keys) so you can operate a system in a wet or unfriendly environment.
Typically 1 inch large conductive area's behind a plastic or glass plate.

What the PICAXE actually does is use the pin's capacitance in an oscillator, and measure the frequency.
The signal at the pin is a 500mVpp triangle wave signal at average 700mV. The larger the capacitance at the pin, the lower the frequency.
Since the capacitance that can be measured is small (even below 1pF) the current that charge and discharge the capacitance is very small. Every load on that pin will stop the oscillation (and the TOUCH command will output 0).

The signal for the shield must be a low impedance signal derived from the very sensitive TOUCH pin.
The buffer in the schematics in the first post (BF245A and BC549C) will do this. The BF245A FET input is very high impedance, and the BC549C output impedance is low. The buffer has a gain of 0.99 (almost 1).
Please make sure when you try to duplicate this circuit that you use a BF245A, not a BF245B or BF245C. Only the BF245A will work on 4V-6V battery voltage.

Last challenge was the output of the analog voltage. The first test where done using the PWM output (at pin C.2 on a 08M2) since it offers a lot of resolution.
The constant pulses at the PWM output caused a lot of jitter in the TOUCH16 reading. Similar things where said in the PICAXE manual about the AXE026 serial port interface. After a lot of testing, I abandoned the PWM idea, and decided to use the DAC at pin C.0.
Disadvantage is that this pin is also used for programming the chip. So after programming, you must disconnect the programmer (jumper).

Practical implementation:
I was able to put all electronics on a PICAXE 08 Experimenter board (see picture first post).
Since every plane is different, I decided to add 2 buttons that allow to calibrate the fuel gauge for empty and full tank. If the plates are placed at the sides, the relation of the DAC output voltage will be linear with the fuel level. Max voltage = 4 volt (full tank), minimum is 0 volt (empty tank).
 

Attachments

#5
The output of the DAC is connected to a "voltage" telemetry input of the RC receiver. Attached photo's show the Telemetry reading on the transmitter LCD (the value ExtV shows the tank is 1/3 full (1.5V of 4V range)).
Another photo shows how the stuff is build into this airplane.
From left to right: top=receiver lower the 2 servo's for elevation and rudder), centre the throttle servo and power switch, right the telemetry input module (CE mark) and finally the PICAXE circuit.Extreme right you can still see part of the fuel tank.
 

Attachments

#6
The code contains a lot of remarks also contained in previous posts, but the actual code is pretty small.
The only thing I have not yet solved is getting some defaults in flash memory so the system works even before you do your first calibration.
So initially the system is useless until you calibrate.
Another imperfection is that you can press the calibrate full button with an empty tank, and the calibrate empty button with a full tank. That won't work either....

Code:
' measue fuel level using the 'touch16' command in picaxe 08M2
' it uses 2 copper plates at left and right side a the fuel tank
' these form a capacitor which value changes with the amount of fuel in the tank
' the output of the circuit is connected to an analog telemetry input of the RC receiver

' the touch16 outputs a 16 bit value

' capacitor plates left and right side of the tank
' with the BF245A buffer the voltage dependency is virtually gone, so no voltage regulator needed.
' empty 0x1500, full tank 0x2100 with +/- 0x40 fluctuations (< 2%).

' uses the C.0 output DAC. It has only 32 levels, but that looks sufficient for a fuel gauge.
' use internal reference fired solves the problem. Output range 0-4V.

' to limit the influences from outside the plane the C.1 pin is buffered
' in a discrete amplifier, and connected to a shielding alu foil.
' due to the telemetry connection to the RC receiver the other electronics are also connected,
' this helps for minimizing the hand effect (pilot holding the plane influencing fuel gauge reading).

'-------------------------------------------------------------------- init -------------------------------------------------------------
low C.0                          ' to define C.0 as output
fvrsetup FVR4096            ' set to 4.0V, simply because telemetry sensor inaccurate below 0.5V
dacsetup %10101000           ' use Vfvref as DAC voltage

' memory usage
' w0 = work register
' w1 = used for averaging
' w2 = used as b4 and 5b
'     b4 = averaging counter
'     b5 = divider for ranging
' w3 = empty tank level
' w4 = full tank level

' read defaults from EEPROM memory
read 0,b5,b6,b7,b8,b9

'-------------------------------------------------------------------- main ------------------------------------------------------------
main:
    gosub measure
    if  pinC.3=0  then              ' calibrate empty by pressing switch at C.3
        w3=w0
        w1=w4-w3
        b5=w1/31                ' and adjust ranging
        write 0,b5,b6,b7,b8,b9  'save all values
    endif
    if pinc.4=0 then                 ' calibrate full when pressing switch at C.4
        w4=w0
        w1=w4-w3
        b5=w1/31                ' and adjust ranging
        write 0,b5,b6,b7,b8,b9  'save all values
    endif

    'debug ' debug is only possible by disabling the DAC since shared pin.

    if w0<w3 then                  ' avoid DAC overrun at empty side
        w0=w3
    endif
    if w0>w4 then                 ' avoid DAC overrun at full side
        w0=w4
    endif
    w0=w0-w3                     ' subtract empty tank capacitance
    w0=w0/b5                     ' range to 32 steps

    'debug

    daclevel b0                  ' set DAC from lsb of w0

    pause 500                    ' just some delay, may not be needed

goto main

'------------------------------------------------------------------ subs -------------------------------------------------------------
measure:                           ' take 4 measurements, and average
                                    ' values are < 0x4000 so no overrun of 16 bit var.
    w1=0
    for b4=1 to 4
        touch16 C.1,w0
        w1=w1+w0
    next b4
    w0=w1/4
    return
 
Last edited:
Top