remove idle thread; just call from periodicSlowCallback (#1924)
* remove thread * remove ui
This commit is contained in:
parent
584b7a6c9e
commit
0e3673e78c
|
@ -421,7 +421,6 @@ void setMiataNA6_MAP_MRE(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
|
|||
engineConfiguration->idleTimingPid.dFactor = 0.0;
|
||||
engineConfiguration->idleTimingPid.minValue = -13;
|
||||
engineConfiguration->idleTimingPid.maxValue = 13;
|
||||
engineConfiguration->idleTimingPid.periodMs = 8;
|
||||
engineConfiguration->idleTimingPidWorkZone = 150;
|
||||
engineConfiguration->idlePidFalloffDeltaRpm = 50;
|
||||
engineConfiguration->idleTimingPidDeadZone = 10;
|
||||
|
|
|
@ -182,7 +182,7 @@ void setIdleMode(idle_mode_e value DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
|||
showIdleInfo();
|
||||
}
|
||||
|
||||
percent_t getIdlePosition(void) {
|
||||
percent_t getIdlePosition() {
|
||||
return engine->engineState.idle.currentIdlePosition;
|
||||
}
|
||||
|
||||
|
@ -329,7 +329,7 @@ static percent_t automaticIdleController(float tpsPos DECLARE_ENGINE_PARAMETER_S
|
|||
// If errorAmpCoef > 1.0, then PID thinks that RPM is lower than it is, and controls IAC more aggressively
|
||||
getIdlePid(PASS_ENGINE_PARAMETER_SIGNATURE)->setErrorAmplification(errorAmpCoef);
|
||||
|
||||
percent_t newValue = getIdlePid(PASS_ENGINE_PARAMETER_SIGNATURE)->getOutput(targetRpm, rpm);
|
||||
percent_t newValue = getIdlePid(PASS_ENGINE_PARAMETER_SIGNATURE)->getOutput(targetRpm, rpm, SLOW_CALLBACK_PERIOD_MS / 1000.0f);
|
||||
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)
|
||||
|
@ -368,12 +368,8 @@ static percent_t automaticIdleController(float tpsPos DECLARE_ENGINE_PARAMETER_S
|
|||
return newValue;
|
||||
}
|
||||
|
||||
int IdleController::getPeriodMs() {
|
||||
return GET_PERIOD_LIMITED(&engineConfiguration->idleRpmPid);
|
||||
}
|
||||
|
||||
void IdleController::PeriodicTask() {
|
||||
efiAssertVoid(OBD_PCM_Processor_Fault, engineConfiguration != NULL, "engineConfiguration pointer");
|
||||
float IdleController::getIdlePosition() {
|
||||
efiAssert(OBD_PCM_Processor_Fault, engineConfiguration != NULL, "engineConfiguration pointer", 0);
|
||||
/*
|
||||
* Here we have idle logic thread - actual stepper movement is implemented in a separate
|
||||
* working thread,
|
||||
|
@ -508,11 +504,22 @@ static percent_t automaticIdleController(float tpsPos DECLARE_ENGINE_PARAMETER_S
|
|||
}
|
||||
|
||||
engine->engineState.idle.currentIdlePosition = iacPosition;
|
||||
applyIACposition(engine->engineState.idle.currentIdlePosition PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
|
||||
return iacPosition;
|
||||
}
|
||||
|
||||
void IdleController::update() {
|
||||
float position = getIdlePosition();
|
||||
applyIACposition(position PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
}
|
||||
|
||||
IdleController idleControllerInstance;
|
||||
|
||||
void updateIdleControl()
|
||||
{
|
||||
idleControllerInstance.update();
|
||||
}
|
||||
|
||||
static void applyPidSettings(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||
getIdlePid(PASS_ENGINE_PARAMETER_SIGNATURE)->updateFactors(engineConfiguration->idleRpmPid.pFactor, engineConfiguration->idleRpmPid.iFactor, engineConfiguration->idleRpmPid.dFactor);
|
||||
iacPidMultMap.init(CONFIG(iacPidMultTable), CONFIG(iacPidMultLoadBins), CONFIG(iacPidMultRpmBins));
|
||||
|
@ -522,7 +529,6 @@ void setDefaultIdleParameters(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
|
|||
engineConfiguration->idleRpmPid.pFactor = 0.1f;
|
||||
engineConfiguration->idleRpmPid.iFactor = 0.05f;
|
||||
engineConfiguration->idleRpmPid.dFactor = 0.0f;
|
||||
engineConfiguration->idleRpmPid.periodMs = 10;
|
||||
|
||||
engineConfiguration->idlerpmpid_iTermMin = -200;
|
||||
engineConfiguration->idlerpmpid_iTermMax = 200;
|
||||
|
@ -564,12 +570,6 @@ void setIdleDFactor(float value) {
|
|||
showIdleInfo();
|
||||
}
|
||||
|
||||
void setIdleDT(int value) {
|
||||
engineConfiguration->idleRpmPid.periodMs = value;
|
||||
applyPidSettings();
|
||||
showIdleInfo();
|
||||
}
|
||||
|
||||
/**
|
||||
* Idle test would activate the solenoid for three seconds
|
||||
*/
|
||||
|
@ -637,8 +637,6 @@ void startIdleThread(Logging*sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
|||
|
||||
//scheduleMsg(logger, "initial idle %d", idlePositionController.value);
|
||||
|
||||
idleControllerInstance.Start();
|
||||
|
||||
#if ! EFI_UNIT_TEST
|
||||
// this is neutral/no gear switch input. on Miata it's wired both to clutch pedal and neutral in gearbox
|
||||
// this switch is not used yet
|
||||
|
|
|
@ -15,15 +15,16 @@
|
|||
class Logging;
|
||||
class Pid;
|
||||
|
||||
class IdleController : public PeriodicTimerController {
|
||||
class IdleController {
|
||||
public:
|
||||
DECLARE_ENGINE_PTR;
|
||||
|
||||
int getPeriodMs() override;
|
||||
void PeriodicTask() override;
|
||||
float getIdlePosition();
|
||||
void update();
|
||||
};
|
||||
|
||||
percent_t getIdlePosition(void);
|
||||
void updateIdleControl();
|
||||
percent_t getIdlePosition();
|
||||
|
||||
void applyIACposition(percent_t position DECLARE_ENGINE_PARAMETER_SUFFIX);
|
||||
void setManualIdleValvePosition(int positionPercent);
|
||||
|
@ -31,14 +32,12 @@ void setManualIdleValvePosition(int positionPercent);
|
|||
void startIdleThread(Logging* sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX);
|
||||
void setDefaultIdleParameters(DECLARE_CONFIG_PARAMETER_SIGNATURE);
|
||||
void startIdleBench(void);
|
||||
void setIdleDT(int value);
|
||||
void setIdleOffset(float value);
|
||||
void setIdlePFactor(float value);
|
||||
void setIdleIFactor(float value);
|
||||
void setIdleDFactor(float value);
|
||||
void setIdleMode(idle_mode_e value DECLARE_ENGINE_PARAMETER_SUFFIX);
|
||||
void setTargetIdleRpm(int value);
|
||||
void setIdleDT(int value);
|
||||
void onConfigurationChangeIdleCallback(engine_configuration_s *previousConfiguration);
|
||||
float getIdlePidOffset(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
||||
Pid * getIdlePid(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
||||
|
|
|
@ -146,8 +146,7 @@ angle_t getAdvanceCorrections(int rpm DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
|||
shouldResetTimingPid = false;
|
||||
}
|
||||
// get PID value (this is not an actual Advance Angle, but just a additive correction!)
|
||||
percent_t timingRawCorr = idleTimingPid.getOutput(targetRpm, rpm,
|
||||
/* is this the right dTime? this period is not exactly the period at which this code is invoked*/engineConfiguration->idleTimingPid.periodMs);
|
||||
percent_t timingRawCorr = idleTimingPid.getOutput(targetRpm, rpm, FAST_CALLBACK_PERIOD_MS / 1000.0f);
|
||||
// tps idle-running falloff
|
||||
pidTimingCorrection = interpolateClamped(0.0f, timingRawCorr, CONFIG(idlePidDeactivationTpsThreshold), 0.0f, tps);
|
||||
// rpm falloff
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "fsio_impl.h"
|
||||
#include "perf_trace.h"
|
||||
#include "backup_ram.h"
|
||||
#include "idle_thread.h"
|
||||
#include "idle_hardware.h"
|
||||
#include "sensor.h"
|
||||
#include "gppwm.h"
|
||||
|
@ -189,6 +190,8 @@ void Engine::periodicSlowCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
|||
|
||||
updateGppwm();
|
||||
|
||||
updateIdleControl();
|
||||
|
||||
cylinderCleanupControl(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||
|
||||
standardAirCharge = getStandardAirCharge(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#endif /* EFI_UNIT_TEST */
|
||||
|
||||
#define FAST_CALLBACK_PERIOD_MS 5
|
||||
#define SLOW_CALLBACK_PERIOD_MS 50
|
||||
|
||||
class RpmCalculator;
|
||||
class AirmassModelBase;
|
||||
|
|
|
@ -156,7 +156,7 @@ class PeriodicSlowController : public PeriodicTimerController {
|
|||
|
||||
int getPeriodMs() override {
|
||||
// no reason to have this configurable, looks like everyone is happy with 20Hz
|
||||
return 50;
|
||||
return SLOW_CALLBACK_PERIOD_MS;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -996,12 +996,6 @@ const plain_get_integer_s getI_plain[] = {
|
|||
// {"bor", setBor},
|
||||
// {"can_mode", setCanType},
|
||||
// {"idle_rpm", setTargetIdleRpm},
|
||||
// {"idle_dt", setIdleDT},
|
||||
// {"", },
|
||||
// {"", },
|
||||
// {"", },
|
||||
// {"", },
|
||||
// {"", },
|
||||
};
|
||||
|
||||
const plain_get_float_s getF_plain[] = {
|
||||
|
@ -1208,7 +1202,6 @@ const command_i_s commandsI[] = {{"ignition_mode", setIgnitionMode},
|
|||
#if EFI_IDLE_CONTROL
|
||||
{"idle_position", setManualIdleValvePosition},
|
||||
{"idle_rpm", setTargetIdleRpm},
|
||||
{"idle_dt", setIdleDT},
|
||||
#endif /* EFI_IDLE_CONTROL */
|
||||
#endif /* EFI_PROD_CODE */
|
||||
|
||||
|
|
|
@ -79,8 +79,7 @@ enable2ndByteCanID = false
|
|||
|
||||
; CONFIG_DEFINITION_END
|
||||
idleRpmPid_offset = "Constant base value"
|
||||
idleRpmPid_periodMs = "PID recalculation period"
|
||||
|
||||
|
||||
|
||||
[Tuning]
|
||||
spotDepth = 2 ; 0 = no indicators, 1 = Z only, 2 = XYZ indicators.
|
||||
|
@ -2445,7 +2444,6 @@ cmd_set_engine_type_default = "@@TS_IO_TEST_COMMAND_char@@\x00\x31\x00\x00"
|
|||
field = "Max", idleRpmPid_maxValue
|
||||
field = "iTerm Min", idlerpmpid_iTermMin
|
||||
field = "iTerm Max", idlerpmpid_iTermMax
|
||||
field = "period", idleRpmPid_periodMs
|
||||
field = "RPM dead zone to deactivate IAC pid", idlePidRpmDeadZone
|
||||
field = "RPM upper limit to deactivate IAC pid",idlePidRpmUpperLimit
|
||||
field = "PID Extra for low RPM", pidExtraForLowRpm
|
||||
|
@ -2479,7 +2477,6 @@ cmd_set_engine_type_default = "@@TS_IO_TEST_COMMAND_char@@\x00\x31\x00\x00"
|
|||
field = "Offset", idleTimingPid_offset, {useIdleTimingPidControl == 1}
|
||||
field = "Min Delta", idleTimingPid_minValue, {useIdleTimingPidControl == 1}
|
||||
field = "Max Delta", idleTimingPid_maxValue, {useIdleTimingPidControl == 1}
|
||||
field = "period", idleTimingPid_periodMs, {useIdleTimingPidControl == 1}
|
||||
field = "#See RPM dead zone to deactivate IAC pid"
|
||||
field = "RPM working zone for timing pid", idleTimingPidWorkZone, {useIdleTimingPidControl == 1}
|
||||
field = "RPM working zone falloff", idlePidFalloffDeltaRpm, {useIdleTimingPidControl == 1}
|
||||
|
|
|
@ -58,7 +58,7 @@ TEST(idle, fsioPidParameters) {
|
|||
|
||||
// todo finish this unit test!
|
||||
// timeNowUs = MS2US(700);
|
||||
idleControllerInstance.PeriodicTask();
|
||||
idleControllerInstance.update();
|
||||
// ASSERT_EQ(0, engine->acSwitchLastChangeTime);
|
||||
// ASSERT_EQ(1, engine->acSwitchState);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue