Index: firmware/App/Modes/ModeGenDialysate.c =================================================================== diff -u -r87ee9712a928c58e3fe8b456bce567df0c6a2038 -ra2ea8edd918761b403cbe2c00e1bfe2fc69be5ea --- firmware/App/Modes/ModeGenDialysate.c (.../ModeGenDialysate.c) (revision 87ee9712a928c58e3fe8b456bce567df0c6a2038) +++ firmware/App/Modes/ModeGenDialysate.c (.../ModeGenDialysate.c) (revision a2ea8edd918761b403cbe2c00e1bfe2fc69be5ea) @@ -656,15 +656,14 @@ /*********************************************************************//** * @brief - * The getCalculatedD48PumpSpeedForBCFill function returns the D48 pump speed - * calculated from dialysate flow rate (Qd) for continuous delivery. - * @details \b Inputs: Qd from TD, test config TEST_CONFIG_DD_ENABLE_DIENER_1000_PUMP. + * The getD48PumpSpeed function returns the ceiled D48 pump speed. + * @details \b Inputs: Active flow rate(Qd), pump test config. * @details \b Outputs: none - * @return Calculated D48 pump speed in RPM (Diener 1000 or 2000 formula per test config). + * @return Ceiled D48 pump speed in RPM . *************************************************************************/ -U32 getCalculatedD48PumpSpeedForBCFill( void ) +U32 getD48PumpSpeed( void ) { - F32 dialFlowrate = getTDDialysateFlowrate(); + F32 dialFlowrate = getBalChamberActiveDialysateFlowrate(); F32 slope; F32 intercept; F32 calculatedSpeed; @@ -681,10 +680,8 @@ intercept = PUMP_SPEED_INTERCEPT_FACTOR_DIENER_1000; } - // Calculate nominal speed from Qd. calculatedSpeed = ( slope * dialFlowrate ) + intercept; - // Prevent negative before converting to unsigned and round up using ceilf. if ( calculatedSpeed < 0.0F ) { calculatedSpeed = 0.0F; @@ -697,6 +694,30 @@ /*********************************************************************//** * @brief + * The getCalculatedD48PumpSpeedForBCFill function returns the D48 pump speed + * for balancing chamber fill after applying the low-speed clamp. + * @details \b Inputs: Active BC Qd (or TD Qd before BC period init), pump test config. + * @details \b Outputs: none + * @return D48 pump speed in RPM for BC fill (Diener formula with low-speed floor). + *************************************************************************/ +U32 getCalculatedD48PumpSpeedForBCFill( void ) +{ + U32 rpm; + U32 nominalRpm; + + nominalRpm = getD48PumpSpeed(); + rpm = nominalRpm; + + if ( nominalRpm <= BAL_CHAMBER_TIME_BASED_D48_SPEED_RPM ) + { + rpm = BAL_CHAMBER_TIME_BASED_D48_SPEED_RPM; + } + + return rpm; +} + +/*********************************************************************//** + * @brief * The handleGenDDialysateIsolatedUFState function performs the * Isolated ultrafiltration operations. * @details \b Inputs: none.