Index: firmware/App/Controllers/BalancingChamber.c =================================================================== diff -u -r26371f0d57553f6786ad6f47ac5587b43e805180 -red96c724f65f6763233b2c427456b6efd19717e6 --- firmware/App/Controllers/BalancingChamber.c (.../BalancingChamber.c) (revision 26371f0d57553f6786ad6f47ac5587b43e805180) +++ firmware/App/Controllers/BalancingChamber.c (.../BalancingChamber.c) (revision ed96c724f65f6763233b2c427456b6efd19717e6) @@ -21,8 +21,8 @@ #include "DialysatePumps.h" #include "FpgaDD.h" #include "Heaters.h" -#include "ModeStandby.h" #include "ModeGenDialysate.h" +#include "ModeStandby.h" #include "Messaging.h" #include "OperationModes.h" #include "Pressure.h" @@ -68,7 +68,7 @@ static U32 balChamberValveClosePeriod; ///< Close balancing chamber valves with the defined time prior switching state. 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 isPressureStabilizedDuringFill; ///< Flag indicating that the pressure is stablized due to fill complete. 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 U32 balChamberFillPressureDropCounter; ///< Counter to check balancing chamber valves opened and there by pressure drop is seen. @@ -133,7 +133,7 @@ balChamberValveClosePeriod = 0; isBalChamberFillInProgress = FALSE; currentBalChamberSwitchingCounter = 0; - isPressureStalbilizedDuringFill = FALSE; + isPressureStabilizedDuringFill = FALSE; lastTdDialysateFlowrate = 0.0F; balChamberDataPublicationTimerCounter = 0; balChamberFillPressureDropCounter = 0; @@ -432,7 +432,7 @@ balChamberSWState = BAL_CHAMBER_SW_STATE1; currentBalChamberFillCounter = 0; isBalChamberFillInProgress = FALSE; - isPressureStalbilizedDuringFill = FALSE; + isPressureStabilizedDuringFill = FALSE; isPressureDroppedDuringFill = FALSE; isSpentFillComplete = FALSE; lastPrevSpentDialPressure = 0.0F; @@ -443,7 +443,7 @@ freshDialPressure = getFilteredPressure( D18_PRES ); spentDialPressure = getFilteredPressure( D51_PRES ); - // Check fresh and spent dialysate pressure in range or BC switch only flag set + // Check fresh dialysate pressure in range or BC switch only flag set or BC pressure alarms are disabled if ( ( ( freshDialPressure >= FRESH_DIAL_PRESSURE_MIN_PSIG ) && ( freshDialPressure <= FRESH_DIAL_PRESSURE_MAX_PSIG ) ) || ( TRUE == getBalChamberSwitchingOnlyStatus() ) || ( TRUE == getTestConfigStatus( TEST_CONFIG_DD_DISABLE_BC_PRESSURE_ALARMS ) ) ) { @@ -551,15 +551,15 @@ if ( ++balChamberFillCompleteStablePressureCounter >= BAL_CHAMBER_FILL_COMPLETE_MS ) { // stabilized pressure indicating fresh side fill is complete - isPressureStalbilizedDuringFill = TRUE; + isPressureStabilizedDuringFill = TRUE; } } // Spent side of balancing chamber fill is complete or not checkSpentFillComplete( spentDialPressure ); // Check both spent and fresh side fill is complete - if ( ( TRUE == isSpentFillComplete ) && ( TRUE == isPressureStalbilizedDuringFill ) || ( FALSE == isFirstCycleBCSwitchingCompleted ) ) + if ( ( TRUE == isSpentFillComplete ) && ( TRUE == isPressureStabilizedDuringFill ) || ( FALSE == isFirstCycleBCSwitchingCompleted ) ) { // close the state 1 opened valves valveControlForBCState1FillEnd(); @@ -605,7 +605,7 @@ // 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 ) + else if ( TRUE != isPressureStabilizedDuringFill ) { // Alarm when switching time expired, but still pressure not in range which indicates fill is not yet completed. SET_ALARM_WITH_2_F32_DATA( ALARM_ID_DD_BC_STATE1_FILL_END_PRESSURE_OUT_OF_RANGE, freshDialPressure, spentDialPressure ); @@ -645,7 +645,7 @@ BAL_CHAMBER_EXEC_STATE_T state = BAL_CHAMBER_STATE2_FILL_START; currentBalChamberSwitchingCounter = 0; isBalChamberFillInProgress = FALSE; - isPressureStalbilizedDuringFill = FALSE; + isPressureStabilizedDuringFill = FALSE; isPressureDroppedDuringFill = FALSE; balChamberSWState = BAL_CHAMBER_SW_STATE2; currentBalChamberFillCounter = 0; @@ -660,7 +660,6 @@ // Check fresh dialysate pressure in range if ( ( ( freshDialPressure >= FRESH_DIAL_PRESSURE_MIN_PSIG ) && ( freshDialPressure <= FRESH_DIAL_PRESSURE_MAX_PSIG ) ) || - // ( ( spentDialPressure >= SPENT_DIAL_PRESSURE_MIN_PSIG ) && ( spentDialPressure <= SPENT_DIAL_PRESSURE_MAX_PSIG ) ) || ( TRUE == getBalChamberSwitchingOnlyStatus() ) || ( TRUE == getTestConfigStatus( TEST_CONFIG_DD_DISABLE_BC_PRESSURE_ALARMS ) ) ) { // Valve control for state 2 fill @@ -708,24 +707,21 @@ freshDialPressure = getFilteredPressure( D18_PRES ); spentDialPressure = getFilteredPressure( D51_PRES ); - BOOL isFreshDialysatePressureInRange = ( freshDialPressure >= FRESH_DIAL_PRESSURE_MIN_PSIG ) && ( freshDialPressure <= FRESH_DIAL_PRESSURE_MAX_PSIG ); - BOOL isSpentDialysatePressureInRange = ( spentDialPressure >= SPENT_DIAL_PRESSURE_MIN_PSIG ) && ( spentDialPressure <= SPENT_DIAL_PRESSURE_MAX_PSIG ); - - // Check fresh and spent dialysate pressure back in range to indicate fill complete. + // Check fresh dialysate pressure back in range to indicate fill complete. if ( ( freshDialPressure >= FRESH_DIAL_PRESSURE_MIN_PSIG ) && ( freshDialPressure <= FRESH_DIAL_PRESSURE_MAX_PSIG ) ) { if ( ++balChamberFillCompleteStablePressureCounter >= BAL_CHAMBER_FILL_COMPLETE_MS ) { // stabilized pressure indicating fresh side fill is complete - isPressureStalbilizedDuringFill = TRUE; + isPressureStabilizedDuringFill = TRUE; } } // Spent side of balancing chamber fill is complete or not checkSpentFillComplete( spentDialPressure ); // Check switching cycle time or pressure check for valve closure - if ( ( TRUE == isSpentFillComplete ) && ( TRUE == isPressureStalbilizedDuringFill ) || ( FALSE == isFirstCycleBCSwitchingCompleted ) ) + if ( ( TRUE == isSpentFillComplete ) && ( TRUE == isPressureStabilizedDuringFill ) || ( FALSE == isFirstCycleBCSwitchingCompleted ) ) { // close the valves valveControlForBCState2FillEnd(); @@ -772,7 +768,7 @@ // 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 ) + else if ( TRUE != isPressureStabilizedDuringFill ) { // Alarm when switching time expired, but still pressure not in range which indicates fill is not completed. SET_ALARM_WITH_2_F32_DATA( ALARM_ID_DD_BC_STATE2_FILL_END_PRESSURE_OUT_OF_RANGE, freshDialPressure, spentDialPressure ); @@ -810,6 +806,7 @@ * fill timing close to the switching period time. * @details \b Inputs: balChamberExecState * @details \b Outputs: none + * @param spentDialPressure to check the switching time for BC and set D48 speed based on it. * @return the current state of balancing chamber states. *************************************************************************/ static void checkSpentFillComplete( F32 spentDialPressure ) @@ -823,11 +820,16 @@ U32 maxD48Speed = initialD48PumpSpeed + ( initialD48PumpSpeed * D48_SPEED_RANGE_LIMIT ); U32 d48SpeedPostRangeCheck = 0; F32 qdMlpm = getTDDialysateFlowrate(); + BOOL result = FALSE; F32 spentFillCompletePresPsig; - // Diener 1000 pump: spent fill complete pressure depends on Qd (7/15/20 PSI). Other pump: use legacy 25 PSI. - if ( TRUE == getTestConfigStatus( TEST_CONFIG_DD_ENABLE_DIENER_1000_PUMP ) ) + // Diener 2000 pump: spent fill complete pressure use legacy 25 PSI. Other pump: depends on Qd. + if ( TRUE == getTestConfigStatus( TEST_CONFIG_DD_ENABLE_DIENER_2000_PUMP ) ) { + spentFillCompletePresPsig = SPENT_FILL_COMPLETE_PRES; + } + else + { if ( qdMlpm <= QD_THRESHOLD_LOW_MLPM ) { spentFillCompletePresPsig = SPENT_FILL_COMPLETE_PRES_QD_LOW_PSIG; @@ -841,10 +843,6 @@ spentFillCompletePresPsig = SPENT_FILL_COMPLETE_PRES_QD_HIGH_PSIG; } } - else - { - spentFillCompletePresPsig = SPENT_FILL_COMPLETE_PRES; - } // Collect the next sample of spent pressure lastPrevSpentDialPressure = prevSpentDialPressure; @@ -859,9 +857,9 @@ absDiffSpentFillCount = abs(diffSpentFillCompleteCount); adjustedSpeed = ( ( (F32)absDiffSpentFillCount / (F32)balChamberValveClosePeriod ) * spentDialPumpSpeed ) * D48_SPEED_ADJUST_FACTOR; - //Not adjust the D48 pump speed if the fill counter is just 50ms difference from the closing period. - if ( 0 == ( ( diffSpentFillCompleteCount <= 0 ) && ( diffSpentFillCompleteCount >= -2 ) ) ) - //if ( absDiffSpentFillCount > SPENT_DIFF_COUNT_DEADBAND ) + result = ( ( diffSpentFillCompleteCount <= 0 ) && ( diffSpentFillCompleteCount >= -2 ) ) ? TRUE : FALSE; + //Not adjust the D48 pump speed if the fill counter is just 50ms difference from the closing period(considering only positive DEADBAND as negative deadband might indicate under fill of BC). + if ( 0 == result ) { if ( diffSpentFillCompleteCount < SPENT_DIFF_COUNT_ZERO ) { @@ -937,6 +935,7 @@ * switching only On/Off status. * @details \b Inputs: balanceChamberSwitchingOnly * @details \b Outputs: none + * @param OnOff to set the BC switch status * @return none *************************************************************************/ void setBalChamberSwitchingOnlyStatus( BOOL OnOff ) @@ -1013,7 +1012,7 @@ data.balChamberSwPeriod = getD48PumpSpeedForBCFill(); data.isBalChamberFillInProgress = isSpentFillComplete; data.currentBalChamberSwitchingCounter = currentBalChamberFillCounter; - data.isPressureStabilizedDuringFill = isPressureStalbilizedDuringFill; + data.isPressureStabilizedDuringFill = isPressureStabilizedDuringFill; data.balChamberSWOnlyState = balanceChamberSwitchingOnly; broadcastData( MSG_ID_DD_BAL_CHAMBER_DATA, COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08*)&data, sizeof( BAL_CHAMBER_DATA_T ) );