Index: firmware/App/Modes/ModeGenDialysate.c =================================================================== diff -u -r2d295ca85f19e95da42476a57ca6b4496baf980a -r8348015aa77e1ee2c4c20e9f8e2c45b59bcf3f17 --- firmware/App/Modes/ModeGenDialysate.c (.../ModeGenDialysate.c) (revision 2d295ca85f19e95da42476a57ca6b4496baf980a) +++ firmware/App/Modes/ModeGenDialysate.c (.../ModeGenDialysate.c) (revision 8348015aa77e1ee2c4c20e9f8e2c45b59bcf3f17) @@ -655,20 +655,25 @@ /*********************************************************************//** * @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 getNominalD48PumpSpeedCeiledForBCFill function returns the ceiled D48 + * pump speed from the Diener formula before any low-speed clamp. + * @details \b Inputs: Active BC Qd (or TD Qd before BC period init), pump test config. * @details \b Outputs: none - * @return Calculated D48 pump speed in RPM (Diener 1000 or 2000 formula per test config). + * @return Nominal D48 pump speed in RPM (ceil of formula output). *************************************************************************/ -U32 getCalculatedD48PumpSpeedForBCFill( void ) +U32 getNominalD48PumpSpeedCeiledForBCFill( void ) { - F32 dialFlowrate = getTDDialysateFlowrate(); + F32 dialFlowrate = getBalChamberActiveDialysateFlowrate(); F32 slope; F32 intercept; F32 calculatedSpeed; U32 rpm; + if ( 0U == getBalChamberSwitchingPeriod() ) + { + dialFlowrate = getTDDialysateFlowrate(); + } + if ( TRUE == getTestConfigStatus( TEST_CONFIG_DD_ENABLE_DIENER_2000_PUMP ) ) { slope = PUMP_SPEED_SLOPE_FACTOR_DIENER_2000; @@ -680,10 +685,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; @@ -696,6 +699,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 = getNominalD48PumpSpeedCeiledForBCFill(); + 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.