Index: firmware/App/Controllers/Valves.c =================================================================== diff -u -r82bd1d24c050e79690a7f5b236e49dd7db7e2a91 -r4dda5ae6127e3580137ebf70caf3560e3b268892 --- firmware/App/Controllers/Valves.c (.../Valves.c) (revision 82bd1d24c050e79690a7f5b236e49dd7db7e2a91) +++ firmware/App/Controllers/Valves.c (.../Valves.c) (revision 4dda5ae6127e3580137ebf70caf3560e3b268892) @@ -20,6 +20,7 @@ #include "gio.h" #include "Battery.h" +#include "CPLD.h" #include "FPGA.h" #include "MessageSupport.h" #include "NVDataMgmt.h" @@ -925,7 +926,7 @@ state = VALVE_STATE_IDLE; } // Check if the valve's transition time has timed out - else if ( ( TRUE == didTimeout( valvesStatus[ valve ].transitionStartTime, VALVE_TRANSITION_TIMEOUT_MS ) ) && ( FALSE == isACPowerLost() ) ) + else if ( ( TRUE == didTimeout( valvesStatus[ valve ].transitionStartTime, VALVE_TRANSITION_TIMEOUT_MS ) ) && ( FALSE == getCPLDACPowerLossDetected() ) ) { // Go back to Idle state and set the valve position to not in position because it was not able to get to the target position valvesStatus[ valve ].currentPosition = VALVE_POSITION_NOT_IN_POSITION; @@ -1187,7 +1188,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,25 +1202,28 @@ 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 ( VALVE_POSITION_C_CLOSE == valvesStatus[ valve ].commandedPosition ) + if ( valvesStatus[ valve ].positionOutOfRangeCounter > MAX_POS_DEVIATION_TIME_INTERVAL_COUNTER ) { - activateSafetyShutdown(); + // 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 ) + { + activateSafetyShutdown(); + } } } else if ( ( TRUE == isValveCloseToCommandedPosition( valve, commandedPositionEnum ) ) && ( valvesStatus[ valve ].positionOutOfRangeCounter > 0 ) ) @@ -1230,6 +1234,7 @@ else { valvesStatus[ valve ].positionOutOfRangeCounter = 0; + } } }