Introduction: Paramotor Fuel Sensor and Gauge

Here is a home built capacitive fuel sensor for a paramotor. It is based on a sensor made from an aluminium tube and rod, and arduino Microcontroller , an LM3914 bargraph chip and 10 superbright LEDs. It has been built for a Parajet Macro and the display in the Parajet throttle handle, specifically, but will modify for different makes.

You will need to be averagely handy, be able to solder some small electronic components and be familiar with the Arduino platform.


I must from the outset acknowledge that this Instructable is a developement of "Building a Capacitive Liquid Sensor" by VadimS
Thanks Vadim!

Please note that if you decide to build this fuel sensor you do so entirely  at your own risk. The author accepts no liability whatsoever for any injury or loss  suffered by you or any third party
if you don't think you are competent to undertake the build or understand the risks posed you should not proceed to build.

Step 1: Making the Sensor

The sensor is basically a variable capacitor whose capacitance changes as the liquid fills the gap between  the tube and the rod. Because it is a little temperature sensitive a reference capacitor of similar size is used to help negate the effect of temperature, the principle being that both capacitors will be affected similarly and by reading the difference we rule out the temperature effect
They are quite resilient to "tank slosh" by virtue of the fuel only getting  between the tubes via a 2mm hole, so its inherently damped.

Follow the attached drawing which should be self explanatory.

Once made you need to mock up the sensor . Jump forward to the Microcontroller section and set the Pro Mini up with the sensor input circuit ( you dont need the output circuit) so you can do all this on a breadboard.
1. Get the sensor to the correct length it will need to be in the tank
2. Load the sketch and connect the board to the Serial Monitor.
3. Follow the instructions in the sketch notes and ascertain the "raw" capacitance value of the empty , ie dry probe , dont be touching any part of it.
4. Use this raw value to choose the value of the "Ref" capacitor by trial and error.
5. Finish off the probe by fitting the Ref capacitor

Step 2: Making the Handle Display

Dismantle the Parajet throttle handle. The fake carbon face plates are simply push fit out of the anodised aluminium body.
Check there is space in the base of the handle to fit the LM3914 chip. You may need to tidy up the way the throttle cable terminates.
If you are going to do a proper job of the installation you are going to have to do a full dismantle of the cable, including removing and desoldering the push buttons so you can run the display cable up the throttle sleeving.
If you don't want to do that you can simply run the 3 core flat servo type cable up the outside, but you may have doctor the faceplate to get it to exit. The hole where the throttle cable comes in is too tight to get anything else through
You will need to remove about 0.5mm depth of material off the top of the cable end receiver to give space for the wires to pass across. See the bright area of bare metal in the photo where I have dremelled the ally away

Step 3: Soldering the LM3914

This is a fiddly bit of work, which needs to be kept neat and tight so it will fit in the handle. It will need you to solder direct to the chip tabs.
LM3914 Data Sheet

1 Start by snipping off the legs of the chip right down to base tabs
2 Tin all the tabs
3 Now solder the links,resistors and wires according to the Throttle part of the appended diagram . Keep the resistors tight to the back of the chip and ensure there are no shorts. It's all got to fit in that slot next to where the throttle cable comes in as marked by the green arrow.
4 Now drill a nice arc of evenly spaced holes in the face plate for the leds. You need to keep them fairly tight to the top edge but be careful not to foul the overhang of the plate into the rebate in the handle. Keep the holes tight so the leds are a tight fit. Glue them in place with a little hot glue. I wouldn't use cyano, it would be a devil to remove them if you have to.
5 Now also snip the the tails of the leds right back to within 2mm of the lamp. Arrange the anode tails towards the outside and solder them all together with a linking wire, which you connect to live +5v.
6 Now solder all the wires from the chip to the cathode rail of each led being careful to observe the correct order
7 The important thing in this section is to keep everything within a couple of mm of the back of the plate and clear of the throttle pivot point so none of the wiring fouls the throttle action. It will all fit!
8 You should test your work here. If you connect the chip to a 5v supply and connect the signal wire via a trim potentiometer 0-5v you can test the lights they should light and stay on  sequentially as you vary the signal voltage from 0 to 5volt
9.If it all works fine hot glue the chip onto the face plate in just the right place so it goes into the handle recess, arrange all the cables nice and flat on the back of the face plate and tape down. Assemble and check everything is clear of the throttle acton.
10. If you want to use this display with some other sensor arrangement you just need to get your sensor to output 0-5volts, the 10 leds will light progressively as the voltage ranges. It is, effectively a 0-5v volt meter!

Step 4: The Microcontroller

This is what converts the signal from the sensor into 0-5v output that is sent to the display. 
Arduino Pro Mini board

