Index: firmware/App/Modes/ModeGenDialysate.c =================================================================== diff -u -r2d295ca85f19e95da42476a57ca6b4496baf980a -rbdf2c733a764466fcc4a0ff4938f5c97456bdb77 --- firmware/App/Modes/ModeGenDialysate.c (.../ModeGenDialysate.c) (revision 2d295ca85f19e95da42476a57ca6b4496baf980a) +++ firmware/App/Modes/ModeGenDialysate.c (.../ModeGenDialysate.c) (revision bdf2c733a764466fcc4a0ff4938f5c97456bdb77) @@ -7,8 +7,8 @@ * * @file ModeGenDialysate.c * -* @author (last) Sameer Kalliadan Poyil -* @date (last) 23-Apr-2026 +* @author (last) Raghu Kallala +* @date (last) 05-May-2026 * * @author (original) Vinayakam Mani * @date (original) 06-Nov-2024 @@ -24,6 +24,7 @@ #include "FpgaDD.h" #include "Heaters.h" #include "Level.h" +#include "MessagePayloads.h" #include "Messaging.h" #include "ModeGenDialysate.h" #include "ModeStandby.h" @@ -655,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; @@ -680,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; @@ -696,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.