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

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