Index: firmware/App/Controllers/BalancingChamber.c =================================================================== diff -u -rdf87716215d606300dd2617a6854b7071c0ce545 -rb26c5dd805f0c95856456fd16c8fc9c56659f76e --- firmware/App/Controllers/BalancingChamber.c (.../BalancingChamber.c) (revision df87716215d606300dd2617a6854b7071c0ce545) +++ firmware/App/Controllers/BalancingChamber.c (.../BalancingChamber.c) (revision b26c5dd805f0c95856456fd16c8fc9c56659f76e) @@ -260,7 +260,7 @@ currentBalChamberSwitchingCounter += 1; currentBalChamberFillCounter += 1; - if ( getTestConfigStatus( TEST_CONFIG_DD_ENABLE_DRY_BICARB ) == TRUE && balChamberExecState > BAL_CHAMBER_STATE_IDLE) + if ( ( getTestConfigStatus( TEST_CONFIG_DD_ENABLE_DRY_BICARB ) == TRUE ) && ( balChamberExecState > BAL_CHAMBER_STATE_IDLE ) ) { // Increment counter for dry bicarb chamber fill bicarbChamberPeriodicFillCounter += 1; @@ -510,8 +510,8 @@ { F32 acidVolume; F32 bicarbVolume; - BAL_CHAMBER_EXEC_STATE_T state = BAL_CHAMBER_STATE1_FILL_START; + balChamberSWState = BAL_CHAMBER_SW_STATE1; balChamberFillTimeoutCount = 0; isBalChamberFillInProgress = FALSE; @@ -655,12 +655,13 @@ static BAL_CHAMBER_EXEC_STATE_T handleBalChamberState1ValvesClose( void ) { 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; + freshDialPressure = getFilteredPressure( D18_PRES ); + spentDialPressure = getFilteredPressure( D51_PRES ); + // If fill is taking too long, set an alarm for fill timeout if ( ( balChamberFillTimeoutCount > 0 ) && ( currentBalChamberFillCounter > balChamberFillTimeoutCount ) ) { @@ -815,8 +816,8 @@ { F32 acidVolume; F32 bicarbVolume; - BAL_CHAMBER_EXEC_STATE_T state = BAL_CHAMBER_STATE2_FILL_START; + isBalChamberFillInProgress = FALSE; isPressureStabilizedDuringFill = FALSE; isPressureDroppedDuringFill = FALSE; @@ -902,12 +903,13 @@ 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 ) ) {