Index: firmware/App/Controllers/BalancingChamber.c =================================================================== diff -u -r6bbe6e35f9c378ad8dd5be2edebb1cc1acd23d37 -r75ecd5ee8a56b8d9faef07cdeb0a8dc7975ff476 --- firmware/App/Controllers/BalancingChamber.c (.../BalancingChamber.c) (revision 6bbe6e35f9c378ad8dd5be2edebb1cc1acd23d37) +++ firmware/App/Controllers/BalancingChamber.c (.../BalancingChamber.c) (revision 75ecd5ee8a56b8d9faef07cdeb0a8dc7975ff476) @@ -56,6 +56,8 @@ static U32 currentBalChamberSwitchingCounter; ///< Counter (in task interval) to monitor the timing spent during balancing chamber fill/drain operation. static BOOL isBalChamberFillInProgress; ///< Flag indicating balancing chamber fill/drain is in progress. static BOOL isPressureStalbilizedDuringFill; ///< Flag indicating that the pressure is stablized due to fill complete. +static BOOL isPressureDroppedDuringState1Fill; ///< Flag indicating that the pressure is dropped due to BC state 1 fill in progress condition. +static BOOL isPressureDroppedDuringState2Fill; ///< Flag indicating that the pressure is dropped due to BC state 2 fill in progress condition. static BAL_CHAMBER_SW_STATE_T balChamberSWState; ///< Current balancing chamber switching state ( state 1 or state 2). static U32 balChamberDataPublicationTimerCounter; ///< Used to schedule balancing chamber data publication to CAN bus. static OVERRIDE_U32_T balChamberDataPublishInterval; ///< Balancing chamber data publish interval. @@ -359,6 +361,8 @@ * state 1 fill and time to fill chamber counter being updated. * @details \b Inputs: Pressure * @details \b Outputs: valve states + * @details \b Alarm: ALARM_ID_DD_BC_STATE1_FILL_START_PRESSURE_OUT_OF_RANGE + * when pressure is not in range during balacing chamber fill start. * @return next balancing chamber state. *************************************************************************/ static BAL_CHAMBER_EXEC_STATE_T handleBalChamberState1FillStart( void ) @@ -367,6 +371,7 @@ currentBalChamberSwitchingCounter = 0; isBalChamberFillInProgress = FALSE; isPressureStalbilizedDuringFill = FALSE; + isPressureDroppedDuringState1Fill = FALSE; balChamberSWState = BAL_CHAMBER_SW_STATE1; F32 freshDialPressure = getFilteredPressure( D18_PRES ); @@ -419,9 +424,27 @@ { BAL_CHAMBER_EXEC_STATE_T state; + F32 freshDialPressure = getFilteredPressure( D18_PRES ); + F32 spentDialPressure = getFilteredPressure( D51_PRES ); + + // Pressure drop check during fill process helps to find if there is any issue with valves opening + if ( ( ( freshDialPressure >= BC_FILL_PRESSURE_MAX_PSIG ) && ( freshDialPressure <= BC_FILL_PRESSURE_MIN_PSIG ) ) && + ( ( spentDialPressure >= BC_FILL_PRESSURE_MAX_PSIG ) && ( spentDialPressure <= BC_FILL_PRESSURE_MIN_PSIG ) ) ) + { + if ( BAL_CHAMBER_SW_STATE1 == balChamberSWState ) + { + isPressureDroppedDuringState1Fill = TRUE; + } + else + { + isPressureDroppedDuringState2Fill = TRUE; + } + } + // On dosing completion, transition to next state based on the current switching state - if ( ( TRUE == getConcentratePumpDosingStatus( D11_PUMP ) ) && - ( TRUE == getConcentratePumpDosingStatus( D10_PUMP ) ) ) + if ( ( ( TRUE == getConcentratePumpDosingStatus( D11_PUMP ) ) && + ( TRUE == getConcentratePumpDosingStatus( D10_PUMP ) ) ) || + ( TRUE == getBalChamberSwitchingOnlyStatus() ) ) { if ( BAL_CHAMBER_SW_STATE1 == balChamberSWState ) { @@ -442,6 +465,10 @@ * fill complete and close the currently opened valves. * @details \b Inputs: balChamberSWState, spent and fresh dialysate pressure * @details \b Outputs: isPressureStalbilizedDuringFill,isBalChamberFillInProgress + * @details \b Alarm: ALARM_ID_DD_BC_STATE1_FILL_PRESSURE_DROP_OUT_OF_RANGE + * when pressure drop is not in range during balacing chamber fill in progress. + * @details \b Alarm: ALARM_ID_DD_BC_STATE1_FILL_END_PRESSURE_OUT_OF_RANGE + * when pressure is not in range during balacing chamber fill complete. * @return next balancing chamber state. *************************************************************************/ static BAL_CHAMBER_EXEC_STATE_T handleBalChamberState1FillEnd( void ) @@ -475,11 +502,23 @@ // On completion of cycle time, transition to next state if ( currentBalChamberSwitchingCounter >= balChamberSwitchingPeriod ) { - if ( ( TRUE != isPressureStalbilizedDuringFill ) && - ( FALSE == getBalChamberSwitchingOnlyStatus() ) ) + if ( FALSE == getBalChamberSwitchingOnlyStatus() ) { - // Alarm when switching time expired, but still pressure not in range, - SET_ALARM_WITH_2_F32_DATA( ALARM_ID_DD_BC_STATE1_FILL_END_PRESSURE_OUT_OF_RANGE, freshDialPressure, spentDialPressure ); + if ( TRUE != isPressureDroppedDuringState1Fill ) + { + // When fill initiated, pressure is not dropped to the expected range, possible valve failures. + SET_ALARM_WITH_2_F32_DATA( ALARM_ID_DD_BC_STATE1_FILL_PRESSURE_DROP_OUT_OF_RANGE, freshDialPressure, spentDialPressure ); + } + else if ( TRUE != isPressureStalbilizedDuringFill ) + { + // Alarm when switching time expired, but still pressure not in range to indicate fill is complete. + SET_ALARM_WITH_2_F32_DATA( ALARM_ID_DD_BC_STATE1_FILL_END_PRESSURE_OUT_OF_RANGE, freshDialPressure, spentDialPressure ); + } + else + { + // Move to next state when pressure is in range. + state = BAL_CHAMBER_STATE2_FILL_START; + } //TODO : Temporarily allow to proceed next state even though pressure is not stabilized. state = BAL_CHAMBER_STATE2_FILL_START; @@ -499,6 +538,8 @@ * state 2 fill and time to fill chamber counter being updated. * @details \b Inputs: fresh and spent dialysate pressure * @details \b Outputs: valve states + * @details \b Alarm: ALARM_ID_DD_BC_STATE2_FILL_START_PRESSURE_OUT_OF_RANGE + * when pressure is not in range during balacing chamber state 2 fill start. * @return next balancing chamber state. *************************************************************************/ static BAL_CHAMBER_EXEC_STATE_T handleBalChamberState2FillStart( void ) @@ -507,6 +548,7 @@ currentBalChamberSwitchingCounter = 0; isBalChamberFillInProgress = FALSE; isPressureStalbilizedDuringFill = FALSE; + isPressureDroppedDuringState2Fill = FALSE; balChamberSWState = BAL_CHAMBER_SW_STATE2; F32 freshDialPressure = getFilteredPressure( D18_PRES ); @@ -553,6 +595,10 @@ * fill complete and close the currently opened valves. * @details \b Inputs: balChamberSWState, spent and fresh dialysate pressure * @details \b Outputs: isPressureStalbilizedDuringFill,isBalChamberFillInProgress + * @details \b Alarm: ALARM_ID_DD_BC_STATE2_FILL_PRESSURE_DROP_OUT_OF_RANGE + * when pressure is not in range during balacing chamber state 2 fill in progress. + * @details \b Alarm: ALARM_ID_DD_BC_STATE2_FILL_END_PRESSURE_OUT_OF_RANGE + * when pressure is not in range during balacing chamber state 2 fill complete. * @return next balancing chamber state. *************************************************************************/ static BAL_CHAMBER_EXEC_STATE_T handleBalChamberState2FillEnd( void ) @@ -586,11 +632,24 @@ // On completion of cycle time, transition to next state if ( currentBalChamberSwitchingCounter >= balChamberSwitchingPeriod ) { - if ( ( TRUE != isPressureStalbilizedDuringFill ) && - ( FALSE == getBalChamberSwitchingOnlyStatus() ) ) + // Pressure alarm check + if ( FALSE == getBalChamberSwitchingOnlyStatus() ) { - // Alarm when switching time expired, but still pressure not in range, - SET_ALARM_WITH_2_F32_DATA( ALARM_ID_DD_BC_STATE2_FILL_END_PRESSURE_OUT_OF_RANGE, freshDialPressure, spentDialPressure ); + if ( TRUE != isPressureDroppedDuringState2Fill ) + { + // When fill initiated, pressure is not dropped to the expected range, possible valve failures. + SET_ALARM_WITH_2_F32_DATA( ALARM_ID_DD_BC_STATE2_FILL_PRESSURE_DROP_OUT_OF_RANGE, freshDialPressure, spentDialPressure ); + } + else if ( TRUE != isPressureStalbilizedDuringFill ) + { + // Alarm when switching time expired, but still pressure not in range to indicate fill is complete. + SET_ALARM_WITH_2_F32_DATA( ALARM_ID_DD_BC_STATE2_FILL_END_PRESSURE_OUT_OF_RANGE, freshDialPressure, spentDialPressure ); + } + else + { + // Move to next state when pressure is in range. + state = BAL_CHAMBER_STATE1_FILL_START; + } //TODO : Temporarily allow to proceed next state even though pressure is not stabilized. state = BAL_CHAMBER_STATE1_FILL_START;