Index: firmware/App/Controllers/Valves.c =================================================================== diff -u -rd9b4581350e00e87b211b0c81f8c34f02576fcf2 -r8eb118992bbb2f40666c68be20de57c5eb34b5dc --- firmware/App/Controllers/Valves.c (.../Valves.c) (revision d9b4581350e00e87b211b0c81f8c34f02576fcf2) +++ firmware/App/Controllers/Valves.c (.../Valves.c) (revision 8eb118992bbb2f40666c68be20de57c5eb34b5dc) @@ -1,14 +1,14 @@ /************************************************************************** * -* Copyright (c) 2020-2022 Diality Inc. - All Rights Reserved. +* Copyright (c) 2020-2023 Diality Inc. - All Rights Reserved. * * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. * * @file Valves.c * * @author (last) Dara Navaei -* @date (last) 17-Oct-2022 +* @date (last) 18-Jan-2023 * * @author (original) Dara Navaei * @date (original) 07-Aug-2020 @@ -478,6 +478,19 @@ /*********************************************************************//** * @brief + * The resetValvesPOSTState function resets the valves POST state; + * @details Inputs: none + * @details Outputs: valveSelfTestState, valvesSelfTestResult + * @return none + *************************************************************************/ +void resetValvesPOSTState( void ) +{ + valveSelfTestState = VALVE_SELF_TEST_ENABLE_VALVES; + valvesSelfTestResult = SELF_TEST_STATUS_IN_PROGRESS; +} + +/*********************************************************************//** + * @brief * The execValves function executes the valves exec state machine. * @details Inputs: valvesStatus * @details Outputs: valvesStatus @@ -1171,7 +1184,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 ) + if ( ( valvesStatus[ valve ].execState == VALVE_STATE_IDLE ) && ( FALSE == isAlarmActive( ALARM_ID_HD_AC_POWER_LOST ) ) ) { U32 maxDeviation = MAX_DEVIATION_FROM_TARGET_IN_COUNTS; @@ -1195,6 +1208,10 @@ 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 ); } else if ( ( abs( currentPosition - commandedPosition ) < MAX_DEVIATION_FROM_TARGET_IN_COUNTS ) && @@ -1203,6 +1220,10 @@ valvesStatus[ valve ].positionOutOfRangeCounter = 0; } } + else + { + valvesStatus[ valve ].positionOutOfRangeCounter = 0; + } } }