Skip to content

Commit

Permalink
AP_BattMonitor: patch for fuel level calibration function from ottanoX
Browse files Browse the repository at this point in the history
  • Loading branch information
Jono453 authored and loki077 committed Nov 22, 2023
1 parent 0c1ab03 commit ed1cdb0
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion libraries/AP_BattMonitor/AP_BattMonitor_FuelLevel_Analog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@

extern const AP_HAL::HAL& hal;

// ADC Calibration for CX31021020 Rev D Voltage Divider for ADC #3
#define CPN_ADC_5V_SLP 797.76
#define CPN_ADC_5V_OFF 1.11

const AP_Param::GroupInfo AP_BattMonitor_FuelLevel_Analog::var_info[] = {

// @Param: FL_VLT_MIN
Expand Down Expand Up @@ -128,7 +132,8 @@ void AP_BattMonitor_FuelLevel_Analog::read()
const uint32_t dt_us = tnow - _state.last_time_micros;

// get voltage from an ADC pin
const float raw_voltage = _analog_source->voltage_average();
//const float raw_voltage = _analog_source->voltage_average();
const float raw_voltage = (_analog_source->read_average() - CPN_ADC_5V_OFF) / CPN_ADC_5V_SLP;

// Converting sensor reading to actual volume in tank in Litres (quadratic fit)
const float voltage =
Expand Down

0 comments on commit ed1cdb0

Please sign in to comment.