Skip to content

Commit

Permalink
Rename GetInternalBatteryVoltage() to GetInternalHeaterVoltage()
Browse files Browse the repository at this point in the history
  • Loading branch information
dron0gus authored and rusefillc committed Nov 20, 2023
1 parent f784d5d commit 49c08f6
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion firmware/heater_control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ void HeaterControllerBase::Update(const ISampler& sampler, HeaterAllow heaterAll
// If we haven't heard from the ECU, use the internally sensed
// battery voltage instead of voltage over CAN.
float batteryVoltage = heaterAllowState == HeaterAllow::Unknown
? sampler.GetInternalBatteryVoltage()
? sampler.GetInternalHeaterVoltage()
: GetRemoteBatteryVoltage();

// Run the state machine
Expand Down
7 changes: 3 additions & 4 deletions firmware/sampling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,12 @@ float Sampler::GetPumpNominalCurrent() const
return pumpCurrentSenseVoltage * ratio;
}

float Sampler::GetInternalBatteryVoltage() const
float Sampler::GetInternalHeaterVoltage() const
{
#ifdef BATTERY_INPUT_DIVIDER
// Dual HW can measure heater voltage for each channel
// by measuring voltage on Heater- while FET is off
// TODO: rename function?
return internalBatteryVoltage;
return internalHeaterVoltage;
#else
// After 5 seconds, pretend that we get battery voltage.
// This makes the controller usable without CAN control
Expand Down Expand Up @@ -116,7 +115,7 @@ void Sampler::ApplySample(AnalogChannelResult& result, float virtualGroundVoltag
PUMP_FILTER_ALPHA * (result.PumpCurrentVoltage - virtualGroundVoltageInt);

#ifdef BATTERY_INPUT_DIVIDER
internalBatteryVoltage = result.BatteryVoltage;
internalHeaterVoltage = result.HeaterVoltage;
#endif

// Shift history over by one
Expand Down
6 changes: 3 additions & 3 deletions firmware/sampling.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ struct ISampler
virtual float GetNernstDc() const = 0;
virtual float GetNernstAc() const = 0;
virtual float GetPumpNominalCurrent() const = 0;
virtual float GetInternalBatteryVoltage() const = 0;
virtual float GetInternalHeaterVoltage() const = 0;
virtual float GetSensorTemperature() const = 0;
virtual float GetSensorInternalResistance() const = 0;
};
Expand All @@ -25,7 +25,7 @@ class Sampler : public ISampler
float GetNernstDc() const override;
float GetNernstAc() const override;
float GetPumpNominalCurrent() const override;
float GetInternalBatteryVoltage() const override;
float GetInternalHeaterVoltage() const override;
float GetSensorTemperature() const override;
float GetSensorInternalResistance() const override;

Expand All @@ -38,7 +38,7 @@ class Sampler : public ISampler
float pumpCurrentSenseVoltage = 0;

#ifdef BATTERY_INPUT_DIVIDER
float internalBatteryVoltage = 0;
float internalHeaterVoltage = 0;
#endif

Timer m_startupTimer;
Expand Down
2 changes: 1 addition & 1 deletion firmware/uart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ static void UartThread(void*)
float lambda = GetLambda(ch);
int lambdaIntPart = lambda;
int lambdaThousandths = (lambda - lambdaIntPart) * 1000;
int batteryVoltageMv = GetSampler(ch).GetInternalBatteryVoltage() * 1000;
int batteryVoltageMv = GetSampler(ch).GetInternalHeaterVoltage() * 1000;
int duty = GetHeaterDuty(ch) * 100;

size_t writeCount = chsnprintf(printBuffer, 200,
Expand Down

0 comments on commit 49c08f6

Please sign in to comment.