Index: firmware/App/Controllers/BalancingChamber.c =================================================================== diff -u -r977f03e20990ed5579160b9b927df1c0f2428101 -ra711f7995e555b503ed8c295f98fbe7bb9e5abf5 --- firmware/App/Controllers/BalancingChamber.c (.../BalancingChamber.c) (revision 977f03e20990ed5579160b9b927df1c0f2428101) +++ firmware/App/Controllers/BalancingChamber.c (.../BalancingChamber.c) (revision a711f7995e555b503ed8c295f98fbe7bb9e5abf5) @@ -369,7 +369,6 @@ setValveState( D22_VALV, VALVE_STATE_OPEN ); } - /*********************************************************************//** * @brief * The valveControlForBCFreshSideOnlyOpenState function opens the fresh side @@ -529,7 +528,6 @@ { // stabilized pressure indicating fill is complete isPressureStalbilizedDuringFill = TRUE; - isBalChamberFillInProgress = FALSE; } } #else @@ -542,6 +540,7 @@ { // close the state 1 opened valves valveControlForBCState1FillEnd(); + isBalChamberFillInProgress = FALSE; //Transition to next state state = BAL_CHAMBER_STATE1_FILL_END; @@ -689,7 +688,6 @@ { // stabilized pressure indicating fill is complete isPressureStalbilizedDuringFill = TRUE; - isBalChamberFillInProgress = FALSE; } } #else @@ -702,6 +700,7 @@ { // close the valves valveControlForBCState2FillEnd(); + isBalChamberFillInProgress = FALSE; //Transition to next state state = BAL_CHAMBER_STATE2_FILL_END; Index: firmware/App/Modes/ModeGenDialysate.c =================================================================== diff -u -re6415d33321e7990c3b5e82b0c8a87c64cc3a2c8 -ra711f7995e555b503ed8c295f98fbe7bb9e5abf5 --- firmware/App/Modes/ModeGenDialysate.c (.../ModeGenDialysate.c) (revision e6415d33321e7990c3b5e82b0c8a87c64cc3a2c8) +++ firmware/App/Modes/ModeGenDialysate.c (.../ModeGenDialysate.c) (revision a711f7995e555b503ed8c295f98fbe7bb9e5abf5) @@ -75,6 +75,8 @@ static OVERRIDE_F32_T targetHydChamberFluidTemp; ///< Target hydraulics chamber fluid temperature. static OVERRIDE_U32_T isDialDeliveryInProgress; ///< To indicate dialysate started delivering to dialyzer for treatment (overrideable) static OVERRIDE_U32_T isDialysateGoodtoDeliver; ///< Flag indicating whether ready to deliver dialysate or not. +static BOOL pendingSpentChamberFill; ///< Flag indicating spent chamber fill process to be initiated. +static BOOL pendingBicarbChamberFill; ///< Flag indicating bicarb chamber fill process to be initiated. static BOOL pendingStopDDGenDialRequest; ///< Flag indicating TD has requested DD stop the generate dialysate. static U32 genDialysateDataPublicationTimerCounter; ///< Used to schedule generate dialysate data publication to CAN bus. static OVERRIDE_U32_T genDialysateDataPublishInterval; ///< Generate dialysate mode data publish interval. @@ -96,6 +98,7 @@ static F32 getGenDialysateTargetTemperature( void ); static void calculateTargetDialysateTemp( void ); static void checkDialysateTemperature( void ); +static void monitorChamberLevelStatus( void ); static void publishGenDialysateModeData( void ); /*********************************************************************//** @@ -128,6 +131,8 @@ genDialysateDataPublicationTimerCounter = 0; isTreatmentParamUpdated = FALSE; bicarbFillStartTimeMS = 0; + pendingSpentChamberFill = FALSE; + pendingBicarbChamberFill = FALSE; //Testing bypassStateDelayStartTimeMS = 0; delayBypassStateFlag = TRUE; @@ -201,13 +206,13 @@ break; case DD_GEND_DIALYSATE_BYPASS_STATE: - //Close all balancing chamber valves - valveControlForBCClosedState(); setValveState( DD_M4_VALV, VALVE_STATE_OPEN ); setValveState( D14_VALV, VALVE_STATE_OPEN ); setValveState( D53_VALV, VALVE_STATE_OPEN ); // Drain valve setValveState( D35_VALV, VALVE_STATE_CLOSED ); // VDI setValveState( D40_VALV, VALVE_STATE_CLOSED ); // VDO + setValveState( D47_VALV, VALVE_STATE_CLOSED ); // spent chamber purge valve + setValveState( D64_VALV, VALVE_STATE_CLOSED ); setValveState( D34_VALV, VALVE_STATE_OPEN ); // Bypass valve // Turn on the primary heater @@ -231,6 +236,8 @@ case DD_GEND_DIALYSATE_DELIVERY_STATE: //Previous state + setValveState( D47_VALV, VALVE_STATE_CLOSED ); // spent chamber purge valve + setValveState( D64_VALV, VALVE_STATE_CLOSED ); setValveState( DD_M4_VALV, VALVE_STATE_OPEN ); setValveState( D14_VALV, VALVE_STATE_OPEN ); setValveState( D53_VALV, VALVE_STATE_OPEN ); // Drain valve @@ -253,8 +260,6 @@ break; case DD_GEND_SPENT_CHAMBER_FILL_STATE: - //Close all balancing chamber valves - valveControlForBCClosedState(); //Set valves and actuators setValveState( D35_VALV, VALVE_STATE_CLOSED ); // VDI setValveState( D40_VALV, VALVE_STATE_CLOSED ); // VDO @@ -283,14 +288,12 @@ break; case DD_GEND_BICARB_CHAMBER_FILL_STATE: - //Close all balancing chamber valves - valveControlForBCClosedState(); requestConcentratePumpOff( D11_PUMP, FALSE ); requestConcentratePumpOff( D10_PUMP, FALSE ); requestConcentratePumpOff( D76_PUMP, FALSE ); //Set valves and actuators - setValveState( D47_VALV, VALVE_STATE_CLOSED ); // Spent chamber purge valve + setValveState( D47_VALV, VALVE_STATE_CLOSED ); // spent chamber purge valve setValveState( D35_VALV, VALVE_STATE_CLOSED ); // VDI setValveState( D40_VALV, VALVE_STATE_CLOSED ); // VDO setValveState( D14_VALV, VALVE_STATE_CLOSED ); @@ -363,6 +366,9 @@ //Check temperature drift between D30 and D28 checkDialysateTemperatureSensors(); + //Monitor spent and bicarb chamber level + monitorChamberLevelStatus(); + //TODO: Transition to post gen dialysate then standby. if ( TRUE == pendingStopDDGenDialRequest ) { @@ -453,6 +459,30 @@ /*********************************************************************//** * @brief + * The monitorChamberLevelStatus function checks the spent chamber and bicarb + * chamber level status and updates the corrosponding flags. + * @details \b Inputs: Spent and bicarb chamber levels. + * @details \b Outputs: none + * @return none + *************************************************************************/ +static void monitorChamberLevelStatus( void ) +{ + LEVEL_STATE_T spentChamberLevel = getLevelStatus( D46_LEVL ); + LEVEL_STATE_T bicarbChamberLevel = getLevelStatus( D63_LEVL ); + + if ( LEVEL_STATE_LOW == spentChamberLevel ) + { + pendingSpentChamberFill = TRUE; + } + + if ( LEVEL_STATE_LOW == bicarbChamberLevel ) + { + pendingBicarbChamberFill = TRUE; + } +} + +/*********************************************************************//** + * @brief * The calculateTargetDialysateTemp function calculate the delta temperature * required for dialysate temperature to meet the set temperature at dialyzer. * @details \b Inputs: Qd and target temperature. @@ -510,9 +540,8 @@ *************************************************************************/ static DD_GEND_MODE_STATE_T handleGenDDialysateBypassState( void ) { - DD_GEND_MODE_STATE_T state = DD_GEND_DIALYSATE_BYPASS_STATE; - LEVEL_STATE_T spentChamberLevel = getLevelStatus( D46_LEVL ); - LEVEL_STATE_T bicarbChamberLevel = getLevelStatus( D63_LEVL ); + DD_GEND_MODE_STATE_T state = DD_GEND_DIALYSATE_BYPASS_STATE; + BOOL balancingChambFillInProgress = getBalancingChamberFillinProgressStatus(); //Testing if ( TRUE == delayBypassStateFlag ) @@ -529,17 +558,19 @@ } #ifdef __SPENT_CHAMBER_FILL__ - if ( LEVEL_STATE_LOW == spentChamberLevel ) + if ( ( TRUE == pendingSpentChamberFill ) && ( FALSE == balancingChambFillInProgress ) ) { setModeGenDStateTransition( DD_GEND_SPENT_CHAMBER_FILL_STATE ); + pendingSpentChamberFill = FALSE; isDialDeliveryInProgress.data = FALSE; state = DD_GEND_SPENT_CHAMBER_FILL_STATE; } #endif #ifdef __BICARB_CHAMBER_FILL__ - if ( LEVEL_STATE_LOW == bicarbChamberLevel ) + if ( ( TRUE == pendingBicarbChamberFill ) && ( FALSE == balancingChambFillInProgress ) ) { setModeGenDStateTransition( DD_GEND_BICARB_CHAMBER_FILL_STATE ); + pendingBicarbChamberFill = FALSE; isDialDeliveryInProgress.data = FALSE; state = DD_GEND_BICARB_CHAMBER_FILL_STATE; } @@ -579,17 +610,19 @@ state = DD_GEND_DIALYSATE_BYPASS_STATE; } #ifdef __SPENT_CHAMBER_FILL__ - else if ( LEVEL_STATE_LOW == spentChamberLevel ) + else if ( ( TRUE == pendingSpentChamberFill ) && ( FALSE == balancingChambFillInProgress ) ) { setModeGenDStateTransition( DD_GEND_SPENT_CHAMBER_FILL_STATE ); + pendingSpentChamberFill = FALSE; isDialDeliveryInProgress.data = FALSE; state = DD_GEND_SPENT_CHAMBER_FILL_STATE; } #endif #ifdef __BICARB_CHAMBER_FILL__ - else if ( LEVEL_STATE_LOW == bicarbChamberLevel ) + else if ( ( TRUE == pendingBicarbChamberFill ) && ( FALSE == balancingChambFillInProgress ) ) { setModeGenDStateTransition( DD_GEND_BICARB_CHAMBER_FILL_STATE ); + pendingBicarbChamberFill = FALSE; isDialDeliveryInProgress.data = FALSE; state = DD_GEND_BICARB_CHAMBER_FILL_STATE; } Index: firmware/App/Modes/ModeGenDialysate.h =================================================================== diff -u -r89cf53e72625123054b11897c2e0a8359d82b7ce -ra711f7995e555b503ed8c295f98fbe7bb9e5abf5 --- firmware/App/Modes/ModeGenDialysate.h (.../ModeGenDialysate.h) (revision 89cf53e72625123054b11897c2e0a8359d82b7ce) +++ firmware/App/Modes/ModeGenDialysate.h (.../ModeGenDialysate.h) (revision a711f7995e555b503ed8c295f98fbe7bb9e5abf5) @@ -33,7 +33,7 @@ #define FRESH_DIAL_PUMP_INITIAL_RPM 2500 ///< Nominal RPM target for fresh dialysate pump to maintain required pressure. #define SPENT_DIAL_PUMP_INITIAL_RPM 2300 ///< Nominal RPM target for spent dialysate pump to maintain required pressure. -#define SPENT_DIAL_PUMP_FILL_RPM 400 ///< Nominal RPM target for spent chamber fill operations. +#define SPENT_DIAL_PUMP_FILL_RPM 350 ///< Nominal RPM target for spent chamber fill operations. /// Generate dialysate mode data structure typedef struct