Index: firmware/App/Controllers/ROPump.c =================================================================== diff -u -r5c967dc311b485769e50e5e4f122be21079b5ae9 -rfba89d67dd2bef913e85a13563e2aa49f0e2e2f5 --- firmware/App/Controllers/ROPump.c (.../ROPump.c) (revision 5c967dc311b485769e50e5e4f122be21079b5ae9) +++ firmware/App/Controllers/ROPump.c (.../ROPump.c) (revision fba89d67dd2bef913e85a13563e2aa49f0e2e2f5) @@ -34,9 +34,6 @@ #ifdef EMC_TEST_BUILD #include "Heaters.h" #endif -#ifdef ENABLE_DIP_SWITCHES -#include "Valves.h" -#endif /** * @addtogroup ROPump @@ -115,7 +112,7 @@ static F32 roPumpPWMDutyCyclePct = 0.0; ///< Initial RO pump PWM duty cycle. static F32 roPumpDutyCyclePctSet = 0.0; ///< Currently set RO pump PWM duty cycle. static PUMP_CONTROL_MODE_T roPumpControlMode = PUMP_CONTROL_MODE_CLOSED_LOOP; ///< Requested RO pump control mode. -static PUMP_CONTROL_MODE_T roPumpControlModeSet = PUMP_CONTROL_MODE_CLOSED_LOOP; ///< Currently set RO pump control mode. +static PUMP_CONTROL_MODE_T roPumpControlModeSet = PUMP_CONTROL_MODE_CLOSED_LOOP; ///< Currently set RO pump control mode. TODO do we need this? static F32 targetROPumpFlowRate = 0.0; ///< Target RO flow rate (in L/min). static F32 targetROPumpMaxPressure = 0.0; ///< Target RO max allowed pressure (in PSI). @@ -315,12 +312,15 @@ flowFilterCounter = 0; } - // To monitor the flow, the control mode must be in closed loop and the pump should be control to target state, - // meaning, it is controlling to a certain pressure - /*if ( roPumpControlMode == PUMP_CONTROL_MODE_CLOSED_LOOP && roPumpState == RO_PUMP_CONTROL_TO_TARGET_FLOW_STATE ) +#ifndef IGNORE_RO_PUMP_MONITOR + // To monitor the flow, the control mode must be in closed loop mode and the pump should be control to flow state + // If the pump is controlled to the maximum pressure, the flow might be different from the target flow for more than 10% + // but the pump is not able to achieve the flow. + if ( ( PUMP_CONTROL_MODE_CLOSED_LOOP == roPumpControlMode ) && ( RO_PUMP_CONTROL_TO_TARGET_FLOW_STATE == roPumpState ) ) { F32 const currentFlow = getMeasuredROFlowRate(); F32 const targetFlow = getTargetROPumpFlowRate(); + // The flow cannot be out of range for than 10% of the target flow BOOL const isFlowOutOfRange = fabs( 1.0 - ( currentFlow / targetFlow ) ) > MAX_ALLOWED_FLOW_DEVIATION; // Figure out whether flow is out of range from which side BOOL const isFlowOutOfUpperRange = isFlowOutOfRange && ( currentFlow > targetFlow ); @@ -343,8 +343,8 @@ { activateSafetyShutdown(); } - }*/ - + } +#endif // Publish RO pump data on interval publishROPumpData(); }