From 7735758ec5c18c4ff6ddcecef87db241d0e55953 Mon Sep 17 00:00:00 2001 From: rusefi Date: Sat, 11 Jul 2020 15:30:40 -0400 Subject: [PATCH] PidIndustrial does not limit iTerm fix #1599 --- firmware/util/math/pid.cpp | 3 +-- firmware/util/math/pid.h | 2 -- unit_tests/tests/test_pid.cpp | 3 +-- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/firmware/util/math/pid.cpp b/firmware/util/math/pid.cpp index e1a73de2ad..45cc4a391e 100644 --- a/firmware/util/math/pid.cpp +++ b/firmware/util/math/pid.cpp @@ -269,8 +269,7 @@ float PidIndustrial::getOutput(float target, float input, float dTime) { // (error - previousError) = (target-input) - (target-prevousInput) = -(input - prevousInput) dTerm = dTerm * ad + (error - previousError) * bd; - // update the I-term - iTerm += parameters->iFactor * dTime * error; + updateITerm(parameters->iFactor * dTime * error); // calculate output and apply the limits float output = pTerm + iTerm + dTerm + getOffset(); diff --git a/firmware/util/math/pid.h b/firmware/util/math/pid.h index 7bed17ee76..c7cddd8f40 100644 --- a/firmware/util/math/pid.h +++ b/firmware/util/math/pid.h @@ -73,8 +73,6 @@ public: float iTermMax = 1000000.0; protected: pid_s *parameters; - -private: virtual void updateITerm(float value); }; diff --git a/unit_tests/tests/test_pid.cpp b/unit_tests/tests/test_pid.cpp index b399e7324b..cb477c937c 100644 --- a/unit_tests/tests/test_pid.cpp +++ b/unit_tests/tests/test_pid.cpp @@ -101,8 +101,7 @@ TEST(util, industrialPidLimits) { commonPidTestParameters(&pidS); PidIndustrial pid(&pidS); -// todo: #1599 -// commonPidTest(&pid); + commonPidTest(&pid); } TEST(util, pidIndustrial) {