Delayed A/C compressor switch #922

This commit is contained in:
rusefi 2019-09-11 20:46:50 -04:00
parent 7395bb44e7
commit f0427360bf
13 changed files with 106 additions and 26 deletions

View File

@ -61,7 +61,29 @@ static bool mightResetPid = false;
// Use new PID with CIC integrator
PidCic idlePid;
#else
Pid idlePid;
class PidWithOverrides : public Pid {
public:
float getOffset() const override {
#if EFI_FSIO && ! EFI_UNIT_TEST
if (engineConfiguration->useFSIO12ForIdleOffset) {
return ENGINE(fsioState.fsioIdleOffset);
}
#endif /* EFI_FSIO */
return parameters->offset;
}
float getMinValue() const override {
#if EFI_FSIO && ! EFI_UNIT_TEST
if (engineConfiguration->useFSIO13ForIdleMinValue) {
return ENGINE(fsioState.fsioIdleMinValue);
}
#endif /* EFI_FSIO */
return parameters->minValue;
}
};
PidWithOverrides idlePid;
#endif /* EFI_IDLE_INCREMENTAL_PID_CIC */
// todo: extract interface for idle valve hardware, with solenoid and stepper implementations?
@ -221,7 +243,6 @@ static percent_t automaticIdleController(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
int targetRpm = getTargetRpmForIdleCorrection(PASS_ENGINE_PARAMETER_SIGNATURE);
efitick_t nowNt = getTimeNowNt();
// check if within the dead zone
float rpm;
if (CONFIG(useInstantRpmForIdle)) {
@ -229,6 +250,8 @@ static percent_t automaticIdleController(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
} else {
rpm = GET_RPM();
}
// check if within the dead zone
if (absI(rpm - targetRpm) <= CONFIG(idlePidRpmDeadZone)) {
engine->engineState.idle.idleState = RPM_DEAD_ZONE;
// current RPM is close enough, no need to change anything
@ -249,9 +272,9 @@ static percent_t automaticIdleController(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
// the state of PID has been changed, so we might reset it now, but only when needed (see idlePidDeactivationTpsThreshold)
mightResetPid = true;
#if EFI_IDLE_INCREMENTAL_PID_CIC
percent_t tpsPos = getTPS(PASS_ENGINE_PARAMETER_SIGNATURE);
#if EFI_IDLE_INCREMENTAL_PID_CIC
// Treat the 'newValue' as if it contains not an actual IAC position, but an incremental delta.
// So we add this delta to the base IAC position, with a smooth taper for TPS transients.
newValue = engine->engineState.idle.baseIdlePosition + interpolateClamped(0.0f, newValue, CONFIGB(idlePidDeactivationTpsThreshold), 0.0f, tpsPos);

View File

@ -148,6 +148,9 @@ public:
float servoValues[SERVO_COUNT];
float fsioLastValue[FSIO_COMMAND_COUNT];
float fsioIdleOffset = 0;
float fsioIdleMinValue = 0;
#if EFI_ENABLE_ENGINE_WARNING
/**
* Shall we purposely miss on some cylinders in order to attract driver's attention to some problem

View File

@ -5,6 +5,8 @@
* set debug_mode 23
* https://rusefi.com/wiki/index.php?title=Manual:Flexible_Logic
*
* 'fsioinfo' command in console shows current state of FSIO - formulas and current value
*
* @date Oct 5, 2014
* @author Andrey Belomutskiy, (c) 2012-2019
*/
@ -27,6 +29,11 @@
*/
#define NO_PWM 0
// see useFSIO12ForIdleOffset
#define MAGIC_OFFSET_FOR_IDLE_OFFSET 12
// see useFSIO13ForIdleMinValue
#define MAGIC_OFFSET_FOR_IDLE_MIN_VALUE 13
// see useFSIO15ForIdleRpmAdjustment
#define MAGIC_OFFSET_FOR_IDLE_TARGET_RPM 14
// see useFSIO16ForTimingAdjustment
@ -50,7 +57,9 @@ static LENameOrdinalPair leVBatt(LE_METHOD_VBATT, "vbatt");
static LENameOrdinalPair leFan(LE_METHOD_FAN, "fan");
static LENameOrdinalPair leCoolant(LE_METHOD_COOLANT, "coolant");
static LENameOrdinalPair leIsCoolantBroken(LE_METHOD_IS_COOLANT_BROKEN, "is_clt_broken");
// @returns boolean state of A/C toggle switch
static LENameOrdinalPair leAcToggle(LE_METHOD_AC_TOGGLE, "ac_on_switch");
// @returns float number of seconds since last A/C toggle
static LENameOrdinalPair leTimeSinceAcToggle(LE_METHOD_TIME_SINCE_AC_TOGGLE, "time_since_ac_on_switch");
static LENameOrdinalPair leTimeSinceBoot(LE_METHOD_TIME_SINCE_BOOT, "time_since_boot");
static LENameOrdinalPair leFsioSetting(LE_METHOD_FSIO_SETTING, "fsio_setting");
@ -496,10 +505,15 @@ void runFsio(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
}
#endif /* EFI_ENABLE_CRITICAL_ENGINE_STOP */
if (engineConfiguration->useFSIO12ForIdleOffset) {
updateValueOrWarning(MAGIC_OFFSET_FOR_IDLE_OFFSET, "idle offset", &ENGINE(fsioState.fsioIdleOffset) PASS_ENGINE_PARAMETER_SUFFIX);
}
if (engineConfiguration->useFSIO13ForIdleMinValue) {
updateValueOrWarning(MAGIC_OFFSET_FOR_IDLE_MIN_VALUE, "idle minValue", &ENGINE(fsioState.fsioIdleMinValue) PASS_ENGINE_PARAMETER_SUFFIX);
}
if (engineConfiguration->useFSIO15ForIdleRpmAdjustment) {
updateValueOrWarning(MAGIC_OFFSET_FOR_IDLE_TARGET_RPM, "RPM target", &ENGINE(fsioState.fsioIdleTargetRPMAdjustment) PASS_ENGINE_PARAMETER_SUFFIX);
}
if (engineConfiguration->useFSIO16ForTimingAdjustment) {
updateValueOrWarning(MAGIC_OFFSET_FOR_TIMING_FSIO, "timing", &ENGINE(fsioState.fsioTimingAdjustment) PASS_ENGINE_PARAMETER_SUFFIX);
}

View File

@ -814,6 +814,6 @@ int getRusEfiVersion(void) {
if (initBootloader() != 0)
return 123;
#endif /* EFI_BOOTLOADER_INCLUDE_CODE */
return 20190910;
return 20190911;
}
#endif /* EFI_UNIT_TEST */

View File

@ -1,4 +1,4 @@
// this file was generated automatically by rusEfi tool ConfigDefinition.jar based on integration\rusefi_config.txt Tue Sep 10 23:14:54 EDT 2019
// this file was generated automatically by rusEfi tool ConfigDefinition.jar based on integration\rusefi_config.txt Wed Sep 11 20:00:32 EDT 2019
// by class com.rusefi.output.FileFsioSettingsConsumer
FSIO_SETTING_FANONTEMPERATURE = 1000,
@ -22,3 +22,5 @@
FSIO_SETTING_AUXPID4_MINVALUE = 1018,
FSIO_SETTING_IDLETIMINGPID_OFFSET = 1019,
FSIO_SETTING_IDLETIMINGPID_MINVALUE = 1020,
FSIO_SETTING_IDLERPMPID2_OFFSET = 1021,
FSIO_SETTING_IDLERPMPID2_MINVALUE = 1022,

View File

@ -1,4 +1,4 @@
// this file was generated automatically by rusEfi tool ConfigDefinition.jar based on integration\rusefi_config.txt Tue Sep 10 23:40:30 EDT 2019
// this file was generated automatically by rusEfi tool ConfigDefinition.jar based on integration\rusefi_config.txt Wed Sep 11 20:00:32 EDT 2019
// by class com.rusefi.output.FileFsioSettingsConsumer
case FSIO_SETTING_FANONTEMPERATURE:
@ -43,3 +43,7 @@
return engineConfiguration->idleTimingPid.offset;
case FSIO_SETTING_IDLETIMINGPID_MINVALUE:
return engineConfiguration->idleTimingPid.minValue;
case FSIO_SETTING_IDLERPMPID2_OFFSET:
return engineConfiguration->idleRpmPid2.offset;
case FSIO_SETTING_IDLERPMPID2_MINVALUE:
return engineConfiguration->idleRpmPid2.minValue;

View File

@ -1,4 +1,4 @@
// this file was generated automatically by rusEfi tool ConfigDefinition.jar based on integration\rusefi_config.txt Wed Sep 11 18:41:30 EDT 2019
// this file was generated automatically by rusEfi tool ConfigDefinition.jar based on integration\rusefi_config.txt Wed Sep 11 20:00:32 EDT 2019
// by class com.rusefi.output.FileFsioSettingsConsumer
static LENameOrdinalPair lefanOnTemperature(FSIO_SETTING_FANONTEMPERATURE, "cfg_fanOnTemperature");
@ -22,3 +22,5 @@ static LENameOrdinalPair leauxPid4_offset(FSIO_SETTING_AUXPID4_OFFSET, "cfg_auxP
static LENameOrdinalPair leauxPid4_minValue(FSIO_SETTING_AUXPID4_MINVALUE, "cfg_auxPid4_minValue");
static LENameOrdinalPair leidleTimingPid_offset(FSIO_SETTING_IDLETIMINGPID_OFFSET, "cfg_idleTimingPid_offset");
static LENameOrdinalPair leidleTimingPid_minValue(FSIO_SETTING_IDLETIMINGPID_MINVALUE, "cfg_idleTimingPid_minValue");
static LENameOrdinalPair leidleRpmPid2_offset(FSIO_SETTING_IDLERPMPID2_OFFSET, "cfg_idleRpmPid2_offset");
static LENameOrdinalPair leidleRpmPid2_minValue(FSIO_SETTING_IDLERPMPID2_MINVALUE, "cfg_idleRpmPid2_minValue");

View File

@ -1,4 +1,4 @@
// this file was generated automatically by rusEfi tool ConfigDefinition.jar based on integration\rusefi_config.txt Wed Sep 11 19:17:01 EDT 2019
// this file was generated automatically by rusEfi tool ConfigDefinition.jar based on integration\rusefi_config.txt Wed Sep 11 20:00:32 EDT 2019
// by class com.rusefi.output.FileFsioSettingsConsumer
case FSIO_SETTING_FANONTEMPERATURE:
@ -43,3 +43,7 @@
return "cfg_idleTimingPid_offset";
case FSIO_SETTING_IDLETIMINGPID_MINVALUE:
return "cfg_idleTimingPid_minValue";
case FSIO_SETTING_IDLERPMPID2_OFFSET:
return "cfg_idleRpmPid2_offset";
case FSIO_SETTING_IDLERPMPID2_MINVALUE:
return "cfg_idleRpmPid2_minValue";

View File

@ -25,7 +25,8 @@
// Human-readable: coolant > 120
#define TOO_HOT_LOGIC "coolant 120 >"
// Human-readable: ac_on_switch & rpm > 850
// Human-readable: ac_on_switch & rpm > 850 & time_since_ac_on_switch > 0.3
// ac_on_switch rpm & 850 time_since_ac_on_switch & > 0.3 >
#define AC_RELAY_LOGIC "ac_on_switch rpm & 850 >"
// Combined RPM, CLT and VBATT warning light

View File

@ -737,8 +737,8 @@ bit hasFrequencyReportingMapSensor;
bit useFSIO15ForIdleRpmAdjustment;
bit useFSIO5ForCriticalIssueEngineStop;Sometimes we just have to shut the engine down. Use carefully!
bit useFSIO4ForSeriousEngineWarning;Sometimes we have to miss injection on purpose to attract driver's attention
bit unused_bit_1472_29;
bit unused_bit_1472_30;
bit useFSIO12ForIdleOffset;
bit useFSIO13ForIdleMinValue;
adc_channel_e hipOutputChannel;
adc_channel_e acSwitchAdc;A/C button input handled as analogue input
@ -1056,7 +1056,8 @@ uint8_t[4] unusuedvref;
uint8_t[4] unusuedsw;
int[3] alFIn;
uint8_t[4] unusedSpiPadding3;
int[590] mainUnusedEnd;
pid_s idleRpmPid2
int[585] mainUnusedEnd;
end_struct

View File

@ -1923,6 +1923,8 @@ cmd_set_engine_type_default = "w\x00\x31\x00\x00"
field = "Max", idleRpmPid_maxValue
field = "iTerm Min", idlerpmpid_iTermMin
field = "iTerm Max", idlerpmpid_iTermMax
field = "Offset#2", idleRpmPid2_offset
field = "Min#2", idleRpmPid2_minValue
field = "period", idleRpmPid_periodMs
field = "RPM dead zone to deactivate IAC pid", idlePidRpmDeadZone
field = "RPM upper limit to deactivate IAC pid",idlePidRpmUpperLimit
@ -2381,14 +2383,16 @@ cmd_set_engine_type_default = "w\x00\x31\x00\x00"
field = "#7", fsioFormulas7
field = "use FSIO #8 for servo #1", useFSIO8ForServo1
field = "#8", fsioFormulas8
field = "use FSIO #9 for servo #2", useFSIO8ForServo1
field = "use FSIO #9 for servo #2", useFSIO9ForServo2
field = "#9", fsioFormulas9
field = "use FSIO #10 for servo #3", useFSIO8ForServo1
field = "use FSIO #10 for servo #3", useFSIO10ForServo3
field = "#10", fsioFormulas10
field = "use FSIO #11 for servo #4", useFSIO8ForServo1
field = "use FSIO #11 for servo #4", useFSIO11ForServo4
field = "#11", fsioFormulas11
field = "use FSIO #12 for servo #5", useFSIO8ForServo1
field = "use FSIO #12 for servo #5", useFSIO12ForServo5
field = "use FSIO #12 idle offset", useFSIO12ForIdleOffset
field = "#12", fsioFormulas12
field = "use FSIO #13 idle min value", useFSIO13ForIdleMinValue
field = "#13", fsioFormulas13
field = "#14", fsioFormulas14
field = "use FSIO #15 for target idle RPM adjustment", useFSIO15ForIdleRpmAdjustment

View File

@ -68,7 +68,7 @@ public:
// todo: move this to pid_s one day
float iTermMin = -1000000.0;
float iTermMax = 1000000.0;
private:
protected:
pid_s *parameters;
private:

View File

@ -1,6 +1,6 @@
package com.rusefi.config.generated;
// this file was generated automatically by rusEfi tool ConfigDefinition.jar based on integration\rusefi_config.txt Tue Sep 10 22:56:58 EDT 2019
// this file was generated automatically by rusEfi tool ConfigDefinition.jar based on integration\rusefi_config.txt Wed Sep 11 20:00:32 EDT 2019
// by class com.rusefi.output.FileJavaFieldsConsumer
import com.rusefi.config.*;
@ -710,6 +710,14 @@ public class Fields {
public static final int idlePidRpmDeadZone_offset = 1894;
public static final int idlePidRpmDeadZone_offset_hex = 766;
public static final int idlePidRpmUpperLimit_offset = 1484;
public static final int idleRpmPid2_dFactor_offset = 4048;
public static final int idleRpmPid2_iFactor_offset = 4044;
public static final int idleRpmPid2_maxValue_offset = 4058;
public static final int idleRpmPid2_minValue_offset = 4056;
public static final int idleRpmPid2_offset = 4040;
public static final int idleRpmPid2_offset_offset = 4052;
public static final int idleRpmPid2_periodMs_offset = 4054;
public static final int idleRpmPid2_pFactor_offset = 4040;
public static final int idleRpmPid_dFactor_offset = 1796;
public static final int idleRpmPid_dFactor_offset_hex = 704;
public static final int idleRpmPid_iFactor_offset = 1792;
@ -899,7 +907,7 @@ public class Fields {
public static final int mafSensorType_offset = 948;
public static final int mainRelayPin_offset = 706;
public static final int mainRelayPinMode_offset = 752;
public static final int mainUnusedEnd_offset = 4040;
public static final int mainUnusedEnd_offset = 4060;
public static final int malfunctionIndicatorPin_offset = 660;
public static final int malfunctionIndicatorPin_offset_hex = 294;
public static final int malfunctionIndicatorPinMode_offset = 661;
@ -1205,8 +1213,6 @@ public class Fields {
public static final int unused1234234_offset = 2042;
public static final int unused_1484_bit_20_offset = 1476;
public static final int unused_1484_bit_21_offset = 1476;
public static final int unused_bit_1472_29_offset = 1464;
public static final int unused_bit_1472_30_offset = 1464;
public static final int unused_board_984_31_offset = 744;
public static final int unused_former_warmup_target_afr_offset = 2096;
public static final int unused_former_warmup_target_afr_offset_hex = 830;
@ -1235,7 +1241,9 @@ public class Fields {
public static final int useFixedBaroCorrFromMap_offset = 1476;
public static final int useFSIO10ForServo3_offset = 1464;
public static final int useFSIO11ForServo4_offset = 1464;
public static final int useFSIO12ForIdleOffset_offset = 1464;
public static final int useFSIO12ForServo5_offset = 1464;
public static final int useFSIO13ForIdleMinValue_offset = 1464;
public static final int useFSIO15ForIdleRpmAdjustment_offset = 1464;
public static final int useFSIO16ForTimingAdjustment_offset = 1464;
public static final int useFSIO4ForSeriousEngineWarning_offset = 1464;
@ -1721,8 +1729,8 @@ public class Fields {
public static final Field USEFSIO15FORIDLERPMADJUSTMENT = Field.create("USEFSIO15FORIDLERPMADJUSTMENT", 1464, FieldType.BIT, 26);
public static final Field USEFSIO5FORCRITICALISSUEENGINESTOP = Field.create("USEFSIO5FORCRITICALISSUEENGINESTOP", 1464, FieldType.BIT, 27);
public static final Field USEFSIO4FORSERIOUSENGINEWARNING = Field.create("USEFSIO4FORSERIOUSENGINEWARNING", 1464, FieldType.BIT, 28);
public static final Field UNUSED_BIT_1472_29 = Field.create("UNUSED_BIT_1472_29", 1464, FieldType.BIT, 29);
public static final Field UNUSED_BIT_1472_30 = Field.create("UNUSED_BIT_1472_30", 1464, FieldType.BIT, 30);
public static final Field USEFSIO12FORIDLEOFFSET = Field.create("USEFSIO12FORIDLEOFFSET", 1464, FieldType.BIT, 29);
public static final Field USEFSIO13FORIDLEMINVALUE = Field.create("USEFSIO13FORIDLEMINVALUE", 1464, FieldType.BIT, 30);
public static final Field HIPOUTPUTCHANNEL = Field.create("HIPOUTPUTCHANNEL", 1468, FieldType.INT8, adc_channel_e);
public static final Field ACSWITCHADC = Field.create("ACSWITCHADC", 1469, FieldType.INT8, adc_channel_e);
public static final Field VREFADCCHANNEL = Field.create("VREFADCCHANNEL", 1470, FieldType.INT8, adc_channel_e);
@ -2039,6 +2047,13 @@ public class Fields {
public static final Field IDLERPMPID_ITERMMAX = Field.create("IDLERPMPID_ITERMMAX", 4006, FieldType.INT16);
public static final Field MC33972SPIDEVICE = Field.create("MC33972SPIDEVICE", 4008, FieldType.INT8);
public static final Field ETBIDLETHROTTLERANGE = Field.create("ETBIDLETHROTTLERANGE", 4012, FieldType.FLOAT);
public static final Field IDLERPMPID2_PFACTOR = Field.create("IDLERPMPID2_PFACTOR", 4040, FieldType.FLOAT);
public static final Field IDLERPMPID2_IFACTOR = Field.create("IDLERPMPID2_IFACTOR", 4044, FieldType.FLOAT);
public static final Field IDLERPMPID2_DFACTOR = Field.create("IDLERPMPID2_DFACTOR", 4048, FieldType.FLOAT);
public static final Field IDLERPMPID2_OFFSET = Field.create("IDLERPMPID2_OFFSET", 4052, FieldType.INT16);
public static final Field IDLERPMPID2_PERIODMS = Field.create("IDLERPMPID2_PERIODMS", 4054, FieldType.INT16);
public static final Field IDLERPMPID2_MINVALUE = Field.create("IDLERPMPID2_MINVALUE", 4056, FieldType.INT16);
public static final Field IDLERPMPID2_MAXVALUE = Field.create("IDLERPMPID2_MAXVALUE", 4058, FieldType.INT16);
public static final Field PEDALTOTPSTABLE = Field.create("PEDALTOTPSTABLE", 6400, FieldType.INT);
public static final Field FSIOFORMULAS1 = Field.create("FSIOFORMULAS1", 6672, FieldType.INT);
public static final Field FSIOFORMULAS2 = Field.create("FSIOFORMULAS2", 6872, FieldType.INT);
@ -2493,8 +2508,8 @@ public class Fields {
USEFSIO15FORIDLERPMADJUSTMENT,
USEFSIO5FORCRITICALISSUEENGINESTOP,
USEFSIO4FORSERIOUSENGINEWARNING,
UNUSED_BIT_1472_29,
UNUSED_BIT_1472_30,
USEFSIO12FORIDLEOFFSET,
USEFSIO13FORIDLEMINVALUE,
HIPOUTPUTCHANNEL,
ACSWITCHADC,
VREFADCCHANNEL,
@ -2806,6 +2821,13 @@ public class Fields {
IDLERPMPID_ITERMMAX,
MC33972SPIDEVICE,
ETBIDLETHROTTLERANGE,
IDLERPMPID2_PFACTOR,
IDLERPMPID2_IFACTOR,
IDLERPMPID2_DFACTOR,
IDLERPMPID2_OFFSET,
IDLERPMPID2_PERIODMS,
IDLERPMPID2_MINVALUE,
IDLERPMPID2_MAXVALUE,
PEDALTOTPSTABLE,
FSIOFORMULAS1,
FSIOFORMULAS2,