i want to use a fuel level sender and use those resistance values to create a PWM to drive a mosfet to make a more accurate fuel gauge and eliminate fuel slosh as much as possible.
But the analog input value only ranges between 3.53V (91Ohms) for full position and 4.91V (3.94Ohms) for emtpy.
I have looked and tested several script but as long as i do not get a decent voltage range between 0 and 5 V this doesn't work.
I am using the fuel gauge as an unknown resistor so the Arduino can constantly measure the change in resistance. Because the sender just has a range from 3 to 90 Ohms the input voltage on the analog channel will not drop enough so i only have a range from 3,53 to 4,91V
Or am i doing something terrably wrong here. I want to use the analog in to create an analogOut.
Could you point me to the forum guide? there is a lot on here, not seeing it at the moment
That will give you a reading between about 722 and 1004. That's a range of around 282 values, enabling you to estimate the fuel level to about 0.35%. Isn't that enough?
that did the trick! so simple actually but if you are looking at it too long you do not see it anymore.
I was only focussing on the voltage range input and thinking about ways to modify resistance, even getting another level sender with a higher range resistance
The best i can put it is that the gauge works on the principle of the amount of current it is being fed. The more current can pas through the more the needle moves to empty. At 255 PWM the needle is spot on at Empty, but at 0 PWM it goes way beyond Full. I have to change from 0 to 85 to be at the original position but the scale does noet make any sense anymore. Full to half is very sensitive and when the needle is at 1/4 the sender is in the middle position
You could power the sender through a 220 ohm resistor from the 3.3volt supply, and swith Aref to 1.1volt in setup(). That will give you about 900 A/D values to start off with.
Multimap() could convert the A/D values into the correct PWM values.
Maybe you should also use a 3.9 ohm (3W cement) resistor (for safety) in the drain line of the mosfet.
Leo..
make a voltage divider from 3 volts with one leg your sensor
read the divider voltage with an analog input in your arduino
do what ever calculations you need to ***
output this to the gauge.
*** by the way, the level sensor algorithm is the largest code section in an automobile's ECU code. Literally. We built fuel modules that includes the level sensor so I've an experience in this area.
@Wawa i tried this but gives me a much smaller resolution to work with
I can experiment with the Multimap function but i still have a lot to learn.
So it can be possible to send out a different range PWM in relation to the AnalogIn?
@JohnRob what exactly do you mean with 'one leg your sensor'?
i would be much appreciative if you could assist me with the calculations.
Physically using the fuel sender with gauge as intended i works spot on.
The use of Arduino will be getting the fuel slosh out so the needle will not follow the sender.
As i have it now with a resolution of analogWrite(PWMpin, map(analogRead(analogPin), 723, 1005, 0, 255)); as per help of @PaulRB the needle goes beyond the Full mark so has to be trimmed back but that throws off the reading of the complete scale..
Starting with an empty tank, make a note of the analogRead() result (==723), then fill it with, say, 5 litres, note the reading again and repeat until the tank is full (==1005). Make a table of litres-of-fill vs the reading.
Connect a pot to an analog pin and write a simple sketch to control the PWM and write the PWM value to serial monitor. Connect this to the fuel gauge and adjust the pot to make the gauge read empty, 1/4, 1/2, 3/4 and full. Make another table of the PWM value for each gauge reading.