diff --git a/firmware/controllers/algo/auto_generated_codes.cpp b/firmware/controllers/algo/auto_generated_codes.cpp index 260c7f5f4c..903e55c8ba 100644 --- a/firmware/controllers/algo/auto_generated_codes.cpp +++ b/firmware/controllers/algo/auto_generated_codes.cpp @@ -1,6 +1,6 @@ #include "global.h" #include "obd_error_codes.h" -// was generated automatically by rusEFI tool from obd_error_codes.h // by enum2string.jar tool on Sun Oct 03 01:41:19 EDT 2021 +// was generated automatically by rusEFI tool from obd_error_codes.h // by enum2string.jar tool on Fri Oct 29 15:39:44 EDT 2021 // see also gen_config_and_enums.bat @@ -615,8 +615,6 @@ case CUSTOM_OBD_95: return "CUSTOM_OBD_95"; case CUSTOM_OBD_96: return "CUSTOM_OBD_96"; -case CUSTOM_OBD_97: - return "CUSTOM_OBD_97"; case CUSTOM_OBD_ANALOG_INPUT_NOT_CONFIGURED: return "CUSTOM_OBD_ANALOG_INPUT_NOT_CONFIGURED"; case CUSTOM_OBD_ANGLE_CONSTRAINT_VIOLATION: @@ -673,6 +671,8 @@ case CUSTOM_OUT_OF_ORDER_COIL: return "CUSTOM_OUT_OF_ORDER_COIL"; case CUSTOM_PARAM_RANGE: return "CUSTOM_PARAM_RANGE"; +case CUSTOM_PID_DTERM: + return "CUSTOM_PID_DTERM"; case CUSTOM_PWM_CYCLE_START: return "CUSTOM_PWM_CYCLE_START"; case CUSTOM_PWM_DUTY_TOO_HIGH: diff --git a/firmware/controllers/algo/obd_error_codes.h b/firmware/controllers/algo/obd_error_codes.h index 9c3d2a4505..e26786dd7f 100644 --- a/firmware/controllers/algo/obd_error_codes.h +++ b/firmware/controllers/algo/obd_error_codes.h @@ -1781,7 +1781,7 @@ typedef enum { CUSTOM_OBD_94 = 6094, CUSTOM_OBD_95 = 6095, CUSTOM_OBD_96 = 6096, - CUSTOM_OBD_97 = 6097, + CUSTOM_PID_DTERM = 6097, CUSTOM_DWELL = 6098, CUSTOM_TS_OVERFLOW = 6099, diff --git a/firmware/util/math/pid.cpp b/firmware/util/math/pid.cpp index c464cd6a86..0a1b52c345 100644 --- a/firmware/util/math/pid.cpp +++ b/firmware/util/math/pid.cpp @@ -61,6 +61,11 @@ float Pid::getUnclampedOutput(float target, float input, float dTime) { previousError = error; + if (dTime <=0) { + warning(CUSTOM_PID_DTERM, "PID: unexpected dTime"); + return pTerm + getOffset(); + } + return pTerm + iTerm + dTerm + getOffset(); }