Index: firmware/App/Controllers/ROPump.c =================================================================== diff -u -r830213bc6dcc1a684610caf78c79d55f2cb41e93 -r18d4cfcb41570947e19250a549a62e52cdcd3aaa --- firmware/App/Controllers/ROPump.c (.../ROPump.c) (revision 830213bc6dcc1a684610caf78c79d55f2cb41e93) +++ firmware/App/Controllers/ROPump.c (.../ROPump.c) (revision 18d4cfcb41570947e19250a549a62e52cdcd3aaa) @@ -74,6 +74,7 @@ static F32 roPumpDutyCyclePctSet; ///< Currently set RO pump PWM duty cycle. static OVERRIDE_F32_T roPumpOpenLoopTargetDutyCycle; ///< Target RO pump open loop PWM. static BOOL roPumpStartControl; ///< boolean to determine when closed loop flow control starts +static U32 roPumpClosedLoopStartTimeMS; ///< Timeout timer for RO pump to reach minimum target flow // ********** private function prototypes ********** @@ -108,8 +109,6 @@ initializePIController( PI_CONTROLLER_ID_RO_PUMP_PRES, MIN_FLUID_PUMP_DUTY_CYCLE_PCT, ROP_PRESSURE_CONTROL_P_COEFFICIENT, ROP_PRESSURE_CONTROL_I_COEFFICIENT, MIN_FLUID_PUMP_DUTY_CYCLE_PCT, MAX_FLUID_PUMP_DUTY_CYCLE_PCT, FALSE, 0 ); - initPersistentAlarm( ALARM_ID_FP_PERMEATE_FLOW_RATE_BELOW_TARGET, FP_FLOW_RATE_BELOW_TARGET_CLEAR_MS, FP_FLOW_RATE_BELOW_TARGET_TIMEOUT_MS ); - roPumpState = RO_PUMP_OFF_STATE; isROPumpOn = FALSE; stopPumpRequest = FALSE; @@ -133,6 +132,7 @@ roPumpOpenLoopTargetDutyCycle.ovData = 0.0; roPumpOpenLoopTargetDutyCycle.ovInitData = 0.0; roPumpOpenLoopTargetDutyCycle.override = OVERRIDE_RESET; + roPumpClosedLoopStartTimeMS = 0; stopROPump(); } @@ -284,10 +284,8 @@ static RO_PUMP_STATE_T handleROPumpControlToTargetFlowState( void ) { RO_PUMP_STATE_T state = RO_PUMP_CONTROL_TO_TARGET_FLOW_STATE; - F32 nexttgtflow = 0.0; - F32 currentFlowRate = 0.0; - F32 adjustedFlowRRate = 0.0; - BOOL isFlowRateLow = FALSE; + F32 currentFlowRate = 0.0F; + F32 minRequiredFlowRate = 0.0F; // Check if need to switch control modes if ( getTargetROPumpPressure() > 0.0F ) @@ -311,10 +309,10 @@ else if ( ++roControlTimerCounter >= ROP_CONTROL_INTERVAL ) { currentFlowRate = getFilteredFlow( P16_FLOW ); - adjustedFlowRRate = (F32)getTargetROPumpFlowRateMLPM() * ROP_MIN_FLOW_TO_CONTROL_PCT; + minRequiredFlowRate = (F32)getTargetROPumpFlowRateMLPM() * ROP_MIN_FLOW_TO_CONTROL_PCT; // P16 flow seems to lag in current Leahi HW. We will wait till we hit a % of target flow before we start changing control. - if( ( TRUE == roPumpStartControl ) || ( currentFlowRate >= ( adjustedFlowRRate ) ) ) + if( ( TRUE == roPumpStartControl ) || ( currentFlowRate >= ( minRequiredFlowRate ) ) ) { roPumpDutyCyclePctSet = runPIController( PI_CONTROLLER_ID_RO_PUMP_FLOW, (F32)getTargetROPumpFlowRateMLPM(), currentFlowRate ); roPumpDutyCyclePctSet = MIN( roPumpDutyCyclePctSet, ( MAX_FLUID_PUMP_PWM_DUTY_CYCLE * MAX_FLUID_PUMP_DUTY_CYCLE_PCT ) ); @@ -326,11 +324,6 @@ } } roControlTimerCounter = 0; - - //is flow rate less than 75% of the target flow rate - // wait for 10 seconds for timeout - isFlowRateLow = ( ( currentFlowRate < ( adjustedFlowRRate ) ) ? TRUE : FALSE); - checkPersistentAlarm( ALARM_ID_FP_PERMEATE_FLOW_RATE_BELOW_TARGET, isFlowRateLow, currentFlowRate, adjustedFlowRRate); } return state; @@ -416,6 +409,7 @@ // Get the initial guess of the duty cycle roPumpDutyCyclePctSet = roPumpFlowToPWM( getTargetROPumpFlowRateMLPM() ); roControlTimerCounter = 0; + roPumpClosedLoopStartTimeMS = getMSTimerCount(); isROPumpOn = TRUE; result = TRUE; }