This is my first post although I've read several threads about stabilizing an analog input, I haven't solved my issue yet.
I had the brilliant idea to use an Arduino to interface between a Ford fuel level sender and a gauge that expects a much larger ohm change. Specifically the Ford sender is at 10 ohms full, 15 ohms at 3/4, 20 ohms at 1/2, 40 ohms at 1/4 and 73 ohms at Empty. Notice the sender is a non-linear rheostat with only a 10 ohm change between 1/2 and Full, but a 53 ohm change between 1/2 and empty. Whereas the gauge sender would normally be 240 full to 33 ohms empty.
The Arduino analog input pin is wired to the junction of a 82 ohm resistor from the 5v source and the sender to ground. Stated another way, there is a 82 ohm resistor connected between the +5v source and the fuel sender and the other connection of the fuel sender is grounded. The Arduino analog input pin is connected to the junction between the resistor and the sender, thus allowing it to monitor the voltage across the sender.
Now I have the Arduino programmed to average 10 readings at 50 ms intervals, then the average is scaled to result in a lookup pointer for an array of 255 which has the required output value to provide the linear value the gauge requires. The output value is sent out a PWM output then by use of a NPN transistor to pull down the voltage source from the gauge. These are not the exact numbers, but assume the gauge requires a 127 output value for 50% reading. The 127 value would reside in the array location pointed to by the lookup pointer.
All of that works as planned and is surprisingly accurate which I proved by emptying my gas tank and adding 1 gallon of fuel at a time until full! Very tedious.
Now to the issue I would like to solve. While driving on level road at a fairly constant speed, the readings are solid. But when I come to a stop I will get some wild fluctuations due to the fuel sloshing in the tank. Unfortunately the tank is not baffled so the float just follows the slosh. The way the factory gauge compensated for slosh is the gauge is actually a heating element made of a bi-metallic material so that as current changes the bi-met bends accordingly to move the pointer. This builds in a damping of the operation. I'm guessing the response in in the order of 5-10 seconds.
I think maybe a capacitor across the sender may be the answer, but was wondering if there would be any other software solution. Some fluctuation can be expected, just like to tamp them down a bit.
Hopefully I have given enough detail, but if not I can add more.
The red line is roughly the fuel sender response as opposed to the black linear line.