Skip to content

Commit

Permalink
livedata: show Nernst voltage
Browse files Browse the repository at this point in the history
  • Loading branch information
dron0gus authored and rusefillc committed Jun 15, 2023
1 parent 3aa12c6 commit 82f5a9d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions firmware/livedata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ void SamplingUpdateLiveData()
data->temperature = GetSensorTemperature(ch) * 10;
data->heaterSupplyVoltage = voltage * 100;
data->nernstDc = GetNernstDc(ch) * 1000;
data->nernstV = (int16_t)(GetNernstV(ch) * 1000.0);
data->nernstAc = GetNernstAc(ch) * 1000;
data->pumpCurrentTarget = GetPumpCurrent(ch);
data->pumpCurrentMeasured = GetPumpNominalCurrent(ch);
Expand Down
3 changes: 2 additions & 1 deletion firmware/livedata.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ struct livedata_afr_s {
float pumpCurrentMeasured;
uint16_t heaterDuty;
uint16_t heaterEffectiveVoltage;
float esr;
uint16_t esr;
int16_t nernstV;
uint8_t fault; // See wbo::Fault
uint8_t heaterState;
} __attribute__((packed));
Expand Down
7 changes: 7 additions & 0 deletions firmware/sampling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
struct measure_results {
float nernstAc;
float nernstDc;
float nernstV;
float pumpCurrentSenseVoltage;
float internalBatteryVoltage;
int clamped;
Expand Down Expand Up @@ -80,6 +81,7 @@ static void SamplingThread(void*)
// Compute AC (difference) and DC (average) components
float nernstAcLocal = f_abs(r2_opposite_phase - r_2[ch]);
res.nernstDc = (r2_opposite_phase + r_2[ch]) / 2;
res.nernstV = result.ch[ch].NernstVoltage;

res.nernstAc =
(1 - ESR_SENSE_ALPHA) * res.nernstAc +
Expand Down Expand Up @@ -160,6 +162,11 @@ float GetNernstDc(int ch)
return results[ch].nernstDc;
}

float GetNernstV(int ch)
{
return results[ch].nernstV;
}

float GetPumpNominalCurrent(int ch)
{
// Gain is 10x, then a 61.9 ohm resistor
Expand Down
1 change: 1 addition & 0 deletions firmware/sampling.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ float GetNernstAc(int ch);
float GetSensorInternalResistance(int ch);
float GetSensorTemperature(int ch);
float GetNernstDc(int ch);
float GetNernstV(int ch);
float GetPumpNominalCurrent(int ch);
float GetInternalBatteryVoltage(int ch);

0 comments on commit 82f5a9d

Please sign in to comment.