Index: firmware/App/Controllers/BalancingChamber.c =================================================================== diff -u -r788a88e8e9f58c60d3b753ef0ae32b6c7a0757e6 -r9e2f3b1c47e1f97c9bad76071f8620082957aded --- firmware/App/Controllers/BalancingChamber.c (.../BalancingChamber.c) (revision 788a88e8e9f58c60d3b753ef0ae32b6c7a0757e6) +++ firmware/App/Controllers/BalancingChamber.c (.../BalancingChamber.c) (revision 9e2f3b1c47e1f97c9bad76071f8620082957aded) @@ -570,6 +570,9 @@ BAL_CHAMBER_EXEC_STATE_T state = BAL_CHAMBER_STATE1_VALVES_CLOSE; freshDialPressure = getFilteredPressure( D18_PRES ); spentDialPressure = getFilteredPressure( D51_PRES ); + BOOL isBothFillsComplete = FALSE; + BOOL isFirstCycleNotDone = FALSE; + BOOL isFillCompleteOrFirstCycle = FALSE; // If fill is taking too long, set an alarm for fill timeout if ( ( balChamberFillTimeoutCount > 0 ) && ( currentBalChamberFillCounter > balChamberFillTimeoutCount ) ) @@ -591,7 +594,11 @@ checkSpentFillComplete( spentDialPressure ); // Check both spent and fresh side fill is complete - if ( ( TRUE == isSpentFillComplete ) && ( TRUE == isPressureStabilizedDuringFill ) || ( FALSE == isFirstCycleBCSwitchingCompleted ) ) + isBothFillsComplete = ( TRUE == isSpentFillComplete ) && ( TRUE == isPressureStabilizedDuringFill ); + isFirstCycleNotDone = ( FALSE == isFirstCycleBCSwitchingCompleted ); + isFillCompleteOrFirstCycle = isBothFillsComplete || isFirstCycleNotDone; + + if ( TRUE == isFillCompleteOrFirstCycle ) { // On successful completion, learn timeout as 150% of the observed fill count (once per cycle). if ( balChamberFillTimeoutCount == 0U ) @@ -742,10 +749,12 @@ static BAL_CHAMBER_EXEC_STATE_T handleBalChamberState2ValvesClose( void ) { BAL_CHAMBER_EXEC_STATE_T state = BAL_CHAMBER_STATE2_VALVES_CLOSE; + freshDialPressure = getFilteredPressure( D18_PRES ); + spentDialPressure = getFilteredPressure( D51_PRES ); + BOOL isBothFillsComplete = FALSE; + BOOL isFirstCycleNotDone = FALSE; + BOOL isFillCompleteOrFirstCycle = FALSE; - freshDialPressure = getFilteredPressure( D18_PRES ); - spentDialPressure = getFilteredPressure( D51_PRES ); - // Check fresh dialysate pressure back in range to indicate fill complete. if ( ( freshDialPressure >= FRESH_DIAL_PRESSURE_MIN_PSIG ) && ( freshDialPressure <= FRESH_DIAL_PRESSURE_MAX_PSIG ) ) { @@ -766,7 +775,11 @@ checkSpentFillComplete( spentDialPressure ); // Check switching cycle time or pressure check for valve closure - if ( ( TRUE == isSpentFillComplete ) && ( TRUE == isPressureStabilizedDuringFill ) || ( FALSE == isFirstCycleBCSwitchingCompleted ) ) + isBothFillsComplete = ( TRUE == isSpentFillComplete ) && ( TRUE == isPressureStabilizedDuringFill ); + isFirstCycleNotDone = ( FALSE == isFirstCycleBCSwitchingCompleted ); + isFillCompleteOrFirstCycle = isBothFillsComplete || isFirstCycleNotDone; + + if ( TRUE == isFillCompleteOrFirstCycle ) { // On successful completion, learn timeout as 150% of the observed fill count (once per cycle). if ( balChamberFillTimeoutCount == 0U ) @@ -909,7 +922,7 @@ adjustedSpeed = ( ( (F32)absDiffSpentFillCount / (F32)balChamberValveClosePeriod ) * spentDialPumpSpeed ) * D48_SPEED_ADJUST_FACTOR; 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). + //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 ) Index: firmware/App/Modes/ModeGenDialysate.c =================================================================== diff -u -r1f3075c2434f33fe481429e762b78f864db2cc30 -r9e2f3b1c47e1f97c9bad76071f8620082957aded --- firmware/App/Modes/ModeGenDialysate.c (.../ModeGenDialysate.c) (revision 1f3075c2434f33fe481429e762b78f864db2cc30) +++ firmware/App/Modes/ModeGenDialysate.c (.../ModeGenDialysate.c) (revision 9e2f3b1c47e1f97c9bad76071f8620082957aded) @@ -63,15 +63,15 @@ #define LOW_DIAL_FLOW_RATE 150.0F ///< Dialysate flow rate lesser than 150 considered to be low Qds. #define ZERO_DIAL_FLOW_RATE 0.0F ///< Zero dialysate flow rate #define SPENT_CHAMBER_FILL_MAX_COUNT 10 ///< Total number of spent chamber fill allowed. -#define BICARB_CHAMBER_FILL_TIMEOUT ( 1 * MS_PER_SECOND ) ///< Bicarb chamber fill timeout. +#define BICARB_CHAMBER_FILL_TIMEOUT ( 1 * MS_PER_SECOND ) ///< Bicarb chamber fill timeout. #define PUMP_SPEED_SLOPE_FACTOR_DIENER_2000 1.24F ///< D48 Diener 2000 pump speed slope (y = 1.24x + 30). #define PUMP_SPEED_INTERCEPT_FACTOR_DIENER_2000 30.0F ///< D48 Diener 2000 pump speed intercept. #define PUMP_SPEED_SLOPE_FACTOR_DIENER_1000 2.869F ///< D48 Diener 1000 pump speed slope (y = 2.869x + 25.956). #define PUMP_SPEED_INTERCEPT_FACTOR_DIENER_1000 25.956F ///< D48 Diener 1000 pump speed intercept. #define BICARB_CHAMBER_FILL_TIMEOUT ( 1 * MS_PER_SECOND ) ///< Bicarb chamber fill timeout. //Testing -#define DELAY_BC_SWITCHING_AT_START_UP ( 10 * MS_PER_SECOND ) ///< Provide a balancing chamber switching start up delay to stabilize pump speed etc., +#define DELAY_BC_SWITCHING_AT_START_UP ( 10 * MS_PER_SECOND ) ///< Provide a balancing chamber switching start up delay to stabilize pump speed etc., /// Payload record structure for Gen dialysate execution state set request typedef struct {