Index: firmware/App/Controllers/ROPump.c =================================================================== diff -u -r609d5c77e1f5bd85e9dd1a90b786e56004a79f06 -r250f7f30b65a740ae957606f144437aee050a4f1 --- firmware/App/Controllers/ROPump.c (.../ROPump.c) (revision 609d5c77e1f5bd85e9dd1a90b786e56004a79f06) +++ firmware/App/Controllers/ROPump.c (.../ROPump.c) (revision 250f7f30b65a740ae957606f144437aee050a4f1) @@ -378,6 +378,8 @@ } #ifndef IGNORE_RO_PUMP_MONITOR + // 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 = 1.0 - ( roFeedbackVoltage / ROP_FEEDBACK_0_PCT_DUTY_CYCLE_VOLTAGE ); // To monitor the flow, the control mode must be in closed loop mode and the pump should be control to flow state @@ -397,24 +399,15 @@ checkPersistentAlarm( ALARM_ID_FLOW_RATE_OUT_OF_LOWER_RANGE, isFlowOutOfLowerRange, currentFlow, targetFlow ); } - if ( FALSE == isROPumpOn ) - { - BOOL isPumpRunning = fabs( roFeedbackVoltage - ROP_FEEDBACK_0_PCT_DUTY_CYCLE_VOLTAGE ) > 0.05 ? TRUE : FALSE; + // Check whether the Duty cycle is out of range + BOOL isDCOutOfRange = ( fabs( roPumpFeedbackDutyCyclePct - roPumpDutyCyclePctSet ) > ROP_DUTY_CYCLE_OUT_OF_RANGE_TOLERANCE ? TRUE : FALSE ); - checkPersistentAlarm( ALARM_ID_RO_PUMP_DUTY_CYCLE_OUT_OF_RANGE, isPumpRunning, roFeedbackVoltage, ROP_FEEDBACK_0_PCT_DUTY_CYCLE_VOLTAGE ); + checkPersistentAlarm( ALARM_ID_RO_PUMP_DUTY_CYCLE_OUT_OF_RANGE, isDCOutOfRange, roPumpFeedbackDutyCyclePct, roPumpDutyCyclePctSet ); - // Check if it has timed out - if ( TRUE == isAlarmActive( ALARM_ID_RO_PUMP_DUTY_CYCLE_OUT_OF_RANGE ) ) - { - activateSafetyShutdown(); - } - } - - if ( TRUE == isROPumpOn ) + // 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_RO_PUMP_DUTY_CYCLE_OUT_OF_RANGE ) ) && ( FALSE == isROPumpOn ) ) { - BOOL isDCOutOfRange = ( fabs( roPumpFeedbackDutyCyclePct - roPumpDutyCyclePctSet ) > ROP_DUTY_CYCLE_OUT_OF_RANGE_TOLERANCE ? TRUE : FALSE ); - - checkPersistentAlarm( ALARM_ID_RO_PUMP_DUTY_CYCLE_OUT_OF_RANGE, isDCOutOfRange, roPumpFeedbackDutyCyclePct, roPumpDutyCyclePctSet ); + activateSafetyShutdown(); } #endif