Index: firmware/App/Controllers/ROPump.c =================================================================== diff -u -rd2ec7bf847131ad0f044fc122aef360d726a2dc5 -rd371983d84daf213db3e39d21cf30c13161ce062 --- firmware/App/Controllers/ROPump.c (.../ROPump.c) (revision d2ec7bf847131ad0f044fc122aef360d726a2dc5) +++ firmware/App/Controllers/ROPump.c (.../ROPump.c) (revision d371983d84daf213db3e39d21cf30c13161ce062) @@ -7,8 +7,8 @@ * * @file ROPump.c * -* @author (last) Dara Navaei -* @date (last) 25-Jul-2023 +* @author (last) Bill Bracken +* @date (last) 01-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; @@ -388,6 +396,7 @@ F32 actualPressure = getMeasuredDGPressure( PRESSURE_SENSOR_RO_PUMP_OUTLET ); BOOL isPressureMax = ( actualPressure >= MAX_ALLOWED_MEASURED_PRESSURE_PSI ? TRUE : 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). @@ -407,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.