mirror of https://github.com/rusefi/wideband.git
Mess (#282)
* 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:
parent
e7bc7132d9
commit
9cd5c23d7a
|
@ -79,8 +79,8 @@ static float GetMaxSample(adcsample_t* buffer, size_t idx)
|
||||||
return (float)max * scale;
|
return (float)max * scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
static float l_vbatt = 0;
|
static float l_heater_voltage = 0;
|
||||||
static float r_vbatt = 0;
|
static float r_heater_voltage = 0;
|
||||||
|
|
||||||
AnalogResult AnalogSample()
|
AnalogResult AnalogSample()
|
||||||
{
|
{
|
||||||
|
@ -94,14 +94,14 @@ AnalogResult AnalogSample()
|
||||||
|
|
||||||
if (l_heater && l_heater_new)
|
if (l_heater && l_heater_new)
|
||||||
{
|
{
|
||||||
float vbatt_raw = GetMaxSample(adcBuffer, 6) / BATTERY_INPUT_DIVIDER;
|
float vbatt_raw = GetMaxSample(adcBuffer, 6) / HEATER_INPUT_DIVIDER;
|
||||||
l_vbatt = BATTERY_FILTER_ALPHA * vbatt_raw + (1.0 - BATTERY_FILTER_ALPHA) * l_vbatt;
|
l_heater_voltage = HEATER_FILTER_ALPHA * vbatt_raw + (1.0 - HEATER_FILTER_ALPHA) * l_heater_voltage;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (r_heater && r_heater_new)
|
if (r_heater && r_heater_new)
|
||||||
{
|
{
|
||||||
float vbatt_raw = GetMaxSample(adcBuffer, 7) / BATTERY_INPUT_DIVIDER;
|
float vbatt_raw = GetMaxSample(adcBuffer, 7) / HEATER_INPUT_DIVIDER;
|
||||||
r_vbatt = BATTERY_FILTER_ALPHA * vbatt_raw + (1.0 - BATTERY_FILTER_ALPHA) * r_vbatt;
|
r_heater_voltage = HEATER_FILTER_ALPHA * vbatt_raw + (1.0 - HEATER_FILTER_ALPHA) * r_heater_voltage;
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
|
@ -111,13 +111,13 @@ AnalogResult AnalogSample()
|
||||||
/* left */
|
/* left */
|
||||||
.NernstVoltage = AverageSamples(adcBuffer, 3) * NERNST_INPUT_GAIN,
|
.NernstVoltage = AverageSamples(adcBuffer, 3) * NERNST_INPUT_GAIN,
|
||||||
.PumpCurrentVoltage = AverageSamples(adcBuffer, 2),
|
.PumpCurrentVoltage = AverageSamples(adcBuffer, 2),
|
||||||
.BatteryVoltage = l_vbatt,
|
.BatteryVoltage = l_heater_voltage,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
/* right */
|
/* right */
|
||||||
.NernstVoltage = AverageSamples(adcBuffer, 1) * NERNST_INPUT_GAIN,
|
.NernstVoltage = AverageSamples(adcBuffer, 1) * NERNST_INPUT_GAIN,
|
||||||
.PumpCurrentVoltage = AverageSamples(adcBuffer, 0),
|
.PumpCurrentVoltage = AverageSamples(adcBuffer, 0),
|
||||||
.BatteryVoltage = r_vbatt,
|
.BatteryVoltage = r_heater_voltage,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
/* Dual board has separate internal virtual ground = 3.3V / 2
|
/* Dual board has separate internal virtual ground = 3.3V / 2
|
||||||
|
|
|
@ -23,13 +23,13 @@
|
||||||
// *******************************
|
// *******************************
|
||||||
// 100K + 10K divider
|
// 100K + 10K divider
|
||||||
#define BATTERY_INPUT_DIVIDER (10.0 / (10.0 + 100.0))
|
#define BATTERY_INPUT_DIVIDER (10.0 / (10.0 + 100.0))
|
||||||
#define BATTERY_FILTER_ALPHA (0.1f)
|
|
||||||
|
|
||||||
// *******************************
|
// *******************************
|
||||||
// Heater low side Sensing
|
// Heater low side Sensing
|
||||||
// *******************************
|
// *******************************
|
||||||
// 100K + 10K divider
|
// 100K + 10K divider
|
||||||
#define HEATER_INPUT_DIVIDER (10.0 / (10.0 + 100.0))
|
#define HEATER_INPUT_DIVIDER (10.0 / (10.0 + 100.0))
|
||||||
|
#define HEATER_FILTER_ALPHA (0.1f)
|
||||||
|
|
||||||
// *******************************
|
// *******************************
|
||||||
// Vm output Sensing
|
// Vm output Sensing
|
||||||
|
|
|
@ -89,8 +89,8 @@ static float GetMaxSample(adcsample_t* buffer, size_t idx)
|
||||||
return (float)max * scale;
|
return (float)max * scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
static float l_vbatt = 0;
|
static float l_heater_voltage = 0;
|
||||||
static float r_vbatt = 0;
|
static float r_heater_voltage = 0;
|
||||||
|
|
||||||
AnalogResult AnalogSample()
|
AnalogResult AnalogSample()
|
||||||
{
|
{
|
||||||
|
@ -108,14 +108,14 @@ AnalogResult AnalogSample()
|
||||||
|
|
||||||
if (l_heater && l_heater_new)
|
if (l_heater && l_heater_new)
|
||||||
{
|
{
|
||||||
float vbatt_raw = GetMaxSample(adcBuffer, 6) / BATTERY_INPUT_DIVIDER;
|
float vbatt_raw = GetMaxSample(adcBuffer, 6) / HEATER_INPUT_DIVIDER;
|
||||||
l_vbatt = BATTERY_FILTER_ALPHA * vbatt_raw + (1.0 - BATTERY_FILTER_ALPHA) * l_vbatt;
|
l_heater_voltage = HEATER_FILTER_ALPHA * vbatt_raw + (1.0 - HEATER_FILTER_ALPHA) * l_heater_voltage;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (r_heater && r_heater_new)
|
if (r_heater && r_heater_new)
|
||||||
{
|
{
|
||||||
float vbatt_raw = GetMaxSample(adcBuffer, 7) / BATTERY_INPUT_DIVIDER;
|
float vbatt_raw = GetMaxSample(adcBuffer, 7) / HEATER_INPUT_DIVIDER;
|
||||||
r_vbatt = BATTERY_FILTER_ALPHA * vbatt_raw + (1.0 - BATTERY_FILTER_ALPHA) * r_vbatt;
|
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
|
/* Dual board has separate internal virtual ground = 3.3V / 2
|
||||||
|
@ -135,10 +135,10 @@ AnalogResult AnalogSample()
|
||||||
}
|
}
|
||||||
/* left */
|
/* left */
|
||||||
res.ch[0].PumpCurrentVoltage = AverageSamples(adcBuffer, 2);
|
res.ch[0].PumpCurrentVoltage = AverageSamples(adcBuffer, 2);
|
||||||
res.ch[0].BatteryVoltage = l_vbatt;
|
res.ch[0].BatteryVoltage = l_heater_voltage;
|
||||||
/* right */
|
/* right */
|
||||||
res.ch[1].PumpCurrentVoltage = AverageSamples(adcBuffer, 0);
|
res.ch[1].PumpCurrentVoltage = AverageSamples(adcBuffer, 0);
|
||||||
res.ch[1].BatteryVoltage = r_vbatt;
|
res.ch[1].BatteryVoltage = r_heater_voltage;
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,13 +24,13 @@
|
||||||
// *******************************
|
// *******************************
|
||||||
// 100K + 10K divider
|
// 100K + 10K divider
|
||||||
#define BATTERY_INPUT_DIVIDER (10.0 / (10.0 + 100.0))
|
#define BATTERY_INPUT_DIVIDER (10.0 / (10.0 + 100.0))
|
||||||
#define BATTERY_FILTER_ALPHA (0.1f)
|
|
||||||
|
|
||||||
// *******************************
|
// *******************************
|
||||||
// Heater low side Sensing
|
// Heater low side Sensing
|
||||||
// *******************************
|
// *******************************
|
||||||
// 100K + 10K divider
|
// 100K + 10K divider
|
||||||
#define HEATER_INPUT_DIVIDER (10.0 / (10.0 + 100.0))
|
#define HEATER_INPUT_DIVIDER (10.0 / (10.0 + 100.0))
|
||||||
|
#define HEATER_FILTER_ALPHA (0.1f)
|
||||||
|
|
||||||
// *******************************
|
// *******************************
|
||||||
// Vm output Sensing
|
// Vm output Sensing
|
||||||
|
|
Loading…
Reference in New Issue