Index: firmware/App/Controllers/BalancingChamber.c =================================================================== diff -u -r9e0db1f82f13693d251e00e8958c8063dd89cae6 -r095866efd8f10bdead490578e7584051d79292f0 --- firmware/App/Controllers/BalancingChamber.c (.../BalancingChamber.c) (revision 9e0db1f82f13693d251e00e8958c8063dd89cae6) +++ firmware/App/Controllers/BalancingChamber.c (.../BalancingChamber.c) (revision 095866efd8f10bdead490578e7584051d79292f0) @@ -15,8 +15,6 @@ * ***************************************************************************/ -#include // For sqrtf - #include "BalancingChamber.h" #include "Conductivity.h" #include "ConcentratePumps.h" @@ -30,6 +28,7 @@ #include "MixingControl.h" #include "ModeGenDialysate.h" #include "ModeStandby.h" +#include "OperationModes.h" #include "Pressure.h" #include "TaskGeneral.h" #include "TDInterface.h" @@ -46,29 +45,24 @@ #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 ( 100 / TASK_GENERAL_INTERVAL ) ///< Time (ms/tasktime) to confirm the balancing chamber fill completed and pressure is within range -#define SPENT_FILL_COMPLETE_QD_LOW_RISE_MAX_MLPM 300.0F ///< For Qd <= 300 mL/min (Diener 1000). +#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 SPENT_FILL_COMPLETE_PRES 25.0F ///< Spent fill complete pressure (PSI) for Diener 2000 pump. +#define SPENT_FILL_COMPLETE_PRES_QD_MID_PSIG 10.0F ///< Spent fill complete pressure (PSI) when Diener 1000 and 200 < Qd <= 400. +#define SPENT_FILL_COMPLETE_PRES_QD_HIGH_PSIG 20.0F ///< Spent fill complete pressure (PSI) when Diener 1000 and Qd > 400. +#define SPENT_FILL_COMPLETE_QD_SLOPE_MAX_MLPM 300.0F ///< For Qd <= 300 mL/min, spent fill completion uses pressure-rise slope detection. #define SPENT_FILL_COMPLETE_DP_RISE_PSIG 0.5F ///< Minimum 100 ms spent pressure rise (current minus n-2) to count as a rise hit at low Qd. -#define SPENT_FILL_COMPLETE_DP_RISE_HIGH_QD_PSIG 3.0F ///< Minimum spent pressure rise for Diener 2000 or Qd > 300 mL/min. -#define SPENT_FILL_SLOPE_SPENT_PRESSURE_HIGH_PSIG 2.0F ///< Above this spent pressure rise, only one rise hit is required. +#define SPENT_FILL_SLOPE_SPENT_PRESSURE_HIGH_PSIG 2.0F ///< Above this absolute spent pressure, only one rise hit is required. #define SPENT_FILL_SLOPE_MAX_RISE_HITS 2 ///< Rise hits required when Qd <= 150 in the low spent-pressure band. #define SPENT_FILL_DETECT_COUNT_TOL_PCT 1.0F ///< Allowed detection timing tolerance as a fraction of expected BC switching count. +#define QD_THRESHOLD_HIGH_MLPM 400.0F ///< Qd threshold (mL/min) below which mid pressure limit applies. #define SPENT_DIFF_COUNT_ZERO 0 ///< Zero count difference for spent side fill comparing target count #define D48_SPEED_ADJUST_FACTOR 0.5F ///< D48 speed adjustment factor ( 50% of speed adjustment = 0.5) #define D48_SPEED_RANGE_LIMIT 0.25F ///< D48 speed adjustment range check limit ( D48 speed can vary +/-25% of initial calculated speed) #define BICARB_CHAMBER_PERIODIC_FILL_TIME ( 1 * SEC_PER_MIN * \ ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ) ///< Periodic bicarb chamber fill request 60 sec x 20 = 1200 -#define NUMBER_OF_CYCLES_BASED_ON_FLOWRATE 4 ///< NUmber of Balancing Chamber cycles required to update the new Qd rate. #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 -/// Bicarb (D10) pump speed from instantaneous mix volume: speed = 240 - sqrt(230400 - 96000*v)/2 -#define BC_BICARB_SPEED_OFFSET_MLPM 240.0F ///< Bicarb speed formula offset (mL/min). -#define BC_BICARB_SPEED_DISC_CONST 230400.0F ///< Bicarb speed formula discriminant constant. -#define BC_BICARB_SPEED_DISC_VOL_COEF 96000.0F ///< Bicarb speed formula volume coefficient. -#define BC_ACID_SPEED_OFFSET_MLPM 160.0F -#define BC_ACID_SPEED_DISC_CONSTANT 102400.0F -#define BC_ACID_SPEED_DISC_VOL_COEF 96000.0F /// Payload record structure for balancing chamber switch only request typedef struct @@ -105,7 +99,6 @@ static U32 balChamberFillTimeoutCount; ///< Timeout count (in task interval) to detect BC fill timeout. static S32 diffSpentFillCompleteCount; ///< Difference between spent target fill to actual fill count static BOOL isSpentFillComplete; ///< Flag indicating spent side fill complete. -static BOOL isFreshSideValvesClosed; ///< Flag indicating fresh-side BC valves are closed while spent side may still be filling. static F32 lastPrevSpentDialPressure; ///< Low-Qd slope: spent pressure last sample of dosing (tick before VALVES_CLOSE); then n-2 in VC. static F32 prevSpentDialPressure; ///< Spent pressure previous sample (n-1) during VALVES_CLOSE for low-Qd slope detection. static U32 spentFillRiseHitCount; ///< Low-Qd slope: counted rise hits (only incremented when in timing window). @@ -119,7 +112,7 @@ static F32 balancingError; ///< Balancing error that has been calculated during balancing chamber switching. //TODO: remove later once level sensor working -static U32 bicarbChamberPeriodicFillCounter; +static U32 bicarbChamberPeriodicFillCounter; // Balancing chamber state change tracker static BAL_CHAMBER_EXEC_STATE_T prevBalChamberState; ///< Balancing chamber Previous State tracking variable @@ -136,17 +129,11 @@ static void publishBalChamberData( void ); static U32 getBalChamberDataPublishInterval( void ); static void checkSpentFillComplete( F32 spentDialPressure ); -static BOOL isSpentFillCompleteByPressure( F32 spentDialPressure, F32 qdMlpm ); +static BOOL isSpentFillCompleteByPressure( F32 spentDialPressure, F32 qdMlpm, F32 spentFillCompletePresPsig ); static void applyBalChamberSwitchingPeriod( F32 tdDialysateFlowrate ); static BOOL isBalChamberTimeBasedSwitching( void ); static void scheduleFirstCycleRelaxAfterQdApply( void ); -static void valveControlForBCState1FreshSideClose( void ); -static void valveControlForBCState2FreshSideClose( void ); -static void closeFreshSideValvesWhenFillComplete( void ); static void calculateBalancingChamberError( void ); -static F32 getBicarbConcentratePumpSpeedMlMin( F32 bicarbVolumeMl ); -static F32 getAcidConcentratePumpSpeedMlMin( F32 acidVolumeMl ); -static void startBalChamberConcPumpDosing( F32 acidVolume, F32 bicarbVolume ); /*********************************************************************//** * @brief @@ -199,7 +186,6 @@ spentFillRiseHitCount = 0; spentFillRiseMissCounter = 0; isSpentFillComplete = FALSE; - isFreshSideValvesClosed = FALSE; isBalChamberSwitchingActive = FALSE; isBalChamberSwitchingOnRequested = FALSE; isBalChamberSwitchingOffRequested = FALSE; @@ -214,98 +200,6 @@ /*********************************************************************//** * @brief - * The getAcidConcentratePumpSpeedMlMin function computes D11 pump speed - * from the instantaneous acid mix volume: - * speed = 160 - sqrt(102400 - 96000*v) / 2 - * Result is clamped to [CONCENTRATE_PUMP_MIN_SPEED, CONCENTRATE_PUMP_MAX_SPEED]. - * @details \b Inputs: acidVolumeMl - * @details \b Outputs: none - * @param acidVolumeMl Instantaneous acid mix volume (mL) - * @return Acid concentrate pump speed (mL/min) - *************************************************************************/ -static F32 getAcidConcentratePumpSpeedMlMin( F32 acidVolumeMl) -{ - - F32 discriminant = BC_ACID_SPEED_DISC_CONSTANT - ( BC_ACID_SPEED_DISC_VOL_COEF * acidVolumeMl ); - F32 result = 0.0F; - - if ( discriminant < 0.0F ) - { - discriminant = 0.0F; - } - - result = BC_ACID_SPEED_OFFSET_MLPM - ( sqrtf( discriminant ) / 2.0F ); - - if ( result > CONCENTRATE_PUMP_MAX_SPEED ) - { - result = CONCENTRATE_PUMP_MAX_SPEED; - } - else if ( result < 0.0F ) - { - result = CONCENTRATE_PUMP_MIN_SPEED; - } - - return result; -} -/*********************************************************************//** - * @brief - * The getBicarbConcentratePumpSpeedMlMin function computes D10 pump speed - * from the instantaneous bicarb mix volume: - * speed = 240 - sqrt(230400 - 96000*v) / 2 - * Result is clamped to [CONCENTRATE_PUMP_MIN_SPEED, CONCENTRATE_PUMP_MAX_SPEED]. - * @details \b Inputs: bicarbVolumeMl - * @details \b Outputs: none - * @param bicarbVolumeMl Instantaneous bicarb mix volume (mL) - * @return Bicarb concentrate pump speed (mL/min) - *************************************************************************/ -static F32 getBicarbConcentratePumpSpeedMlMin( F32 bicarbVolumeMl ) -{ - F32 discriminant = BC_BICARB_SPEED_DISC_CONST - ( BC_BICARB_SPEED_DISC_VOL_COEF * bicarbVolumeMl ); - F32 result = 0.0F; - - if ( discriminant < 0.0F ) - { - discriminant = 0.0F; - } - - result = BC_BICARB_SPEED_OFFSET_MLPM - ( sqrtf( discriminant ) / 2.0F ); - - if ( result > CONCENTRATE_PUMP_MAX_SPEED ) - { - result = CONCENTRATE_PUMP_MAX_SPEED; - } - else if ( result < 0.0F ) - { - result = CONCENTRATE_PUMP_MIN_SPEED; - } - - return result; -} - -/*********************************************************************//** - * @brief - * The startBalChamberConcPumpDosing function starts acid and bicarb dosing. - * Acid (D11) runs at fixed 100 mL/min. Bicarb (D10) speed is computed from - * the instantaneous bicarb mix volume on every BC dose start. - * @details \b Inputs: acidVolume, bicarbVolume - * @details \b Outputs: concentrate pumps - * @param acidVolume Acid dose volume (mL) - * @param bicarbVolume Bicarb dose volume (mL) - * @return none - *************************************************************************/ -static void startBalChamberConcPumpDosing( F32 acidVolume, F32 bicarbVolume ) -{ - F32 acidSpeed = getAcidConcentratePumpSpeedMlMin( acidVolume ); - F32 bicarbSpeed = getBicarbConcentratePumpSpeedMlMin( bicarbVolume ); - - setConcentratePumpTargetSpeed( D11_PUMP, acidSpeed, acidVolume ); - setConcentratePumpTargetSpeed( D10_PUMP, bicarbSpeed, bicarbVolume ); - requestConcentratePumpOn( D11_PUMP ); - requestConcentratePumpOn( D10_PUMP ); -} - -/*********************************************************************//** - * @brief * The transitionToBalChamberFill function prepares for transition to * balancing chamber fill/switching operations. * @details \b Inputs: none @@ -426,7 +320,6 @@ spentFillRiseHitCount = 0; spentFillRiseMissCounter = 0; isSpentFillComplete = FALSE; - isFreshSideValvesClosed = FALSE; spentDialPressure = getFilteredPressure( D51_PRES ); lastPrevSpentDialPressure = spentDialPressure; prevSpentDialPressure = spentDialPressure; @@ -450,7 +343,7 @@ *************************************************************************/ static void scheduleFirstCycleRelaxAfterQdApply( void ) { - bcSwitchingBasedOnClosedPeriodCounter = NUMBER_OF_CYCLES_BASED_ON_FLOWRATE; + bcSwitchingBasedOnClosedPeriodCounter = 2; } /*********************************************************************//** @@ -465,9 +358,7 @@ static BOOL isBalChamberTimeBasedSwitching( void ) { BOOL state = FALSE; - F32 dialFlowRate = getBalChamberActiveDialysateFlowrate(); - //state = ( getD48PumpSpeed() <= BAL_CHAMBER_TIME_BASED_D48_SPEED_RPM ) ? TRUE : FALSE; - state = ( dialFlowRate <= BAL_CHAMBER_OPEN_LOOP_FLOW_RATE_BAND_3 )? TRUE : FALSE; + state = ( getD48PumpSpeed() <= BAL_CHAMBER_TIME_BASED_D48_SPEED_RPM ) ? TRUE : FALSE; return state; } @@ -749,59 +640,6 @@ /*********************************************************************//** * @brief - * The valveControlForBCState1FreshSideClose function closes only the fresh-side - * balancing chamber valves opened during state 1 fill. - * @details \b Inputs: none - * @details \b Outputs: valve states - * @return none. - *************************************************************************/ -static void valveControlForBCState1FreshSideClose( void ) -{ - setValveState( D19_VALV, VALVE_STATE_CLOSED ); - setValveState( D24_VALV, VALVE_STATE_CLOSED ); -} - -/*********************************************************************//** - * @brief - * The valveControlForBCState2FreshSideClose function closes only the fresh-side - * balancing chamber valves opened during state 2 fill. - * @details \b Inputs: none - * @details \b Outputs: valve states - * @return none. - *************************************************************************/ -static void valveControlForBCState2FreshSideClose( void ) -{ - setValveState( D26_VALV, VALVE_STATE_CLOSED ); - setValveState( D21_VALV, VALVE_STATE_CLOSED ); -} - -/*********************************************************************//** - * @brief - * The closeFreshSideValvesWhenFillComplete function closes the fresh-side BC - * valves once fresh fill is detected, without waiting for spent fill. - * @details \b Inputs: balChamberSWState, isPressureStabilizedDuringFill, isFreshSideValvesClosed - * @details \b Outputs: isFreshSideValvesClosed, valve states - * @return none. - *************************************************************************/ -static void closeFreshSideValvesWhenFillComplete( void ) -{ - if ( ( TRUE == isPressureStabilizedDuringFill ) && ( FALSE == isFreshSideValvesClosed ) ) - { - if ( BAL_CHAMBER_SW_STATE1 == balChamberSWState ) - { - valveControlForBCState1FreshSideClose(); - } - else - { - valveControlForBCState2FreshSideClose(); - } - - isFreshSideValvesClosed = TRUE; - } -} - -/*********************************************************************//** - * @brief * The handleBalChamberState1FillStart function handles the balancing chamber * state 1 fill and time to fill chamber counter being updated. * @details \b Inputs: Pressure @@ -827,7 +665,6 @@ spentFillRiseHitCount = 0; spentFillRiseMissCounter = 0; isSpentFillComplete = FALSE; - isFreshSideValvesClosed = FALSE; if ( FALSE == getTestConfigStatus( TEST_CONFIG_DD_DISABLE_DRY_BICARB ) ) { @@ -843,7 +680,7 @@ freshDialPressure = getFilteredPressure( D18_PRES ); spentDialPressure = getFilteredPressure( D51_PRES ); - if ( TRUE == getTestConfigStatus( TEST_CONFIG_DD_FP_ENABLE_BETA_1_0_HW ) ) + if ( getTestConfigStatus( TEST_CONFIG_DD_FP_ENABLE_BETA_1_0_HW ) == TRUE ) { //Set Trimmer heater Target temp every BC cycle to catch up fresh dialysate temp setHeaterTargetTemperature( D45_HEAT, getFilteredTemperatureValue( D4_TEMP ) ); @@ -867,7 +704,11 @@ // Deliver dosing during generate dialysate mode if ( TRUE != getBalChamberSwitchingOnlyStatus() ) { - startBalChamberConcPumpDosing( acidVolume, bicarbVolume ); + // start acid and bicarb pump with the expected quantity + setConcentratePumpTargetSpeed( D11_PUMP, DOSING_CONCENTRATE_PUMP_SPEED, acidVolume ); + setConcentratePumpTargetSpeed( D10_PUMP, DOSING_CONCENTRATE_PUMP_SPEED, bicarbVolume ); + requestConcentratePumpOn( D11_PUMP ); + requestConcentratePumpOn( D10_PUMP ); } state = BAL_CHAMBER_STATE1_BICARB_ACID_DOSING_CNTRL; @@ -954,6 +795,7 @@ static BAL_CHAMBER_EXEC_STATE_T handleBalChamberState1FillDetectComplete( void ) { BAL_CHAMBER_EXEC_STATE_T state = BAL_CHAMBER_STATE1_FILL_DETECT_COMPLETE; + BOOL isBothFillsComplete = FALSE; BOOL isFirstCycleNotDone = FALSE; BOOL isFillCompleteOrFirstCycle = FALSE; @@ -965,14 +807,17 @@ { SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DD_BC_FILL_TIMEOUT_FAULT, currentBalChamberFillCounter, balChamberFillTimeoutCount ); - SEND_EVENT_WITH_2_U32_DATA( DD_EVENT_BC_FILL_TIMEOUT, isPressureStabilizedDuringFill, isSpentFillComplete ); - // Move to the idle state state = BAL_CHAMBER_STATE_IDLE; } + // If the dry bicarbonate is enabled then we ignore looking at d18 pressure to be in range. + if ( ( FALSE == getTestConfigStatus( TEST_CONFIG_DD_DISABLE_DRY_BICARB ) ) && ( TRUE == getBicarbChamberFillRequested() ) ) + { + isPressureStabilizedDuringFill = TRUE; + } // Check fresh dialysate pressure back in range to indicate fresh fill complete. - if ( ( freshDialPressure >= FRESH_DIAL_PRESSURE_MIN_PSIG ) && ( freshDialPressure <= FRESH_DIAL_PRESSURE_MAX_PSIG ) ) + else if ( ( freshDialPressure >= FRESH_DIAL_PRESSURE_MIN_PSIG ) && ( freshDialPressure <= FRESH_DIAL_PRESSURE_MAX_PSIG ) ) { if ( ++balChamberFillCompleteStablePressureCounter >= BAL_CHAMBER_FILL_COMPLETE_MS ) { @@ -981,19 +826,16 @@ } } - // Close fresh side valves only upon fresh fill completion by detecting pressure rise. - closeFreshSideValvesWhenFillComplete(); - - // Check Spent side fill complete checkSpentFillComplete( spentDialPressure ); + // Check both spent and fresh side fill is complete + isBothFillsComplete = ( ( TRUE == isSpentFillComplete ) && ( TRUE == isPressureStabilizedDuringFill ) ) ? TRUE : FALSE; isFirstCycleNotDone = ( ( FALSE == isFirstCycleBCSwitchingCompleted ) && ( currentBalChamberSwitchingCounter >= balChamberValveClosePeriod ) ) ? TRUE : FALSE; if ( FALSE == getBalChamberSwitchingOnlyStatus() ) { - isFillCompleteOrFirstCycle = ( ( ( TRUE == isSpentFillComplete ) && ( TRUE == isFreshSideValvesClosed ) ) || - ( TRUE == isFirstCycleNotDone ) ) ? TRUE : FALSE; + isFillCompleteOrFirstCycle = ( ( TRUE == isBothFillsComplete ) || ( TRUE == isFirstCycleNotDone ) ) ? TRUE : FALSE; } if ( ( TRUE == isFillCompleteOrFirstCycle ) || @@ -1141,7 +983,6 @@ spentFillRiseHitCount = 0; spentFillRiseMissCounter = 0; isSpentFillComplete = FALSE; - isFreshSideValvesClosed = FALSE; if ( FALSE == getTestConfigStatus( TEST_CONFIG_DD_DISABLE_DRY_BICARB ) ) { @@ -1153,11 +994,10 @@ acidVolume = getF32OverrideValue( &acidDoseVolume ); bicarbVolume = getF32OverrideValue( &bicarbDoseVolume ); } - freshDialPressure = getFilteredPressure( D18_PRES ); spentDialPressure = getFilteredPressure( D51_PRES ); - if ( TRUE == getTestConfigStatus( TEST_CONFIG_DD_FP_ENABLE_BETA_1_0_HW ) ) + if ( getTestConfigStatus( TEST_CONFIG_DD_FP_ENABLE_BETA_1_0_HW ) == TRUE ) { //Set Trimmer heater Target temp every BC cycle to catch up fresh dialysate temp setHeaterTargetTemperature( D45_HEAT, getFilteredTemperatureValue( D4_TEMP ) ); @@ -1181,7 +1021,11 @@ // Deliver dosing during generate dialysate mode if ( TRUE != getBalChamberSwitchingOnlyStatus() ) { - startBalChamberConcPumpDosing( acidVolume, bicarbVolume ); + // start acid and bicarb pump with the expected quantity + setConcentratePumpTargetSpeed( D11_PUMP, DOSING_CONCENTRATE_PUMP_SPEED, acidVolume ); + setConcentratePumpTargetSpeed( D10_PUMP, DOSING_CONCENTRATE_PUMP_SPEED, bicarbVolume ); + requestConcentratePumpOn( D11_PUMP ); + requestConcentratePumpOn( D10_PUMP ); } state = BAL_CHAMBER_STATE2_BICARB_ACID_DOSING_CNTRL; @@ -1212,24 +1056,38 @@ static BAL_CHAMBER_EXEC_STATE_T handleBalChamberState2FillDetectComplete( void ) { BAL_CHAMBER_EXEC_STATE_T state = BAL_CHAMBER_STATE2_FILL_DETECT_COMPLETE; + BOOL isBothFillsComplete = FALSE; BOOL isFirstCycleNotDone = FALSE; BOOL isFillCompleteOrFirstCycle = FALSE; freshDialPressure = getFilteredPressure( D18_PRES ); spentDialPressure = getFilteredPressure( D51_PRES ); + // If the dry bicarbonate is enabled then we ignore looking at d18 pressure to be in range. + if ( ( FALSE == getTestConfigStatus( TEST_CONFIG_DD_DISABLE_DRY_BICARB ) ) && ( TRUE == getBicarbChamberFillRequested() ) ) + { + isPressureStabilizedDuringFill = TRUE; + } + // Check fresh dialysate pressure back in range to indicate fresh fill complete. + else if ( ( freshDialPressure >= FRESH_DIAL_PRESSURE_MIN_PSIG ) && ( freshDialPressure <= FRESH_DIAL_PRESSURE_MAX_PSIG ) ) + { + if ( ++balChamberFillCompleteStablePressureCounter >= BAL_CHAMBER_FILL_COMPLETE_MS ) + { + // stabilized pressure indicating fresh side fill is complete + isPressureStabilizedDuringFill = TRUE; + } + } + // After the first BC cycle, fault if fill never completes at the Qd-based timeout. if ( ( currentBalChamberFillCounter > balChamberFillTimeoutCount ) && ( TRUE != getTestConfigStatus( TEST_CONFIG_DD_DISABLE_BC_PRESSURE_ALARMS ) ) ) { SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DD_BC_FILL_TIMEOUT_FAULT, currentBalChamberFillCounter, balChamberFillTimeoutCount ); - SEND_EVENT_WITH_2_U32_DATA( DD_EVENT_BC_FILL_TIMEOUT, isPressureStabilizedDuringFill, isSpentFillComplete ); - // Move to the idle state state = BAL_CHAMBER_STATE_IDLE; } - // Check fresh dialysate pressure back in range to indicate fresh fill complete. + // Check fresh dialysate pressure back in range to indicate fill complete. if ( ( freshDialPressure >= FRESH_DIAL_PRESSURE_MIN_PSIG ) && ( freshDialPressure <= FRESH_DIAL_PRESSURE_MAX_PSIG ) ) { if ( ++balChamberFillCompleteStablePressureCounter >= BAL_CHAMBER_FILL_COMPLETE_MS ) @@ -1239,19 +1097,16 @@ } } - // Close fresh side valves only upon fresh fill completion by detecting pressure rise. - closeFreshSideValvesWhenFillComplete(); - - // Check Spent side fill complete checkSpentFillComplete( spentDialPressure ); + // Check switching cycle time or pressure check for valve closure + isBothFillsComplete = ( ( TRUE == isSpentFillComplete ) && ( TRUE == isPressureStabilizedDuringFill ) ) ? TRUE : FALSE; isFirstCycleNotDone = ( ( FALSE == isFirstCycleBCSwitchingCompleted ) && ( currentBalChamberSwitchingCounter >= balChamberValveClosePeriod ) ) ? TRUE : FALSE; if ( FALSE == getBalChamberSwitchingOnlyStatus() ) { - isFillCompleteOrFirstCycle = ( ( ( TRUE == isSpentFillComplete ) && ( TRUE == isFreshSideValvesClosed ) ) || - ( TRUE == isFirstCycleNotDone ) ) ? TRUE : FALSE; + isFillCompleteOrFirstCycle = ( ( TRUE == isBothFillsComplete ) || ( TRUE == isFirstCycleNotDone ) ) ? TRUE : FALSE; } if ( ( TRUE == isFillCompleteOrFirstCycle ) || @@ -1412,7 +1267,7 @@ // Check if a request made was to activate the balancing chamber switching. if ( TRUE == isBalChamberSwitchingOnRequested ) { - //Clear request was processed. + //Clear the request flag to indicate that the request was processed. isBalChamberSwitchingOnRequested = FALSE; // Set flag to indicate that balancing chamber switching is active @@ -1429,65 +1284,73 @@ * @brief * The isSpentFillCompleteByPressure function evaluates whether the spent side of the * balancing chamber fill is complete from D51 pressure. - * @details \b Inputs: spentDialPressure, qdMlpm, valve-close period, fill counter, - * Diener pump test config, and D51 slope history. + * @details \b Inputs: spentDialPressure, qdMlpm, spentFillCompletePresPsig, valve-close period, + * fill counter, Diener pump test config, and D51 slope history for low-Qd slope mode. * @details \b Outputs: spentFillRiseHitCount, spentFillRiseMissCounter, - * lastPrevSpentDialPressure, prevSpentDialPressure. + * lastPrevSpentDialPressure, prevSpentDialPressure (updated only in slope mode). * @param spentDialPressure filtered spent dialysate pressure (PSIG). * @param qdMlpm dialysate flow rate (mL/min). + * @param spentFillCompletePresPsig spent fill complete pressure threshold for current Qd and pump. * @return TRUE if spent fill is detected this task period; FALSE otherwise. *************************************************************************/ -static BOOL isSpentFillCompleteByPressure( F32 spentDialPressure, F32 qdMlpm ) +static BOOL isSpentFillCompleteByPressure( F32 spentDialPressure, F32 qdMlpm, F32 spentFillCompletePresPsig ) { - BOOL useLowQdRiseThreshold = ( ( ( TRUE != getTestConfigStatus( TEST_CONFIG_DD_ENABLE_DIENER_2000_PUMP ) ) && - ( qdMlpm <= SPENT_FILL_COMPLETE_QD_LOW_RISE_MAX_MLPM ) ) ? TRUE : FALSE ); - F32 riseThresholdPsig = ( TRUE == useLowQdRiseThreshold ) ? SPENT_FILL_COMPLETE_DP_RISE_PSIG : - SPENT_FILL_COMPLETE_DP_RISE_HIGH_QD_PSIG; + BOOL useSlopeDetector = ( ( ( TRUE != getTestConfigStatus( TEST_CONFIG_DD_ENABLE_DIENER_2000_PUMP ) ) && + ( qdMlpm <= SPENT_FILL_COMPLETE_QD_SLOPE_MAX_MLPM ) ) ? TRUE : FALSE ); BOOL state; - // Gate slope hits near expected valve-close count (current vs balChamberValveClosePeriod +/- tolerance). - U32 detectTolCount = (U32)( (F32)balChamberValveClosePeriod * SPENT_FILL_DETECT_COUNT_TOL_PCT ); - U32 maxDetectCount = balChamberValveClosePeriod + detectTolCount; - U32 minDetectCount = balChamberValveClosePeriod - detectTolCount; - BOOL isDetectionInCountWindow = ( ( currentBalChamberFillCounter >= minDetectCount ) && - ( currentBalChamberFillCounter <= maxDetectCount ) ) ? TRUE : FALSE; - F32 riseDeltaPsi = spentDialPressure - lastPrevSpentDialPressure; - BOOL riseHit = ( riseDeltaPsi > riseThresholdPsig ) ? TRUE : FALSE; - U32 requiredRiseCount; - - // Mid band between low/high spent pressure rise: require two rise hits. - if ( riseDeltaPsi > SPENT_FILL_SLOPE_SPENT_PRESSURE_HIGH_PSIG ) + if ( TRUE == useSlopeDetector ) { - requiredRiseCount = 1U; - } - else - { - requiredRiseCount = 2U; - } + // Gate slope hits near expected valve-close count (current vs balChamberValveClosePeriod +/- tolerance). + U32 detectTolCount = (U32)( (F32)balChamberValveClosePeriod * SPENT_FILL_DETECT_COUNT_TOL_PCT ); + U32 maxDetectCount = balChamberValveClosePeriod + detectTolCount; + U32 minDetectCount = balChamberValveClosePeriod - detectTolCount; + BOOL isDetectionInCountWindow = ( ( currentBalChamberFillCounter >= minDetectCount ) && + ( currentBalChamberFillCounter <= maxDetectCount ) ) ? TRUE : FALSE; + F32 riseDeltaPsi = spentDialPressure - lastPrevSpentDialPressure; + BOOL riseHit = ( riseDeltaPsi > SPENT_FILL_COMPLETE_DP_RISE_PSIG ) ? TRUE : FALSE; + U32 requiredRiseCount; - if ( ( TRUE == riseHit ) && ( TRUE == isDetectionInCountWindow ) ) - { - spentFillRiseHitCount += 1; - spentFillRiseMissCounter = 0; - } - else if ( spentFillRiseHitCount > 0 ) - { - if ( ( FALSE == riseHit ) && ( TRUE == isDetectionInCountWindow ) ) + // Mid band between low/high spent pressure: require two rise hits. + if ( riseDeltaPsi > SPENT_FILL_SLOPE_SPENT_PRESSURE_HIGH_PSIG ) { - spentFillRiseMissCounter += 1; + requiredRiseCount = 1U; + } + else + { + requiredRiseCount = 2U; + } - if ( spentFillRiseMissCounter >= 2 ) + if ( ( TRUE == riseHit ) && ( TRUE == isDetectionInCountWindow ) ) + { + spentFillRiseHitCount += 1; + spentFillRiseMissCounter = 0; + } + else if ( spentFillRiseHitCount > 0 ) + { + if ( ( FALSE == riseHit ) && ( TRUE == isDetectionInCountWindow ) ) { - spentFillRiseHitCount = 0; - spentFillRiseMissCounter = 0; + spentFillRiseMissCounter += 1; + + if ( spentFillRiseMissCounter >= 2 ) + { + spentFillRiseHitCount = 0; + spentFillRiseMissCounter = 0; + } } } - } - lastPrevSpentDialPressure = prevSpentDialPressure; - prevSpentDialPressure = spentDialPressure; + lastPrevSpentDialPressure = prevSpentDialPressure; + prevSpentDialPressure = spentDialPressure; - state = ( spentFillRiseHitCount >= requiredRiseCount ) ? TRUE : FALSE; + // Complete on slope hits, or on absolute pressure at period only if Qd > low band (low Qd: slope-only, no absolute-pressure fallback). + state = ( spentFillRiseHitCount >= requiredRiseCount ) ? TRUE : FALSE; + } + else + { + // Not in slope mode (Diener 2000 pump or Qd > SPENT_FILL_COMPLETE_QD_SLOPE_MAX_MLPM): threshold-only spent fill complete. + state = ( spentDialPressure >= spentFillCompletePresPsig ) ? TRUE : FALSE; + } return state; } @@ -1512,6 +1375,7 @@ U32 d48SpeedPostRangeCheck = 0; F32 qdMlpm = getBalChamberActiveDialysateFlowrate(); BOOL result = FALSE; + F32 spentFillCompletePresPsig; BOOL isSpentFillCompleteDetected = FALSE; if ( TRUE == isBalChamberTimeBasedSwitching() ) @@ -1523,8 +1387,25 @@ } else { - isSpentFillCompleteDetected = isSpentFillCompleteByPressure( spentDialPressure, qdMlpm ); + // Diener 2000 pump: spent fill complete pressure use legacy 25 PSI. Other pump: depends on Qd. + if ( TRUE == getTestConfigStatus( TEST_CONFIG_DD_ENABLE_DIENER_2000_PUMP ) ) + { + spentFillCompletePresPsig = SPENT_FILL_COMPLETE_PRES; + } + else + { + if ( qdMlpm <= QD_THRESHOLD_HIGH_MLPM ) + { + spentFillCompletePresPsig = SPENT_FILL_COMPLETE_PRES_QD_MID_PSIG; + } + else + { + spentFillCompletePresPsig = SPENT_FILL_COMPLETE_PRES_QD_HIGH_PSIG; + } + } + isSpentFillCompleteDetected = isSpentFillCompleteByPressure( spentDialPressure, qdMlpm, spentFillCompletePresPsig ); + if ( ( TRUE == isSpentFillCompleteDetected ) && ( isSpentFillComplete != TRUE ) ) { // Check spent fill time against the balancing chamber closing period @@ -1598,66 +1479,6 @@ /*********************************************************************//** * @brief - * The getBalChamberFreshSideValvesClosedStatus function returns whether the - * fresh-side balancing chamber valves are closed for the current switch state. - * @details \b Inputs: isFreshSideValvesClosed - * @details \b Outputs: none - * @return TRUE when fresh-side BC valves are closed. - *************************************************************************/ -BOOL getBalChamberFreshSideValvesClosedStatus( void ) -{ - return isFreshSideValvesClosed; -} - -/*********************************************************************//** - * @brief - * The getBalChamberFreshFillCompleteStatus function returns whether fresh-side - * fill completed during the current BC switch cycle. - * @details \b Inputs: isPressureStabilizedDuringFill - * @details \b Outputs: none - * @return TRUE when fresh-side fill is complete. - *************************************************************************/ -BOOL getBalChamberFreshFillCompleteStatus( void ) -{ - return isPressureStabilizedDuringFill; -} - -/*********************************************************************//** - * @brief - * The getBalChamberSpentFillCompleteStatus function returns whether spent-side - * fill completed during the current BC switch cycle. - * @details \b Inputs: isSpentFillComplete - * @details \b Outputs: none - * @return TRUE when spent-side fill is complete. - *************************************************************************/ -BOOL getBalChamberSpentFillCompleteStatus( void ) -{ - return isSpentFillComplete; -} - -/*********************************************************************//** - * @brief - * The isBalChamberSwitchImminent function returns whether the balancing chamber - * is within the valve-close window (50 ms) before switching. - * @details \b Inputs: currentBalChamberSwitchingCounter, balChamberValveClosePeriod - * @details \b Outputs: none - * @return TRUE when BC switch is imminent. - *************************************************************************/ -BOOL isBalChamberSwitchImminent( void ) -{ - BOOL result = FALSE; - - if ( ( balChamberValveClosePeriod > 0 ) && - ( currentBalChamberSwitchingCounter >= balChamberSwitchingPeriod ) ) - { - result = TRUE; - } - - return result; -} - -/*********************************************************************//** - * @brief * The getBalChamberSwitchingFreq function gets the balancing chamber switching * frequency value. * @details \b Inputs: balChamberSwitchingFreq Index: firmware/App/Controllers/BalancingChamber.h =================================================================== diff -u -rc53b6d8d57bd64bcfedf8a1bbb0d0eeab4502971 -r095866efd8f10bdead490578e7584051d79292f0 --- firmware/App/Controllers/BalancingChamber.h (.../BalancingChamber.h) (revision c53b6d8d57bd64bcfedf8a1bbb0d0eeab4502971) +++ firmware/App/Controllers/BalancingChamber.h (.../BalancingChamber.h) (revision 095866efd8f10bdead490578e7584051d79292f0) @@ -39,13 +39,6 @@ #define BC_SPENT_FILL_PRESSURE_PSIG 29.0F ///< Spent side pressure (drop) during balancing chamber switching, indicates fill has been started / in progress. #define BAL_CHAMBER_FILL_VOLUME_ML 30.0F ///< Balancing chamber fill/drain volume per batch operation. #define BAL_CHAMBER_TIME_BASED_D48_SPEED_RPM 250 ///< Minimum D48 speed and fixed speed for time-based balancing chamber switching. -#define BAL_CHAMBER_OPEN_LOOP_FLOW_RATE_BAND_1 50.0F ///< Band 1 flowrate(50 mL/min) -#define BAL_CHAMBER_OPEN_LOOP_FLOW_RATE_BAND_2 60.0F ///< Band 2 flowrate(60 mL/min) -#define BAL_CHAMBER_OPEN_LOOP_FLOW_RATE_BAND_3 70.0F ///< Band 3 flowrate(70 mL/min) -#define BAL_CHAMBER_OPEN_LOOP_FLOW_RATE_BAND_4 80.0F ///< Band 4 flowrate(80 mL/min) -#define BAL_CHAMBER_TIME_BASED_BAND_1 250 ///< Speed at D48 pump runs when the flowrate is between 50 mL/min and 60 mL/min. -#define BAL_CHAMBER_TIME_BASED_BAND_2 290 ///< Speed at D48 pump runs when the flowrate is between 60 mL/min and 70 mL/min. -#define BAL_CHAMBER_TIME_BASED_BAND_3 330 ///< Speed at D48 pump runs when the flowrate is between 80 mL/min and 80 mL/min. /// balancing chamber data structure typedef struct @@ -82,8 +75,6 @@ F32 getBalancingChamberError( void ); // Get balancing chamber error to adjust UF rate. F32 getBicarbDoseVol( void ); // Get liquid bicarb dose volume F32 getAcidDoseVol( void ); // Get acid dose volume -BOOL isBalChamberSwitchImminent( void ); // Get the balancing chamber is within the valve-close window (50 ms) before switching. -BOOL getBalChamberFreshSideValvesClosedStatus( void ); // Get the balancing chamber fresh side valve close status BOOL testDDBalChamberDataPublishIntervalOverride( MESSAGE_T *message ); // To override the balancing chamber data publish interval BOOL testBalChamberSwFreqOverride( MESSAGE_T *message ); // To override the balancing chamber switching frequency Index: firmware/App/Controllers/ConcentratePumps.c =================================================================== diff -u -rf43d59af8e69ef1459bafe91873ce41cf63a4a75 -r095866efd8f10bdead490578e7584051d79292f0 --- firmware/App/Controllers/ConcentratePumps.c (.../ConcentratePumps.c) (revision f43d59af8e69ef1459bafe91873ce41cf63a4a75) +++ firmware/App/Controllers/ConcentratePumps.c (.../ConcentratePumps.c) (revision 095866efd8f10bdead490578e7584051d79292f0) @@ -41,7 +41,7 @@ #define CONCENTRATE_PUMP_CLEANING_SPD_OUT_OF_RANGE_TOL_PCT 0.05F ///< Concentrate pump cleaning mode speed out of range tolerance when on in percentage. #define CONCENTRATE_PUMP_SPD_OUT_OF_RANGE_TOL_WHEN_SLOW_MLPM 0.5F ///< Concentrate pump speed out of range tolerance when slow in mL/min. #define CONCENTRATE_PUMP_LOW_SPEED_THRESHOLD_MLPM 5.0F ///< Concentrate pump low speed threshold in mL/min. -#define CONCENTRATE_PUMP_ZERO_FLOW_RATE 0xFFFFFFFF ///< Pulse width value when zero flow rate or pump is off. +#define CONCENTRATE_PUMP_ZERO_FLOW_RATE 0xFFFFFFFF ///< Pulse width value when zero flow rate or pump is off #define CONCENTRATE_PUMP_VOLUME_PER_REV_DIENER 0.4F ///< Volume output every revolution (mL). #define CONCENTRATE_PUMP_VOLUME_PER_REV 0.1F ///< Volume output every revolution (mL). Index: firmware/App/Controllers/ConcentratePumps.h =================================================================== diff -u -r42541cc4700d748d524400f61d99e288a0e11f3e -r095866efd8f10bdead490578e7584051d79292f0 --- firmware/App/Controllers/ConcentratePumps.h (.../ConcentratePumps.h) (revision 42541cc4700d748d524400f61d99e288a0e11f3e) +++ firmware/App/Controllers/ConcentratePumps.h (.../ConcentratePumps.h) (revision 095866efd8f10bdead490578e7584051d79292f0) @@ -32,13 +32,11 @@ // ********** public definitions ********** // For 150 RPM, Diener pump delivers 60ml/min #define CONCENTRATE_PUMP_MAX_SPEED 200.0F ///< Maximum Diener pump speed for concentrate pump in mL/min -#define CONCENTRATE_PUMP_MIN_SPEED 20.0F ///< Minimum Diener pump speed for concentrate pump in mL/min -#define DOSING_ACID_CONCENTRATE_PUMP_SPEED 60.0F ///< Diener pump speed for acid pump -#define DOSING_CONCENTRATE_PUMP_SPEED 100.F ///< Dosing pump speed for spent chamber fill for acid and bicarb pumps +#define DOSING_CONCENTRATE_PUMP_SPEED 100.0F ///< Diener pump speed for acid and bicarb dosing pump speed in mL/min #define DRAIN_BICART_PUMP_SPEED 200.0F ///< Diener pump speed for cartridge drains at maximum speed in mL/min #define DEFAULT_ACID_VOLUME_ML 0.666666667F ///< Acid concentrate volume in ml. -#define DEFAULT_BICARB_VOLUME_ML 0.95F ///< Bicarb concentrate volume in ml. +#define DEFAULT_BICARB_VOLUME_ML 1.146666667F ///< Bicarb concentrate volume in ml. #define DOSING_CONT_VOLUME 0xFFFFFFFF ///< Volume set to 0xFFFFFFFF enables continuous delivery based on the speed set. Index: firmware/App/Controllers/DryBiCart.c =================================================================== diff -u -r483ebbb75171ec93ab24d1f69f83a6248376266f -r095866efd8f10bdead490578e7584051d79292f0 --- firmware/App/Controllers/DryBiCart.c (.../DryBiCart.c) (revision 483ebbb75171ec93ab24d1f69f83a6248376266f) +++ firmware/App/Controllers/DryBiCart.c (.../DryBiCart.c) (revision 095866efd8f10bdead490578e7584051d79292f0) @@ -46,18 +46,18 @@ #define DRY_BICART_DATA_PUBLISH_INTERVAL ( 250 / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the drybicart data published. #define WCDI2_PRESSURE_OFFSET_PSI 7.0F ///< The difference between the actual pressure measured at bicart assembly and the measured D66 pressure based on the placement of the sensor for WCID1 #define WCID1_PRESSURE_OFFSET_PSI 1.0F ///< The difference between the actual pressure measured at bicart assembly and the measured D66 pressure based on the placement of the sensor for WCID2 -#define DRY_BICART_PERSISTENCE_DURATION_MS 500 ///< Fill persistence duration to overcome the pressure overshoot/ drop for beta 1.9 and above. -//#define DRY_BICART_FILL_PERSISTENCE_DURATION_MS ( 1 * MS_PER_SECOND ) ///< Fill persistence duration to overcome the pressure overshoot/ drop for beta 1.9 and above. +#define DRY_BICART_PERSISTENCE_DURATION_MS 200 ///< Fill persistence duration to overcome the pressure overshoot/ drop for beta 1.9 and above. // Dry Bicart Fill + #define DRY_BICART_FILL_COMPLETE_TIME_MS ( 1 * MS_PER_SECOND ) ///< Wait time to reset the request flag after fill complete -#define DRY_BICART_WCID2_FILL_COMPLETE_PRESSURE_PSI ( 3.0F + WCDI2_PRESSURE_OFFSET_PSI ) ///< Maximum pressure reached to indicate the dry bicart fill being completed for WCID2 -#define DRY_BICART_WCID1_FILL_COMPLETE_PRESSURE_PSI ( 10.0F + WCID1_PRESSURE_OFFSET_PSI ) ///< Maximum pressure reached to indicate the dry bicart fill being completed for WCID1. +#define DRY_BICART_WCID2_FILL_COMPLETE_PRESSURE_PSI ( 10.0F + WCDI2_PRESSURE_OFFSET_PSI ) ///< Maximum pressure reached to indicate the dry bicart fill being completed for WCID2 +#define DRY_BICART_WCID1_FILL_COMPLETE_PRESSURE_PSI ( 10.0F + WCID1_PRESSURE_OFFSET_PSI ) ///< Maximum pressure reached to indicate the dry bicart fill being completed for WCID1 #define GET_FILL_COMPLETE_PRESSURE_PSI (getTestConfigStatus( TEST_CONFIG_DD_ENABLE_WCID_1 ) != TRUE ? \ DRY_BICART_WCID2_FILL_COMPLETE_PRESSURE_PSI : DRY_BICART_WCID1_FILL_COMPLETE_PRESSURE_PSI ) ///< Get fill complete pressure based on the WCID configuration #define DRY_BICART_FILL_INITIATE_PRESSURE_PSI 1.5F ///< Minimum pressure required to initiate the dry bicart fill process. -#define DRY_BICART_FILL_COMPLETE_SUPPLY_PRESSURE_PSI 10.0F ///< Maximum pressure allowed at bicart fill during supply process/state -#define DRY_BICART_FILL_INITIATE_SUPPLY_PRESSURE_PSI 4.0F ///< Minimum pressure required to initiate the dry bicart fill during supply process/state +#define DRY_BICART_FILL_COMPLETE_SUPPLY_PRESSURE_PSI 10.0F ///< Maximum pressure allowed at bicart fill during supply process/state +#define DRY_BICART_FILL_INITIATE_SUPPLY_PRESSURE_PSI 3.0F ///< Minimum pressure required to initiate the dry bicart fill during supply process/state #define DRY_BICART_MAX_FILL_CYCLE_CNT 10 ///< Max fill cycle allowed (by override) for dry bicart fill/mix with water. #define DRY_BICART_MINIMUM_FILL_CYCLE_CNT 3 ///< Minimum fill cycle count for filling dry bicart // Dry Bicart Fill Vent @@ -67,15 +67,13 @@ // Bicarb chamber fill/Supply #ifdef CONDUCTIVE_LEVEL_SENSOR_ENABLED -#define DRY_BICART_SUPPLY_VALVE_D80_OPEN_TIME_MS ( 60 * MS_PER_SECOND ) ///< Max time allowed for supply (opening D80 valve) during bicarb chamber (F) fill using level sensor +#define DRY_BICART_SUPPLY_VALVE_D80_OPEN_TIME_MS ( 10 * MS_PER_SECOND ) ///< Max time allowed for supply (opening D80 valve) during bicarb chamber (F) fill using level sensor #else #define DRY_BICART_SUPPLY_VALVE_D80_OPEN_TIME_MS ( 3 * MS_PER_SECOND ) ///< Max time allowed for supply (opening D80 valve) during bicarb chamber (F) fill time based fill #endif #define DRY_BICART_SUPPLY_VENT_TIME_MS ( 1 * MS_PER_SECOND ) ///< Wait time to vent dry bicart gas before actuating Bicarb chamber(F) venting. #define DRY_BICART_SUPPLY_VENT_MAX_TIME_MS ( 1 * MS_PER_SECOND ) ///< Max time to vent both dry bicart and Chamber F. #define DRY_BICART_SUPPLY_COMPLETE_TIME_MS ( 2 * MS_PER_SECOND ) ///< Wait time to close the D80 valve after D65 is closed -#define DRY_BICART_SUPPLY_DECAY_COMPLETE_PRESSURE_PSI 4.0F ///< Minimum decay pressure needed to end the supply process. -#define DRY_BICART_SUPPLY_VENT_CYCLE_TIME_MS ( 15 * SEC_PER_MIN * MS_PER_SECOND ) ///< Vent cycle time to initiate D85 opening. // Dry Bicart Drain #define LARGE_DRY_BICART_MAX_DRAIN_TIME_MS ( 8 * SEC_PER_MIN * MS_PER_SECOND ) ///< Max drain time for large dry bicart in ms. @@ -86,10 +84,6 @@ #define DRY_BICART_DRAIN_COND_ZERO_THRESH 0.05F ///< Zero conductivity threshold #define DRY_BICART_DRAIN_COND_STABLE_SAMPLES 10U ///< De-bounce samples (10*50ms=500ms) -#define STD_MIX_BC_VOLUME 30.0F ///< Standard balancing chamber volume -#define TARGET_ADJ_BICARB_SETTING 137.0F ///< User defined Bicarb setting -#define TARGET_ADJ_NA_SETTINGS 32.0F ///< User defined Na setting - /// Payload record structure for dry bicart fill request typedef struct { @@ -147,8 +141,6 @@ static U32 dryBiCartPersistenceStartTime; ///< Dry bicart Persistence time. static U32 drybicartPersistenceOnLowercartPressureStartTime; ///< Dry bicart Persistence on lower cart pressure start time. static BOOL dryBiCartPressureDecayStartTimeFlag; ///< Dry bicart d66 pressure decay start timer. -static BOOL dryBiCartVentCycleWaitTimeStartedFlag; ///< Flag indicating venting cycle timer started for opening D85. -static U32 dryBiCartVentCycleStartTime; ///< Dry bicart Vent cycle start time. static DRY_BICART_OPERATION_T dryBicartStartRequest; ///< Dry bicart operation, fill or supply or drain request static DRY_BICART_OPERATION_T prevDryBicartState; ///< Dry BiCart State Change Tracker @@ -172,8 +164,6 @@ static BICARB_CHAMBER_FILL_EXEC_STATE_T handleBicarbChamberPressureCheckState( void ); static BICARB_CHAMBER_FILL_EXEC_STATE_T handleBicarbChamberSupplyVentStartState(void); static BICARB_CHAMBER_FILL_EXEC_STATE_T handleBicarbChamberSupplyVentEndState(void); -static BOOL isDryBicartChamberFillWindowOpen( void ); -static void closeD65IfBalChamberSwitchImminent( void ); // Drain static DRY_BICART_DRAIN_EXEC_STATE_T handleDryBicartDrainStartState( void ); static DRY_BICART_DRAIN_EXEC_STATE_T handleDryBicartFluidDrainState( void ); @@ -247,9 +237,7 @@ dryBiCartLowerCartPressure.override = OVERRIDE_RESET; dryBiCartPressureDecayStartTimeFlag = FALSE; - dryBiCartVentCycleWaitTimeStartedFlag = FALSE; dryBiCartFillVentTimeOut = FALSE; - dryBiCartVentCycleStartTime = 0; dryBiCartFillStartTime = 0; lastFillDurationInMS = 0; currentFillDurationInMS = 0; @@ -563,46 +551,6 @@ /*********************************************************************//** * @brief - * The isDryBicartChamberFillWindowOpen function checks whether D65 may be - * opened for dry bicarb refill: fresh-side BC valves closed and BC switch not - * within the 50 ms valve-close window. - * @details \b Inputs: getBalChamberFreshSideValvesClosedStatus, isBalChamberSwitchImminent - * @details \b Outputs: none - * @return TRUE when the BC fill is completed and allow D65 to fill Chamber F - *************************************************************************/ -static BOOL isDryBicartChamberFillWindowOpen( void ) -{ - BOOL result = FALSE; - - if ( ( TRUE == getBalChamberFreshSideValvesClosedStatus() ) && - ( FALSE == isBalChamberSwitchImminent() ) ) - { - result = TRUE; - } - - return result; -} - -/*********************************************************************//** - * @brief - * The closeD65IfBalChamberSwitchImminent function closes D65 when the balancing - * chamber is within 100 ms of switching. - * @details \b Inputs: isBalChamberSwitchImminent - * @details \b Outputs: valve states - * @return none - *************************************************************************/ -static void closeD65IfBalChamberSwitchImminent( void ) -{ - if ( TRUE == isBalChamberSwitchImminent() ) - { - setValveState( D65_VALV, VALVE_STATE_CLOSED ); - // Open D80 only in supply state - setValveState( D80_VALV, VALVE_STATE_OPEN ); - } -} - -/*********************************************************************//** - * @brief * The setBicartFillRequested function sets the bicart fill request * flag value to be True. * @details \b Inputs: bicarbChamberFillRequested, dryBiCartDrainRequested, @@ -890,16 +838,16 @@ F32 d66Pressure = getFilteredPressure( D66_PRES ); F32 fillCompletePressure = GET_FILL_COMPLETE_PRESSURE_PSI; - // Close dry bicart inlet water if D66 pressure is equal to fill complete pressure + // Close dry bicart inlet water if D66 pressure is 17 PSI if ( d66Pressure >= fillCompletePressure ) { - // start the persistence timer once d66 reaches fill complete pressure + // start the persistence timer once d66 reaches 17 PSI if ( 0 == dryBiCartPersistenceStartTime ) { dryBiCartPersistenceStartTime = getMSTimerCount(); } - // defined persistence on D66 pressure since pressure overshoot just after D65 opening + // 200 ms persistence on D66 pressure since pressure overshoot just after D65 opening if ( TRUE == didTimeout( dryBiCartPersistenceStartTime, DRY_BICART_PERSISTENCE_DURATION_MS ) ) { setValveState( D65_VALV, VALVE_STATE_CLOSED ); @@ -966,15 +914,15 @@ //Vent chamber F to atmosphere setValveState( D64_VALV, VALVE_STATE_OPEN ); - // D66 pressure drops to below fill vent complete pressure + // D66 pressure drops to below 1.5 PSI if ( ( d66Pressure <= DRY_BICART_FILL_VENT_COMPLETE_PRESSURE_PSI ) ) { - // start the persistence timer once d66 reaches fill vent complete pressure + // start the persistence timer once d66 reaches 1.5 PSI if ( 0 == dryBiCartPersistenceStartTime ) { dryBiCartPersistenceStartTime = getMSTimerCount(); } - // defined persistence on D66 pressure since pressure drop below fill vent complete pressure after opening D64 + // 200 ms persistence on D66 pressure since pressure drop below 1.5 PSI after opening D64 if ( TRUE == didTimeout( dryBiCartPersistenceStartTime, DRY_BICART_PERSISTENCE_DURATION_MS ) ) { setValveState( D85_VALV, VALVE_STATE_CLOSED ); @@ -1098,9 +1046,8 @@ * @brief * The handleBicarbChamberStartState function wait for bicarb chamber fill request * @details \b Inputs: bicarbChamberFillRequested - * @details \b Outputs: dryBiCartVentCycleWaitTimeStartedFlag, dryBiCartPressureDecayStartTimeFlag, - * dryBiCartVentCycleStartTime. - * @return the next drybicart fluid supply state. + * @details \b Outputs: none + * @return the next drybicart fluid drain state. *************************************************************************/ static BICARB_CHAMBER_FILL_EXEC_STATE_T handleBicarbChamberStartState( void ) { @@ -1110,13 +1057,7 @@ if ( TRUE == getU32OverrideValue( &bicarbChamberFillRequested ) ) { - state = BICARB_CHAMBER_SUPPLY_STATE; - - if ( FALSE == dryBiCartVentCycleWaitTimeStartedFlag ) - { - dryBiCartVentCycleWaitTimeStartedFlag = TRUE; - dryBiCartVentCycleStartTime = getMSTimerCount(); - } + state = BICARB_CARTRIDGE_FILL_WATER_START_STATE; } return state; @@ -1130,32 +1071,27 @@ *************************************************************************/ static BICARB_CHAMBER_FILL_EXEC_STATE_T handleBicarbChamberCartridgeFillWaterStartState( void ) { - BICARB_CHAMBER_FILL_EXEC_STATE_T state = BICARB_CARTRIDGE_FILL_WATER_START_STATE; + BICARB_CHAMBER_FILL_EXEC_STATE_T state = BICARB_CARTRIDGE_FILL_WATER_END_STATE; - if ( TRUE == isDryBicartChamberFillWindowOpen() ) - { - // Close vent valves and descaling valve - setValveState( D80_VALV, VALVE_STATE_CLOSED ); - setValveState( D81_VALV, VALVE_STATE_CLOSED ); - setValveState( D85_VALV, VALVE_STATE_CLOSED ); + // Close vent valves and descaling valve + setValveState( D80_VALV, VALVE_STATE_CLOSED ); + setValveState( D81_VALV, VALVE_STATE_CLOSED ); + setValveState( D85_VALV, VALVE_STATE_CLOSED ); - // open inlet water to bicart only when fresh-side BC valves are closed - setValveState( D65_VALV, VALVE_STATE_OPEN ); - setValveState( D64_VALV, VALVE_STATE_OPEN ); + // open inlet water to bicart + setValveState( D65_VALV, VALVE_STATE_OPEN ); + setValveState( D64_VALV, VALVE_STATE_OPEN ); - dryBiCarbSupplyStartTime = getMSTimerCount(); - dryBiCartPersistenceStartTime = 0; + dryBiCarbSupplyStartTime = getMSTimerCount(); + dryBiCartPersistenceStartTime = 0; - state = BICARB_CARTRIDGE_FILL_WATER_END_STATE; - } - return state; } /*********************************************************************//** * @brief - * The handleBicarbChamberCartridgeFillWaterStartState function stops the inlet water to cartridge. - * @details \b Inputs: dryBiCartPersistenceStartTime + * The handleBicarbChamberCartridgeFillWaterStartState function stop water in the dry bicart + * @details \b Inputs: D66 pressure, dryBiCartPersistenceStartTime * @details \b Outputs: valve states * @return the next bicarb chamber check level state. *************************************************************************/ @@ -1164,18 +1100,8 @@ BICARB_CHAMBER_FILL_EXEC_STATE_T state = BICARB_CARTRIDGE_FILL_WATER_END_STATE; F32 d66Pressure = getFilteredPressure( D66_PRES ); F32 fillCompletePressure = GET_FILL_COMPLETE_PRESSURE_PSI; - LVL_STATE_T bicarbChamberLevel = getBicarbChamberLevelStatus(); - if ( FALSE == isDryBicartChamberFillWindowOpen() ) - { - setValveState( D65_VALV, VALVE_STATE_CLOSED ); - } - else if ( TRUE == isDryBicartChamberFillWindowOpen() ) - { - setValveState( D65_VALV, VALVE_STATE_OPEN ); - } - - // check D66 pressure greater than or equal to Fill complete pressure + // check D66 pressure greater than or equal to 17 PSI if ( d66Pressure >= fillCompletePressure ) { // start the persistence timer once d66 reaches 17 PSI @@ -1184,30 +1110,21 @@ dryBiCartPersistenceStartTime = getMSTimerCount(); } - // Defined persistence on D66 pressure since pressure overshoot just after D65 opening only for chamber fill + // 200 ms persistence on D66 pressure since pressure overshoot just after D65 opening if ( TRUE == didTimeout( dryBiCartPersistenceStartTime, DRY_BICART_PERSISTENCE_DURATION_MS ) ) { // Close water inlet valve as D66 pressure reaches 11 PSI after persistence setValveState( D65_VALV, VALVE_STATE_CLOSED ); dryBiCartPersistenceStartTime = 0; - //state = BICARB_CHAMBER_SUPPLY_STATE; - state = BICARB_SUPPLY_VENT_END_STATE; - + state = BICARB_CHAMBER_SUPPLY_STATE; } } else { dryBiCartPersistenceStartTime = 0; } - //Additional code - if ( LVL_STATE_LOW == bicarbChamberLevel ) - { - //Force transition to end state to allow next supply - state = BICARB_SUPPLY_VENT_END_STATE; - } - return state; } @@ -1223,8 +1140,7 @@ BICARB_CHAMBER_FILL_EXEC_STATE_T state = BICARB_CHAMBER_PRESSURE_CHECK_STATE; // TODO: set supply in progress to inform BC control to disable alarm - setValveState( D64_VALV, VALVE_STATE_OPEN ); - + setValveState( D64_VALV, VALVE_STATE_CLOSED ); // Open the Bicarb chamber inlet valve setValveState( D80_VALV, VALVE_STATE_OPEN ); @@ -1240,9 +1156,10 @@ * @brief * The handleBicarbChamberPressureCheckStartState function actuates the vent valve * present in the Bicart assembly. - * @details \b Inputs: dryBiCarbSupplyStartTime, dryBiCarbSypplyVentStartTime, dryBiCartPersistenceStartTime, - * bicarbChamberLevel, dryBiCartPressureDecayStartTimeFlag, drybicartPersistenceOnLowercartPressureStartTime - * @details \b Outputs: dryBiCarbSypplyVentStartTime, valve states + * @details \b Inputs: D66 Pressure, D63 level, dryBiCarbSupplyStartTime, + * dryBiCarbSypplyVentStartTime, dryBiCartPersistenceStartTime, bicarbChamberLevel, + * dryBiCartPressureDecayStartTimeFlag, drybicartPersistenceOnLowercartPressureStartTime + * @details \b Outputs: dryBiCarbSypplyVentStartTime * @return the next bicarb chamber Supply Vent Start state. *************************************************************************/ static BICARB_CHAMBER_FILL_EXEC_STATE_T handleBicarbChamberPressureCheckState( void ) @@ -1251,46 +1168,32 @@ F32 d66Pressure = getFilteredPressure( D66_PRES ); LVL_STATE_T bicarbChamberLevel = getBicarbChamberLevelStatus(); - // Close D65 irrespective of pressure for balancing chamber fresh side fill to complete. - closeD65IfBalChamberSwitchImminent(); - // Once upper level reached high , close the valve, timeout is for safety in case level sensor didn't work(10 sec), or else its a time based filling (3 sec) if ( ( LVL_STATE_HIGH == bicarbChamberLevel ) || ( TRUE == didTimeout( dryBiCarbSupplyStartTime, DRY_BICART_SUPPLY_VALVE_D80_OPEN_TIME_MS ) ) ) { - if ( TRUE == didTimeout( dryBiCartVentCycleStartTime, DRY_BICART_SUPPLY_VENT_CYCLE_TIME_MS ) ) + setValveState( D65_VALV, VALVE_STATE_CLOSED ); + + // start the timer for d66 pressure decay + if( FALSE == dryBiCartPressureDecayStartTimeFlag ) { - // start the timer for d66 pressure decay - if ( FALSE == dryBiCartPressureDecayStartTimeFlag ) + dryBiCarbSupplyStartTime = getMSTimerCount(); + dryBiCartPressureDecayStartTimeFlag = TRUE; + } + // do not close the D80 valve, wait till d66 decays to 3 PSI + if ( TRUE == didTimeout( dryBiCarbSupplyStartTime, DRY_BICART_SUPPLY_COMPLETE_TIME_MS ) ) + { + if ( d66Pressure <= getDryBicartLowerCartPressure() ) { + setValveState( D80_VALV, VALVE_STATE_CLOSED ); + setValveState( D85_VALV, VALVE_STATE_OPEN ); + dryBiCarbSupplyStartTime = getMSTimerCount(); - dryBiCartPressureDecayStartTimeFlag = TRUE; - } - // do not close the D80 valve, wait till d66 decays to supply decay complete pressure - if ( TRUE == didTimeout( dryBiCarbSupplyStartTime, DRY_BICART_SUPPLY_COMPLETE_TIME_MS ) ) - { - if ( d66Pressure <= DRY_BICART_SUPPLY_DECAY_COMPLETE_PRESSURE_PSI ) - { - setValveState( D80_VALV, VALVE_STATE_CLOSED ); - setValveState( D64_VALV, VALVE_STATE_CLOSED ); - setValveState( D85_VALV, VALVE_STATE_OPEN ); + dryBiCarbSypplyVentStartTime = getMSTimerCount(); - dryBiCarbSupplyStartTime = getMSTimerCount(); - dryBiCarbSypplyVentStartTime = getMSTimerCount(); - - state = BICARB_SUPPLY_VENT_START_STATE; - } + state = BICARB_SUPPLY_VENT_START_STATE; } } - else - { - setValveState( D65_VALV, VALVE_STATE_CLOSED ); - setValveState( D80_VALV, VALVE_STATE_CLOSED ); - dryBiCarbSupplyStartTime = getMSTimerCount(); - - state = BICARB_CARTRIDGE_FILL_WATER_START_STATE; - - } } else if ( d66Pressure <= getDryBicartLowerCartPressure() ) { @@ -1299,13 +1202,10 @@ { drybicartPersistenceOnLowercartPressureStartTime = getMSTimerCount(); } - - // defined persistence on D66 pressure - if ( ( TRUE == didTimeout( drybicartPersistenceOnLowercartPressureStartTime, DRY_BICART_PERSISTENCE_DURATION_MS ) ) && - ( TRUE == isDryBicartChamberFillWindowOpen() ) ) + // 200 ms persistence on D66 pressure + if ( TRUE == didTimeout( drybicartPersistenceOnLowercartPressureStartTime, DRY_BICART_PERSISTENCE_DURATION_MS ) ) { setValveState( D65_VALV, VALVE_STATE_OPEN ); - setValveState( D80_VALV, VALVE_STATE_CLOSED ); drybicartPersistenceOnLowercartPressureStartTime = 0; } } @@ -1318,11 +1218,10 @@ dryBiCartPersistenceStartTime = getMSTimerCount(); } - // defined persistence on D66 pressure since pressure overshoot just after D65 opening + // 200 ms persistence on D66 pressure since pressure overshoot just after D65 opening if ( TRUE == didTimeout( dryBiCartPersistenceStartTime, DRY_BICART_PERSISTENCE_DURATION_MS ) ) { setValveState( D65_VALV, VALVE_STATE_CLOSED ); - setValveState( D80_VALV, VALVE_STATE_OPEN ); dryBiCartPersistenceStartTime = 0; } } @@ -1340,7 +1239,7 @@ * The handleBicarbChamberSupplyVentStartState function actuates the vent valve * present in the Bicart assembly. * @details \b Inputs: dryBiCarbSypplyVentStartTime, dryBiCartPersistenceStartTime - * @details \b Outputs: dryBiCarbSypplyVentStartTime, valve states + * @details \b Outputs: dryBiCarbSypplyVentStartTime * @return the next bicarb chamber Supply Vent End state. *************************************************************************/ static BICARB_CHAMBER_FILL_EXEC_STATE_T handleBicarbChamberSupplyVentStartState(void) @@ -1353,20 +1252,20 @@ //Vent chamber F to atmosphere setValveState( D64_VALV, VALVE_STATE_OPEN ); - // D66 pressure drops to below fill vent complete pressure or time out + // D66 pressure drops to below 1.5 PSI or time out if ( ( d66Pressure <= DRY_BICART_FILL_VENT_COMPLETE_PRESSURE_PSI ) ) { - // start the persistence timer once d66 reaches if it drops below fill vent complete pressure + // start the persistence timer once d66 reaches if it drops below 1.5 if ( 0 == dryBiCartPersistenceStartTime ) { dryBiCartPersistenceStartTime = getMSTimerCount(); } - // defined persistence on D66 pressure since pressure overshoot just after D65 opening + // 200 ms persistence on D66 pressure since pressure overshoot just after D65 opening if ( TRUE == didTimeout( dryBiCartPersistenceStartTime, DRY_BICART_PERSISTENCE_DURATION_MS ) ) { setValveState( D85_VALV, VALVE_STATE_CLOSED ); dryBiCartPersistenceStartTime = 0; - dryBiCartVentCycleWaitTimeStartedFlag = FALSE; + state = BICARB_SUPPLY_VENT_END_STATE; } } @@ -1375,7 +1274,6 @@ setValveState( D85_VALV, VALVE_STATE_CLOSED ); dryBiCartPersistenceStartTime = 0; dryBiCartFillVentTimeOut = TRUE; - dryBiCartVentCycleWaitTimeStartedFlag = FALSE; state = BICARB_SUPPLY_VENT_END_STATE; } @@ -1721,7 +1619,7 @@ * @details \b Outputs: dryBiCartDataPublishInterval * @param Override message from Dialin which includes the interval * (in ms) to override the DD dry bicart data publish interval to. - * @return TRUE if override successful, FALSE if not. + * @return TRUE if override successful, FALSE if not *************************************************************************/ BOOL testDryBiCartDataPublishIntervalOverride( MESSAGE_T *message ) { Index: firmware/App/Controllers/Heaters.c =================================================================== diff -u -r96f8a305d3253904a4355cae78614a9333249896 -r095866efd8f10bdead490578e7584051d79292f0 --- firmware/App/Controllers/Heaters.c (.../Heaters.c) (revision 96f8a305d3253904a4355cae78614a9333249896) +++ firmware/App/Controllers/Heaters.c (.../Heaters.c) (revision 095866efd8f10bdead490578e7584051d79292f0) @@ -78,7 +78,6 @@ #define HEATERS_MAX_VOLTAGE_OUT_OF_RANGE_TOL 0.2F ///< Heaters max voltage out of range tolerance. #define D5_HEATER_DEADBAND_CONTROL 0.1F ///< Heater dead band range for control. -//#define D5_HEAT_CONTROL_INTERVAL_MS 30000 /// Primary heater control interval in milli seconds #define D5_HEAT_CONTROL_INTERVAL_MS 3000 /// Primary heater control interval in milli seconds #define D5_HEAT_CONTROL_INTERVAL_COUNT ( D5_HEAT_CONTROL_INTERVAL_MS / TASK_GENERAL_INTERVAL ) ///< Primary heater control interval count. #define D45_HEAT_CONTROL_INTERVAL_MS ( 1 * MS_PER_SECOND ) ///< Trimmer heater control interval in milli seconds @@ -607,7 +606,9 @@ if ( ++primaryTargetTempAdjCounter >= d5OuterLoopControlInterval ) { #ifdef __USE_D1_TEMP_ + // Use new RTD sensor placed closed to dialyzer, connected to D1 port + measuredTempAtDialyzer = getFilteredTemperatureValue( D1_TEMP ); #else if ( TRUE == getTestConfigStatus( TEST_CONFIG_DD_FP_ENABLE_BETA_1_9_HW ) ) @@ -888,18 +889,7 @@ isLevelLow = ( ( getLevelStatus( D46_LEVL ) != LEVEL_STATE_LOW ) ? FALSE : TRUE ); } - // Disable alarm if test config enabled for D45 heater conductive level check. - if ( D5_HEAT == heater ) - { - checkPersistentAlarm( alarm, isLevelLow, 0.0F, 0.0F ); - } - else - { - if ( getTestConfigStatus( TEST_CONFIG_DD_DISABLE_CONDUCTIVE_LEVEL_SENSOR_ERROR ) != TRUE ) - { - checkPersistentAlarm( alarm, isLevelLow, 0.0F, 0.0F ); - } - } + checkPersistentAlarm( alarm, isLevelLow, 0.0F, 0.0F ); } else { Index: firmware/App/Controllers/MixingControl.c =================================================================== diff -u -rfc6a157a48debd4ee8c2fb8dec8af21f5b07abe2 -r095866efd8f10bdead490578e7584051d79292f0 --- firmware/App/Controllers/MixingControl.c (.../MixingControl.c) (revision fc6a157a48debd4ee8c2fb8dec8af21f5b07abe2) +++ firmware/App/Controllers/MixingControl.c (.../MixingControl.c) (revision 095866efd8f10bdead490578e7584051d79292f0) @@ -46,8 +46,8 @@ #define MIXING_CONTROL_DATA_PUBLISH_INTERVAL ( 250 / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the mixing control data published. // drybicarb mixing -#define BICARB_VOL_CONTROL_P_COEFFICIENT ( 0.00008484F ) ///< Bicarb proportional gain (kp) -#define BICARB_VOL_CONTROL_I_COEFFICIENT ( 0.00033936F / 8 ) ///< Bicarb integral gain. (ki) +#define BICARB_VOL_CONTROL_P_COEFFICIENT ( 0.00008484F * 2 ) ///< Bicarb proportional gain (kp) +#define BICARB_VOL_CONTROL_I_COEFFICIENT ( 0.00033936F / 4 ) ///< Bicarb integral gain. (ki) #define MIN_BICARB_VOLUME_ML 0.4F ///< Minimum bicarb volume in mL #define MAX_BICARB_VOLUME_ML 1.8F ///< Maximum bicarb volume in mL @@ -69,11 +69,11 @@ #define MIX_NO_FEED_FORWARD 0.0F ///< Feed forward term for dialysate closed loop control -#define BICARB_MIX_CONTROL_INTERVAL_MULTIPLIER ( 3 * MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the bicarb mix is controlled. -#define ACID_MIX_CONTROL_INTERVAL_MULTIPLIER ( 5 * MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the dialysate mix is controlled. +#define BICARB_MIX_CONTROL_INTERVAL ( 9 * MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the bicarb mix is controlled. +#define ACID_MIX_CONTROL_INTERVAL ( 15 * MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the dialysate mix is controlled. -#define BICARB_DEADBAND_CONTROL 30.0F ///< Bicarb dead band control -#define ACID_DEADBAND_CONTROL 70.0F ///< Acid dead band control +#define BICARB_DEADBAND_CONTROL 15.0F ///< Bicarb dead band control +#define ACID_DEADBAND_CONTROL 50.0F ///< Acid dead band control // Proportioning Ratios: 1 Part Acid : 1.72 Parts Bicarb : 42.28 Parts Water // Total parts = 1 + 1.72 + 42.28 = 45.0 @@ -121,8 +121,6 @@ #define FINAL_BICARB_MIX ( BICARB_MIX_VOLUME_ML * BICARB_PERCENT_CHANGE ) ///< Final bicarb mix volume -#define FINAL_BICARB_MIX_VOLUME_UPDATE ( FINAL_BICARB_MIX / 1.25 ) - #define BICARB_CONDUCTIVITY_PRE ( STD_DILUTION_BICARB_POST_MIX_NA * BICARB_PERCENT_CHANGE * getTDBicarbConversionFactor() ) ///< Theoretical bicarb conductivity pre mix #define BICARB_CONDUCTIVITY_POST ( STD_DILUTION_BICARB_POST_MIX_CHO3 * BICARB_PERCENT_CHANGE * getTDBicarbConversionFactor() ) ///< Theoretical bicarb conductivity post mix @@ -203,7 +201,6 @@ static void setBicarbMixVol( F32 targetValue ); static void setAcidMixVol( F32 targetValue ); -static void updatedCMixingControlInterval( void ); static F32 getBicarbDeltaConductivity( void ); static F32 getBicarbTargetConductivity( void ); @@ -255,8 +252,8 @@ mixingControlAcidVolume.ovInitData = 0.0F; mixingControlAcidVolume.override = OVERRIDE_RESET; - mixingControlBicarbVolume.data = FINAL_BICARB_MIX_VOLUME_UPDATE; - mixingControlBicarbVolume.ovData = FINAL_BICARB_MIX_VOLUME_UPDATE; + mixingControlBicarbVolume.data = FINAL_BICARB_MIX; + mixingControlBicarbVolume.ovData = FINAL_BICARB_MIX; mixingControlBicarbVolume.ovInitData = 0.0F; mixingControlBicarbVolume.override = OVERRIDE_RESET; @@ -315,19 +312,19 @@ mixingControlTargetAdjBicarbSettings.ovInitData = 0.0F; mixingControlTargetAdjBicarbSettings.override = OVERRIDE_RESET; - mixingControlBicarbControlInterval.data = BICARB_MIX_CONTROL_INTERVAL_MULTIPLIER; - mixingControlBicarbControlInterval.ovData = BICARB_MIX_CONTROL_INTERVAL_MULTIPLIER; + mixingControlBicarbControlInterval.data = BICARB_MIX_CONTROL_INTERVAL; + mixingControlBicarbControlInterval.ovData = BICARB_MIX_CONTROL_INTERVAL; mixingControlBicarbControlInterval.ovInitData = 0; mixingControlBicarbControlInterval.override = OVERRIDE_RESET; - mixingControlAcidControlInterval.data = ACID_MIX_CONTROL_INTERVAL_MULTIPLIER; - mixingControlAcidControlInterval.ovData = ACID_MIX_CONTROL_INTERVAL_MULTIPLIER; + mixingControlAcidControlInterval.data = ACID_MIX_CONTROL_INTERVAL; + mixingControlAcidControlInterval.ovData = ACID_MIX_CONTROL_INTERVAL; mixingControlAcidControlInterval.ovInitData = 0; mixingControlAcidControlInterval.override = OVERRIDE_RESET; mixingControlDataPublicationTimerCounter = 0; - mixingControlLastBicarbMixVolume = 0.0F; - mixingControlLastAcidMixVolume = 0.0F; + mixingControlLastBicarbMixVolume = 0; + mixingControlLastAcidMixVolume = 0; initializePIController( PI_CONTROLLER_ID_BICARB_VOL, 0.0F,\ getBicarbKpGainCoefficient(), getBicarbKiGainCoefficient(),\ @@ -364,8 +361,6 @@ { if ( getCurrentBalancingChamberExecState() > BAL_CHAMBER_STATE_IDLE ) { - updatedCMixingControlInterval(); - // closed loop bicarb and acid mixing controller handleDialysateCompositionMixing(); } @@ -432,36 +427,6 @@ /*********************************************************************//** * @brief - * The updatedCMixingControlInterval function sets both acid and bicarb - * Mix volume provided by the controller - * @details \b Inputs: none - * @details \b Outputs: mixingControlBicarbMixVolume - * @param targetValue bicarb Mix volume - * @return TRUE if successful, FALSE if not. - *************************************************************************/ -static void updatedCMixingControlInterval( void ) -{ - F32 tdDialysateFlowRate = 0.0F; - F32 balChamberSwitchingFreq = 0.0F; - U32 balChamberSwitchingPeriod = 0; - - tdDialysateFlowRate = getTDDialysateFlowrate(); - - balChamberSwitchingFreq = tdDialysateFlowRate / 30.0; - balChamberSwitchingPeriod = ( SEC_PER_MIN ) / (U32)balChamberSwitchingFreq; - - // For acid control period, we are using 3 cycles of balancing chamber switching period (for ex: At Qd = 600, switching period = 3sec, so acid control interval = 3*3 = 9sec - // For bicarb control period, we are using 5 cycles of balancing chamber switching period (for ex: At Qd = 600, switching period = 3sec, so bicarb control interval = 3*5 = 15sec - - if ( balChamberSwitchingPeriod > 0) - { - mixingControlAcidControlInterval.data = ACID_MIX_CONTROL_INTERVAL_MULTIPLIER * balChamberSwitchingPeriod; - mixingControlBicarbControlInterval.data = BICARB_MIX_CONTROL_INTERVAL_MULTIPLIER * balChamberSwitchingPeriod; - } -} - -/*********************************************************************//** - * @brief * The getBicarbDeltaConductivity function gets the delta target conductivity * @details \b Inputs: mixingControlBicarbDeltaConductivity * @details \b Outputs: none @@ -1149,7 +1114,7 @@ *************************************************************************/ BOOL testMixingControlBicarbControlIntervalOverride( MESSAGE_T *message ) { - BOOL result = u32Override( message, &mixingControlBicarbControlInterval, 0, BICARB_MIX_CONTROL_INTERVAL_MULTIPLIER ); + BOOL result = u32Override( message, &mixingControlBicarbControlInterval, 0, BICARB_MIX_CONTROL_INTERVAL ); return result; } @@ -1166,7 +1131,7 @@ *************************************************************************/ BOOL testMixingControlAcidControlIntervalOverride( MESSAGE_T *message ) { - BOOL result = u32Override( message, &mixingControlAcidControlInterval, 0, ACID_MIX_CONTROL_INTERVAL_MULTIPLIER ); + BOOL result = u32Override( message, &mixingControlAcidControlInterval, 0, BICARB_MIX_CONTROL_INTERVAL ); return result; } Index: firmware/App/Controllers/MixingControl.h =================================================================== diff -u -rfc6a157a48debd4ee8c2fb8dec8af21f5b07abe2 -r095866efd8f10bdead490578e7584051d79292f0 --- firmware/App/Controllers/MixingControl.h (.../MixingControl.h) (revision fc6a157a48debd4ee8c2fb8dec8af21f5b07abe2) +++ firmware/App/Controllers/MixingControl.h (.../MixingControl.h) (revision 095866efd8f10bdead490578e7584051d79292f0) @@ -65,16 +65,16 @@ // ********** public function prototypes ********** -void initMixingControl( void ); -void execMixingControl( void ); + void initMixingControl( void ); + void execMixingControl( void ); F32 getBicarbMixVol( void ); F32 getAcidMixVol( void ); BOOL testMixingControlDataPublishIntervalOverride( MESSAGE_T *message ); -BOOL testMixingControlAcidMixVolumeOverride( MESSAGE_T *message ); -BOOL testMixingControlBicarbMixVolumeOverride( MESSAGE_T *message ); +BOOL testMixingControlAcidVolumeOverride( MESSAGE_T *message ); +BOOL testMixingControlBicarbVolumeOverride( MESSAGE_T *message ); BOOL testMixingControlBicarbVolControlKpGainOverride( MESSAGE_T *message ); BOOL testMixingControlBicarbVolControlKiGainOverride( MESSAGE_T *message ); Index: firmware/App/Controllers/RinsePump.c =================================================================== diff -u -r35ccc443e6440d79231ab4a3951bebc0e9789b68 -r095866efd8f10bdead490578e7584051d79292f0 --- firmware/App/Controllers/RinsePump.c (.../RinsePump.c) (revision 35ccc443e6440d79231ab4a3951bebc0e9789b68) +++ firmware/App/Controllers/RinsePump.c (.../RinsePump.c) (revision 095866efd8f10bdead490578e7584051d79292f0) @@ -277,11 +277,6 @@ if ( TRUE == getTestConfigStatus( TEST_CONFIG_DD_FP_ENABLE_BETA_1_9_HW ) ) { - // Current Beta 1.9 system uses on/off bit - setValveState( D88_79_VALV, VALVE_STATE_CLOSED ); - } - else - { F32 pwmPercent; // Set PWM to zero to stop the logical rinse pump @@ -290,6 +285,11 @@ pwmPercent = rinsePumpPwmPercentage.data; setRinsePumpPwm( D79_RINSE_PUMP, pwmPercent ); } + else + { + // Set PWM count zero to stop the logical rinse pump + setRinsePumpPwm( D79_RINSE_PUMP, RINSE_PUMP_OFF_COUNT ); + } return state; } @@ -307,11 +307,6 @@ if ( TRUE == getTestConfigStatus( TEST_CONFIG_DD_FP_ENABLE_BETA_1_9_HW ) ) { - // Current Beat 1.9 system uses on/off bit - setValveState( D88_79_VALV, VALVE_STATE_OPEN ); - } - else - { F32 pwmPercent; rinsePumpPwmPercentage.data = RINSE_PUMP_DEFAULT_PWM_PERCENT; Index: firmware/App/Controllers/Valves.c =================================================================== diff -u -r520b5b97e2a1a6d7af037e1144f1ffeb39153e3e -r095866efd8f10bdead490578e7584051d79292f0 --- firmware/App/Controllers/Valves.c (.../Valves.c) (revision 520b5b97e2a1a6d7af037e1144f1ffeb39153e3e) +++ firmware/App/Controllers/Valves.c (.../Valves.c) (revision 095866efd8f10bdead490578e7584051d79292f0) @@ -62,7 +62,6 @@ static U32 valveStateMismatchTimerCounter; ///< Initialize valve state mismatch timer. static U32 pendingValveStateChanges[ DD_NUM_OF_VALVES ]; ///< Delayed (pending) valve state changes. static U32 pendingValveStateChangeCountDowns[ DD_NUM_OF_VALVES ]; ///< Delayed (pending) valve state change count down timers (in task intervals). -static RECOVERY_STATE_T recoveryState; ///< IOFP valve recovery setting. static OVERRIDE_U32_T valveStates[ DD_NUM_OF_VALVES ]; ///< Currently commanded valves states. static OVERRIDE_U32_T valveSensedStates[ DD_NUM_OF_VALVES ]; ///< Valve sensed states override. @@ -625,18 +624,6 @@ /*********************************************************************//** * @brief - * The getRecoveryState function gets the current valve recovery state. - * @details \b Inputs: recoveryState - * @details \b Outputs: recoveryState - * @return the current valve recovery state. - *************************************************************************/ -RECOVERY_STATE_T getRecoveryState( void ) -{ - return recoveryState; -} - -/*********************************************************************//** - * @brief * The publishValvesStates function publishes DD valves states at the set interval. * @details \b Inputs: valvesStatesPublicationTimerCounter * @details \b Outputs: valvesStatesPublicationTimerCounter Index: firmware/App/DDCommon.h =================================================================== diff -u -re4ebc712939ba8ab586a577176089bce772276a6 -r095866efd8f10bdead490578e7584051d79292f0 --- firmware/App/DDCommon.h (.../DDCommon.h) (revision e4ebc712939ba8ab586a577176089bce772276a6) +++ firmware/App/DDCommon.h (.../DDCommon.h) (revision 095866efd8f10bdead490578e7584051d79292f0) @@ -25,7 +25,7 @@ #define DD_VERSION_MAJOR 0 #define DD_VERSION_MINOR 0 #define DD_VERSION_MICRO 0 -#define DD_VERSION_BUILD 181 +#define DD_VERSION_BUILD 99 // ********** development build switches ********** @@ -48,9 +48,6 @@ //Uncomment below for bicarb chamber filling //#define __BICARB_CHAMBER_FILL__ 1 -//UnComment below for DryBicarb testing -//#define __DRY_BICARB__ 1 - //Uncomment below to disable heaters debug message #define __HEATERS_DEBUG__ 1 Index: firmware/App/Drivers/ConductivitySensors.c =================================================================== diff -u -r75f32cd59369b07708e2d1118ea3695872484e31 -r095866efd8f10bdead490578e7584051d79292f0 --- firmware/App/Drivers/ConductivitySensors.c (.../ConductivitySensors.c) (revision 75f32cd59369b07708e2d1118ea3695872484e31) +++ firmware/App/Drivers/ConductivitySensors.c (.../ConductivitySensors.c) (revision 095866efd8f10bdead490578e7584051d79292f0) @@ -52,7 +52,7 @@ #define MAX_CONDUCTIVITY_SENSOR_FAILURES 2 ///< Number of failures before alarming in timed window count. #define MAX_CONDUCTIVITY_SENSOR_FAILURE_WINDOW_MS ( 60 * MS_PER_SECOND ) ///< Set time for timed window count. -#define MAX_ALLOWED_UNCHANGED_CONDUCTIVITY_READS ( 800 / TASK_PRIORITY_INTERVAL ) ///< New reading every 333ms, expect to get valid new reading in 500ms. +#define MAX_ALLOWED_UNCHANGED_CONDUCTIVITY_READS ( 500 / TASK_PRIORITY_INTERVAL ) ///< New reading every 333ms, expect to get valid new reading in 500ms. #define COND_SENSORS_FPGA_ERROR_TIMEOUT_MS ( 2 * MS_PER_SECOND ) ///< Conductivity sensors FPGA error timeout in milliseconds. #define COND_SENSORS_READ_ERR_MAX_CNT 255 ///< Conductivity sensors read and error count max value. @@ -140,6 +140,7 @@ *************************************************************************/ void initConductivitySensors( void ) { + /// TODO: Revert back to init state. currentConductivityState = CONDUCTIVITY_INIT_STATE; CONDUCTIVITY_SENSORS_T sensor; @@ -215,7 +216,6 @@ initFPGAPersistentAlarm( FPGA_PERS_ERROR_D74_COND_SENSOR, ALARM_ID_DD_D74_COND_SENSOR_FPGA_FAULT, COND_SENSORS_FPGA_ERROR_TIMEOUT_MS, COND_SENSORS_FPGA_ERROR_TIMEOUT_MS ); initFPGAPersistentAlarm( FPGA_PERS_ERROR_P9_COND_SENSOR, ALARM_ID_FP_P9_COND_SENSOR_FPGA_FAULT, COND_SENSORS_FPGA_ERROR_TIMEOUT_MS, COND_SENSORS_FPGA_ERROR_TIMEOUT_MS ); initFPGAPersistentAlarm( FPGA_PERS_ERROR_P18_COND_SENSOR, ALARM_ID_FP_P18_COND_SENSOR_FPGA_FAULT, COND_SENSORS_FPGA_ERROR_TIMEOUT_MS, COND_SENSORS_FPGA_ERROR_TIMEOUT_MS ); - } /*********************************************************************//** @@ -1095,7 +1095,6 @@ break; } } - calculateResistance( sensorNum, isFPSensor ); calculateTemperature( sensorNum ); @@ -1411,5 +1410,4 @@ return result; } - /**@}*/ Index: firmware/App/Drivers/TemperatureSensors.c =================================================================== diff -u -r2c03afdfe1161cfdca00fc2318e23eb4ca670fd7 -r095866efd8f10bdead490578e7584051d79292f0 --- firmware/App/Drivers/TemperatureSensors.c (.../TemperatureSensors.c) (revision 2c03afdfe1161cfdca00fc2318e23eb4ca670fd7) +++ firmware/App/Drivers/TemperatureSensors.c (.../TemperatureSensors.c) (revision 095866efd8f10bdead490578e7584051d79292f0) @@ -381,9 +381,8 @@ //TODO: revert back once issue resolved //checkPersistentAlarm( ALARM_ID_DD_TEMPERATURE_SENSOR_OUT_OF_RANGE, isTemperatureOutOfRange, sensorInAlarm, alarmTemperature ); - //TODO: revert back once issue resolved //check freshness of temperature read - //checkTemperatureSensors(); + checkTemperatureSensors(); } /*********************************************************************//** Index: firmware/App/Modes/FPModes/ModePreGenPermeate.c =================================================================== diff -u -rbc22e4fbb56800101e22ac1752c2f1b67541ba02 -r095866efd8f10bdead490578e7584051d79292f0 --- firmware/App/Modes/FPModes/ModePreGenPermeate.c (.../ModePreGenPermeate.c) (revision bc22e4fbb56800101e22ac1752c2f1b67541ba02) +++ firmware/App/Modes/FPModes/ModePreGenPermeate.c (.../ModePreGenPermeate.c) (revision 095866efd8f10bdead490578e7584051d79292f0) @@ -203,6 +203,7 @@ { setBoostPumpTargetPressure( VERIFY_WATER_BOOST_PUMP_TGT_PSI ); } + //TODO change target flow to 750 + rinse pump rate setROPumpTargetFlowRateMLPM( VERIFY_WATER_RO_PUMP_TGT_FLOW_ML, TRUE ); verifyWaterTimer = getMSTimerCount(); break; Index: firmware/App/Modes/FPModes/StateFlushPermeate.c =================================================================== diff -u -r27dab35610123b728c64b9db11967c95a45a2b01 -r095866efd8f10bdead490578e7584051d79292f0 --- firmware/App/Modes/FPModes/StateFlushPermeate.c (.../StateFlushPermeate.c) (revision 27dab35610123b728c64b9db11967c95a45a2b01) +++ firmware/App/Modes/FPModes/StateFlushPermeate.c (.../StateFlushPermeate.c) (revision 095866efd8f10bdead490578e7584051d79292f0) @@ -262,6 +262,7 @@ { setBoostPumpTargetPressure( PERMEATE_FLUSH_BOOST_PUMP_TGT_PSI ); } + //TODO update target macro after changing it to 750 + rinse pump rate setROPumpTargetFlowRateMLPM( PERMEATE_FLUSH_RO_PUMP_TGT_ML, TRUE ); permeateFlushTimer = getMSTimerCount(); permeateFlushAlarmTimer = getMSTimerCount(); Index: firmware/App/Modes/ModeGenDialysate.c =================================================================== diff -u -r9e0db1f82f13693d251e00e8958c8063dd89cae6 -r095866efd8f10bdead490578e7584051d79292f0 --- firmware/App/Modes/ModeGenDialysate.c (.../ModeGenDialysate.c) (revision 9e0db1f82f13693d251e00e8958c8063dd89cae6) +++ firmware/App/Modes/ModeGenDialysate.c (.../ModeGenDialysate.c) (revision 095866efd8f10bdead490578e7584051d79292f0) @@ -61,11 +61,11 @@ #define ZERO_DIAL_FLOW_RATE 0.0F ///< Zero dialysate flow rate #define SPENT_CHAMBER_FILL_MAX_COUNT 10 ///< Total number of spent chamber fill allowed. #define BICARB_CHAMBER_FILL_TIMEOUT ( 1 * MS_PER_SECOND ) ///< Bicarb chamber fill timeout. + #define PUMP_SPEED_SLOPE_FACTOR_DIENER_2000 1.24F ///< D48 Diener 2000 pump speed slope (y = 1.24x + 30). #define PUMP_SPEED_INTERCEPT_FACTOR_DIENER_2000 30.0F ///< D48 Diener 2000 pump speed intercept. #define PUMP_SPEED_SLOPE_FACTOR_DIENER_1000 2.869F ///< D48 Diener 1000 pump speed slope (y = 2.869x + 25.956). #define PUMP_SPEED_INTERCEPT_FACTOR_DIENER_1000 25.956F ///< D48 Diener 1000 pump speed intercept. - #define BICARB_CHAMBER_FILL_TIMEOUT ( 1 * MS_PER_SECOND ) ///< Bicarb chamber fill timeout. //Testing @@ -270,7 +270,7 @@ startHeater( D5_HEAT ); //Turn on Trimmer heater - if ( TRUE == getTestConfigStatus( TEST_CONFIG_DD_FP_ENABLE_BETA_1_0_HW ) ) + if ( getTestConfigStatus( TEST_CONFIG_DD_FP_ENABLE_BETA_1_0_HW ) == TRUE ) { setHeaterTargetTemperature( D45_HEAT, getFilteredTemperatureValue( D4_TEMP ) ); } @@ -319,7 +319,7 @@ startHeater( D5_HEAT ); //Turn on Trimmer heater - if ( TRUE == getTestConfigStatus( TEST_CONFIG_DD_FP_ENABLE_BETA_1_0_HW ) ) + if ( getTestConfigStatus( TEST_CONFIG_DD_FP_ENABLE_BETA_1_0_HW ) == TRUE ) { setHeaterTargetTemperature( D45_HEAT, getFilteredTemperatureValue( D4_TEMP ) ); } @@ -704,28 +704,14 @@ { U32 rpm; U32 nominalRpm; - F32 dialFlowRate = getBalChamberActiveDialysateFlowrate(); nominalRpm = getD48PumpSpeed(); rpm = nominalRpm; -// if ( nominalRpm <= BAL_CHAMBER_TIME_BASED_D48_SPEED_RPM ) -// { -// rpm = BAL_CHAMBER_TIME_BASED_D48_SPEED_RPM; -// } - - if ( ( dialFlowRate >= BAL_CHAMBER_OPEN_LOOP_FLOW_RATE_BAND_1 ) && ( dialFlowRate <= BAL_CHAMBER_OPEN_LOOP_FLOW_RATE_BAND_2 ) ) + if ( nominalRpm <= BAL_CHAMBER_TIME_BASED_D48_SPEED_RPM ) { - rpm = BAL_CHAMBER_TIME_BASED_BAND_1; + rpm = BAL_CHAMBER_TIME_BASED_D48_SPEED_RPM; } - else if ( ( dialFlowRate > BAL_CHAMBER_OPEN_LOOP_FLOW_RATE_BAND_2 ) && ( dialFlowRate <= BAL_CHAMBER_OPEN_LOOP_FLOW_RATE_BAND_3 ) ) - { - rpm = BAL_CHAMBER_TIME_BASED_BAND_2; - } - else if ( ( dialFlowRate > BAL_CHAMBER_OPEN_LOOP_FLOW_RATE_BAND_3 ) && ( dialFlowRate <= BAL_CHAMBER_OPEN_LOOP_FLOW_RATE_BAND_4 ) ) - { - rpm = BAL_CHAMBER_TIME_BASED_BAND_3; - } return rpm; } Index: firmware/App/Modes/ModeGenDialysate.h =================================================================== diff -u -rf1dc3383b840c39f202b15679e0bbe2b2f7a2f83 -r095866efd8f10bdead490578e7584051d79292f0 --- firmware/App/Modes/ModeGenDialysate.h (.../ModeGenDialysate.h) (revision f1dc3383b840c39f202b15679e0bbe2b2f7a2f83) +++ firmware/App/Modes/ModeGenDialysate.h (.../ModeGenDialysate.h) (revision 095866efd8f10bdead490578e7584051d79292f0) @@ -32,7 +32,7 @@ // ********** public definitions ********** #define FRESH_DIAL_PUMP_INITIAL_RPM 2500 ///< Nominal RPM target for fresh dialysate pump to maintain required pressure. -#define FRESH_DIAL_PUMP_INITIAL_RPM_B1_9_B2_0 1600 ///< Nominal RPM target for fresh dialysate pump for beta 1.9 and 2.0 hardware. +#define FRESH_DIAL_PUMP_INITIAL_RPM_B1_9_B2_0 1250 ///< Nominal RPM target for fresh dialysate pump for beta 1.9 and 2.0 hardware. #define SPENT_DIAL_PUMP_INITIAL_RPM 2300 ///< Nominal RPM target for spent dialysate pump to maintain required pressure. #define DIAL_PUMP_DRAIN_RPM 1000 ///< Nominal RPM target for dialysate pump to drain the dry bicart. #define SPENT_DIAL_PUMP_FILL_RPM 200 ///< Nominal RPM target for spent chamber fill operations. Index: firmware/App/Monitors/Conductivity.c =================================================================== diff -u -r483ebbb75171ec93ab24d1f69f83a6248376266f -r095866efd8f10bdead490578e7584051d79292f0 --- firmware/App/Monitors/Conductivity.c (.../Conductivity.c) (revision 483ebbb75171ec93ab24d1f69f83a6248376266f) +++ firmware/App/Monitors/Conductivity.c (.../Conductivity.c) (revision 095866efd8f10bdead490578e7584051d79292f0) @@ -17,14 +17,12 @@ #include // Used for calculating the polynomial calibration equation. #include // For memcpy -#include "BalancingChamber.h" #include "Conductivity.h" #include "MessageSupport.h" #include "Messaging.h" #include "ModeGenPermeate.h" #include "OperationModes.h" #include "TaskPriority.h" -#include "TDInterface.h" #include "Utilities.h" /** @@ -40,9 +38,9 @@ #define FP_CONDUCTIVITY_DATA_PUBLISH_COUNTER_START_COUNT 41 ///< FP Conductivity data publish counter start count. #define RO_DATA_PUBLISH_COUNTER_START_COUNT 42 ///< FP RO Data publish counter start count. #define RESISTANCE_DATA_PUBLISH_COUNTER_START_COUNT 43 ///< DD Resistance data publish counter start count. -#define CONDUCTIVITY_MAX_FILTER_SIZE_MULTIPLIER ( 252 ) ///< Maximum conductivity filter sample count (At 50qd, we switch once for every 36sec, so 36 * FILTER_SIZE_MULTIPLIER = 252). +#define CONDUCTIVITY_SAMPLE_FILTER_MS ( 210 ) ///< Filter conductivity data for given time. Currently set to have 5 samples over 3.5s ( 700ms sample rate ) #define CONDUCTIVITY_TEMP_SAMPLE_FILTER_MS ( 30 ) ///< Filter conductivity temperature data for given time. Currently set to have 5 samples over 3.5s ( 700ms sample rate ) -#define FILTER_SIZE_MULTIPLIER ( 7 ) ///< Conductivity filter size multiplier. +#define SIZE_OF_COND_ROLLING_AVG ( CONDUCTIVITY_SAMPLE_FILTER_MS / TASK_PRIORITY_INTERVAL ) ///< Filtered conductivity moving average sample count. #define SIZE_OF_COND_TEMP_ROLLING_AVG ( CONDUCTIVITY_TEMP_SAMPLE_FILTER_MS / TASK_PRIORITY_INTERVAL ) ///< Filtered conductivity temprature moving average sample count. #define RO_RR_MOVING_AVG_NUM_OF_SAMPLES 30 ///< RO rejection ratio moving average number of samples. #define FRACTION_TO_PERCENT_CONVERSION_FACTOR 100.0F ///< RO rejection ratio factor to percentage conversion factor value @@ -51,7 +49,7 @@ /// Filter conductivity readings record. typedef struct { - F32 conductivityReadings[ CONDUCTIVITY_MAX_FILTER_SIZE_MULTIPLIER ]; ///< Holds conductivity sample rolling average. + F32 conductivityReadings[ SIZE_OF_COND_ROLLING_AVG ]; ///< Holds conductivity sample rolling average. U32 conductivityReadingsIdx; ///< Index for next sample in rolling average array. F32 conductivityReadingsTotal; ///< Rolling total - used to calc average. U32 conductivityReadingsCount; ///< Number of samples in rolling average buffer @@ -91,7 +89,6 @@ static U32 roRRCount; ///< RO rejection ratio Number of samples in average buffer. static F32 roRRTankFillAvg; ///< Average RO rejection ratio during permeate tank fill state. static U32 roRRSampleIntervalCounter; ///< RO rejection ratio sample collection timer counter. -static U32 conductivityFilterSize; ///< Active conductivity filter sample count. // ********** private function prototypes ********** @@ -101,9 +98,6 @@ static void filterConductivitySensorTemperatureReadings( void ); static void calcRORejectionRatio( void ); static void filterRORejectionRatioReadings( void ); -static void broadcastResistanceData( void ); -static U32 getConductivityFilterSize( void ); -static void resetConductivityFilterReadings( void ); /*********************************************************************//** * @brief @@ -133,7 +127,6 @@ roRRAvg.ovInitData = 0.0F; roRRAvg.override = OVERRIDE_RESET; roRRSampleIntervalCounter = 0; - conductivityFilterSize = FILTER_SIZE_MULTIPLIER; memset( &roRRSamples, 0, sizeof( roRRSamples ) ); @@ -297,15 +290,8 @@ CONDUCTIVITY_SENSORS_T sensor; F32 calculatedConductivity = 0.0F; F32 uncompenstatedConductivity = 0.0F; - U32 activeFilterSize = getConductivityFilterSize(); BOOL freshData = FALSE; - if ( conductivityFilterSize != activeFilterSize ) - { - conductivityFilterSize = activeFilterSize; - resetConductivityFilterReadings(); - } - for ( sensor = FIRST_DD_COND_SENSOR; sensor < NUM_OF_CONDUCTIVITY_SENSORS; sensor++ ) { if ( getTestConfigStatus( TEST_CONFIG_DD_FP_ENABLE_BETA_1_9_HW ) == TRUE ) @@ -338,24 +324,24 @@ { freshData = FALSE; // TODO - calibrate - if ( filteredConductivityReadings[ sensor ].conductivityReadingsCount >= conductivityFilterSize ) + if ( filteredConductivityReadings[ sensor ].conductivityReadingsCount >= SIZE_OF_COND_ROLLING_AVG ) { filteredConductivityReadings[ sensor ].conductivityReadingsTotal -= filteredConductivityReadings[ sensor ].conductivityReadings[ filteredConductivityReadings[ sensor ].conductivityReadingsIdx ]; } filteredConductivityReadings[ sensor ].conductivityReadings[ filteredConductivityReadings[ sensor ].conductivityReadingsIdx ] = calculatedConductivity; filteredConductivityReadings[ sensor ].conductivityReadingsTotal += calculatedConductivity; - filteredConductivityReadings[ sensor ].conductivityReadingsIdx = INC_WRAP( filteredConductivityReadings[ sensor ].conductivityReadingsIdx, 0, conductivityFilterSize - 1 ); - filteredConductivityReadings[ sensor ].conductivityReadingsCount = INC_CAP( filteredConductivityReadings[ sensor ].conductivityReadingsCount, conductivityFilterSize ); + filteredConductivityReadings[ sensor ].conductivityReadingsIdx = INC_WRAP( filteredConductivityReadings[ sensor ].conductivityReadingsIdx, 0, SIZE_OF_COND_ROLLING_AVG - 1 ); + filteredConductivityReadings[ sensor ].conductivityReadingsCount = INC_CAP( filteredConductivityReadings[ sensor ].conductivityReadingsCount, SIZE_OF_COND_ROLLING_AVG ); filteredcurrentConductivityReadings[ sensor ].data = filteredConductivityReadings[ sensor ].conductivityReadingsTotal / (F32)filteredConductivityReadings[ sensor ].conductivityReadingsCount; - if ( filteredUConductivityReadings[ sensor ].conductivityReadingsCount >= conductivityFilterSize ) + if ( filteredUConductivityReadings[ sensor ].conductivityReadingsCount >= SIZE_OF_COND_ROLLING_AVG ) { filteredUConductivityReadings[ sensor ].conductivityReadingsTotal -= filteredUConductivityReadings[ sensor ].conductivityReadings[ filteredUConductivityReadings[ sensor ].conductivityReadingsIdx ]; } filteredUConductivityReadings[ sensor ].conductivityReadings[ filteredUConductivityReadings[ sensor ].conductivityReadingsIdx ] = uncompenstatedConductivity; filteredUConductivityReadings[ sensor ].conductivityReadingsTotal += uncompenstatedConductivity; - filteredUConductivityReadings[ sensor ].conductivityReadingsIdx = INC_WRAP( filteredUConductivityReadings[ sensor ].conductivityReadingsIdx, 0, conductivityFilterSize - 1 ); - filteredUConductivityReadings[ sensor ].conductivityReadingsCount = INC_CAP( filteredUConductivityReadings[ sensor ].conductivityReadingsCount, conductivityFilterSize ); + filteredUConductivityReadings[ sensor ].conductivityReadingsIdx = INC_WRAP( filteredUConductivityReadings[ sensor ].conductivityReadingsIdx, 0, SIZE_OF_COND_ROLLING_AVG - 1 ); + filteredUConductivityReadings[ sensor ].conductivityReadingsCount = INC_CAP( filteredUConductivityReadings[ sensor ].conductivityReadingsCount, SIZE_OF_COND_ROLLING_AVG ); filteredcurrentUConductivityReadings[ sensor ].data = filteredUConductivityReadings[ sensor ].conductivityReadingsTotal / (F32)filteredUConductivityReadings[ sensor ].conductivityReadingsCount; } @@ -364,75 +350,6 @@ /*********************************************************************//** * @brief - * The getConductivityFilterSize function gets the active conductivity filter - * sample count based on the Qd balancing chamber switching period. - * @details \b Inputs: TD dialysate flow rate - * @details \b Outputs: none - * @return active conductivity filter sample count. - *************************************************************************/ -static U32 getConductivityFilterSize( void ) -{ - F32 tdDialysateFlowRate = getTDDialysateFlowrate(); - U32 result = FILTER_SIZE_MULTIPLIER; - - if ( tdDialysateFlowRate > NEARLY_ZERO ) - { - F32 balChamberSwitchingFreq = tdDialysateFlowRate / BAL_CHAMBER_FILL_VOLUME_ML; - F32 balChamberSwitchingPeriod = (F32)SEC_PER_MIN / balChamberSwitchingFreq; - - result = (U32)( (F32)FILTER_SIZE_MULTIPLIER * balChamberSwitchingPeriod ); - } - - return result; -} - -/*********************************************************************//** - * @brief - * The resetConductivityFilterReadings function clears conductivity rolling - * average data when the active filter window changes. - * @details \b Inputs: filteredConductivityReadings - * @details \b Outputs: filteredConductivityReadings - * @return none - *************************************************************************/ -static void resetConductivityFilterReadings( void ) -{ - CONDUCTIVITY_SENSORS_T sensor; - - for ( sensor = FIRST_DD_COND_SENSOR; sensor < NUM_OF_CONDUCTIVITY_SENSORS; sensor++ ) - { - U32 readingIndex; - - F32 seedConductivity = filteredcurrentConductivityReadings[ sensor ].data; - BOOL hasPreviousSamples = ( filteredConductivityReadings[ sensor ].conductivityReadingsCount > 0 ); - - for ( readingIndex = 0; readingIndex < CONDUCTIVITY_MAX_FILTER_SIZE_MULTIPLIER; readingIndex++ ) - { - if ( ( TRUE == hasPreviousSamples ) && ( readingIndex < conductivityFilterSize ) ) - { - filteredConductivityReadings[ sensor ].conductivityReadings[ readingIndex ] = seedConductivity; - } - else - { - filteredConductivityReadings[ sensor ].conductivityReadings[ readingIndex ] = 0.0F; - } - } - - filteredConductivityReadings[ sensor ].conductivityReadingsIdx = 0; - if ( TRUE == hasPreviousSamples ) - { - filteredConductivityReadings[ sensor ].conductivityReadingsTotal = seedConductivity * (F32)conductivityFilterSize; - filteredConductivityReadings[ sensor ].conductivityReadingsCount = conductivityFilterSize; - } - else - { - filteredConductivityReadings[ sensor ].conductivityReadingsTotal = 0.0F; - filteredConductivityReadings[ sensor ].conductivityReadingsCount = 0; - } - } -} - -/*********************************************************************//** - * @brief * The getFilteredConductivitySensorTemperature function gets the filtered * temperature (in C) for a given conductivity sensor. * @details \b Alarm: ALARM_ID_DD_SOFTWARE_FAULT if given sensor is invalid. Index: firmware/App/Monitors/Level.c =================================================================== diff -u -r35ccc443e6440d79231ab4a3951bebc0e9789b68 -r095866efd8f10bdead490578e7584051d79292f0 --- firmware/App/Monitors/Level.c (.../Level.c) (revision 35ccc443e6440d79231ab4a3951bebc0e9789b68) +++ firmware/App/Monitors/Level.c (.../Level.c) (revision 095866efd8f10bdead490578e7584051d79292f0) @@ -525,7 +525,6 @@ // upperlevel == TRUE while lowerlevel == FALSE - illegal status = LVL_STATE_ILLEGAL; } - return status; } Index: firmware/App/Monitors/WaterQualityMonitor.c =================================================================== diff -u -r287ff91800ef4490432954f51df2dfbf2bf171e0 -r095866efd8f10bdead490578e7584051d79292f0 --- firmware/App/Monitors/WaterQualityMonitor.c (.../WaterQualityMonitor.c) (revision 287ff91800ef4490432954f51df2dfbf2bf171e0) +++ firmware/App/Monitors/WaterQualityMonitor.c (.../WaterQualityMonitor.c) (revision 095866efd8f10bdead490578e7584051d79292f0) @@ -43,7 +43,7 @@ #define MAX_INLET_RO_PUMP_PRESSURE_WARNING_HIGH_PSIG 120.0F ///< Maximum allowed Input warning pressure to the RO membrane. #define MAX_INLET_RO_PUMP_PRESSURE_WARNING_LOW_PSIG 58.0F ///< Minimum Input warning pressure to the RO membrane. -#define MIN_INLET_WATER_PRESSURE_WARNING_LOW_PSIG 20.0F ///< Minimum allowed M3 Input warning low pressure value in psig for RO featured. +#define MIN_INLET_WATER_PRESSURE_WARNING_LOW_PSIG 25.0F ///< Minimum allowed M3 Input warning low pressure value in psig for RO featured. #define MAX_INLET_WATER_PRESSURE_WARNING_HIGH_PSIG 40.0F ///< Maximum allowed M3 Input warning high pressure value in psig for RO featured. #define MAX_INLET_WATER_PRESSURE_FAULT_HIGH_PSIG 75.0F ///< Maximum allowed M3 Input fault high pressure value in psig for RO featured. #define MIN_INLET_WATER_PRESSURE_PSIG 1.0F ///< Minimum allowed P8 Input fault pressure value in psig for RO featured. @@ -53,7 +53,7 @@ #define MIN_PRESSURE_RELIEF_WARNING_LOW_PSIG 13.0F ///< Minimum P17 pressure relief warning in psi #define MAX_PRESSURE_RELIEF_WARNING_HIGH_PSIG 17.0F ///< Maximum P17 pressure relief warning in psi #define MAX_PERMEATE_FLOW_FAULT_THRESHOLD 1.25F ///< Maximum permeate flow threshold value in percentage. -#define INLET_WATER_PRES_OUT_OF_RANGE_TIMEOUT_MS ( 10 * MS_PER_SECOND ) ///< Persistence period for M3 pressure out of range error in milliseconds. +#define INLET_WATER_PRES_OUT_OF_RANGE_TIMEOUT_MS ( 5 * MS_PER_SECOND ) ///< Persistence period for M3 pressure out of range error in milliseconds. #define INLET_WATER_PRES_OUT_OF_RANGE_CLEAR_MS ( 5 * MS_PER_SECOND ) ///< Persistence period for M3 pressure out of range clear in milliseconds. #define INLET_WATER_PRES_RELIEF_OUT_OF_RANGE_TIMEOUT_MS ( 1 * MS_PER_SECOND ) ///< Persistence period for P17 pressure out of range error in milliseconds. #define INLET_WATER_PRES_RELIEF_OUT_OF_RANGE_CLEAR_MS ( 1 * MS_PER_SECOND ) ///< Persistence period for P17 pressure out of range clear in milliseconds. Index: firmware/App/Services/AlarmMgmtDD.c =================================================================== diff -u -ra89da634ef6fe29cc08692b0821fa4e35372cecb -r095866efd8f10bdead490578e7584051d79292f0 --- firmware/App/Services/AlarmMgmtDD.c (.../AlarmMgmtDD.c) (revision a89da634ef6fe29cc08692b0821fa4e35372cecb) +++ firmware/App/Services/AlarmMgmtDD.c (.../AlarmMgmtDD.c) (revision 095866efd8f10bdead490578e7584051d79292f0) @@ -197,7 +197,7 @@ ( ( props.alarmBlockEndTx != TRUE ) || ( tdModes.tdMode != MODE_POST ) ) ) { // broadcast alarm and data if alarm not already active - if ( ( FALSE == isAlarmActive( alarm ) ) ) + if ( ( FALSE == isAlarmActive( alarm ) ) && ( TRUE == isTDCommunicating() ) ) { broadcastAlarmTriggered( alarm, alarmData1, alarmData2, props.alarmSource ); } @@ -228,8 +228,10 @@ // clear alarm and broadcast alarm clear if not already cleared (and not a DD fault which should not be cleared) if ( ( TRUE == isAlarmActive( alarm ) ) && ( props.alarmIsDDFault != TRUE ) ) { - - broadcastAlarmCleared( alarm, props.alarmSource ); + if ( TRUE == isTDCommunicating() ) + { + broadcastAlarmCleared( alarm, props.alarmSource ); + } setAlarmActive( alarm, FALSE ); clearAlarmConditionDD( alarm ); } @@ -263,7 +265,10 @@ // clear alarm and broadcast alarm clear if not already cleared if ( TRUE == isAlarmConditionDetected( alarm ) ) { - broadcastAlarmConditionCleared( alarm, props.alarmSource ); + if ( TRUE == isTDCommunicating() ) + { + broadcastAlarmConditionCleared( alarm, props.alarmSource ); + } setAlarmConditionDetected( alarm, FALSE ); } } Index: firmware/App/Services/FpgaDD.c =================================================================== diff -u -rf43d59af8e69ef1459bafe91873ce41cf63a4a75 -r095866efd8f10bdead490578e7584051d79292f0 --- firmware/App/Services/FpgaDD.c (.../FpgaDD.c) (revision f43d59af8e69ef1459bafe91873ce41cf63a4a75) +++ firmware/App/Services/FpgaDD.c (.../FpgaDD.c) (revision 095866efd8f10bdead490578e7584051d79292f0) @@ -57,6 +57,7 @@ /// Macro to clear the FPGA actuator bits based on HW type #define CLEAR_FPGA_ACTUATOR_BITS(field, bits) (getTestConfigStatus( TEST_CONFIG_DD_FP_ENABLE_BETA_1_9_HW ) != TRUE ? ( fpgaActuatorSetPoints.field &= bits ) : ( fpgaBeta19ActuatorSetPoints.field &= bits )) +//#define CLEAR_FPGA_ACTUATOR_BITS(field, bits) (fpgaActuatorSetPoints.field &= bits) #define FPGA_EXPECTED_ID 0x06 ///< FPGA expected ID for Beta 2 systems. //TODO: Remove once Beta 1.9 is obsolete @@ -1126,7 +1127,6 @@ SET_FPGA_ACTUATOR_FIELD( fpgaD12PumpSpeed, currentSpeed ); } - /*********************************************************************//** * @brief * The setFPGAD48PumpControl function sets the controls for Index: firmware/App/Tasks/TaskGeneral.c =================================================================== diff -u -r75f32cd59369b07708e2d1118ea3695872484e31 -r095866efd8f10bdead490578e7584051d79292f0 --- firmware/App/Tasks/TaskGeneral.c (.../TaskGeneral.c) (revision 75f32cd59369b07708e2d1118ea3695872484e31) +++ firmware/App/Tasks/TaskGeneral.c (.../TaskGeneral.c) (revision 095866efd8f10bdead490578e7584051d79292f0) @@ -31,7 +31,6 @@ #include "PermeateTank.h" #include "RinsePump.h" #include "ROPump.h" -#include "SubstitutionPump.h" #include "SystemCommDD.h" #include "TaskGeneral.h" #include "WatchdogMgmt.h" @@ -107,9 +106,6 @@ execDryBicart(); } - // Control Substitution pump - execSubstitutionPumpController(); - // Control closed loop mixing of bicarb and acid execMixingControl(); Index: firmware/source/sys_main.c =================================================================== diff -u -rdaa4204266112042cdd5ea671df81b7501f1623f -r095866efd8f10bdead490578e7584051d79292f0 --- firmware/source/sys_main.c (.../sys_main.c) (revision daa4204266112042cdd5ea671df81b7501f1623f) +++ firmware/source/sys_main.c (.../sys_main.c) (revision 095866efd8f10bdead490578e7584051d79292f0) @@ -100,7 +100,6 @@ #include "StateFlushFilterDefeatured.h" #include "StateFlushPermeate.h" #include "StateInletPressureCheck.h" -#include "SubstitutionPump.h" #include "SystemCommDD.h" #include "TaskBG.h" #include "TDInterface.h" @@ -211,7 +210,6 @@ initUltrafiltration(); initRinsePump(); initDryBiCart(); - initSubstitutionPump(); initMixingControl(); initIntegrity();