Index: firmware/App/Controllers/ROPump.c =================================================================== diff -u -rbcb768dd6a13286e028533394916a9f69c9f254f -rbb7a4629cc96d96b6d1749c924e77886e0d64bcb --- firmware/App/Controllers/ROPump.c (.../ROPump.c) (revision bcb768dd6a13286e028533394916a9f69c9f254f) +++ firmware/App/Controllers/ROPump.c (.../ROPump.c) (revision bb7a4629cc96d96b6d1749c924e77886e0d64bcb) @@ -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 @@ -643,17 +643,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