mirror of https://github.com/rusefi/rusefi-1.git
no fan if stopped engine (#2822)
* no fan if stopped engine * config * use config * more tests * merge Co-authored-by: Matthew Kennedy <makenne@microsoft.com>
This commit is contained in:
parent
3f63a108aa
commit
32f5ce6fb4
|
@ -7,10 +7,19 @@
|
||||||
|
|
||||||
EXTERN_ENGINE;
|
EXTERN_ENGINE;
|
||||||
|
|
||||||
static void fanControl(bool acActive, OutputPin& pin, int8_t fanOnTemp, int8_t fanOffTemp, bool enableWithAc DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
static void fanControl(bool acActive, OutputPin& pin, int8_t fanOnTemp, int8_t fanOffTemp, bool enableWithAc, bool disableWhenStopped DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||||
auto [cltValid, clt] = Sensor::get(SensorType::Clt);
|
auto [cltValid, clt] = Sensor::get(SensorType::Clt);
|
||||||
|
|
||||||
if (!cltValid) {
|
bool isCranking = ENGINE(rpmCalculator).isCranking();
|
||||||
|
bool isRunning = ENGINE(rpmCalculator).isRunning();
|
||||||
|
|
||||||
|
if (isCranking) {
|
||||||
|
// Inhibit while cranking
|
||||||
|
pin.setValue(false);
|
||||||
|
} else if (disableWhenStopped && !isRunning) {
|
||||||
|
// Inhibit while not running (if so configured)
|
||||||
|
pin.setValue(false);
|
||||||
|
} else if (!cltValid) {
|
||||||
// If CLT is broken, turn the fan on
|
// If CLT is broken, turn the fan on
|
||||||
pin.setValue(true);
|
pin.setValue(true);
|
||||||
} else if (enableWithAc && acActive) {
|
} else if (enableWithAc && acActive) {
|
||||||
|
@ -33,6 +42,6 @@ void updateFans(bool acActive DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
fanControl(acActive, enginePins.fanRelay, CONFIG(fanOnTemperature), CONFIG(fanOffTemperature), CONFIG(enableFan1WithAc) PASS_ENGINE_PARAMETER_SUFFIX);
|
fanControl(acActive, enginePins.fanRelay, CONFIG(fanOnTemperature), CONFIG(fanOffTemperature), CONFIG(enableFan1WithAc), CONFIG(disableFan1WhenStopped) PASS_ENGINE_PARAMETER_SUFFIX);
|
||||||
fanControl(acActive, enginePins.fanRelay2, CONFIG(fan2OnTemperature), CONFIG(fan2OffTemperature), CONFIG(enableFan2WithAc) PASS_ENGINE_PARAMETER_SUFFIX);
|
fanControl(acActive, enginePins.fanRelay2, CONFIG(fan2OnTemperature), CONFIG(fan2OffTemperature), CONFIG(enableFan2WithAc), CONFIG(disableFan2WhenStopped) PASS_ENGINE_PARAMETER_SUFFIX);
|
||||||
}
|
}
|
||||||
|
|
|
@ -532,8 +532,8 @@ bit isVerboseAuxPid1
|
||||||
bit overrideTriggerGaps
|
bit overrideTriggerGaps
|
||||||
bit enableFan1WithAc;+Turn on this fan when AC is on.
|
bit enableFan1WithAc;+Turn on this fan when AC is on.
|
||||||
bit enableFan2WithAc;+Turn on this fan when AC is on.
|
bit enableFan2WithAc;+Turn on this fan when AC is on.
|
||||||
bit unused_294_6
|
bit disableFan1WhenStopped;+Inhibit operation of this fan while the engine is not running.
|
||||||
bit unused_294_7
|
bit disableFan2WhenStopped;+Inhibit operation of this fan while the engine is not running.
|
||||||
bit unused_294_8
|
bit unused_294_8
|
||||||
bit isCJ125Verbose;enable cj125verbose/disable cj125verbose
|
bit isCJ125Verbose;enable cj125verbose/disable cj125verbose
|
||||||
bit cj125isUaDivided;+Is your UA CJ125 output wired to MCU via resistor divider? Ua can go over 3.3v but only at lambda >3, i.e very lean AFR above 44.1\nWhen exposed to free air and 17x gain, Ua will be 4.17 volt
|
bit cj125isUaDivided;+Is your UA CJ125 output wired to MCU via resistor divider? Ua can go over 3.3v but only at lambda >3, i.e very lean AFR above 44.1\nWhen exposed to free air and 17x gain, Ua will be 4.17 volt
|
||||||
|
|
|
@ -2690,6 +2690,7 @@ cmd_set_engine_type_default = "@@TS_IO_TEST_COMMAND_char@@\x00\x31\x00\x00"
|
||||||
field = "On temperature", fanOnTemperature
|
field = "On temperature", fanOnTemperature
|
||||||
field = "Off temperature", fanOffTemperature
|
field = "Off temperature", fanOffTemperature
|
||||||
field = "Enable with AC", enableFan1WithAc
|
field = "Enable with AC", enableFan1WithAc
|
||||||
|
field = "Disable when engine stopped", disableFan1WhenStopped
|
||||||
|
|
||||||
dialog = fan2Settings, "Fan 2"
|
dialog = fan2Settings, "Fan 2"
|
||||||
field = "Pin", fan2Pin
|
field = "Pin", fan2Pin
|
||||||
|
@ -2697,6 +2698,7 @@ cmd_set_engine_type_default = "@@TS_IO_TEST_COMMAND_char@@\x00\x31\x00\x00"
|
||||||
field = "On temperature", fan2OnTemperature
|
field = "On temperature", fan2OnTemperature
|
||||||
field = "Off temperature", fan2OffTemperature
|
field = "Off temperature", fan2OffTemperature
|
||||||
field = "Enable with AC", enableFan2WithAc
|
field = "Enable with AC", enableFan2WithAc
|
||||||
|
field = "Disable when engine stopped", disableFan2WhenStopped
|
||||||
|
|
||||||
dialog = acSettings, "A/C Settings"
|
dialog = acSettings, "A/C Settings"
|
||||||
field = "A/C Relay", acRelayPin
|
field = "A/C Relay", acRelayPin
|
||||||
|
|
|
@ -43,4 +43,29 @@ TEST(FanControl, fan1) {
|
||||||
// Turn off AC, fan should turn off too.
|
// Turn off AC, fan should turn off too.
|
||||||
updateFans(false PASS_ENGINE_PARAMETER_SUFFIX);
|
updateFans(false PASS_ENGINE_PARAMETER_SUFFIX);
|
||||||
EXPECT_EQ(false, enginePins.fanRelay.getLogicValue());
|
EXPECT_EQ(false, enginePins.fanRelay.getLogicValue());
|
||||||
|
|
||||||
|
// Back to hot, fan should turn on
|
||||||
|
Sensor::setMockValue(SensorType::Clt, 95);
|
||||||
|
updateFans(false PASS_ENGINE_PARAMETER_SUFFIX);
|
||||||
|
EXPECT_EQ(true, enginePins.fanRelay.getLogicValue());
|
||||||
|
|
||||||
|
// Engine starts cranking, fan should turn off
|
||||||
|
ENGINE(rpmCalculator).setRpmValue(100);
|
||||||
|
updateFans(false PASS_ENGINE_PARAMETER_SUFFIX);
|
||||||
|
EXPECT_EQ(false, enginePins.fanRelay.getLogicValue());
|
||||||
|
|
||||||
|
// Engine running, fan should turn back on
|
||||||
|
ENGINE(rpmCalculator).setRpmValue(1000);
|
||||||
|
updateFans(false PASS_ENGINE_PARAMETER_SUFFIX);
|
||||||
|
EXPECT_EQ(true, enginePins.fanRelay.getLogicValue());
|
||||||
|
|
||||||
|
// Stop the engine, fan should stay on
|
||||||
|
ENGINE(rpmCalculator).setRpmValue(0);
|
||||||
|
updateFans(false PASS_ENGINE_PARAMETER_SUFFIX);
|
||||||
|
EXPECT_EQ(true, enginePins.fanRelay.getLogicValue());
|
||||||
|
|
||||||
|
// Set configuration to inhibit fan while engine is stopped, fan should stop
|
||||||
|
engineConfiguration->disableFan1WhenStopped = true;
|
||||||
|
updateFans(false PASS_ENGINE_PARAMETER_SUFFIX);
|
||||||
|
EXPECT_EQ(false, enginePins.fanRelay.getLogicValue());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue