Index: firmware/App/Controllers/BalancingChamber.c =================================================================== diff -u -rf1dc3383b840c39f202b15679e0bbe2b2f7a2f83 -r42541cc4700d748d524400f61d99e288a0e11f3e --- firmware/App/Controllers/BalancingChamber.c (.../BalancingChamber.c) (revision f1dc3383b840c39f202b15679e0bbe2b2f7a2f83) +++ firmware/App/Controllers/BalancingChamber.c (.../BalancingChamber.c) (revision 42541cc4700d748d524400f61d99e288a0e11f3e) @@ -58,6 +58,7 @@ #define D48_SPEED_RANGE_LIMIT 0.25F ///< D48 speed adjustment range check limit ( D48 speed can vary +/-25% of initial calculated speed) #define BICARB_CHAMBER_PERIODIC_FILL_TIME ( 1 * SEC_PER_MIN * \ ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ) ///< Periodic bicarb chamber fill request 60 sec x 20 = 1200 +#define NUMBER_OF_CYCLES_BASED_ON_FLOWRATE 4 ///< NUmber of Balancing Chamber cycles required to update the new Qd rate. #define BAL_CHAMBER_FILL_TIMEOUT_FACTOR 3.0F ///< Balancing Chamber fill timeout factor (300% of observed fill count) #define COMP_SLOPE -0.000376F ///< Balancing chamber temperature compensation slope factor #define COMP_INTERCEPT 1.007269F ///< Balancing chamber temperature compensation intercept factor @@ -212,8 +213,9 @@ * The getBicarbConcentratePumpSpeedMlMin function computes D10 pump speed * from the instantaneous bicarb mix volume: * speed = 240 - sqrt(230400 - 96000*v) / 2 - * Result is clamped to [0, CONCENTRATE_PUMP_MAX_SPEED]. + * Result is clamped to [CONCENTRATE_PUMP_MIN_SPEED, CONCENTRATE_PUMP_MAX_SPEED]. * @details \b Inputs: bicarbVolumeMl + * @details \b Outputs: none * @param bicarbVolumeMl Instantaneous bicarb mix volume (mL) * @return Bicarb concentrate pump speed (mL/min) *************************************************************************/ @@ -235,7 +237,7 @@ } else if ( result < 0.0F ) { - result = 0.0F; + result = CONCENTRATE_PUMP_MIN_SPEED; } return result; @@ -409,9 +411,7 @@ *************************************************************************/ static void scheduleFirstCycleRelaxAfterQdApply( void ) { - //TODO : revert after testing - //bcSwitchingBasedOnClosedPeriodCounter = 2; - bcSwitchingBasedOnClosedPeriodCounter = 4; + bcSwitchingBasedOnClosedPeriodCounter = NUMBER_OF_CYCLES_BASED_ON_FLOWRATE; } /*********************************************************************//** @@ -924,11 +924,12 @@ { SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DD_BC_FILL_TIMEOUT_FAULT, currentBalChamberFillCounter, balChamberFillTimeoutCount ); + SEND_EVENT_WITH_2_U32_DATA( DD_EVENT_BC_FILL_TIMEOUT, isPressureStabilizedDuringFill, isSpentFillComplete ); + // Move to the idle state state = BAL_CHAMBER_STATE_IDLE; } -#if 1 // Check fresh dialysate pressure back in range to indicate fresh fill complete. if ( ( freshDialPressure >= FRESH_DIAL_PRESSURE_MIN_PSIG ) && ( freshDialPressure <= FRESH_DIAL_PRESSURE_MAX_PSIG ) ) { @@ -938,22 +939,6 @@ isPressureStabilizedDuringFill = TRUE; } } -#else - // If the dry bicarbonate is enabled then we ignore looking at d18 pressure to be in range. - if ( ( FALSE == getTestConfigStatus( TEST_CONFIG_DD_DISABLE_DRY_BICARB ) ) && ( TRUE == getBicarbChamberFillRequested() ) ) - { - isPressureStabilizedDuringFill = TRUE; - } - // Check fresh dialysate pressure back in range to indicate fresh fill complete. - else 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 - isPressureStabilizedDuringFill = TRUE; - } - } -#endif // Close fresh side valves only upon fresh fill completion by detecting pressure rise. closeFreshSideValvesWhenFillComplete(); @@ -1191,7 +1176,17 @@ freshDialPressure = getFilteredPressure( D18_PRES ); spentDialPressure = getFilteredPressure( D51_PRES ); -#if 1 + // After the first BC cycle, fault if fill never completes at the Qd-based timeout. + if ( ( currentBalChamberFillCounter > balChamberFillTimeoutCount ) && ( TRUE != getTestConfigStatus( TEST_CONFIG_DD_DISABLE_BC_PRESSURE_ALARMS ) ) ) + { + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DD_BC_FILL_TIMEOUT_FAULT, currentBalChamberFillCounter, balChamberFillTimeoutCount ); + + SEND_EVENT_WITH_2_U32_DATA( DD_EVENT_BC_FILL_TIMEOUT, isPressureStabilizedDuringFill, isSpentFillComplete ); + + // Move to the idle state + state = BAL_CHAMBER_STATE_IDLE; + } + // Check fresh dialysate pressure back in range to indicate fresh fill complete. if ( ( freshDialPressure >= FRESH_DIAL_PRESSURE_MIN_PSIG ) && ( freshDialPressure <= FRESH_DIAL_PRESSURE_MAX_PSIG ) ) { @@ -1201,32 +1196,7 @@ isPressureStabilizedDuringFill = TRUE; } } -#else - // If the dry bicarbonate is enabled then we ignore looking at d18 pressure to be in range. - if ( ( FALSE == getTestConfigStatus( TEST_CONFIG_DD_DISABLE_DRY_BICARB ) ) && ( TRUE == getBicarbChamberFillRequested() ) ) - { - isPressureStabilizedDuringFill = TRUE; - } - // Check fresh dialysate pressure back in range to indicate fresh fill complete. - else 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 - isPressureStabilizedDuringFill = TRUE; - } - } -#endif - // After the first BC cycle, fault if fill never completes at the Qd-based timeout. - if ( ( currentBalChamberFillCounter > balChamberFillTimeoutCount ) && ( TRUE != getTestConfigStatus( TEST_CONFIG_DD_DISABLE_BC_PRESSURE_ALARMS ) ) ) - { - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DD_BC_FILL_TIMEOUT_FAULT, currentBalChamberFillCounter, balChamberFillTimeoutCount ); - - // Move to the idle state - state = BAL_CHAMBER_STATE_IDLE; - } - // Close fresh side valves only upon fresh fill completion by detecting pressure rise. closeFreshSideValvesWhenFillComplete();