This where you need to be familiar with Arduino. If you're not you will need to stop altogether or stop and find out about it. That's how I came to it , I came across it in some instructable or other and just started to use it, it's incredibly versatile and actually pretty straight forward. There are millions of sketches ( programmes) written for all sorts of systems and all my projects start with some code somebody has written, which I then adapt . It's all open source, so that's OK, it's just good practice to acknowledge your source.
My sketch for this application is in the end step, copy and paste it into the Arduino application 

The hardware for this section is an
Arduino Pro Mini
a couple of 1Mohm resistors,
a resistor and capacitor for a low pass filter to convert the PWM output from the Arduino to a 0-5v signal,
and 2 10kohm trim potentiometers that are used for fine adjustment.

The capacitive sensor connects to D6
The Reference sensor connects to D8
D5 to D6 and D7 to D8 are bridged with 1Mohm resistors
The output PWM will come from D3 to the low pass filter 
2No 10kohm Potentiometers are connected to A0 and A3 for the trimmers.

Probably best to solder pins to the board and put it all on a small piece of Proto-board.
Follow the circuit diagram for Arduino Pro Mini 5v and house it all in a little enclosure on top of the fuel tank as close as possible to the sensor. Try to run the shielded coaxes right into the enclosure and keep their length as short as possible. These are carrying very small signals that will be susceptible to interference.

Step 5: The Power Supply

You will need a regulated 5v power source for this project I chose a 2A one (L78S05CV)

because I have other stuff to power, but if all you are feeding is this display, then the 1A version will be fine. Follow the diagram for the voltage regulator, tantallum bead capacitors will be best for this application.
This wants to be up near the battery with all the rest of the other paramotor electrics, tap the input into the appropriate battery supplies in the electrics panel. You will probably have a LIPO 3S turning out 11.8 v, but the regulator will deal with anything from about 7v to more then 18 v. Make sure you fuse it appropriately.
If you want to use this on a machine with no onboard electrics use a 2S Lipo  7.4v a small 800mah one will give you more than 2 hrs running time and will weigh only about 50g

Step 6: Getting It Working

I used 22g good quality silicone Futaba type  3- core flat flex to join all the pieces together

For Commissioning you will need to follow the Arduino sketch notes quite carefully.
Go back to Step 1 and recheck the parameters on the Serial monitor, you may need to re-run that procedure.
If all OK, with the tank empty use Trim 1 to just turn the first LED off. 
Then fill the tank with fuel and  adjust trim 2 to just turn on the  tenth led.

That should be it! Happy Flying.

If you have an odd shaped tank where depth is not proportional to  capacity, I have inserted some code into sketch that will write a specific analog output  ( voltage) for given depths on the sensor, but commented it out so it would need to be activated. The notes say what to do.

Step 7: Parts

12mm aluminium tube, 6mm aluminium rod, 12mm compression connector from B&Q

