Index: firmware/App/Controllers/DrainPump.c =================================================================== diff -u -rb8f298547eb578000b3ff3cf55732fda7a689ce0 -ra3916397312e1dc73efe99d6b3569b7387a9419b --- firmware/App/Controllers/DrainPump.c (.../DrainPump.c) (revision b8f298547eb578000b3ff3cf55732fda7a689ce0) +++ firmware/App/Controllers/DrainPump.c (.../DrainPump.c) (revision a3916397312e1dc73efe99d6b3569b7387a9419b) @@ -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 ) )