Index: firmware/App/Controllers/ROPump.c =================================================================== diff -u -rdef06013312d270b1704787a4473caf5612dd6ac -r164e1a3ffca18c703676bc7f57f5903c76050600 --- firmware/App/Controllers/ROPump.c (.../ROPump.c) (revision def06013312d270b1704787a4473caf5612dd6ac) +++ firmware/App/Controllers/ROPump.c (.../ROPump.c) (revision 164e1a3ffca18c703676bc7f57f5903c76050600) @@ -7,8 +7,8 @@ * * @file ROPump.c * -* @author (last) Dara Navaei -* @date (last) 07-Apr-2023 +* @author (last) Sean Nash +* @date (last) 30-Sep-2023 * * @author (original) Sean * @date (original) 04-Apr-2020 @@ -79,12 +79,17 @@ #define MAX_ALLOWED_FLOW_DEVIATION_PCT 0.1F ///< Max allowed deviation from target flow in percent. #define MAX_ALLOWED_FLOW_DEVIATION_MLPM 100.0F ///< Max allowed deviation from target flow in mL/min. #define FLOW_OUT_OF_RANGE_TIME_OUT_MS ( 12 * MS_PER_SECOND ) ///< Flow out of range time out in counts. +#define FLOW_OUT_OF_LOWER_RANGE_TIMEOUT_MS ( 30 * MS_PER_SECOND ) ///< Flow out of lower range time out in ms +#define FLOW_OUT_OF_LOWER_RANGE_CLEAR_MS ( 10 * MS_PER_SECOND ) ///< Flow out of lower range clear time out in ms #define MAX_PRESSURE_TARGET_TOLERANCE 5 ///< Pressure tolerance from maximum set pressure by user in psi. #define MAX_ALLOWED_PRESSURE_PSI 130 ///< Maximum allowed pressure that the RO pump can go to. #define MIN_ALLOWED_PRESSURE_PSI 10 ///< Minimum allowed pressure that the RO pump can go to. #define MAX_ALLOWED_MEASURED_PRESSURE_PSI 135 ///< Maximum allowed pressure that the sensor measures. RO pump shut off pressure is 140psi. #define MAX_PRESSURE_OUT_OF_RANGE_PERSISTENT_INTERVAL MS_PER_SECOND ///< Maximum allowed time that the pressure can be very high. #define MAX_ALLOWED_RAMP_UP_TIME ( 10 * MS_PER_SECOND ) ///< Maximum allowed ramp up time to a flow rate in ms. +#define MAX_ALLOWED_RO_PUMP_PWM_PERCENT ( 0.95F ) ///< Maximum allowed RO Pump PWM . +#define MAX_RO_PUMP_PWM_PERSISTENT_INTERVAL ( 30 * MS_PER_SECOND ) ///< Maximum allowed time that ROPump PWM exceeded max in ms. +#define MAX_RO_PUMP_PWM_CLEAR_INTERVAL ( MS_PER_SECOND ) ///< Maximum clear time for ROPump PWM max exceeded in ms. #define ROP_PSI_TO_PWM_DC(p) ( 0.2F + ( (F32)((p) - 100) * 0.01F ) ) ///< Conversion factor from target PSI to PWM duty cycle estimate. #define SAFETY_SHUTDOWN_TIMEOUT ( 3 * MS_PER_SECOND ) ///< RO pump safety shutdown activation timeout in ms. @@ -186,7 +191,7 @@ // Initialize the persistent alarm for flow out of upper and lower range initPersistentAlarm( ALARM_ID_DG_FLOW_RATE_OUT_OF_UPPER_RANGE, FLOW_OUT_OF_RANGE_TIME_OUT_MS, FLOW_OUT_OF_RANGE_TIME_OUT_MS ); - initPersistentAlarm( ALARM_ID_DG_FLOW_RATE_OUT_OF_LOWER_RANGE, FLOW_OUT_OF_RANGE_TIME_OUT_MS, FLOW_OUT_OF_RANGE_TIME_OUT_MS ); + initPersistentAlarm( ALARM_ID_DG_FLOW_RATE_OUT_OF_LOWER_RANGE, FLOW_OUT_OF_LOWER_RANGE_CLEAR_MS, FLOW_OUT_OF_LOWER_RANGE_TIMEOUT_MS ); // Initialize the persistent alarm for max allowed pressure out of range initPersistentAlarm( ALARM_ID_DG_RO_PUMP_PRESSURE_OUT_OF_RANGE, MAX_PRESSURE_OUT_OF_RANGE_PERSISTENT_INTERVAL, @@ -195,6 +200,9 @@ // Initialize the persistent alarm for not turning off the pump initPersistentAlarm( ALARM_ID_DG_RO_PUMP_DUTY_CYCLE_OUT_OF_RANGE, SAFETY_SHUTDOWN_TIMEOUT, SAFETY_SHUTDOWN_TIMEOUT ); + // Initialize the persistent alarm for maximum RO PWM exceeded + initPersistentAlarm( ALARM_ID_DG_MAX_RO_PUMP_PWM_EXCEEDED, MAX_RO_PUMP_PWM_CLEAR_INTERVAL, MAX_RO_PUMP_PWM_PERSISTENT_INTERVAL ); + // Initialize the variables roControlTimerCounter = 0; roPumpOpenLoopTargetDutyCycle = 0; @@ -315,7 +323,7 @@ * roPumpPWMDutyCyclePctSet, roPumpControlMode * @details Outputs: roPumpOpenLoopTargetDutyCycle, roPumpPWMDutyCyclePct, * roPumpPWMDutyCyclePctSet, roPumpControlMode - * @param: duty which is the duty cycle + * @param duty which is the duty cycle * @return none *************************************************************************/ BOOL setROPumpTargetDutyCycle( F32 duty ) @@ -387,8 +395,14 @@ // to make sure the hardware (especially the ROF) is not damaged. If it is the case, we need to stop immediately F32 actualPressure = getMeasuredDGPressure( PRESSURE_SENSOR_RO_PUMP_OUTLET ); BOOL isPressureMax = ( actualPressure >= MAX_ALLOWED_MEASURED_PRESSURE_PSI ? TRUE : FALSE ); - BOOL isDutyCylceOutOfRange = FALSE; + BOOL isDutyCycleOutOfRange = FALSE; + BOOL isMaxPWM = ( roPumpDutyCyclePctSet > MAX_ALLOWED_RO_PUMP_PWM_PERCENT ) ? TRUE : FALSE; + // The feedback voltage is on the 0V line so when the duty cycle is 0, the feedback is 2.5V + // The duty cycle is calculated by getting the 1 - (ratio of feedback / to the voltage at 0 percent duty cycle). + roPumpFeedbackDutyCyclePct.data = 1.0F - ( roFeedbackVoltage / ROP_FEEDBACK_0_PCT_DUTY_CYCLE_VOLTAGE ); + isDutyCycleOutOfRange = ( fabs( getROFeedbackDutyCycle() - roPumpDutyCyclePctSet ) > ROP_DUTY_CYCLE_OUT_OF_RANGE_TOLERANCE ? TRUE : FALSE ); + checkPersistentAlarm( ALARM_ID_DG_RO_PUMP_PRESSURE_OUT_OF_RANGE, isPressureMax, actualPressure, MAX_ALLOWED_MEASURED_PRESSURE_PSI ); if ( ( getMeasuredFlowRateLPM( RO_FLOW_SENSOR ) > NEARLY_ZERO ) && ( VALVE_STATE_CLOSED == getValveStateName( VBF ) ) ) @@ -402,6 +416,9 @@ if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_RO_PUMP_MONITOR ) != SW_CONFIG_ENABLE_VALUE ) #endif { + // See if the maximum PWM alarm has occurred + checkPersistentAlarm( ALARM_ID_DG_MAX_RO_PUMP_PWM_EXCEEDED, isMaxPWM, roPumpDutyCyclePctSet, MAX_ALLOWED_RO_PUMP_PWM_PERCENT ); + // 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 the target // but the pump is not able to achieve the flow. @@ -431,15 +448,26 @@ case DG_MODE_FILL: case DG_MODE_FLUS: - case DG_MODE_HEAT: case DG_MODE_CHEM: case DG_MODE_CHFL: + case DG_MODE_ROPS: // The flow cannot be out of range for than 10% of the target flow isFlowOutOfRange = ( fabs( 1.0F - ( currentFlowLPM / targetFlowLPM ) ) > MAX_ALLOWED_FLOW_DEVIATION_PCT ? TRUE : FALSE ); isFlowOutOfUpperRange = ( isFlowOutOfRange && ( currentFlowLPM > targetFlowLPM ) ? TRUE : FALSE ); isFlowOutOfLowerRange = ( isFlowOutOfRange && ( currentFlowLPM < targetFlowLPM ) ? TRUE : FALSE ); break; + case DG_MODE_HEAT: + case DG_MODE_HCOL: + if ( getTargetROPumpPressurePSI() > CLEANING_MODE_HIGH_TEMP_MAX_RO_PRESSURE_PSI ) + { + // The flow cannot be out of range for than 10% of the target flow + isFlowOutOfRange = ( fabs( 1.0F - ( currentFlowLPM / targetFlowLPM ) ) > MAX_ALLOWED_FLOW_DEVIATION_PCT ? TRUE : FALSE ); + isFlowOutOfUpperRange = ( isFlowOutOfRange && ( currentFlowLPM > targetFlowLPM ) ? TRUE : FALSE ); + isFlowOutOfLowerRange = ( isFlowOutOfRange && ( currentFlowLPM < targetFlowLPM ) ? TRUE : FALSE ); + } + break; + default: // Do nothing in the rest of the modes. // Do not check the flow target in heat disinfect active cool since the flow during cooling might be very different from the target flow @@ -461,13 +489,8 @@ if ( getHardwareConfigStatus() != HW_CONFIG_BETA ) #endif { - // The feedback voltage is on the 0V line so when the duty cycle is 0, the feedback is 2.5V - // The duty cycle is calculated by getting the 1 - (ratio of feedback / to the voltage at 0 percent duty cycle). - roPumpFeedbackDutyCyclePct.data = 1.0F - ( roFeedbackVoltage / ROP_FEEDBACK_0_PCT_DUTY_CYCLE_VOLTAGE ); - isDutyCylceOutOfRange = ( fabs( getROFeedbackDutyCycle() - roPumpDutyCyclePctSet ) > ROP_DUTY_CYCLE_OUT_OF_RANGE_TOLERANCE ? TRUE : FALSE ); + checkPersistentAlarm( ALARM_ID_DG_RO_PUMP_DUTY_CYCLE_OUT_OF_RANGE, isDutyCycleOutOfRange, getROFeedbackDutyCycle(), roPumpDutyCyclePctSet ); - checkPersistentAlarm( ALARM_ID_DG_RO_PUMP_DUTY_CYCLE_OUT_OF_RANGE, isDutyCylceOutOfRange, getROFeedbackDutyCycle(), roPumpDutyCyclePctSet ); - // Check if it the alarm has timed out and if the pump is supposed to be off but it is still on, activate the safety shutdown if ( ( TRUE == isAlarmActive( ALARM_ID_DG_RO_PUMP_DUTY_CYCLE_OUT_OF_RANGE ) ) && ( FALSE == isROPumpOn ) ) { @@ -735,11 +758,13 @@ F32 actualPressure = getMeasuredDGPressure( PRESSURE_SENSOR_RO_PUMP_OUTLET ); // Control at set interval - if ( ++roControlTimerCounter >= ROP_CONTROL_INTERVAL && roPumpControlMode == PUMP_CONTROL_MODE_CLOSED_LOOP ) + if ( ( ++roControlTimerCounter >= ROP_CONTROL_INTERVAL ) && ( roPumpControlMode == PUMP_CONTROL_MODE_CLOSED_LOOP ) ) { if ( actualPressure > targetROPumpMaxPressure ) { + // Reduce the duty cycle and make sure it does not go below 0% roPumpDutyCyclePctSet -= ROP_RAMP_DOWN_DUTY_CYCLE_RATIO; + roPumpDutyCyclePctSet = MAX( roPumpDutyCyclePctSet, MIN_RO_PUMP_DUTY_CYCLE ); resetPIController( PI_CONTROLLER_ID_RO_PUMP_MAX_PRES, roPumpDutyCyclePctSet ); } else @@ -919,7 +944,7 @@ * RO pump data publish interval. * @details Inputs: roPumpDataPublishInterval * @details Outputs: roPumpDataPublishInterval - * @param: value : override RO pump data publish interval with (in ms) + * @param value : override RO pump data publish interval with (in ms) * @return TRUE if override successful, FALSE if not *************************************************************************/ BOOL testSetROPumpDataPublishIntervalOverride( U32 value )