Index: firmware/App/Controllers/BalancingChamber.c =================================================================== diff -u -rb50acaa8dda74292fb41110440eaaa40f2959fb7 -re48bec7b1330b195afadcbf8bc58bdb4f1d5b03e --- firmware/App/Controllers/BalancingChamber.c (.../BalancingChamber.c) (revision b50acaa8dda74292fb41110440eaaa40f2959fb7) +++ firmware/App/Controllers/BalancingChamber.c (.../BalancingChamber.c) (revision e48bec7b1330b195afadcbf8bc58bdb4f1d5b03e) @@ -39,10 +39,10 @@ // ********** private definitions ********** -#define BAL_CHAMBER_DATA_PUBLISH_INTERVAL ( 250 / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the balancing chamber data published. -#define BAL_CHAMBER_FILL_PRES_DROP_MS ( 200 / TASK_GENERAL_INTERVAL ) ///< Time (ms/tasktime) to confirm the balancing chamber filling started and corrosponding valves opened. -#define BAL_CHAMBER_FILL_COMPLETE_MS ( 300 / TASK_GENERAL_INTERVAL ) ///< Time (ms/tasktime) to confirm the balancing chamber fill completed and pressure is within range -#define DRY_BICARB_CHAMBER_MAX_TIMEOUT_COUNT ( 20 * 15 ) ///< Periodic bicarb chamber fill request. +#define BAL_CHAMBER_DATA_PUBLISH_INTERVAL ( 250 / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the balancing chamber data published. +#define BAL_CHAMBER_FILL_PRES_DROP_MS ( 200 / TASK_GENERAL_INTERVAL ) ///< Time (ms/tasktime) to confirm the balancing chamber filling started and corresponding valves opened. +#define BAL_CHAMBER_FILL_COMPLETE_MS ( 300 / TASK_GENERAL_INTERVAL ) ///< Time (ms/tasktime) to confirm the balancing chamber fill completed and pressure is within range +#define BAL_CHAMBER_BICARB_CHAMBER_FILL_TIMEOUT_COUNT ( 1 * SEC_PER_MIN * ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ) ///< Periodic bicarb chamber fill request. /// Payload record structure for balancing chamber switch only request typedef struct @@ -73,9 +73,11 @@ static F32 lastTdDialysateFlowrate; ///< Previous TD dialysate flow rate static F32 freshDialPressure; ///< Fresh side dialysate pressure static F32 spentDialPressure; ///< Spent side dialysate pressure + #ifdef __DRY_BICARB__ static U32 dryBiCarbChamberFillTimeoutCount; ///< Counter for checking the timeout for drybicart chamber fill request. #endif + // ********** private function prototypes ********** static BAL_CHAMBER_EXEC_STATE_T handleBalChamberState1FillStart( void ); @@ -203,14 +205,13 @@ //Increment counter for dry bicarb chamber fill dryBiCarbChamberFillTimeoutCount += 1; // Fill bicarb chamber once every 60secs. - if ( dryBiCarbChamberFillTimeoutCount >= DRY_BICARB_CHAMBER_MAX_TIMEOUT_COUNT) + if ( dryBiCarbChamberFillTimeoutCount >= BAL_CHAMBER_BICARB_CHAMBER_FILL_TIMEOUT_COUNT) { setBicarbChamberFillRequested(); dryBiCarbChamberFillTimeoutCount = 0; } #endif - // execute current balancing chamber exec state switch ( balChamberExecState ) { case BAL_CHAMBER_STATE_START: Index: firmware/App/Controllers/DryBiCart.c =================================================================== diff -u -r2fb473f4574f9c150849bb39991a31bcadaae693 -re48bec7b1330b195afadcbf8bc58bdb4f1d5b03e --- firmware/App/Controllers/DryBiCart.c (.../DryBiCart.c) (revision 2fb473f4574f9c150849bb39991a31bcadaae693) +++ firmware/App/Controllers/DryBiCart.c (.../DryBiCart.c) (revision e48bec7b1330b195afadcbf8bc58bdb4f1d5b03e) @@ -8,10 +8,10 @@ * @file DryBiCart.c * * @author (original) Sameer poyil -* @date (original) 23-Oct-2025 +* @date (original) 10-Nov-2025 * * @author (original) Sameer poyil -* @date (original) 23-Oct-2025 +* @date (original) 10-Nov-2025 * ***************************************************************************/ @@ -41,24 +41,31 @@ // ********** private definitions ********** #define DRY_BICART_DATA_PUBLISH_INTERVAL ( 250 / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the balancing chamber data published. + +// Bicart Fill +#define DRY_BICART_FILL_DURATION_MIN_MS (2 * MS_PER_SECOND) ///< Minimum fill duration to be met to end the fill cycle. +#define DRY_BICART_FILL_DURATION_DIFF_MS 750 ///< Fill duration difference between last and current fill cycle. #define DRY_BICART_FILL_MAX_PRESSURE 12.0F ///< Maximum pressure that drybicart can withstand. #define DRY_BICART_FILL_COMPLETE_PRESSURE 15.0F ///< Maximum pressure reached to inidcate the drybicart fill being completed. #define DRY_BICART_FILL_INITIATE_PRESSURE 5.0F ///< Minimum pressure required to initiate the drybicart fill process. -#define DRY_BICART_VENT_COMPLETE_PRESSURE 1.5F ///< Pressure reached to inidcate the drybicart venting being completed. -#define DRY_BICART_VENT_TIME_MS ( 1 * MS_PER_SECOND ) ///< Wait time to vent dry bibag gas before actuating Bicarb chamber(F) venting. -#define DRY_BICART_VENT_MAX_TIME_MS ( 10 * MS_PER_SECOND ) ///< Max time to vent both bicart and Chamber F. -#define DRY_BICART_FILL_DURATION_DIFF_MS 500 ///< Fill duration difference between last and current fill cycle. -#define DRY_BICART_FILL_DURATION_MIN_MS 1500 ///< Minimum fill duration to be met to end the fill cycle. #define DRY_BICART_DEFAULT_MAX_FILL_CYCLE_CNT 10 ///< Default max fill cycle allowed for dry bicart fill/mix with water. #define DRY_BICART_MAX_FILL_CYCLE_CNT 30 ///< Max fill cycle allowed (by override) for dry bicart fill/mix with water. -//TODO: uncomment later based on the testing results -//#define VALV_D80_MAX_OPEN_TIME_MS ( 10 * MS_PER_SECOND ) ///< Max time allowed for opening D80 valve during bicarb chamber (F) fill. -#define VALV_D80_MAX_OPEN_TIME_MS ( 500 ) ///< Max time allowed for opening D80 valve during bicarb chamber (F) fill. -#define DRY_BICART_MAX_DRAIN_TIME_MS ( 240 * MS_PER_SECOND ) ///< Max drain time for bicart chamber in ms. + +// Bicart Vent +#define DRY_BICART_VENT_TIME_MS ( 1 * MS_PER_SECOND ) ///< Wait time to vent dry bibag gas before actuating Bicarb chamber(F) venting. +#define DRY_BICART_VENT_MAX_TIME_MS ( 10 * MS_PER_SECOND ) ///< Max time to vent both bicart and Chamber F. +#define DRY_BICART_VENT_TIME_MS ( 5 * MS_PER_SECOND ) ///< Max time to vent both bicart and Chamber F. +#define DRY_BICART_VENT_COMPLETE_PRESSURE 1.5F ///< Pressure reached to inidcate the drybicart venting being completed. + +// Bicarb chamber fill/Supply +#define DRY_BICART_SUPPLY_VALVE_D80_OPEN_TIME_MS ( 3 * MS_PER_SECOND ) ///< Max time allowed for opening D80 valve during bicarb chamber (F) fill. + +// Bicart Drain +#define DRY_BICART_MAX_DRAIN_TIME_MS ( 4 * SEC_PER_MIN * MS_PER_SECOND ) ///< Max drain time for bicart chamber in ms. +#define DRY_BICART_DRAIN_FLUID_PHASE_TIME_MS ( 3 * MS_PER_SECOND ) ///< Time to stay in fluid drain per cycle #define DRY_BICART_DRAIN_COND_SAMPLE_PERIOD_MS 50 ///< Conductivity sample period #define DRY_BICART_DRAIN_COND_ZERO_THRESH 0.05F ///< "Zero" conductivity threshold #define DRY_BICART_DRAIN_COND_STABLE_SAMPLES 10U ///< Debounce samples (10*50ms=500ms) -#define DRY_BICART_DRAIN_FLUID_PHASE_TIME_MS ( 3 * MS_PER_SECOND ) ///< Time to stay in fluid drain per cycle #define DRY_BICART_DRAIN_VENT_PHASE_TIME_MS 1500 ///< Time to keep D64 open per vent cycle #define DRY_BICART_DRAIN_COND_STABLE_COUNT_MAX 0xFFFFU @@ -80,6 +87,7 @@ static U32 currentFillDurationInMS; ///< Current time duartion to fill the bicart fill. static OVERRIDE_U32_T dryBiCartFillRequested; ///< Start/stop Dry bicart fill. static OVERRIDE_U32_T dryBiCartDrainRequested; ///< Start/stop Dry bicart drain. +static OVERRIDE_U32_T dryBiCartFillRequested; ///< Start/stop Dry bicart fill. static OVERRIDE_U32_T dryBiCartDataPublishInterval; ///< Dry bicart data publish interval. static U32 dryBiCartDataPublicationTimerCounter; ///< Used to schedule drybicart data publication to CAN bus. static U32 dryBiCarbSupplyStartTime; ///< Bicarb supply start time from bicart to Chamber F. @@ -132,6 +140,10 @@ dryBiCartFillRequested.ovData = FALSE; dryBiCartFillRequested.ovInitData = FALSE; dryBiCartFillRequested.override = 0; + dryBiCartDrainRequested.data = FALSE; + dryBiCartDrainRequested.ovData = FALSE; + dryBiCartDrainRequested.ovInitData = FALSE; + dryBiCartDrainRequested.override = 0; bicarbChamberFillRequested.data = FALSE; bicarbChamberFillRequested.ovData = FALSE; bicarbChamberFillRequested.ovInitData = FALSE; @@ -252,7 +264,7 @@ { DRY_BICART_FILL_EXEC_STATE_T state = DRY_BICART_FILL_WATER_START_STATE; - // Close vent valves and descaling valve + // Close vent valves and de-scaling valve setValveState( D80_VALV, VALVE_STATE_CLOSED ); setValveState( D81_VALV, VALVE_STATE_CLOSED ); setValveState( D85_VALV, VALVE_STATE_CLOSED ); @@ -455,8 +467,10 @@ switch ( bicarbChamberFillExecState ) { case BICARB_CHAMBER_START_STATE: + if ( TRUE == getU32OverrideValue( &bicarbChamberFillRequested ) ) { + bicarbChamberFillExecState = BICARB_CHAMBER_CHECK_LEVEL_STATE; bicarbChamberFillRequested.data = FALSE; } @@ -560,10 +574,11 @@ // Once level reached, close the valve if ( ( LEVEL_STATE_HIGH == bicarbChamberLevel ) || - ( TRUE == didTimeout( dryBiCarbSupplyStartTime, VALV_D80_MAX_OPEN_TIME_MS ) ) ) + ( TRUE == didTimeout( dryBiCarbSupplyStartTime, DRY_BICART_SUPPLY_VALVE_D80_OPEN_TIME_MS ) ) ) { setValveState( D65_VALV, VALVE_STATE_CLOSED ); setValveState( D80_VALV, VALVE_STATE_CLOSED ); + state = BICARB_CHAMBER_START_STATE; } @@ -598,6 +613,13 @@ dryBiCartDrainLastCondSampleTime = dryBiCartDrainStartTime; dryBiCartDrainCondStableCount = 0; dryBiCartDrainExecState = DRY_BICART_FLUID_DRAIN_STATE; + + // open bypass valve + setValveState( D34_VALV, VALVE_STATE_OPEN ); + // open DD drain + setValveState( D53_VALV, VALVE_STATE_OPEN ); + // open iofp drain valve + setValveState( M12_VALV, VALVE_STATE_OPEN ); } break; @@ -649,7 +671,7 @@ setValveState( D14_VALV, VALVE_STATE_CLOSED ); // RUn D10 IN OPpen loop mode(max speed) - setConcentratePumpTargetSpeed( D10_PUMP, CONCENTRATE_PUMP_MAX_SPEED, 0xFFFF ); + setConcentratePumpTargetSpeed( D10_PUMP, CONCENTRATE_PUMP_MAX_SPEED, DOSING_CONT_VOLUME ); requestConcentratePumpOn( D10_PUMP ); // Run D48 @@ -768,6 +790,13 @@ setValveState( D80_VALV, VALVE_STATE_CLOSED ); setValveState( D85_VALV, VALVE_STATE_CLOSED ); + // close bypass valve + setValveState( D34_VALV, VALVE_STATE_CLOSED ); + // close DD drain + setValveState( D53_VALV, VALVE_STATE_CLOSED ); + // close iofp drain valve + setValveState( M12_VALV, VALVE_STATE_CLOSED ); + // Go idle when request cleared if ( FALSE == getU32OverrideValue( &dryBiCartDrainRequested ) ) { @@ -790,8 +819,35 @@ bicarbChamberFillRequested.data = TRUE; } + /*********************************************************************//** * @brief + * The setBicartFillRequested function sets the bicart fill request + * flag value to be True. + * @details \b Inputs: none + * @details \b Outputs: dryBiCartFillRequested + * @return none. + *************************************************************************/ +void setBicartFillRequested( void ) +{ + dryBiCartFillRequested.data = TRUE; +} + +/*********************************************************************//** + * @brief + * The setBicartDrainRequested function sets the bicart drain request + * flag value to be True. + * @details \b Inputs: none + * @details \b Outputs: dryBiCartDrainRequested + * @return none. + *************************************************************************/ +void setBicartDrainRequested( void ) +{ + dryBiCartDrainRequested.data = TRUE; +} + +/*********************************************************************//** + * @brief * The publishDryBicartData function broadcasts the dry bicart * data at defined interval. * @details \b Inputs: dryBiCartDataPublicationTimerCounter @@ -808,10 +864,12 @@ data.dryBiCartFillExecState = (U32)dryBiCartFillExecState; data.bicarbChamberFillExecState = (U32)bicarbChamberFillExecState; + data.dryBiCartDrainExecState = (U32)dryBiCartDrainExecState; data.dryBiCartFillCycleCounter = biCartFillCycleCounter; data.dryBiCartMaxFillCycleCount = getU32OverrideValue( &biCartMaxFillCycleCount ); data.dryBiCartFillRequest = getU32OverrideValue( &dryBiCartFillRequested ); data.bicarbChamberFillRequest = getU32OverrideValue( &bicarbChamberFillRequested ); + data.dryBiCartDrainRequested = getU32OverrideValue( &dryBiCartDrainRequested ); data.dryBiCartLastFillTime = lastFillDurationInMS; data.dryBiCartCurrentFillTime = currentFillDurationInMS; @@ -895,4 +953,20 @@ return result; } +/*********************************************************************//** + * @brief + * The testDryBiCartDrainRequestOverride function starts/stops the bicart + * drain request + * @details \b Inputs: tester logged in + * @details \b Outputs: bicarbChamberFillRequested + * @param message set message from Dialin which includes the bicart + * drain request start/stop. + * @return TRUE if set request is successful, FALSE if not + *************************************************************************/ +BOOL testDryBiCartDrainRequestOverride( MESSAGE_T *message ) +{ + BOOL result = u32Override( message, &dryBiCartDrainRequested, FALSE, TRUE ); + + return result; +} /**@}*/ Index: firmware/App/Controllers/DryBiCart.h =================================================================== diff -u -r2fb473f4574f9c150849bb39991a31bcadaae693 -re48bec7b1330b195afadcbf8bc58bdb4f1d5b03e --- firmware/App/Controllers/DryBiCart.h (.../DryBiCart.h) (revision 2fb473f4574f9c150849bb39991a31bcadaae693) +++ firmware/App/Controllers/DryBiCart.h (.../DryBiCart.h) (revision e48bec7b1330b195afadcbf8bc58bdb4f1d5b03e) @@ -37,10 +37,12 @@ { U32 dryBiCartFillExecState; ///< Dry bicart execution state U32 bicarbChamberFillExecState; ///< Bicarb chamber Fill execution state + U32 dryBiCartDrainExecState; ///< Dry bicart drain execution state U32 dryBiCartFillCycleCounter; ///< Dry bicart fill cycle counter U32 dryBiCartMaxFillCycleCount; ///< Dry bicart fill cycle max count U32 dryBiCartFillRequest; ///< Dry bicart fill request U32 bicarbChamberFillRequest; ///< Bicarb chamber fill request + U32 dryBiCartDrainRequested; ///< Dry bicart drain request U32 dryBiCartLastFillTime; ///< Dry bicart last fill duration in milli second U32 dryBiCartCurrentFillTime; ///< Dry bicart current fill duration in milli second } DRY_BICART_DATA_T; @@ -54,14 +56,15 @@ U32 execDryBicartDrainMode( void ); // Execute dry bicart drain state machine void execDryBicart( void ); // Execute the list of drybicart state machines void setBicarbChamberFillRequested( void ); // Sets the Flag for dry bicarb chamber fill request data to be true +void setBicartFillRequested( void ); DRY_BICART_FILL_EXEC_STATE_T getCurrentDryBiCartFillExecState( void ); // Get the current state of the dry bicart fill execution BOOL testDryBiCartDataPublishIntervalOverride( MESSAGE_T *message ); // To override the dry bicart data publish interval BOOL testDryBiCartFillCycleMaxCountOverride( MESSAGE_T *message ); // To override the dry bicart max fill cycle BOOL testDryBiCartFillRequestOverride( MESSAGE_T *message ); // To override the dry bicart fill start/stop request BOOL testBiCarbChamberFillRequestOverride( MESSAGE_T *message ); // To override the bicarb chamber fill start/stop request -BOOL testBiCarbChamberDrainRequestOverride( MESSAGE_T *message ); // To override the bicart drain start/stop request +BOOL testDryBiCartDrainRequestOverride( MESSAGE_T *message ); // To override the bicart drain start/stop request /**@}*/ Index: firmware/App/Modes/ModePreGenDialysate.c =================================================================== diff -u -r3417933e6edf61a914c428e2fa944b3b349272a4 -re48bec7b1330b195afadcbf8bc58bdb4f1d5b03e --- firmware/App/Modes/ModePreGenDialysate.c (.../ModePreGenDialysate.c) (revision 3417933e6edf61a914c428e2fa944b3b349272a4) +++ firmware/App/Modes/ModePreGenDialysate.c (.../ModePreGenDialysate.c) (revision e48bec7b1330b195afadcbf8bc58bdb4f1d5b03e) @@ -17,6 +17,7 @@ #include "ConcentratePumps.h" #include "DialysatePumps.h" +#include "DryBiCart.h" #include "Heaters.h" #include "ModePreGenDialysate.h" #include "ModeGenDialysate.h" @@ -51,12 +52,14 @@ static BOOL pendingStopDDPreGenDialRequest; ///< Flag indicating TD has requested DD stop the pre generation dialysate. static U32 preGenDialysatePublishTimerCounter; ///< Pre-Gen Dialysate data broadcast timer counter used to schedule when to transmit data. static OVERRIDE_U32_T preGenDialysateModePublishInterval; ///< Interval (in task intervals) at which to publish pre-gen dialysate mode data to CAN bus. - +static BOOL dryBicartFillRequest; +static U32 StartTimeMS; // ********** private function prototypes ********** static void publishPreGenDialysateState( void ); static DD_PRE_GEN_DIALYSATE_STATE_T handlePreGenDialysateFillCompleteCheckState( void ); static DD_PRE_GEN_DIALYSATE_STATE_T handlePreGenWetSelfTestState( void ); +static DD_PRE_GEN_DIALYSATE_STATE_T handleDryBicartFillCheckState( void ); //Wet Self test static void setModePreGenWetSelfStateTransition( DD_WET_SELF_TEST_STATE_T state ); @@ -78,8 +81,10 @@ wetSelfTestState = DD_WET_SELF_TEST_START; hydChamberPressureCheckStartTimeMS = 0; pressureCheckPersistanceStartTimeMS = 0; + StartTimeMS = 0; pendingStartDDGenDialRequest = FALSE; pendingStopDDPreGenDialRequest = FALSE; + dryBicartFillRequest = FALSE; preGenDialysateModePublishInterval.data = PRE_GEN_DIALYSATE_DATA_PUB_INTERVAL; preGenDialysateModePublishInterval.ovData = PRE_GEN_DIALYSATE_DATA_PUB_INTERVAL; preGenDialysateModePublishInterval.ovInitData = 0; @@ -144,6 +149,10 @@ preGenDialysateState = handlePreGenWetSelfTestState(); break; + case DD_PRE_GEN_DRY_BICART_FILL_CHECK: + preGenDialysateState = handleDryBicartFillCheckState(); + break; + case DD_PRE_GEN_DIALYSATE_WAIT_FOR_GEND: // TODO : handle wait for Gen dialysate break; @@ -241,15 +250,60 @@ static DD_PRE_GEN_DIALYSATE_STATE_T handlePreGenWetSelfTestState( void ) { //TODO: Change to wet self test state later - DD_PRE_GEN_DIALYSATE_STATE_T state = DD_PRE_GEN_DIALYSATE_WAIT_FOR_GEND; + DD_PRE_GEN_DIALYSATE_STATE_T state = DD_PRE_GEN_DRY_BICART_FILL_CHECK; + if ( getTestConfigStatus( TEST_CONFIG_ENABLE_DRY_BICART_FILL ) == TRUE ) + { + setValveState( D14_VALV, VALVE_STATE_OPEN ); + setDialysatePumpTargetRPM( D12_PUMP, FRESH_DIAL_PUMP_INITIAL_RPM, TRUE ); + + StartTimeMS = getMSTimerCount(); + } + //execWetSelfTest(); return state; } + /*********************************************************************//** * @brief + * The handleDryBicartFillCheckState function executes intial dryy bicart fill request + * @details \b Inputs: state + * @details \b Outputs: none + * @return current state of PreGenDialysate mode + *************************************************************************/ +static DD_PRE_GEN_DIALYSATE_STATE_T handleDryBicartFillCheckState( void ) +{ + //TODO: Change to wet self test state later + DD_PRE_GEN_DIALYSATE_STATE_T state = DD_PRE_GEN_DRY_BICART_FILL_CHECK; + U32 currentFillDurationInMS; + + if ( getTestConfigStatus( TEST_CONFIG_ENABLE_DRY_BICART_FILL ) == TRUE ) + { + // if ( FALSE == dryBicartFillRequest ) + { + setBicartFillRequested(); + + dryBicartFillRequest = TRUE; + } + + if ( getCurrentDryBiCartFillExecState() == DRY_BICART_FILL_COMPLETE_STATE ) + { + currentFillDurationInMS = calcTimeSince( StartTimeMS ); + state = DD_PRE_GEN_DIALYSATE_WAIT_FOR_GEND; + } + } + else + { + state = DD_PRE_GEN_DIALYSATE_WAIT_FOR_GEND; + } + + return state; +} + +/*********************************************************************//** + * @brief * The setModePreGenWetSelfStateTransition function sets the actuators and variables * for the state transition in pre-gen WetSlef test mode. * @details Inputs: Valve states, Pump speed Index: firmware/App/Services/Messaging.c =================================================================== diff -u -rb50acaa8dda74292fb41110440eaaa40f2959fb7 -re48bec7b1330b195afadcbf8bc58bdb4f1d5b03e --- firmware/App/Services/Messaging.c (.../Messaging.c) (revision b50acaa8dda74292fb41110440eaaa40f2959fb7) +++ firmware/App/Services/Messaging.c (.../Messaging.c) (revision e48bec7b1330b195afadcbf8bc58bdb4f1d5b03e) @@ -247,6 +247,7 @@ { MSG_ID_DD_BICARB_CHAMBER_FILL_REQUEST_OVERRIDE_REQUEST, &testBiCarbChamberFillRequestOverride }, { MSG_ID_FP_RO_REJECTION_RATIO_PUBLISH_INTERVAL_OVERRIDE_REQUEST, &testRORejectionRatioDataPublishIntervalOverride }, { MSG_ID_FP_RO_FILTERED_REJECTION_RATIO_OVERRIDE_REQUEST, &testRORejectionRatioFilteredOverride }, + { MSG_ID_DD_BICART_DRAIN_REQUEST_OVERRIDE_REQUEST, &testDryBiCartDrainRequestOverride }, }; /// Calculation for number of entries in the incoming message function handler look-up table.