From eBay and elsewhere
Arduino Pro Mini 5v 
LM 3914 bargraph chip
L78S05C voltage regulator
.33uF, 0.1 uF, 10uF capacitors
2x1Mohm, 5kohm,620ohm, 1.8kohm, resistors
10kohm pots.
10No Superbright Red Leds or any other colour you fancy( other colours may need slightly different  resistors
Futaba 3 core. 
Fine multi strand alarm cable, stripped for wiring
You will also need a means of uploading sketches to your Pro Mini, which if this not your first foray into Arduino you will most likely have
if not you need this FTDI Breakout board

Step 8: The Arduino Code


/*Fuel Sensor with Pro Mini at tank output filtered analog to 2nd PM
D3-output to Low pass filter
D5-1Mohm res to D6
D6- Centre of cap Sensor
D7-1Mohm res to D8
D8-to positive of Reference capacitor
GND
Set potentiometers to centre
Start with empty tank

There are a number of stages in setting up
1. Reading the Raw value of "fuel" to ascertain the reference capacitor in Step 1
2. Setting "fuel" for an empty tank
3. Setting "fuel" for a full tank
Written values for Analogwrite range from 0=0volts to 255 =5volts,
so we are aiming for an empty tank value of "fuel" of zero with no leds lit and 
a full tank value of "fuel" of 255 so we get 5 volts and all 10 leds lit
As I said in the sensor section the probe is quite well damped against sloshing, but you could always add a bit of smoothing code
Another thing you might like to try is to have some attention grabbing effect when the fuel is very low, you can use your imagination but a simple all flashing on and off could be included, thus

if fuel>27
{analogWrite(3,fuel)
}
else 
{analogWrite (3,255);
delay 250;
analogWrite (3,0)
delay 250;
}

*/


#include <CapacitiveSensor.h>

CapacitiveSensor   cs_5_6 = CapacitiveSensor(5,6);// variable capacitor made of two concentric aluminium tubes. Centre connected to D6 with 1Mohm connected between 5&6, outer to ground.

CapacitiveSensor   cs_7_8= CapacitiveSensor(7,8);// Reference capacitor equal to variable cap on empty.Connected to D8 with 1Mohm connected between 5&6, other to ground.

int val=0;
int var=0;
int trim1=0;//trim values will range from 0-1023 from full off (0v) to full on (5v), trim value will be 512 for centre position (2.5v)
int trim2=0;//trim values will range from 0-1023 from full off (0v) to full on (5v), trim value will be 512 for centre position (2.5v)
int analogPin=3; // the output pin for voltage to Display via low pass filter

//This section of code has not been tested
//Leave the next section commented out till normal set up is complete
//If you have a non symetrical tank where depth is not proportional to volume, having set as for symetrical tank,
//connect to Serial monitor and record fuel for each 1/10 fill of the tank
// insert those as the values for Q1-9 and uncomment the next section
/*
int Q1=??; //value of fuel for 1/10 fuel capacity, fill tank with 1/10 fuel and read val on serial monitor
int Q2=??; //value of fuel for 2/10 fuel capacity, fill tank with 2/10 fuel and read val on serial monitor
int Q3=??; //value of fuel for 3/10 fuel capacity, fill tank with 3/10 fuel and read val on serial monitor
int Q4=??; //value of fuel for 4/10 fuel capacity, fill tank with 4/10 fuel and read val on serial monitor
int Q5=??; //value of fuel for 5/10 fuel capacity, fill tank with 5/10 fuel and read val on serial monitor
int Q6=??; //value of fuel for 6/10 fuel capacity, fill tank with 6/10 fuel and read val on serial monitor
int Q7=??; //value of fuel for 7/10 fuel capacity, fill tank with 7/10 fuel and read val on serial monitor
int Q8=??; //value of fuel for 8/10 fuel capacity, fill tank with 8/10 fuel and read val on serial monitor
int Q9=??; //value of fuel for 9/10 fuel capacity, fill tank with 9/10 fuel and read val on serial monitor

*/



void setup()
{
  pinMode(analogPin, INPUT);
Serial.begin(9600);
}
void loop()
{ trim1=analogRead (0);// reads the voltage off the potentiometer 1 as a value 0-1023, 0v to 5v
trim2=analogRead (3);



  long fuel;
   long Ref;
  fuel = cs_5_6.  capacitiveSensorRaw (200);//Raw value of fuel
  Ref = cs_7_8.  capacitiveSensorRaw (200);


// For  Step 1 to determine the size of the reference capacitor.
//Start by reading fuel on the serial monitor for no liquid on probe and experiment with different capacitors for Ref to match, later when //you are all assembled and you reach Step 6, uncomment the next line


//fuel = fuel-Ref+920-(512+trim1);

//Adjust 920 in line above until fuel reads zero in the serial monitor for tank on empty,
//then fill the tank and uncomment the line below

//fuel = fuel/(10+(trim2/30));//start with this line commented out, until you have adjusted the zero fill reading

//Adjust 10 in line above to give fuel =  255 ( or other adjusted value , see below) with tank full
// because of tolerance of resistors it is possible that the LM3914 may not be ranging exactly to 5volts, so you may wish to experiment
//and ascertain what value around 255 just gives all 10 leds lit
//it may be easier first to dispense with (10+(trim2/30) and just experiment to get the figure that gives you fuel=255 (5v)
// Then adjust the whole divisor equation (10+(trim2/30) to give you that figure
// remembering that trim2 will range in value from 0-1023, but will be 512 if you have set the pot to centre.

  //IRREGULAR TANK ADDITIONAL CODE
// if you are using the irregular tank code uncomment this next section, but you will need to comment out  following line analogWrite(3,fuel);
/*
  {
    val=fuel;
if val< Q1
var=0;
else if val var=27;
else if val   var=60;
else if val   var=80;
else if val   var=105;
else if val   var=130;
else if val   var=160;
else if val   var=185;
else if val   var=210;
else
  var=255;

}

analogWrite (3,var);// if you are utilising the irregular tank sketch then comment out the next line
*/ 

  analogWrite(3,fuel); // write the resulting value of fuel to digital pin 3 .

  //This output to be run through a low pass RC filter, using 5kohm and 10uF.
{
Serial.print(fuel);
Serial.println("Fuel");//debug fuel
Serial.print(Ref);
Serial.println("Ref");//debug Ref
Serial.print(var);
Serial.println("Var");//debug Var
Serial.print(trim1);
Serial.println("T1");
Serial.print(trim2);
Serial.println("T2");
}

  delay (100);
}