Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

livedata: show Nernst voltage #251

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion firmware/boards/f1_dual/wideband_board_config.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

// TS settings
#define TS_SIGNATURE "rusEFI 2023.03.23.wideband_dual"
#define TS_SIGNATURE "rusEFI 2023.04.21.wideband_dual"

// This board implements two channels
#define AFR_CHANNELS 2
Expand Down
2 changes: 1 addition & 1 deletion firmware/boards/f1_dual_rev1/wideband_board_config.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

// TS settings
#define TS_SIGNATURE "rusEFI 2023.03.23.wideband_dual"
#define TS_SIGNATURE "rusEFI 2023.04.21.wideband_dual"

// This board implements two channels
#define AFR_CHANNELS 2
Expand Down
2 changes: 1 addition & 1 deletion firmware/boards/f1_rev2/wideband_board_config.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

// TS settings
#define TS_SIGNATURE "rusEFI 2023.03.23.wideband_f1"
#define TS_SIGNATURE "rusEFI 2023.04.21.wideband_f1"

// Fundamental board constants
#define VCC_VOLTS (3.3f)
Expand Down
2 changes: 1 addition & 1 deletion firmware/boards/f1_rev3/wideband_board_config.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

// TS settings
#define TS_SIGNATURE "rusEFI 2023.03.23.wideband_f1"
#define TS_SIGNATURE "rusEFI 2023.04.21.wideband_f1"

// Fundamental board constants
#define VCC_VOLTS (3.3f)
Expand Down
1 change: 1 addition & 0 deletions firmware/livedata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ void SamplingUpdateLiveData()
data->lambda = GetLambda(ch);
data->temperature = GetSensorTemperature(ch);
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 @@ -29,7 +29,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;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we have nernstAc, nernstDc, and nernstV?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To log only what we interested in.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

????

why do we have all three of these channels? what is the value of logging the newly added nernstV?

float pumpCurrentSenseVoltage;
float internalBatteryVoltage;
};
Expand Down Expand Up @@ -71,6 +72,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 @@ -144,6 +146,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);