Index: firmware/App/Controllers/BalancingChamber.c =================================================================== diff -u -r78dc7a98fb2a3d28bbdeb4eade1bba03641433d3 -r2ef132047d9438cb0e452e31b046546e2350e0bb --- firmware/App/Controllers/BalancingChamber.c (.../BalancingChamber.c) (revision 78dc7a98fb2a3d28bbdeb4eade1bba03641433d3) +++ firmware/App/Controllers/BalancingChamber.c (.../BalancingChamber.c) (revision 2ef132047d9438cb0e452e31b046546e2350e0bb) @@ -7,8 +7,8 @@ * * @file BalancingChamber.c * -* @author (last) Vinayakam Mani -* @date (last) 01-Jun-2026 +* @author (last) Sameer Kalliadan Poyil +* @date (last) 24-Jun-2026 * * @author (original) Vinayakam Mani * @date (original) 28-Jan-2025 @@ -23,6 +23,7 @@ #include "FpgaDD.h" #include "Heaters.h" #include "Level.h" +#include "MixingControl.h" #include "ModeGenDialysate.h" #include "ModeStandby.h" #include "Messaging.h" @@ -61,6 +62,7 @@ #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 + /// Payload record structure for balancing chamber switch only request typedef struct { @@ -106,7 +108,7 @@ static F32 pendingTdDialysateFlowrate; ///< Pending TD dialysate flow rate; applied at FillEnd after a BC switch completes. static BOOL isBalChamberSwitchingPeriodUpdatePending; ///< BC switching period update pending apply at fill end. static U32 bcSwitchingBasedOnClosedPeriodCounter; ///< Valve-close segments remaining before first-cycle relaxations clear after Qd timing apply. -static F32 balancingError; ///< balancing error that has been calculated during balancing chamber switching. +static F32 balancingError; ///< Balancing error that has been calculated during balancing chamber switching. //TODO: remove later once level sensor working static U32 bicarbChamberPeriodicFillCounter; @@ -244,6 +246,34 @@ /*********************************************************************//** * @brief + * The getBicarbDoseVol function gets the bicarb dose volume + * @details \b Inputs: bicarbDoseVolume + * @details \b Outputs: none + * @return TRUE if successful, FALSE if not. + *************************************************************************/ +F32 getBicarbDoseVol( void ) +{ + F32 result = getF32OverrideValue( &bicarbDoseVolume ); + + return result; +} + +/*********************************************************************//** + * @brief + * The getAcidDoseVol function gets acid mix volume + * @details \b Inputs: acidDoseVolume + * @details \b Outputs: none + * @return TRUE if successful, FALSE if not. + *************************************************************************/ +F32 getAcidDoseVol( void ) +{ + F32 result = getF32OverrideValue( &acidDoseVolume ); + + return result; +} + +/*********************************************************************//** + * @brief * The applyBalChamberSwitchingPeriod function applies the active balancing * chamber switching time based on the provided dialysis flow rate. * @details \b Inputs: Dialysis flow rate. @@ -345,14 +375,8 @@ currentBalChamberSwitchingCounter += 1; currentBalChamberFillCounter += 1; - //Calculate balancing error to be used to adjust UF rate - if ( balChamberExecState > BAL_CHAMBER_STATE_IDLE ) + if ( ( FALSE == getTestConfigStatus( TEST_CONFIG_DD_DISABLE_DRY_BICARB ) ) && ( balChamberExecState > BAL_CHAMBER_STATE_IDLE ) ) { - calculateBalancingChamberError(); - } - - if ( ( getTestConfigStatus( TEST_CONFIG_DD_ENABLE_DRY_BICARB ) == TRUE ) && ( balChamberExecState > BAL_CHAMBER_STATE_IDLE ) ) - { #ifdef CONDUCTIVE_LEVEL_SENSOR_ENABLED if ( LVL_STATE_LOW == bicarbChamberLevel ) { @@ -627,7 +651,7 @@ spentFillRiseMissCounter = 0; isSpentFillComplete = FALSE; - if ( getTestConfigStatus( TEST_CONFIG_DD_ENABLE_DRY_BICARB ) == TRUE ) + if ( FALSE == getTestConfigStatus( TEST_CONFIG_DD_DISABLE_DRY_BICARB ) ) { bicarbVolume = getBicarbMixVol(); acidVolume = getAcidMixVol(); @@ -773,7 +797,7 @@ } // If the dry bicarbonate is enabled then we ignore looking at d18 pressure to be in range. - if ( ( TRUE == getTestConfigStatus( TEST_CONFIG_DD_ENABLE_DRY_BICARB ) ) && ( TRUE == getBicarbChamberFillRequested() ) ) + if ( ( FALSE == getTestConfigStatus( TEST_CONFIG_DD_DISABLE_DRY_BICARB ) ) && ( TRUE == getBicarbChamberFillRequested() ) ) { isPressureStabilizedDuringFill = TRUE; } @@ -945,7 +969,7 @@ spentFillRiseMissCounter = 0; isSpentFillComplete = FALSE; - if ( getTestConfigStatus( TEST_CONFIG_DD_ENABLE_DRY_BICARB ) == TRUE ) + if ( FALSE == getTestConfigStatus( TEST_CONFIG_DD_DISABLE_DRY_BICARB ) ) { bicarbVolume = getBicarbMixVol(); acidVolume = getAcidMixVol(); @@ -1025,7 +1049,7 @@ spentDialPressure = getFilteredPressure( D51_PRES ); // If the dry bicarbonate is enabled then we ignore looking at d18 pressure to be in range. - if ( ( TRUE == getTestConfigStatus( TEST_CONFIG_DD_ENABLE_DRY_BICARB ) ) && ( TRUE == getBicarbChamberFillRequested() ) ) + if ( ( FALSE == getTestConfigStatus( TEST_CONFIG_DD_DISABLE_DRY_BICARB ) ) && ( TRUE == getBicarbChamberFillRequested() ) ) { isPressureStabilizedDuringFill = TRUE; }