Index: firmware/App/Controllers/ROPump.c =================================================================== diff -u -r47a7b0fce13cf38919932a8662c378f4f6a8b9f3 -rf1de0420490d71f85393a1e281bbbbc87a232c64 --- firmware/App/Controllers/ROPump.c (.../ROPump.c) (revision 47a7b0fce13cf38919932a8662c378f4f6a8b9f3) +++ firmware/App/Controllers/ROPump.c (.../ROPump.c) (revision f1de0420490d71f85393a1e281bbbbc87a232c64) @@ -8,7 +8,7 @@ * @file ROPump.c * * @author (last) “rkallala” -* @date (last) 15-Jan-2026 +* @date (last) 20-Jan-2026 * * @author (original) Michael Garthwaite * @date (original) 08-Sep-2025 @@ -59,7 +59,8 @@ #define ROP_FLOW_TO_PWM(flow) ( ROP_FLOW_TO_PWM_SLOPE * log(flow) + ROP_FLOW_TO_PWM_INTERCEPT ) ///< PWM line equation for flow converted to percentage. #define FP_FLOW_RATE_BELOW_TARGET_TIMEOUT_MS ( 10 * MS_PER_SECOND ) ///< Timeout for flow rate below 75% of target flow rate -#define FP_FLOW_RATE_BELOW_TARGET_CLEAR_MS ( 10 * MS_PER_SECOND ) ///< Clear timeout for flow rate below target flow rate +#define FP_FLOW_RATE_BELOW_TARGET_CLEAR_MS ( 10 * MS_PER_SECOND ) ///< Clear timeout for flow rate below target flow rate +#define PERMEATE_FLOW_LOW_OUT_OF_RANGE_EXEMPT_MS ( 10 * MS_PER_SECOND ) ///< Permeate flow low alarm exempt for 10 seconds after starting from Off // ********** private data ********** @@ -74,7 +75,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 +static U32 timeSinceP12Started; ///< Time when RO pump is started from off state. // ********** private function prototypes ********** @@ -83,6 +84,7 @@ static RO_PUMP_STATE_T handleROPumpControlToTargetPressureState( void ); static RO_PUMP_STATE_T handleROPumpOpenLoopState( void ); +static U32 getROPumpLowFlowExemptTimer( void ); static F32 roPumpPresToPWM( F32 targetPressure ); static F32 roPumpFlowToPWM( U32 targetFlow ); static void stopROPump( void ); @@ -91,9 +93,7 @@ /*********************************************************************//** * @brief * The initROPump function initializes the RO Pump module. - * @details \b Inputs: roPumpState, roPumpControlMode, isROPumpOn, stopPumpRequest, - * roControlTimerCounter, roPumpDutyCyclePctSet, roPumpOpenLoopTargetDutyCycle, roPumpDataPublicationTimerCounter, - * roPumpDataPublishInterval, targetROPumpFlowRate, targetROPumpPressure + * @details \b Inputs: none * @details \b Outputs: RO Pump controller unit initialized * @return none *************************************************************************/ @@ -132,7 +132,7 @@ roPumpOpenLoopTargetDutyCycle.ovData = 0.0; roPumpOpenLoopTargetDutyCycle.ovInitData = 0.0; roPumpOpenLoopTargetDutyCycle.override = OVERRIDE_RESET; - roPumpClosedLoopStartTimeMS = 0; + timeSinceP12Started = 0; stopROPump(); } @@ -190,6 +190,7 @@ { RO_PUMP_STATE_T state = RO_PUMP_OFF_STATE; isROPumpOn = FALSE; + timeSinceP12Started = 0; // If there is a target flow set, transition to the PI controller and control to flow if ( getTargetROPumpFlowRateMLPM() > 0 ) @@ -222,6 +223,11 @@ state = RO_PUMP_OPEN_LOOP_STATE; } + if ( state != RO_PUMP_OFF_STATE ) + { + timeSinceP12Started = getMSTimerCount(); + } + return state; } @@ -409,7 +415,6 @@ // Get the initial guess of the duty cycle roPumpDutyCyclePctSet = roPumpFlowToPWM( getTargetROPumpFlowRateMLPM() ); roControlTimerCounter = 0; - roPumpClosedLoopStartTimeMS = getMSTimerCount(); isROPumpOn = TRUE; result = TRUE; } @@ -601,6 +606,39 @@ /*********************************************************************//** * @brief + * The isROPumpLowflowAlarmExempt function gets the flag whether or not + * to exempt the low flow alarm. + * @details \b Inputs: none + * @details \b Outputs: none + * @return TRUE if low flow alarm is exempt, FALSE if not. + *************************************************************************/ +BOOL isROPumpLowflowAlarmExempt( void ) +{ + BOOL result = FALSE; + + if ( ( roPumpState == RO_PUMP_CONTROL_TO_TARGET_FLOW_STATE ) && ( FALSE == didTimeout( getROPumpLowFlowExemptTimer(), PERMEATE_FLOW_LOW_OUT_OF_RANGE_EXEMPT_MS ) ) ) + { + result = TRUE; + } + + return result; +} + +/*********************************************************************//** + * @brief + * The getROPumpLowFlowExemptTimer function gets the timer when RO pump + * starts from Off state. + * @details \b Inputs: none + * @details \b Outputs: none + * @return the timer when RO pump started from Off state (in ms). + *************************************************************************/ +static U32 getROPumpLowFlowExemptTimer( void ) +{ + return timeSinceP12Started; +} + +/*********************************************************************//** + * @brief * The roPumpPresToPWM function calculates the duty cycle for the given target * pressure. * @details \b Inputs: none