Index: firmware/App/Controllers/ROPump.c =================================================================== diff -u -rf4a444de1b2b78922a911448a65cfcc8677f86cb -r1747702a2e89998cd3fa1348907eeb623e9c16c8 --- firmware/App/Controllers/ROPump.c (.../ROPump.c) (revision f4a444de1b2b78922a911448a65cfcc8677f86cb) +++ firmware/App/Controllers/ROPump.c (.../ROPump.c) (revision 1747702a2e89998cd3fa1348907eeb623e9c16c8) @@ -8,7 +8,7 @@ * @file ROPump.c * * @author (last) Dara Navaei -* @date (last) 31-Mar-2022 +* @date (last) 25-May-2022 * * @author (original) Sean * @date (original) 04-Apr-2020 @@ -339,14 +339,14 @@ { U32 roFlowReading = (U32)getFPGAROPumpFlowRate(); F32 roFeedbackVoltage = getIntADCVoltageConverted( INT_ADC_RO_PUMP_FEEDBACK_DUTY_CYCLE ); - - // Update sum for flow average calculation - measuredFlowReadingsSum += (S32)roFlowReading; - // Read the pressure at the sensor. The pump cannot be more that the maximum allowed pressure // 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 ); + + // Update sum for flow average calculation + measuredFlowReadingsSum += (S32)roFlowReading; + checkPersistentAlarm( ALARM_ID_RO_PUMP_PRESSURE_OUT_OF_RANGE, isPressureMax, actualPressure, MAX_ALLOWED_MEASURED_PRESSURE_PSI ); // Check if a new calibration is available @@ -642,17 +642,15 @@ RO_PUMP_STATE_T state = RO_PUMP_RAMP_UP_TO_TARGET_FLOW_STATE; // Get the current pressure from the sensor - F32 actualPressure = getMeasuredDGPressure( PRESSURE_SENSOR_RO_PUMP_OUTLET ); - F32 targetFlowRate = getTargetROPumpFlowRate(); - F32 actualFlowRate = (F32)getMeasuredROFlowRateLPM(); - + F32 actualPressure = getMeasuredDGPressure( PRESSURE_SENSOR_RO_PUMP_OUTLET ); + F32 targetFlowRate = getTargetROPumpFlowRate(); + F32 actualFlowRate = (F32)getMeasuredROFlowRateLPM(); F32 flowRateDeviation = fabs( targetFlowRate - actualFlowRate ) / targetFlowRate; BOOL isFlowOutOfRange = flowRateDeviation > ROP_FLOW_TARGET_TOLERANCE; + F32 targetPressure = getTargetROPumpPressure(); if ( ++roControlTimerCounter >= ROP_RAMP_UP_CONTROL_INTERVAL ) { - F32 targetPressure = getTargetROPumpPressure(); - // If the actual pressure is greater than the target pressure or it is within the tolerance of the maximum pressure, move to set // to target pressure straight. At the beginning the maximum pressure is set in the targetROPumpPressure override variable. // If the flow rate was reached without reaching to maximum pressure, the pressure that was set to targetROPumpPressure override will