The Shop > Electronics & IC Programing

capacitive fuel gauge for petrol

<< < (6/6)

angus:
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



Navigation

[0] Message Index

[*] Previous page

Go to full version