From 884532cb6f55f0617a28e40d68351989c6e1741a Mon Sep 17 00:00:00 2001 From: Matthew Kennedy Date: Tue, 7 Sep 2021 11:07:47 -0700 Subject: [PATCH] boost debug fields (#3228) --- .../controllers/actuators/boost_control.cpp | 19 +++++++++++++++---- .../controllers/actuators/boost_control.h | 2 ++ firmware/tunerstudio/rusefi.input | 4 ++-- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/firmware/controllers/actuators/boost_control.cpp b/firmware/controllers/actuators/boost_control.cpp index ea1e8520b4..e524d10bda 100644 --- a/firmware/controllers/actuators/boost_control.cpp +++ b/firmware/controllers/actuators/boost_control.cpp @@ -63,7 +63,7 @@ expected BoostController::getSetpoint() const { } expected BoostController::getOpenLoop(float target) const { - // Boost control open loop doesn't care about target - only MAP/RPM + // Boost control open loop doesn't care about target - only TPS/RPM UNUSED(target); float rpm = GET_RPM(); @@ -88,7 +88,7 @@ expected BoostController::getOpenLoop(float target) const { return openLoop; } -expected BoostController::getClosedLoop(float target, float manifoldPressure) { +percent_t BoostController::getClosedLoopImpl(float target, float manifoldPressure) { // If we're in open loop only mode, make no closed loop correction. if (engineConfiguration->boostType != CLOSED_LOOP) { return 0; @@ -112,12 +112,16 @@ expected BoostController::getClosedLoop(float target, float manifoldP return 0; } - float closedLoop = m_pid.getOutput(target, manifoldPressure, SLOW_CALLBACK_PERIOD_MS / 1000.0f); + return m_pid.getOutput(target, manifoldPressure, SLOW_CALLBACK_PERIOD_MS / 1000.0f); +} + +expected BoostController::getClosedLoop(float target, float manifoldPressure) { + auto closedLoop = getClosedLoopImpl(target, manifoldPressure); #if EFI_TUNER_STUDIO if (engineConfiguration->debugMode == DBG_BOOST) { - m_pid.postState(&tsOutputChannels); tsOutputChannels.debugFloatField2 = closedLoop; + tsOutputChannels.debugFloatField3 = target; } #endif /* EFI_TUNER_STUDIO */ @@ -126,6 +130,13 @@ expected BoostController::getClosedLoop(float target, float manifoldP void BoostController::setOutput(expected output) { percent_t percent = output.value_or(CONFIG(boostControlSafeDutyCycle)); + +#if EFI_TUNER_STUDIO + if (engineConfiguration->debugMode == DBG_BOOST) { + tsOutputChannels.debugFloatField3 = percent; + } +#endif /* EFI_TUNER_STUDIO */ + float duty = PERCENT_TO_DUTY(percent); if (m_pwm) { diff --git a/firmware/controllers/actuators/boost_control.h b/firmware/controllers/actuators/boost_control.h index 6b39773583..2147062e41 100644 --- a/firmware/controllers/actuators/boost_control.h +++ b/firmware/controllers/actuators/boost_control.h @@ -33,6 +33,8 @@ public: void setOutput(expected outputValue) override; private: + percent_t getClosedLoopImpl(float target, float manifoldPressure); + bool m_shouldResetPid = false; Pid m_pid; diff --git a/firmware/tunerstudio/rusefi.input b/firmware/tunerstudio/rusefi.input index 99fbec4477..b413364355 100644 --- a/firmware/tunerstudio/rusefi.input +++ b/firmware/tunerstudio/rusefi.input @@ -445,8 +445,8 @@ enable2ndByteCanID = false ; DBG_ALTERNATOR_PID DBG_TPS_ACCEL DBG_GPPWM DBG_IDLE_CONTROL debugFieldF1List = bits, U08, [0:7], "Alt: Controller Output", "From TPS", "GPPWM 1", "Idle: Controller Output", "Idle output", "Channel 1 Rise Counter", "", "VVT1: Controller Output","VVT Event Position", "", "Ign IAT Corr", "", "", "Total SD", "last volts", "", "", "ETB Controller Output", "", "", "df1", "df1", "InstantRpm", "fsio 1", "24:df1", "CJ125: output", "", "", "", "", "", "", "TPS1 Pri/Sec Diff", "", "", "", "Boost Open Loop Duty", "S unused" "", "Osc Amplitude", "", "fsio 8", "idle offset", "Pressure across injector(kpa)", "VSS", "", "WB: Pump DAC duty", "", "Lua Debug 1", "VVT2: Controller Output","VVT3: Controller Output","VVT4: Controller Output" debugFieldF2List = bits, U08, [0:7], "Alt: I Term", "To TPS", "GPPWM 2", "Idle: I Term", "Idle df2", "Channel 2 Rise Counter", "", "VVT1: I Term", "VVT Ratio", "", "Ign CLT Corr", "", "", "Write Cnt","last filtered","", "", "ETB I Term", "", "", "df2", "df2", "InstantRPM Ratio","fsio 2", "24:df2", "CJ125: i term", "", "", "", "", "", "", "TPS2 Pri/Sec Diff", "", "", "", "Boost Closed Loop Duty","S unused" "", "Duty Amplitude", "", "fsio 9", "idle min", "Pressure ratio vs. nominal", "Speed", "", "WB: ESR", "", "Lua Debug 2", "VVT2: I Term", "VVT3: I Term", "VVT4: I Term" - debugFieldF3List = bits, U08, [0:7], "Alt: Previous Error", "Current TPS<>TPS", "GPPWM 3", "Idle: prev error", "Idle df3", "ICU sum", "", "VVT1: prev error", "", "", "Ign FSIO Adj", "", "", "Sync Cnt", "", "", "", "ETB err", "", "", "df3", "df3", "22df3", "fsio 3", "24:df3", "CJ125: err", "", "", "", "", "", "", "TPS1/2 Diff", "", "", "", "", "S unused" "", "Tu", "", "fsio 10", "", "Flow ratio vs. configured", "DeltaSpeed", "", "WB: Nernst Voltage", "", "Lua Debug 3", "VVT2: prev error", "VVT3: prev error", "VVT4: prev error" - debugFieldF4List = bits, U08, [0:7], "Alt: I Gain", "Extra Fuel", "GPPWM 4", "Idle: I Gain", "Idle df4", "VVT rise", "", "VVT1: I Gain", "", "", "Ign PID Adj", "", "", "File Cnt", "", "", "", "ETB I setting", "", "", "df4", "df4", "22df4", "fsio 4", "24:df4", "CJ125: UA", "", "MAP Estimate", "", "", "", "", "Acc Pedal Pri/Sec Diff","", "", "", "", "S unused" "", "Ku", "", "fsio 11", "", "", "accel", "", "WB: Lambda", "", "Lua Debug 4", "VVT2: I Gain", "VVT3: I Gain", "VVT4: I Gain" + debugFieldF3List = bits, U08, [0:7], "Alt: Previous Error", "Current TPS<>TPS", "GPPWM 3", "Idle: prev error", "Idle df3", "ICU sum", "", "VVT1: prev error", "", "", "Ign FSIO Adj", "", "", "Sync Cnt", "", "", "", "ETB err", "", "", "df3", "df3", "22df3", "fsio 3", "24:df3", "CJ125: err", "", "", "", "", "", "", "TPS1/2 Diff", "", "", "", "Boost Duty", "S unused" "", "Tu", "", "fsio 10", "", "Flow ratio vs. configured", "DeltaSpeed", "", "WB: Nernst Voltage", "", "Lua Debug 3", "VVT2: prev error", "VVT3: prev error", "VVT4: prev error" + debugFieldF4List = bits, U08, [0:7], "Alt: I Gain", "Extra Fuel", "GPPWM 4", "Idle: I Gain", "Idle df4", "VVT rise", "", "VVT1: I Gain", "", "", "Ign PID Adj", "", "", "File Cnt", "", "", "", "ETB I setting", "", "", "df4", "df4", "22df4", "fsio 4", "24:df4", "CJ125: UA", "", "MAP Estimate", "", "", "", "", "Acc Pedal Pri/Sec Diff","", "", "", "Boost Target", "S unused" "", "Ku", "", "fsio 11", "", "", "accel", "", "WB: Lambda", "", "Lua Debug 4", "VVT2: I Gain", "VVT3: I Gain", "VVT4: I Gain" debugFieldF5List = bits, U08, [0:7], "Alt: D Gain", "df5", "df5", "Idle: D Gain", "Idle df5", "VVT fall", "df5", "VVT1: D Gain", "", "", "", "", "", "", "", "", "", "ETB D setting", "df5", "df5", "df5", "df5", "22df5", "fsio 5", "24:df5", "CJ125: UR", "", "", "", "", "", "", "TPS1 Pri/Sec Ratio", "", "", "", "", "S unused" "", "Kp", "", "fsio 12", "", "", "", "", "", "", "Lua Debug 5", "VVT2: D Gain", "VVT3: D Gain", "VVT4: D Gain" debugFieldF6List = bits, U08, [0:7], "Alt: D Term", "", "", "Idle: D Term", "Idle df6", "Current Gap", "", "VVT1: D Term", "", "", "", "", "", "", "", "", "", "ETB df6", "", "", "df6", "df6", "22df6", "fsio 6", "24:df6", "cj: f7", "", "", "", "", "", "", "", "", "", "", "", "S unused" "", "Ki", "", "fsio 13", "", "", "", "", "", "", "Lua Debug 6", "VVT2: D Term", "VVT3: D Term", "VVT4: D Term" debugFieldF7List = bits, U08, [0:7], "Alt: Max-Value", "", "", "Idle: Max-Value", "Idle df7", "", "", "VVT1: Max-Value", "", "", "", "", "", "", "", "", "", "ETB df7", "", "", "df7", "df7", "22df7", "fsio 7", "24:df7", "cj: f7", "", "", "", "", "", "", "", "", "", "", "", "S unused" "", "Kd", "", "fsio 14", "", "", "", "", "", "", "Lua Debug 7", "", "", ""