Skip to content

Commit 8f4522d

Browse files
committed
Add heater control parameters to TunerStudio
1 parent 5aaa9e6 commit 8f4522d

4 files changed

Lines changed: 29 additions & 8 deletions

File tree

firmware/boards/port.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class Configuration {
5757
private:
5858
// Increment this any time the configuration format changes
5959
// It is stored along with the data to ensure that it has been written before
60-
static constexpr uint32_t ExpectedTag = 0xDEADBE02;
60+
static constexpr uint32_t ExpectedTag = 0xDEADBE03;
6161
uint32_t Tag = ExpectedTag;
6262

6363
public:
@@ -107,6 +107,10 @@ class Configuration {
107107
egt[i].AemNetIdOffset = i;
108108
}
109109

110+
heaterConfig.HeaterSupplyOffVoltage = HEATER_SUPPLY_OFF_VOLTAGE * 100;
111+
heaterConfig.HeaterSupplyOnVoltage = HEATER_SUPPLY_ON_VOLTAGE * 100;
112+
heaterConfig.HeaterBatteryStabTime = HEATER_BATTERY_STAB_TIME * 100;
113+
110114
/* Finaly */
111115
Tag = ExpectedTag;
112116
}
@@ -143,6 +147,13 @@ class Configuration {
143147
uint8_t AemNetIdOffset;
144148
uint8_t pad[5];
145149
} egt[2];
150+
151+
struct {
152+
uint16_t HeaterSupplyOffVoltage; // volts * 100
153+
uint16_t HeaterSupplyOnVoltage; // volts * 100
154+
uint16_t HeaterBatteryStabTime; // seconds * 100
155+
uint8_t pad[2];
156+
} heaterConfig;
146157
} __attribute__((packed));
147158

148159
// pad to 256 bytes including tag

firmware/heater_control.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,12 @@
33
#include "status.h"
44
#include "sampling.h"
55

6+
#include "port.h"
7+
68
using namespace wbo;
79

10+
static Configuration* configuration;
11+
812
static const PidConfig heaterPidConfig =
913
{
1014
.kP = 0.3f, // kP
@@ -23,6 +27,8 @@ HeaterControllerBase::HeaterControllerBase(int ch, int preheatTimeSec, int warmu
2327

2428
void HeaterControllerBase::Configure(float targetTempC, float targetEsr)
2529
{
30+
configuration = GetConfiguration();
31+
2632
m_targetTempC = targetTempC;
2733
m_targetEsr = targetEsr;
2834

@@ -60,14 +66,14 @@ HeaterState HeaterControllerBase::GetNextState(HeaterState currentState, HeaterA
6066
if (heaterAllowState == HeaterAllow::Unknown)
6167
{
6268
// measured voltage too low to auto-start heating
63-
if (heaterSupplyVoltage < HEATER_SUPPLY_OFF_VOLTAGE)
69+
if (heaterSupplyVoltage < configuration->heaterConfig.HeaterSupplyOffVoltage / 100.0f)
6470
{
6571
m_heaterStableTimer.reset();
6672
}
67-
else if (heaterSupplyVoltage > HEATER_SUPPLY_ON_VOLTAGE)
73+
else if (heaterSupplyVoltage > configuration->heaterConfig.HeaterSupplyOnVoltage / 100.0f)
6874
{
6975
// measured voltage is high enougth to auto-start heating, wait some time to stabilize
70-
heaterAllowed = m_heaterStableTimer.hasElapsedSec(HEATER_BATTERY_STAB_TIME);
76+
heaterAllowed = m_heaterStableTimer.hasElapsedSec(configuration->heaterConfig.HeaterBatteryStabTime / 100.0f);
7177
}
7278
}
7379

@@ -168,8 +174,6 @@ HeaterState HeaterControllerBase::GetNextState(HeaterState currentState, HeaterA
168174
// looks like heavy ramped Ipump affects sensorTemp measure
169175
// and right after switch to closed loop sensorTemp drops below underhead threshold
170176
}
171-
// reset fault
172-
SetFault(ch, Fault::None);
173177

174178
break;
175179
case HeaterState::Stopped:

firmware/heater_control.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,6 @@ class HeaterControllerBase : public IHeaterController
7777
// occured
7878
Timer m_underheatTimer;
7979
Timer m_overheatTimer;
80-
81-
static const int batteryStabTimeCounter = HEATER_BATTERY_STAB_TIME / HEATER_CONTROL_PERIOD;
8280
};
8381

8482
const IHeaterController& GetHeaterController(int ch);

firmware/ini/wideband_dual.ini

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ AemNetEgtIdx0 = scalar, U08, 154, "", 1, 0, 0, 2
8787
AemNetEgtTx1 = bits, U08, 160, [2:2], "Disable", "Enable"
8888
AemNetEgtIdx1 = scalar, U08, 162, "", 1, 0, 0, 255, 0
8989

90+
HeaterSupplyOffVoltage = scalar, U16, 168, "V", 0.01, 0, 0, 24.0, 2
91+
HeaterSupplyOnVoltage = scalar, U16, 170, "V", 0.01, 0, 0, 24.0, 2
92+
9093
page = 2 ; this is a RAM only page with no burnable flash
9194
; name = class, type, offset, [shape], units, scale, translate, min, max, digits
9295
highSpeedOffsets = array, U16, 0, [32], "", 1, 0, 0, 65535, 0, noMsqSave
@@ -333,6 +336,7 @@ entry = EGT1_commErrors, "EGT 1: comm errors", int, "%d"
333336
menuDialog = main
334337
menu = "&Settings"
335338
subMenu = sensor_settings, "Sensor settings"
339+
subMenu = heater_settings, "Heater settings"
336340
subMenu = can_settings, "CAN AFR settings"
337341
subMenu = can_egt_settings, "CAN EGT settings"
338342

@@ -365,6 +369,10 @@ cmd_openblt = "Z\x00\xbc\x00\x00"
365369
dialog = sensor_settings, "Sensor Settings"
366370
field = "Sensor Type", LsuSensorType
367371

372+
dialog = heater_settings, "Heater Settings"
373+
field = "Heater Supply Off Voltage", HeaterSupplyOffVoltage
374+
field = "Heater Supply On Voltage", HeaterSupplyOnVoltage
375+
368376
dialog = afr0_can_settings, "AFR 0 (left) channel CAN Settings"
369377
field = "RusEFI protocol:"
370378
field = "Output AFR", RusEfiTx0

0 commit comments

Comments
 (0)