ardupilot
ardupilot copied to clipboard
AP_BattMonitor: Add FuelLevel_Analog support
Adds a BattMonitor driver to use analog fuel sensors. Such as SAE fuel senders that output resistance or voltage. Tested on a CubeOrange with a potentiometer as the fuel level sensors on pin 103.
I think we'll need a low pass filter, maybe 0.2Hz cutoff?
I'm pretty sure the sensor I'm looking at is internally filtered, but obviously not all sensors are, and for gas applications I don't think we will notice any problems from a filter that slow. (Maybe 0.5Hz, but that might be too fast?)
Built and tested on Cube Orange pin 103.
- Added a low pass filter at 0.3Hz. 0.2Hz seemed a little slow and 0.5Hz seemed a little fast for a typically slow speed signal. So I put it on the safe side of the middle.
- Used _volt_offset for empty voltage and _volt_multiplier for full voltage. Slightly cumbersome, but not additional parameter space is taken up. The AP_Float values were already there.
- Added the ADC value to the voltage field and the filtered value to the current_amps.
- Linear interpolation between low and high voltage.
- Added an option to enable the low pass filter.
I'll wait for the reviews before asking for the flapping CI tests to be re-run.
Changed the filter toggle to be slightly more helpful. Retested on a cube orange.