Index: firmware/App/Controllers/SpentChamberFill.c =================================================================== diff -u -re6415d33321e7990c3b5e82b0c8a87c64cc3a2c8 -r56410a2475a4a6d1aa93642c630cdf37683d3231 --- firmware/App/Controllers/SpentChamberFill.c (.../SpentChamberFill.c) (revision e6415d33321e7990c3b5e82b0c8a87c64cc3a2c8) +++ firmware/App/Controllers/SpentChamberFill.c (.../SpentChamberFill.c) (revision 56410a2475a4a6d1aa93642c630cdf37683d3231) @@ -1,17 +1,17 @@ /************************************************************************** * -* Copyright (c) 2024-2025 Diality Inc. - All Rights Reserved. +* Copyright (c) 2025-2026 Diality Inc. - All Rights Reserved. * * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. * * @file SpentChamberFill.c * -* @author (last) Vinayakam Mani -* @date (last) 20-Aug-2025 +* @author (last) Sameer Kalliadan Poyil +* @date (last) 03-Feb-2026 * * @author (original) Vinayakam Mani -* @date (original) 20-Aug-2025 +* @date (original) 21-Aug-2025 * ***************************************************************************/ @@ -39,6 +39,7 @@ // ********** private definitions ********** #define SPENT_CHAMBER_FILL_DATA_PUBLISH_INTERVAL ( 250 / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the balancing chamber data published. +#define SPENT_CHAMBER_SWITCHING_PERIOD 59 ///< Spent Chamber Fill Switching Period to max dialysate flow rate Qd: 600 minus 50ms to stabilize the valve closure // ********** private data ********** @@ -53,6 +54,7 @@ // ********** private function prototypes ********** +static SPENT_CHAMBER_FILL_EXEC_STATE_T handleSpentChamberFillWaitPressureStabilizeState( void ); static SPENT_CHAMBER_FILL_EXEC_STATE_T handleSpentChamberFillState1FillStart( void ); static SPENT_CHAMBER_FILL_EXEC_STATE_T handleSpentChamberState1DosingControl( void ); static SPENT_CHAMBER_FILL_EXEC_STATE_T handleSpentChamberFillState1FillEnd(void); @@ -95,8 +97,8 @@ { initSpentChamberFill(); updateBalChamberSwitchingPeriod(); - // Follow the same cycle for spent chamber fill - spentChamberFillSwitchingPeriod = getBalChamberSwitchingPeriod(); + // Update the Switching Period to max dialysate flow rate(Qd: 600) for filling spent chamber at max rate. + spentChamberFillSwitchingPeriod = SPENT_CHAMBER_SWITCHING_PERIOD; } /*********************************************************************//** @@ -118,9 +120,13 @@ switch ( spentChamberFillExecState ) { case SPENT_CHAMBER_FILL_STATE_START: - spentChamberFillExecState = SPENT_CHAMBER_FILL_STATE1_FILL_START; + spentChamberFillExecState = SPENT_CHAMBER_FILL_WAIT_PRESSURE_STABILIZE_STATE; break; + case SPENT_CHAMBER_FILL_WAIT_PRESSURE_STABILIZE_STATE: + spentChamberFillExecState = handleSpentChamberFillWaitPressureStabilizeState(); + break; + case SPENT_CHAMBER_FILL_STATE1_FILL_START: spentChamberFillExecState = handleSpentChamberFillState1FillStart(); break; @@ -182,6 +188,32 @@ /*********************************************************************//** * @brief + * The handleSpentChamberFillWaitPressureStabilizeState function introduces the pressure + * stabilization period before starting the spent chamber fill. + * @details \b Inputs: none + * @details \b Outputs: valve states + * @return none. + *************************************************************************/ +static SPENT_CHAMBER_FILL_EXEC_STATE_T handleSpentChamberFillWaitPressureStabilizeState( void ) +{ + SPENT_CHAMBER_FILL_EXEC_STATE_T nextState = SPENT_CHAMBER_FILL_WAIT_PRESSURE_STABILIZE_STATE; + + F32 freshDialPressure = getFilteredPressure( D18_PRES ); + F32 spentDialPressure = getFilteredPressure( D51_PRES ); + + BOOL spentInRange = ( ( spentDialPressure >= SPENT_DIAL_FILL_PRESSURE_MIN_PSIG ) && ( spentDialPressure <= SPENT_DIAL_FILL_PRESSURE_MAX_PSIG ) ); + BOOL freshInRange = ( ( freshDialPressure >= FRESH_DIAL_FILL_PRESSURE_MIN_PSIG ) && ( freshDialPressure <= FRESH_DIAL_FILL_PRESSURE_MAX_PSIG ) ); + + if ( ( TRUE == spentInRange ) && ( TRUE == freshInRange ) ) + { + nextState = SPENT_CHAMBER_FILL_STATE1_FILL_START; + } + + return nextState; +} + +/*********************************************************************//** + * @brief * The valveControlForSCFillState2FillStart function actuates the valve combination * for state 2 fill process. * @details \b Inputs: none @@ -228,8 +260,8 @@ //Valve control for state 1 spent chamber fill valveControlForSCFillState1FillStart(); // start acid and bicarb pump with the expected quantity - setConcentratePumpTargetSpeed( D11_PUMP, CONCENTRATE_PUMP_MAX_SPEED, acidDoseVolume ); - setConcentratePumpTargetSpeed( D10_PUMP, CONCENTRATE_PUMP_MAX_SPEED, bicarbDoseVolume ); + setConcentratePumpTargetSpeed( D11_PUMP, DOSING_CONCENTRATE_PUMP_SPEED, acidDoseVolume ); + setConcentratePumpTargetSpeed( D10_PUMP, DOSING_CONCENTRATE_PUMP_SPEED, bicarbDoseVolume ); requestConcentratePumpOn( D11_PUMP ); requestConcentratePumpOn( D10_PUMP ); @@ -317,8 +349,8 @@ // Valve control for state 2 fill valveControlForSCFillState2FillStart(); // start acid and bicarb pump with the expected quantity - setConcentratePumpTargetSpeed( D11_PUMP, CONCENTRATE_PUMP_MAX_SPEED, acidDoseVolume ); - setConcentratePumpTargetSpeed( D10_PUMP, CONCENTRATE_PUMP_MAX_SPEED, bicarbDoseVolume ); + setConcentratePumpTargetSpeed( D11_PUMP, DOSING_CONCENTRATE_PUMP_SPEED, acidDoseVolume ); + setConcentratePumpTargetSpeed( D10_PUMP, DOSING_CONCENTRATE_PUMP_SPEED, bicarbDoseVolume ); requestConcentratePumpOn( D11_PUMP ); requestConcentratePumpOn( D10_PUMP );