Index: firmware/App/Controllers/DrainPump.c =================================================================== diff -u -r5c430c3ac17fc8ad836fd70b8a3b8a12af44319e -rb4f8e2229eb0a08cdce5fdd2e0a14ca25d792946 --- firmware/App/Controllers/DrainPump.c (.../DrainPump.c) (revision 5c430c3ac17fc8ad836fd70b8a3b8a12af44319e) +++ firmware/App/Controllers/DrainPump.c (.../DrainPump.c) (revision b4f8e2229eb0a08cdce5fdd2e0a14ca25d792946) @@ -8,7 +8,7 @@ * @file DrainPump.c * * @author (last) Dara Navaei -* @date (last) 03-Nov-2022 +* @date (last) 06-Mar-2023 * * @author (original) Sean * @date (original) 08-Apr-2020 @@ -50,7 +50,7 @@ #define DRAIN_PUMP_DATA_PUB_INTERVAL ( MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) ///< Interval (ms/task time) at which the Drain Pump data is published on the CAN bus. -#define DRP_CONTROL_INTERVAL ( 200 / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the Drain pump is controlled. +#define DRP_CONTROL_INTERVAL ( 1000 / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the Drain pump is controlled. #define DRP_CONTROL_MAX_ALLOWED_PPO_PSI 30.0F ///< Drain pump maximum allowed PPo pressure in psi. #define DRP_CONTROL_MAX_ALLOWED_PDR_PSI 40.0F ///< Drain pump maximum allowed PDr pressure in psi. #define DRP_CONTROL_PSI_TO_DAC_P_ONLY_TERM 0.2F ///< Drain pump psi to DAC conversion. @@ -283,6 +283,8 @@ drainPumpControlModeSet = drainPumpControlMode; result = TRUE; isDrainPumpControlInFlowMode = TRUE; + + resetPIController( PI_CONTROLLER_ID_DRAIN_PUMP, DRAIN_PUMP_MIN_DAC ); } else { @@ -677,10 +679,11 @@ isDrainPumpControlInFlowMode = FALSE; } } - else if ( flowSubLPM > NEARLY_ZERO ) + else if ( flowSubLPM > 0.0F ) { // If measured flow if greater than the target flow, adjust the DAC to lower the flow rate tempDACSet = (U32)( ( flowSubLPM * DRP_CONTROL_FLOW_TO_DAC_P_ONLY_TERM ) + FLOAT_TO_INT_ROUNDUP_OFFSET ); + tempDACSet = ( tempDACSet > drainPumpDACSet ? DRAIN_PUMP_MIN_DAC : tempDACSet ); drainPumpDACSet -= ( tempDACSet > 0.0F ? tempDACSet : DRP_CONTROL_MIN_DAC_CHANGE ); } else @@ -691,11 +694,12 @@ F32 ppoSubPSI = roPumpOutletPressurePSI - DRP_CONTROL_MAX_ALLOWED_PPO_PSI; F32 maxPresPSI = MAX( pdrSubPSI, ppoSubPSI ); - if ( ( pdrSubPSI > NEARLY_ZERO ) || ( ppoSubPSI > NEARLY_ZERO ) ) + if ( ( pdrSubPSI > 0.0F ) || ( ppoSubPSI > 0.0F ) ) { // If either of the pressure values are greater than the maximum pressure, recalculate the DAC by the maximum pressure difference // If the calculated DAC value turned out to be 0, set it to 1 so it changes at least by 1 DAC tempDACSet = (U32)( ( maxPresPSI * DRP_CONTROL_PSI_TO_DAC_P_ONLY_TERM ) + FLOAT_TO_INT_ROUNDUP_OFFSET ); + tempDACSet = ( tempDACSet > drainPumpDACSet ? DRAIN_PUMP_MIN_DAC : tempDACSet ); drainPumpDACSet -= ( tempDACSet > 0.0F ? tempDACSet : DRP_CONTROL_MIN_DAC_CHANGE ); } else if ( ( fabs(pdrSubPSI) > DRP_CONTROL_PRES_TO_MAX_THRESHOLD_PSI ) && ( fabs(ppoSubPSI) > DRP_CONTROL_PRES_TO_MAX_THRESHOLD_PSI ) ) @@ -940,17 +944,13 @@ { BOOL status = FALSE; - // Check if the requested drain pump RPM is within range - if ( ( value >= MIN_DRAIN_PUMP_RPM ) && ( value <= MAX_DRAIN_PUMP_RPM ) ) + // Check if the user is logged in + if ( TRUE == isTestingActivated() ) { - // Check if the user is logged in - if ( TRUE == isTestingActivated() ) - { - drainPumpMeasuredRPM.ovData = value; - drainPumpMeasuredRPM.override = OVERRIDE_KEY; - drainPumpMeasuredRPM.ovInitData = drainPumpMeasuredRPM.data; - status = TRUE; - } + drainPumpMeasuredRPM.ovData = value; + drainPumpMeasuredRPM.override = OVERRIDE_KEY; + drainPumpMeasuredRPM.ovInitData = drainPumpMeasuredRPM.data; + status = TRUE; } return status;