EFI_IDLE_INCREMENTAL_PID_CIC should be a runtime parameter #806

This commit is contained in:
rusefi 2020-07-12 18:11:10 -04:00
parent 2ba31803cd
commit 677d5888ed
5 changed files with 26 additions and 26 deletions

View File

@ -95,16 +95,6 @@
#if EFI_TUNER_STUDIO #if EFI_TUNER_STUDIO
#ifndef EFI_IDLE_CONTROL
#if EFI_IDLE_PID_CIC
extern PidCic idlePid;
#else
extern Pid idlePid;
#endif /* EFI_IDLE_PID_CIC */
#endif /* EFI_IDLE_CONTROL */
EXTERN_ENGINE; EXTERN_ENGINE;
extern persistent_config_container_s persistentState; extern persistent_config_container_s persistentState;
@ -298,7 +288,7 @@ static const void * getStructAddr(int structId) {
#ifndef EFI_IDLE_CONTROL #ifndef EFI_IDLE_CONTROL
case LDS_IDLE_PID_STATE_INDEX: case LDS_IDLE_PID_STATE_INDEX:
return static_cast<pid_state_s*>(&idlePid); return static_cast<pid_state_s*>(getIdlePid());
#endif /* EFI_IDLE_CONTROL */ #endif /* EFI_IDLE_CONTROL */
default: default:

View File

@ -72,7 +72,8 @@ static bool mightResetPid = false;
#if EFI_IDLE_PID_CIC #if EFI_IDLE_PID_CIC
// Use new PID with CIC integrator // Use new PID with CIC integrator
PidCic idlePid; static PidCic idlePid;
#else #else
class PidWithOverrides : public PidIndustrial { class PidWithOverrides : public PidIndustrial {
@ -106,15 +107,19 @@ public:
} }
}; };
PidWithOverrides idlePid; static PidWithOverrides idlePid;
#endif /* EFI_IDLE_PID_CIC */ #endif /* EFI_IDLE_PID_CIC */
Pid * getIdlePid() {
return &idlePid;
}
float getIdlePidOffset() { float getIdlePidOffset() {
return idlePid.getOffset(); return getIdlePid()->getOffset();
} }
float getIdlePidMinValue() { float getIdlePidMinValue() {
return idlePid.getMinValue(); return getIdlePid()->getMinValue();
} }
// todo: extract interface for idle valve hardware, with solenoid and stepper implementations? // todo: extract interface for idle valve hardware, with solenoid and stepper implementations?
@ -176,7 +181,7 @@ static void showIdleInfo(void) {
} }
if (engineConfiguration->idleMode == IM_AUTO) { if (engineConfiguration->idleMode == IM_AUTO) {
idlePid.showPidStatus(logger, "idle"); getIdlePid()->showPidStatus(logger, "idle");
} }
} }
@ -342,9 +347,9 @@ static percent_t automaticIdleController(float tpsPos DECLARE_ENGINE_PARAMETER_S
if (rpm < targetRpm) if (rpm < targetRpm)
errorAmpCoef += (float)CONFIG(pidExtraForLowRpm) / PERCENT_MULT; errorAmpCoef += (float)CONFIG(pidExtraForLowRpm) / PERCENT_MULT;
// If errorAmpCoef > 1.0, then PID thinks that RPM is lower than it is, and controls IAC more aggressively // If errorAmpCoef > 1.0, then PID thinks that RPM is lower than it is, and controls IAC more aggressively
idlePid.setErrorAmplification(errorAmpCoef); getIdlePid()->setErrorAmplification(errorAmpCoef);
percent_t newValue = idlePid.getOutput(targetRpm, rpm); percent_t newValue = getIdlePid()->getOutput(targetRpm, rpm);
engine->engineState.idle.idleState = PID_VALUE; engine->engineState.idle.idleState = PID_VALUE;
// the state of PID has been changed, so we might reset it now, but only when needed (see idlePidDeactivationTpsThreshold) // the state of PID has been changed, so we might reset it now, but only when needed (see idlePidDeactivationTpsThreshold)
@ -395,8 +400,8 @@ static percent_t automaticIdleController(float tpsPos DECLARE_ENGINE_PARAMETER_S
* @see stepper.cpp * @see stepper.cpp
*/ */
idlePid.iTermMin = engineConfiguration->idlerpmpid_iTermMin; getIdlePid()->iTermMin = engineConfiguration->idlerpmpid_iTermMin;
idlePid.iTermMax = engineConfiguration->idlerpmpid_iTermMax; getIdlePid()->iTermMax = engineConfiguration->idlerpmpid_iTermMax;
SensorResult tps = Sensor::get(SensorType::DriverThrottleIntent); SensorResult tps = Sensor::get(SensorType::DriverThrottleIntent);
@ -405,11 +410,11 @@ static percent_t automaticIdleController(float tpsPos DECLARE_ENGINE_PARAMETER_S
if (engineConfiguration->isVerboseIAC && engine->engineState.isAutomaticIdle) { if (engineConfiguration->isVerboseIAC && engine->engineState.isAutomaticIdle) {
scheduleMsg(logger, "Idle state %s%s", getIdle_state_e(engine->engineState.idle.idleState), scheduleMsg(logger, "Idle state %s%s", getIdle_state_e(engine->engineState.idle.idleState),
(prettyClose ? " pretty close" : "")); (prettyClose ? " pretty close" : ""));
idlePid.showPidStatus(logger, "idle"); getIdlePid()->showPidStatus(logger, "idle");
} }
if (shouldResetPid) { if (shouldResetPid) {
idlePid.reset(); getIdlePid()->reset();
// alternatorPidResetCounter++; // alternatorPidResetCounter++;
shouldResetPid = false; shouldResetPid = false;
} }
@ -506,7 +511,7 @@ static percent_t automaticIdleController(float tpsPos DECLARE_ENGINE_PARAMETER_S
if (engineConfiguration->idleMode == IM_AUTO) { if (engineConfiguration->idleMode == IM_AUTO) {
#if EFI_TUNER_STUDIO #if EFI_TUNER_STUDIO
// see also tsOutputChannels->idlePosition // see also tsOutputChannels->idlePosition
idlePid.postState(&tsOutputChannels, 1000000); getIdlePid()->postState(&tsOutputChannels, 1000000);
tsOutputChannels.debugIntField4 = engine->engineState.idle.idleState; tsOutputChannels.debugIntField4 = engine->engineState.idle.idleState;
#endif /* EFI_TUNER_STUDIO */ #endif /* EFI_TUNER_STUDIO */
} else { } else {
@ -533,7 +538,7 @@ static percent_t automaticIdleController(float tpsPos DECLARE_ENGINE_PARAMETER_S
IdleController idleControllerInstance; IdleController idleControllerInstance;
static void applyPidSettings(DECLARE_ENGINE_PARAMETER_SIGNATURE) { static void applyPidSettings(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
idlePid.updateFactors(engineConfiguration->idleRpmPid.pFactor, engineConfiguration->idleRpmPid.iFactor, engineConfiguration->idleRpmPid.dFactor); getIdlePid()->updateFactors(engineConfiguration->idleRpmPid.pFactor, engineConfiguration->idleRpmPid.iFactor, engineConfiguration->idleRpmPid.dFactor);
iacPidMultMap.init(CONFIG(iacPidMultTable), CONFIG(iacPidMultLoadBins), CONFIG(iacPidMultRpmBins)); iacPidMultMap.init(CONFIG(iacPidMultTable), CONFIG(iacPidMultLoadBins), CONFIG(iacPidMultRpmBins));
} }
@ -550,7 +555,7 @@ void setDefaultIdleParameters(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
#if ! EFI_UNIT_TEST #if ! EFI_UNIT_TEST
void onConfigurationChangeIdleCallback(engine_configuration_s *previousConfiguration) { void onConfigurationChangeIdleCallback(engine_configuration_s *previousConfiguration) {
shouldResetPid = !idlePid.isSame(&previousConfiguration->idleRpmPid); shouldResetPid = !getIdlePid()->isSame(&previousConfiguration->idleRpmPid);
idleSolenoidOpen.setFrequency(CONFIG(idle).solenoidFrequency); idleSolenoidOpen.setFrequency(CONFIG(idle).solenoidFrequency);
idleSolenoidClose.setFrequency(CONFIG(idle).solenoidFrequency); idleSolenoidClose.setFrequency(CONFIG(idle).solenoidFrequency);
} }
@ -706,7 +711,7 @@ void startIdleThread(Logging*sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX) {
logger = sharedLogger; logger = sharedLogger;
INJECT_ENGINE_REFERENCE(&idleControllerInstance); INJECT_ENGINE_REFERENCE(&idleControllerInstance);
idlePid.initPidClass(&engineConfiguration->idleRpmPid); getIdlePid()->initPidClass(&engineConfiguration->idleRpmPid);
#if ! EFI_UNIT_TEST #if ! EFI_UNIT_TEST
// todo: we still have to explicitly init all hardware on start in addition to handling configuration change via // todo: we still have to explicitly init all hardware on start in addition to handling configuration change via

View File

@ -37,4 +37,5 @@ void initIdleHardware(DECLARE_ENGINE_PARAMETER_SIGNATURE);
bool isIdleHardwareRestartNeeded(); bool isIdleHardwareRestartNeeded();
void onConfigurationChangeIdleCallback(engine_configuration_s *previousConfiguration); void onConfigurationChangeIdleCallback(engine_configuration_s *previousConfiguration);
float getIdlePidOffset(); float getIdlePidOffset();
Pid * getIdlePid();
float getIdlePidMinValue(); float getIdlePidMinValue();

View File

@ -0,0 +1,4 @@
package com.rusefi.tools.online;
public class ProxyClient {
}