Coolant/RPM Protection (#785)

* Coolant/RPM Protection

* removed test  clear flash option

* Add new update section for coolantProtEnbl rather than using old area

Co-authored-by: Benas <bbrazdziunas@gavea.co.uk>
Co-authored-by: Josh Stewart <josh@noisymime.org>
This commit is contained in:
Benas Brazdziunas 2022-02-13 23:41:58 +00:00 committed by GitHub
parent 6be6cd7795
commit 07a4d1ea79
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 77 additions and 20 deletions

View File

@ -1038,7 +1038,15 @@ page = 9
boostByGear6 = scalar, U08, 161, { bitStringValue(boostByGearLabels , boostByGearEnabled) }, 2.0, 0.0, 0.0, {boostTableLimit}, 0
PWMFanDuty = array, U08, 162, [4], "%", 0.5, 0, 0, 100, 1
unused10_160 = array, U08, 166, [26], "", 1, 0, 0, 255, 0
coolantProtEnbl = bits, U08, 166, [0:0], "Off", "On"
coolantProtRPM = array, U08, 167, [6], "RPM", 100.0, 0.0, 100.0, 25500, 0
#if CELSIUS
coolantProtTemp = array, U08, 173, [6], "C", 1.0, -40, -40, 215, 0
#else
coolantProtTemp = array, U08, 173, [6], "F", 1.8, -22.23, -40, 215, 0
#endif
unused179_191 = array, U08, 179, [13], "", 1, 0, 0, 255, 0
page = 10
#if CELSIUS
@ -1824,7 +1832,7 @@ menuDialog = main
menuDialog = main
menu = "Hardware Testing"
subMenu = outputtest1, "Test Output Hardware"
subMenu = stm32cmd, "STM32 Commands"
subMenu = stm32cmd, "STM32 Commands"
;subMenu = rtc_settings, "Setup realtime clock"
#endif
@ -2748,12 +2756,17 @@ menuDialog = main
field = "Oil Pressure Protection", oilPressureProtEnbl, { oilPressureEnable }
panel = oil_pressure_prot_curve, { oilPressureEnable && oilPressureProtEnbl }
dialog = coolantProtection, "Coolant Temperature Protection"
field = "Coolant Temperature Protection", coolantProtEnbl
panel = coolant_prot_curve, { coolantProtEnbl }
indicatorPanel = protectIndicatorPanel, 1, { 1 }
indicator = { engineProtectStatus}, "Engine Protect OFF", "Engine Protect ON", green, black, red, black
indicator = { engineProtectRPM }, "Rev Limiter Off", "Rev Limiter ON", green, black, red, black
indicator = { engineProtectMAP }, "Boost Limit OFF", "Boost Limit ON", green, black, red, black
indicator = { engineProtectOil }, "Oil Pres. Protect OFF","Oil Pres. Protect ON",green, black, red, black
indicator = { engineProtectAFR }, "AFR Protect OFF", "AFR Protect ON", green, black, red, black
indicator = { engineProtectCoolant }, "Coolant Protect OFF", "Coolant Protect ON", green, black, red, black
dialog = engineProtectionWest, ""
field = "Protection Cut", engineProtectType
@ -2767,6 +2780,7 @@ menuDialog = main
panel = revLimiterDialog, { engineProtectType }
panel = boostCut, { engineProtectType }
panel = oilPressureProtection, { engineProtectType }
panel = coolantProtection, { engineProtectType }
dialog = clutchInput, "Clutch input"
@ -4397,6 +4411,19 @@ cmdVSSratio6 = "E\x99\x06"
yBins = oilPressureProtMins
size = 400, 200
; Coolant protection curve
curve = coolant_prot_curve, "Coolant Temperature Protection"
columnLabel = "Coolant", "RPM"
#if CELSIUS
xAxis = 0, 140, 5
#else
xAxis = -40, 315, 5
#endif
yAxis = 0, 8000, 3
xBins = coolantProtTemp, coolant
yBins = coolantProtRPM
size = 200, 200
; Warmup enrichment VEAL AFR adjustment curves
curve = warmup_afr_curve, "Target Adjustment"
columnLabel = "Coolant", "Offset"
@ -4786,6 +4813,7 @@ cmdVSSratio6 = "E\x99\x06"
indicator = { engineProtectMAP }, "Boost Limit OFF", "Boost Limit ON", white, black, red, black
indicator = { engineProtectOil }, "Oil Pres. Protect OFF","Oil Pres. Protect ON",white, black, red, black
indicator = { engineProtectAFR }, "AFR Protect OFF", "AFR Protect ON", white, black, red, black
indicator = { engineProtectCoolant }, "Coolant Protect OFF","Coolant Protect ON",white, black, red, black
indicator = { wmiEmptyBit }, "WMI Tank NOT Empty", "WMI Tank Empty", white, black, red, black
indicator = { vvt1Error }, "VVT1 Ok", "VVT1 Error", white, black, red, black
indicator = { vvt2Error }, "VVT2 Ok", "VVT2 Error", white, black, red, black
@ -4913,7 +4941,8 @@ cmdVSSratio6 = "E\x99\x06"
engineProtectMAP = bits, U08, 84, [1:1]
engineProtectOil = bits, U08, 84, [2:2]
engineProtectAFR = bits, U08, 84, [3:3]
engineProtectOth = bits, U08, 84, [4:6] ; Unused for now
engineProtectCoolant = bits, U08, 84, [4:4]
engineProtectOth = bits, U08, 84, [5:6] ; Unused for now
IOError = bits, U08, 84, [7:7]
unused1 = scalar, U08, 84, "ADC",1.000, 0.000
fuelLoad = scalar, S16, 85, { bitStringValue( algorithmUnits , algorithm ) }, fuelLoadFeedBack, 0.000

View File

@ -5,7 +5,7 @@
byte checkEngineProtect()
{
byte protectActive = 0;
if(checkRevLimit() || checkBoostLimit() || checkOilPressureLimit() || checkAFRLimit())
if(checkRevLimit() || checkBoostLimit() || checkOilPressureLimit() || checkAFRLimit() || checkCoolantTempLimit())
{
if( currentStatus.RPMdiv100 > configPage4.engineProtectMaxRPM ) { protectActive = 1; }
}
@ -95,6 +95,24 @@ byte checkOilPressureLimit()
return oilProtectActive;
}
byte checkCoolantTempLimit()
{
byte coolantProtectActive = 0;
BIT_CLEAR(currentStatus.engineProtectStatus, ENGINE_PROTECT_BIT_COOLANT); //Will be set true below if required
if( (configPage9.coolantProtEnbl == true))
{
int8_t coolantLimit = (int16_t)(table2D_getValue(&coolantProtectTable, currentStatus.coolant + CALIBRATION_TEMPERATURE_OFFSET));
if(currentStatus.RPMdiv100 > coolantLimit)
{
BIT_SET(currentStatus.engineProtectStatus, ENGINE_PROTECT_BIT_COOLANT);
coolantProtectActive = 1;
}
}
return coolantProtectActive;
}
byte checkAFRLimit()
{
byte checkAFRLimitActive = 0;

View File

@ -390,6 +390,7 @@
#define ENGINE_PROTECT_BIT_MAP 1
#define ENGINE_PROTECT_BIT_OIL 2
#define ENGINE_PROTECT_BIT_AFR 3
#define ENGINE_PROTECT_BIT_COOLANT 4
#define CALIBRATION_TABLE_SIZE 512 ///< Calibration table size for CLT, IAT, O2
@ -476,6 +477,7 @@ extern struct table2D knockWindowStartTable;
extern struct table2D knockWindowDurationTable;
extern struct table2D oilPressureProtectTable;
extern struct table2D wmiAdvTable; //6 bin wmi correction table for timing advance (2D)
extern struct table2D coolantProtectTable; //6 bin coolant temperature protection table for engine protection (2D)
extern struct table2D fanPWMTable;
//These are for the direct port manipulation of the injectors, coils and aux outputs
@ -1152,19 +1154,9 @@ struct config9 {
byte boostByGear6;
byte PWMFanDuty[4];
byte unused10_166;
byte unused10_167;
byte unused10_168;
byte unused10_169;
byte unused10_170;
byte unused10_171;
byte unused10_172;
byte unused10_173;
byte unused10_174;
byte unused10_175;
byte unused10_176;
byte unused10_177;
byte unused10_178;
byte coolantProtEnbl : 1;
byte coolantProtRPM[6];
byte coolantProtTemp[6];
byte unused10_179;
byte unused10_180;
byte unused10_181;

View File

@ -52,6 +52,7 @@ struct table2D knockWindowStartTable;
struct table2D knockWindowDurationTable;
struct table2D oilPressureProtectTable;
struct table2D wmiAdvTable; //6 bin wmi correction table for timing advance (2D)
struct table2D coolantProtectTable;
struct table2D fanPWMTable;
/// volatile inj*_pin_port and inj*_pin_mask vars are for the direct port manipulation of the injectors, coils and aux outputs.

View File

@ -239,6 +239,13 @@ void initialiseAll()
oilPressureProtectTable.values = configPage10.oilPressureProtMins;
oilPressureProtectTable.axisX = configPage10.oilPressureProtRPM;
coolantProtectTable.valueSize = SIZE_BYTE;
coolantProtectTable.axisSize = SIZE_BYTE; //Set this table to use byte axis bins
coolantProtectTable.xSize = 6;
coolantProtectTable.values = configPage9.coolantProtRPM;
coolantProtectTable.axisX = configPage9.coolantProtTemp;
fanPWMTable.valueSize = SIZE_BYTE;
fanPWMTable.axisSize = SIZE_BYTE; //Set this table to use byte axis bins
fanPWMTable.xSize = 4;

View File

@ -16,7 +16,7 @@
void doUpdates()
{
#define CURRENT_DATA_VERSION 19
#define CURRENT_DATA_VERSION 20
//Only the latest updat for small flash devices must be retained
#ifndef SMALL_FLASH_MODE
@ -403,7 +403,7 @@ void doUpdates()
configPage10.oilPressureProtEnbl = false;
configPage10.oilPressureEnable = false;
configPage10.fuelPressureEnable = false;
//wmi
configPage10.wmiEnabled = 0;
configPage10.wmiMode = 0;
@ -522,6 +522,7 @@ void doUpdates()
if(readEEPROMVersion() == 18)
{
//202202
configPage2.fanEnable = configPage6.fanUnused; // PWM Fan mode added, but take the previous setting of Fan in use.
//TPS resolution increased to 0.5%
@ -582,6 +583,15 @@ void doUpdates()
writeAllConfig();
storeEEPROMVersion(19);
}
if(readEEPROMVersion() == 19)
{
//202204
configPage9.coolantProtEnbl = false;
writeAllConfig();
storeEEPROMVersion(20);
}
//Final check is always for 255 and 0 (Brand new arduino)
if( (readEEPROMVersion() == 0) || (readEEPROMVersion() == 255) )
@ -625,4 +635,4 @@ void divideTableLoad(const void *pTable, table_type_t key, uint8_t divisor)
*y_it = (byte)*y_it / divisor; //Previous TS scale was 2.0, now is 0.5, 4x increase
++y_it;
}
}
}