Index: firmware/App/Controllers/Valves.c =================================================================== diff -u -rc20c77ef196a760a7642d2426e509995e4a98e01 -rca1d817247bb037d238f611b99f01a0577b4c71c --- firmware/App/Controllers/Valves.c (.../Valves.c) (revision c20c77ef196a760a7642d2426e509995e4a98e01) +++ firmware/App/Controllers/Valves.c (.../Valves.c) (revision ca1d817247bb037d238f611b99f01a0577b4c71c) @@ -7,8 +7,8 @@ * * @file Valves.c * -* @author (last) Sean Nash -* @date (last) 13-Jul-2022 +* @author (last) Dara Navaei +* @date (last) 01-Sep-2022 * * @author (original) Dara Navaei * @date (original) 07-Aug-2020 @@ -79,15 +79,16 @@ #define INITIAL_EDGE_OFFSET_READ_COUNT 100U ///< Offset in counts from energized and de-energized edges -#define INITIAL_ENERGIZED_EDGE_UPPER_RANGE 14000U // TODO it was originally 13000 ///< Energized edge maximum count +#define INITIAL_ENERGIZED_EDGE_UPPER_RANGE 14000U ///< Energized edge maximum count (originally 13000 count) #define INITIAL_ENERGIZED_EDGE_LOWER_RANGE 9000U ///< Energized edge minimum count #define AIR_TRAP_VALVE_GPIO_PIN 0x12 ///< Air trap valve GPIO Pin 18 of HET Port 1 #define HOMING_STEP_CHANGE_IN_COUNTS 1000 ///< Step change in counts during homing #define TRANSITION_STEP_CHANGE_IN_COUNTS 15000 ///< Step change in counts during normal operations -#define MAX_DEVIATION_FROM_TARGET_IN_COUNTS 150 ///< Maximum deviation from target in counts +#define MAX_DEVIATION_FROM_TARGET_IN_COUNTS 2500 ///< Maximum deviation from target in counts +#define MAX_DEVIATION_FROM_TGT_IN_TRAVEL_CNTS 150 ///< Maximum deviation from target in counts #define MAX_DEVIATION_FROM_TRAGET_IN_POS_B 1000 ///< Maximum allowed deviation from position B in counts #define MAX_ALLOWED_FAILED_HOMINGS 3U ///< Maximum allowed failed homings /// The time that the valve must be at the edge to be considered for edge detection @@ -267,6 +268,7 @@ void initValves( void ) { VALVE_T valve; + valveSelfTestState = VALVE_SELF_TEST_ENABLE_VALVES; valvesSelfTestResult = SELF_TEST_STATUS_IN_PROGRESS; valveAirTrapStatus = STATE_CLOSED; @@ -294,11 +296,11 @@ /*********************************************************************//** * @brief - * The homeValve function sets the homing request flag of a valve to TRUE. - * @details Inputs: none - * @details Outputs: valvesStatus (The flag that sets the homing request) + * The homeValve function processes the homing of a valve + * @details Inputs: valvesStatus + * @details Outputs: valvesStatus * @param valve that is set to be homed - * @return none + * @return TRUE if the homing command accepted otherwise, FALSE *************************************************************************/ BOOL homeValve( VALVE_T valve ) { @@ -663,7 +665,7 @@ S16 deltaPosition = targetPosition - currentPosition; // If there has not been any major travel for a certain period of time - if ( deltaPosition > MAX_DEVIATION_FROM_TARGET_IN_COUNTS ) + if ( deltaPosition > MAX_DEVIATION_FROM_TGT_IN_TRAVEL_CNTS ) { if ( valvesStatus[ valve ].homingEdgeDetectionCounter >= HOMING_EDGE_DETECTION_TIME_INTERVAL ) { @@ -709,7 +711,7 @@ S16 deltaPosition = currentPosition - targetPosition; // Still too far from intermediate target position? Either still more travel to go or stuck at end of travel - if ( deltaPosition > MAX_DEVIATION_FROM_TARGET_IN_COUNTS ) + if ( deltaPosition > MAX_DEVIATION_FROM_TGT_IN_TRAVEL_CNTS ) { // Are we stuck at end of travel? if ( valvesStatus[ valve ].homingEdgeDetectionCounter >= HOMING_EDGE_DETECTION_TIME_INTERVAL ) @@ -877,7 +879,7 @@ } } // Check if the valve is close to the temporary target position and if it is, assign the next target position - else if ( abs( currentPosition - targetPosition ) < MAX_DEVIATION_FROM_TARGET_IN_COUNTS ) + else if ( abs( currentPosition - targetPosition ) < MAX_DEVIATION_FROM_TGT_IN_TRAVEL_CNTS ) { setValveNextStep( valve, TRANSITION_STEP_CHANGE_IN_COUNTS ); } @@ -1183,8 +1185,7 @@ valvesStatus[ valve ].positionOutOfRangeCounter++; } - if ( ( valvesStatus[ valve ].positionOutOfRangeCounter > MAX_POS_DEVIATION_TIME_INTERVAL_COUNTER ) && - ( FALSE == isAlarmActive( ALARM_ID_HD_AC_POWER_LOST ) ) ) + if ( valvesStatus[ valve ].positionOutOfRangeCounter > MAX_POS_DEVIATION_TIME_INTERVAL_COUNTER ) { SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_VALVE_POSITION_OUT_OF_RANGE, (U32)valve, currentPosition ); }