Index: firmware/App/Controllers/Valves.c =================================================================== diff -u -r82bd1d24c050e79690a7f5b236e49dd7db7e2a91 -r335c721d795f22c6dc4a24f5180dee3ba095a2b2 --- firmware/App/Controllers/Valves.c (.../Valves.c) (revision 82bd1d24c050e79690a7f5b236e49dd7db7e2a91) +++ firmware/App/Controllers/Valves.c (.../Valves.c) (revision 335c721d795f22c6dc4a24f5180dee3ba095a2b2) @@ -1187,7 +1187,7 @@ for ( valve = VDI; valve < NUM_OF_VALVES; valve++ ) { // Check the valve is in Idle state, otherwise the position should not be checked - if ( ( valvesStatus[ valve ].execState == VALVE_STATE_IDLE ) && ( FALSE == isACPowerLost() ) ) + if ( ( valvesStatus[ valve ].execState == VALVE_STATE_IDLE ) && ( FALSE == getCPLDACPowerLossDetected() ) ) { U32 maxDeviation = MAX_DEVIATION_FROM_TARGET_IN_COUNTS; @@ -1201,28 +1201,35 @@ maxDeviation = MAX_DEVIATION_FROM_TRAGET_IN_POS_B; } - // Check if the current position has deviated from the position it is supposed to be in - // For more than a certain amount of time. If it has, raise an alarm - // Absolute value is used for comparison to cover +/- from the commanded position - if ( abs( currentPosition - commandedPosition ) > maxDeviation ) + if ( FALSE == isACPowerLost() ) { - valvesStatus[ valve ].positionOutOfRangeCounter++; - } + // Check if the current position has deviated from the position it is supposed to be in + // For more than a certain amount of time. If it has, raise an alarm + // Absolute value is used for comparison to cover +/- from the commanded position + if ( abs( currentPosition - commandedPosition ) > maxDeviation ) + { + valvesStatus[ valve ].positionOutOfRangeCounter++; + } - if ( valvesStatus[ valve ].positionOutOfRangeCounter > MAX_POS_DEVIATION_TIME_INTERVAL_COUNTER ) - { - // If the valve's deviation from target was more than the counts for the define period of time trigger the alarm. - // Also, set the state to Idle so in the fault mode, the valve can transition to Pos C. The exec state is directly set here - // because this is a monitor function that is called in the controller function. - valvesStatus[ valve ].execState = VALVE_STATE_IDLE; - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_VALVE_POSITION_OUT_OF_RANGE, (U32)valve, currentPosition ); + if ( valvesStatus[ valve ].positionOutOfRangeCounter > MAX_POS_DEVIATION_TIME_INTERVAL_COUNTER ) + { + // If the valve's deviation from target was more than the counts for the define period of time trigger the alarm. + // Also, set the state to Idle so in the fault mode, the valve can transition to Pos C. The exec state is directly set here + // because this is a monitor function that is called in the controller function. + valvesStatus[ valve ].execState = VALVE_STATE_IDLE; + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_VALVE_POSITION_OUT_OF_RANGE, (U32)valve, currentPosition ); - if ( VALVE_POSITION_C_CLOSE == valvesStatus[ valve ].commandedPosition ) + if ( VALVE_POSITION_C_CLOSE == valvesStatus[ valve ].commandedPosition ) + { + activateSafetyShutdown(); + } + } + else if ( ( TRUE == isValveCloseToCommandedPosition( valve, commandedPositionEnum ) ) && ( valvesStatus[ valve ].positionOutOfRangeCounter > 0 ) ) { - activateSafetyShutdown(); + valvesStatus[ valve ].positionOutOfRangeCounter = 0; } } - else if ( ( TRUE == isValveCloseToCommandedPosition( valve, commandedPositionEnum ) ) && ( valvesStatus[ valve ].positionOutOfRangeCounter > 0 ) ) + else { valvesStatus[ valve ].positionOutOfRangeCounter = 0; }