Index: firmware/App/Controllers/BalancingChamber.c =================================================================== diff -u -r902889c30391b6ca8c9f19adfd3c841c86a5d49f -rb4afc325ebcad1ba8303d307925a2257eff7d8ac --- firmware/App/Controllers/BalancingChamber.c (.../BalancingChamber.c) (revision 902889c30391b6ca8c9f19adfd3c841c86a5d49f) +++ firmware/App/Controllers/BalancingChamber.c (.../BalancingChamber.c) (revision b4afc325ebcad1ba8303d307925a2257eff7d8ac) @@ -60,7 +60,7 @@ #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 BAL_CHAMBER_FILL_TIMEOUT_FACTOR 1.5 ///< Balancing Chamber fill timeout factor (150% of observed fill count) +#define BAL_CHAMBER_FILL_TIMEOUT_FACTOR 2.0F ///< Balancing Chamber fill timeout factor (2000% of observed fill count) /// Payload record structure for balancing chamber switch only request typedef struct @@ -106,7 +106,7 @@ static BOOL isBalChamberSwitchingOffRequested; ///< Flag indicating that a request was made to deactivate balancing chamber switching. //TODO: remove later once level sensor working -static U32 bicarbChamberPeriodicFillCounter; +static U32 bicarbChamberPeriodicFillCounter; // ********** private function prototypes ********** @@ -221,7 +221,7 @@ //Update last td dialysate flow rate lastTdDialysateFlowrate = tdDialysateFlowrate; - // Update fill timeout count based on the switching period (e.g. 150% of period) + // Update fill timeout count based on the switching period (e.g. 200% of period) balChamberFillTimeoutCount = (U32)( (F32)balChamberSwitchingPeriod * BAL_CHAMBER_FILL_TIMEOUT_FACTOR ); //Reset the BC switching flag for new Qd. @@ -528,7 +528,7 @@ BAL_CHAMBER_EXEC_STATE_T state = BAL_CHAMBER_STATE1_FILL_START; balChamberSWState = BAL_CHAMBER_SW_STATE1; - balChamberFillTimeoutCount = 0; + // Preserve the Qd-based timeout so a stuck fill can fault. isBalChamberFillInProgress = FALSE; isPressureStabilizedDuringFill = FALSE; isPressureDroppedDuringFill = FALSE; @@ -554,7 +554,7 @@ freshDialPressure = getFilteredPressure( D18_PRES ); spentDialPressure = getFilteredPressure( D51_PRES ); - if ( getTestConfigStatus( TEST_CONFIG_DD_FP_ENABLE_BETA_1_0_HW ) == TRUE ) + if ( TRUE == getTestConfigStatus( TEST_CONFIG_DD_FP_ENABLE_BETA_1_0_HW ) ) { //Set Trimmer heater Target temp every BC cycle to catch up fresh dialysate temp setHeaterTargetTemperature( D45_HEAT, getFilteredTemperatureValue( D4_TEMP ) ); @@ -673,12 +673,14 @@ BOOL isBothFillsComplete = FALSE; BOOL isFirstCycleNotDone = FALSE; BOOL isFillCompleteOrFirstCycle = FALSE; + BOOL isFillTimeoutEnabled = ( ( TRUE == isFirstCycleBCSwitchingCompleted ) && + ( FALSE == getBalChamberSwitchingOnlyStatus() ) ) ? TRUE : FALSE; freshDialPressure = getFilteredPressure( D18_PRES ); spentDialPressure = getFilteredPressure( D51_PRES ); - // If fill is taking too long, set an alarm for fill timeout - if ( ( balChamberFillTimeoutCount > 0 ) && ( currentBalChamberFillCounter > balChamberFillTimeoutCount ) ) + // After the first BC cycle, fault if fill never completes at the Qd-based timeout. + if ( ( TRUE == isFillTimeoutEnabled ) && ( balChamberFillTimeoutCount > 0 ) && ( currentBalChamberFillCounter > balChamberFillTimeoutCount ) ) { SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DD_BC_FILL_TIMEOUT_FAULT, currentBalChamberFillCounter, balChamberFillTimeoutCount ); @@ -700,21 +702,24 @@ checkSpentFillComplete( spentDialPressure ); // Check both spent and fresh side fill is complete - isBothFillsComplete = ( TRUE == isSpentFillComplete ) && ( TRUE == isPressureStabilizedDuringFill ); - isFirstCycleNotDone = ( FALSE == isFirstCycleBCSwitchingCompleted ); + isBothFillsComplete = ( ( TRUE == isSpentFillComplete ) && ( TRUE == isPressureStabilizedDuringFill ) ) ? TRUE : FALSE; + isFirstCycleNotDone = ( FALSE == isFirstCycleBCSwitchingCompleted ) && ( currentBalChamberSwitchingCounter >= balChamberValveClosePeriod ); if ( FALSE == getBalChamberSwitchingOnlyStatus() ) { - isFillCompleteOrFirstCycle = isBothFillsComplete || isFirstCycleNotDone; + isFillCompleteOrFirstCycle = ( ( TRUE == isBothFillsComplete ) || ( TRUE == isFirstCycleNotDone ) ) ? TRUE : FALSE; } if ( ( TRUE == isFillCompleteOrFirstCycle ) || - ( ( currentBalChamberSwitchingCounter >= balChamberValveClosePeriod ) && ( TRUE == getBalChamberSwitchingOnlyStatus() ) ) ) + ( ( currentBalChamberSwitchingCounter >= balChamberValveClosePeriod ) && ( TRUE == getBalChamberSwitchingOnlyStatus() ) ) ) { // close the state 1 opened valves valveControlForBCState1FillEnd(); isBalChamberFillInProgress = FALSE; - setDialysatePumpTargetRPM( D48_PUMP, getD48PumpSpeedForBCFill(), TRUE ); + if ( FALSE == getBalChamberSwitchingOnlyStatus() ) + { + setDialysatePumpTargetRPM( D48_PUMP, getD48PumpSpeedForBCFill(), TRUE ); + } // Transition to next state state = BAL_CHAMBER_STATE1_FILL_END; @@ -837,7 +842,6 @@ isPressureStabilizedDuringFill = FALSE; isPressureDroppedDuringFill = FALSE; balChamberSWState = BAL_CHAMBER_SW_STATE2; - balChamberFillTimeoutCount = 0; lastPrevSpentDialPressure = 0.0F; prevSpentDialPressure = 0.0F; currentBalChamberSwitchingCounter = 0; @@ -856,10 +860,11 @@ acidVolume = getF32OverrideValue( &acidDoseVolume ); bicarbVolume = getF32OverrideValue( &bicarbDoseVolume ); } + freshDialPressure = getFilteredPressure( D18_PRES ); spentDialPressure = getFilteredPressure( D51_PRES ); - if ( getTestConfigStatus( TEST_CONFIG_DD_FP_ENABLE_BETA_1_0_HW ) == TRUE ) + if ( TRUE == getTestConfigStatus( TEST_CONFIG_DD_FP_ENABLE_BETA_1_0_HW ) ) { //Set Trimmer heater Target temp every BC cycle to catch up fresh dialysate temp setHeaterTargetTemperature( D45_HEAT, getFilteredTemperatureValue( D4_TEMP ) ); @@ -921,6 +926,8 @@ BOOL isBothFillsComplete = FALSE; BOOL isFirstCycleNotDone = FALSE; BOOL isFillCompleteOrFirstCycle = FALSE; + BOOL isFillTimeoutEnabled = ( ( TRUE == isFirstCycleBCSwitchingCompleted ) && + ( FALSE == getBalChamberSwitchingOnlyStatus() ) ) ? TRUE : FALSE; freshDialPressure = getFilteredPressure( D18_PRES ); spentDialPressure = getFilteredPressure( D51_PRES ); @@ -935,8 +942,8 @@ } } - // If fill is taking too long, set an alarm for fill timeout - if ( ( balChamberFillTimeoutCount > 0 ) && ( currentBalChamberFillCounter > balChamberFillTimeoutCount ) ) + // After the first BC cycle, fault if fill never completes at the Qd-based timeout. + if ( ( TRUE == isFillTimeoutEnabled ) && ( balChamberFillTimeoutCount > 0 ) && ( currentBalChamberFillCounter > balChamberFillTimeoutCount ) ) { SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DD_BC_FILL_TIMEOUT_FAULT, currentBalChamberFillCounter, balChamberFillTimeoutCount ); @@ -948,21 +955,24 @@ checkSpentFillComplete( spentDialPressure ); // Check switching cycle time or pressure check for valve closure - isBothFillsComplete = ( TRUE == isSpentFillComplete ) && ( TRUE == isPressureStabilizedDuringFill ); - isFirstCycleNotDone = ( FALSE == isFirstCycleBCSwitchingCompleted ); + isBothFillsComplete = ( ( TRUE == isSpentFillComplete ) && ( TRUE == isPressureStabilizedDuringFill ) ) ? TRUE : FALSE; + isFirstCycleNotDone = ( ( FALSE == isFirstCycleBCSwitchingCompleted ) && ( currentBalChamberSwitchingCounter >= balChamberValveClosePeriod ) ); if ( FALSE == getBalChamberSwitchingOnlyStatus() ) { - isFillCompleteOrFirstCycle = isBothFillsComplete || isFirstCycleNotDone; + isFillCompleteOrFirstCycle = ( ( TRUE == isBothFillsComplete ) || ( TRUE == isFirstCycleNotDone ) ) ? TRUE : FALSE; } if ( ( TRUE == isFillCompleteOrFirstCycle ) || - ( ( currentBalChamberSwitchingCounter >= balChamberValveClosePeriod ) && ( TRUE == getBalChamberSwitchingOnlyStatus() ) ) ) + ( ( currentBalChamberSwitchingCounter >= balChamberValveClosePeriod ) && ( TRUE == getBalChamberSwitchingOnlyStatus() ) ) ) { // close the valves valveControlForBCState2FillEnd(); isBalChamberFillInProgress = FALSE; - setDialysatePumpTargetRPM( D48_PUMP, getD48PumpSpeedForBCFill(), TRUE ); + if ( FALSE == getBalChamberSwitchingOnlyStatus() ) + { + setDialysatePumpTargetRPM( D48_PUMP, getD48PumpSpeedForBCFill(), TRUE ); + } //Transition to next state state = BAL_CHAMBER_STATE2_FILL_END; @@ -1113,7 +1123,7 @@ // Check if a request made was to activate the balancing chamber switching. if ( TRUE == isBalChamberSwitchingOnRequested ) { - //Clear the request flag to indicate that the request was processed. + //Clear request was processed. isBalChamberSwitchingOnRequested = FALSE; // Set flag to indicate that balancing chamber switching is active @@ -1274,6 +1284,7 @@ d48SpeedPostRangeCheck = RANGE( spentDialPumpSpeed, minD48Speed, maxD48Speed ); + // Do not turn on the pump if the switching only is enabled in the standby mode. if ( FALSE == getBalChamberSwitchingOnlyStatus() ) { Index: firmware/App/DDCommon.h =================================================================== diff -u -r96468474a209ba55660ba0f1c7441bb381d24ff8 -rb4afc325ebcad1ba8303d307925a2257eff7d8ac --- firmware/App/DDCommon.h (.../DDCommon.h) (revision 96468474a209ba55660ba0f1c7441bb381d24ff8) +++ firmware/App/DDCommon.h (.../DDCommon.h) (revision b4afc325ebcad1ba8303d307925a2257eff7d8ac) @@ -25,7 +25,7 @@ #define DD_VERSION_MAJOR 0 #define DD_VERSION_MINOR 0 #define DD_VERSION_MICRO 0 -#define DD_VERSION_BUILD 79 +#define DD_VERSION_BUILD 128 // ********** development build switches ********** @@ -39,24 +39,34 @@ //Uncomment below if barometric pressure sensor reading available //#define __BARO_PRES_SENSOR__ 1 -//Uncomment below if required hardware available ( baro and cond sensor) for testing -//#define ENABLE_ALARM_1 +//Uncomment below if TD is integrated with DD +#define ENABLE_ALARM_1 //Uncomment below once characterization/study completed //#define ENABLE_ALARM_2 //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 //Uncomment below to disable revised heater model #define __REVISED_HEATER_MODEL__ 1 + // comment below to disable bicarb multi level sensor for time based chamber F fill #define CONDUCTIVE_LEVEL_SENSOR_ENABLED 1 +//Uncomment below to enable d30 heater alarm(as all units are not equipped with d30 temp sensor) +//#define ENABLE_ALARM_3 +//Define to enable the DD too-many-bad-message-CRCs alarm. +//#define __BAD_MSG_CRC_ALARM_ENABLED__ 1 + + #include #include #endif Index: firmware/App/Monitors/Level.c =================================================================== diff -u -rd78a9114b71d8a6483dd0c40ef505e917889f862 -rb4afc325ebcad1ba8303d307925a2257eff7d8ac --- firmware/App/Monitors/Level.c (.../Level.c) (revision d78a9114b71d8a6483dd0c40ef505e917889f862) +++ firmware/App/Monitors/Level.c (.../Level.c) (revision b4afc325ebcad1ba8303d307925a2257eff7d8ac) @@ -206,6 +206,10 @@ SEND_EVENT_WITH_2_U32_DATA( DD_EVENT_D46_LEVL_CHANGE, (U32)status[ level ].data, (U32)currentLevelStatus ); break; + case P25_LEVL: + SEND_EVENT_WITH_2_U32_DATA( FP_EVENT_P25_LEVL_CHANGE, (U32)status[ level ].data, (U32)currentLevelStatus ); + break; + #ifndef _VECTORCAST_ default: SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DD_SOFTWARE_FAULT, SW_FAULT_ID_INVALID_LEVEL_SELECTED, level);