* f1_dual_rev1: fix Heater vs Battery naming mess

* f1_dual: fix Heater vs Battery naming mess

* fix f1_dual_rev1

---------

Co-authored-by: Andrey Gusakov <dron0gus@gmail.com>
This commit is contained in:
rusefillc 2023-11-15 00:22:32 -06:00 committed by GitHub
parent e7bc7132d9
commit 9cd5c23d7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 18 deletions

View File

@ -79,8 +79,8 @@ static float GetMaxSample(adcsample_t* buffer, size_t idx)
return (float)max * scale;
}
static float l_vbatt = 0;
static float r_vbatt = 0;
static float l_heater_voltage = 0;
static float r_heater_voltage = 0;
AnalogResult AnalogSample()
{
@ -94,14 +94,14 @@ AnalogResult AnalogSample()
if (l_heater && l_heater_new)
{
float vbatt_raw = GetMaxSample(adcBuffer, 6) / BATTERY_INPUT_DIVIDER;
l_vbatt = BATTERY_FILTER_ALPHA * vbatt_raw + (1.0 - BATTERY_FILTER_ALPHA) * l_vbatt;
float vbatt_raw = GetMaxSample(adcBuffer, 6) / HEATER_INPUT_DIVIDER;
l_heater_voltage = HEATER_FILTER_ALPHA * vbatt_raw + (1.0 - HEATER_FILTER_ALPHA) * l_heater_voltage;
}
if (r_heater && r_heater_new)
{
float vbatt_raw = GetMaxSample(adcBuffer, 7) / BATTERY_INPUT_DIVIDER;
r_vbatt = BATTERY_FILTER_ALPHA * vbatt_raw + (1.0 - BATTERY_FILTER_ALPHA) * r_vbatt;
float vbatt_raw = GetMaxSample(adcBuffer, 7) / HEATER_INPUT_DIVIDER;
r_heater_voltage = HEATER_FILTER_ALPHA * vbatt_raw + (1.0 - HEATER_FILTER_ALPHA) * r_heater_voltage;
}
return
@ -111,13 +111,13 @@ AnalogResult AnalogSample()
/* left */
.NernstVoltage = AverageSamples(adcBuffer, 3) * NERNST_INPUT_GAIN,
.PumpCurrentVoltage = AverageSamples(adcBuffer, 2),
.BatteryVoltage = l_vbatt,
.BatteryVoltage = l_heater_voltage,
},
{
/* right */
.NernstVoltage = AverageSamples(adcBuffer, 1) * NERNST_INPUT_GAIN,
.PumpCurrentVoltage = AverageSamples(adcBuffer, 0),
.BatteryVoltage = r_vbatt,
.BatteryVoltage = r_heater_voltage,
},
},
/* Dual board has separate internal virtual ground = 3.3V / 2

View File

@ -23,13 +23,13 @@
// *******************************
// 100K + 10K divider
#define BATTERY_INPUT_DIVIDER (10.0 / (10.0 + 100.0))
#define BATTERY_FILTER_ALPHA (0.1f)
// *******************************
// Heater low side Sensing
// *******************************
// 100K + 10K divider
#define HEATER_INPUT_DIVIDER (10.0 / (10.0 + 100.0))
#define HEATER_FILTER_ALPHA (0.1f)
// *******************************
// Vm output Sensing

View File

@ -89,8 +89,8 @@ static float GetMaxSample(adcsample_t* buffer, size_t idx)
return (float)max * scale;
}
static float l_vbatt = 0;
static float r_vbatt = 0;
static float l_heater_voltage = 0;
static float r_heater_voltage = 0;
AnalogResult AnalogSample()
{
@ -108,14 +108,14 @@ AnalogResult AnalogSample()
if (l_heater && l_heater_new)
{
float vbatt_raw = GetMaxSample(adcBuffer, 6) / BATTERY_INPUT_DIVIDER;
l_vbatt = BATTERY_FILTER_ALPHA * vbatt_raw + (1.0 - BATTERY_FILTER_ALPHA) * l_vbatt;
float vbatt_raw = GetMaxSample(adcBuffer, 6) / HEATER_INPUT_DIVIDER;
l_heater_voltage = HEATER_FILTER_ALPHA * vbatt_raw + (1.0 - HEATER_FILTER_ALPHA) * l_heater_voltage;
}
if (r_heater && r_heater_new)
{
float vbatt_raw = GetMaxSample(adcBuffer, 7) / BATTERY_INPUT_DIVIDER;
r_vbatt = BATTERY_FILTER_ALPHA * vbatt_raw + (1.0 - BATTERY_FILTER_ALPHA) * r_vbatt;
float vbatt_raw = GetMaxSample(adcBuffer, 7) / HEATER_INPUT_DIVIDER;
r_heater_voltage = HEATER_FILTER_ALPHA * vbatt_raw + (1.0 - HEATER_FILTER_ALPHA) * r_heater_voltage;
}
/* Dual board has separate internal virtual ground = 3.3V / 2
@ -135,10 +135,10 @@ AnalogResult AnalogSample()
}
/* left */
res.ch[0].PumpCurrentVoltage = AverageSamples(adcBuffer, 2);
res.ch[0].BatteryVoltage = l_vbatt;
res.ch[0].BatteryVoltage = l_heater_voltage;
/* right */
res.ch[1].PumpCurrentVoltage = AverageSamples(adcBuffer, 0);
res.ch[1].BatteryVoltage = r_vbatt;
res.ch[1].BatteryVoltage = r_heater_voltage;
return res;
}

View File

@ -24,13 +24,13 @@
// *******************************
// 100K + 10K divider
#define BATTERY_INPUT_DIVIDER (10.0 / (10.0 + 100.0))
#define BATTERY_FILTER_ALPHA (0.1f)
// *******************************
// Heater low side Sensing
// *******************************
// 100K + 10K divider
#define HEATER_INPUT_DIVIDER (10.0 / (10.0 + 100.0))
#define HEATER_FILTER_ALPHA (0.1f)
// *******************************
// Vm output Sensing