Index: firmware/App/Controllers/BalancingChamber.c =================================================================== diff -u -r3d69f9a417c8473a16cc32f37db9b2c96faf7f6a -r788a88e8e9f58c60d3b753ef0ae32b6c7a0757e6 --- firmware/App/Controllers/BalancingChamber.c (.../BalancingChamber.c) (revision 3d69f9a417c8473a16cc32f37db9b2c96faf7f6a) +++ firmware/App/Controllers/BalancingChamber.c (.../BalancingChamber.c) (revision 788a88e8e9f58c60d3b753ef0ae32b6c7a0757e6) @@ -54,6 +54,7 @@ #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 BAL_CHAMBER_FILL_TIMEOUT_FACTOR 1.5 ///< Balancing Chamber fill timeout factor (150% of observed fill count) /// Payload record structure for balancing chamber switch only request typedef struct @@ -87,6 +88,7 @@ static F32 prevSpentDialPressure; ///< Previous spent side dialysate pressure static F32 lastPrevSpentDialPressure; ///< Last previous spent side dialysate pressure static U32 currentBalChamberFillCounter; ///< Counter (in task interval) to monitor the timing spent for the spent side fill operation. +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; //TODO: remove later once level sensor working @@ -149,6 +151,7 @@ prevSpentDialPressure = 0.0F; lastPrevSpentDialPressure = 0.0F; currentBalChamberFillCounter = 0; + balChamberFillTimeoutCount = 0; diffSpentFillCompleteCount = 0; isSpentFillComplete = FALSE; //TODO:remove once level sensor working @@ -453,6 +456,7 @@ currentBalChamberSwitchingCounter = 0; balChamberSWState = BAL_CHAMBER_SW_STATE1; currentBalChamberFillCounter = 0; + balChamberFillTimeoutCount = 0; isBalChamberFillInProgress = FALSE; isPressureStabilizedDuringFill = FALSE; isPressureDroppedDuringFill = FALSE; @@ -567,6 +571,12 @@ 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 ) ) + { + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DD_BC_FILL_TIMEOUT_FAULT, currentBalChamberFillCounter, balChamberFillTimeoutCount ); + } + // 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 ) ) { @@ -583,6 +593,12 @@ // Check both spent and fresh side fill is complete if ( ( TRUE == isSpentFillComplete ) && ( TRUE == isPressureStabilizedDuringFill ) || ( FALSE == isFirstCycleBCSwitchingCompleted ) ) { + // On successful completion, learn timeout as 150% of the observed fill count (once per cycle). + if ( balChamberFillTimeoutCount == 0U ) + { + balChamberFillTimeoutCount = currentBalChamberFillCounter * BAL_CHAMBER_FILL_TIMEOUT_FACTOR; + } + // close the state 1 opened valves valveControlForBCState1FillEnd(); isBalChamberFillInProgress = FALSE; @@ -671,6 +687,7 @@ isPressureDroppedDuringFill = FALSE; balChamberSWState = BAL_CHAMBER_SW_STATE2; currentBalChamberFillCounter = 0; + balChamberFillTimeoutCount = 0; isSpentFillComplete = FALSE; lastPrevSpentDialPressure = 0.0F; prevSpentDialPressure = 0.0F; @@ -739,12 +756,24 @@ } } + // If fill is taking too long, set an alarm for fill timeout + if ( ( balChamberFillTimeoutCount > 0 ) && ( currentBalChamberFillCounter > balChamberFillTimeoutCount ) ) + { + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DD_BC_FILL_TIMEOUT_FAULT, currentBalChamberFillCounter, balChamberFillTimeoutCount ); + } + // Spent side of balancing chamber fill is complete or not checkSpentFillComplete( spentDialPressure ); // Check switching cycle time or pressure check for valve closure if ( ( TRUE == isSpentFillComplete ) && ( TRUE == isPressureStabilizedDuringFill ) || ( FALSE == isFirstCycleBCSwitchingCompleted ) ) { + // On successful completion, learn timeout as 150% of the observed fill count (once per cycle). + if ( balChamberFillTimeoutCount == 0U ) + { + balChamberFillTimeoutCount = currentBalChamberFillCounter * BAL_CHAMBER_FILL_TIMEOUT_FACTOR; + } + // close the valves valveControlForBCState2FillEnd(); isBalChamberFillInProgress = FALSE; Index: firmware/App/Controllers/DialysatePumps.h =================================================================== diff -u -r3d69f9a417c8473a16cc32f37db9b2c96faf7f6a -r788a88e8e9f58c60d3b753ef0ae32b6c7a0757e6 --- firmware/App/Controllers/DialysatePumps.h (.../DialysatePumps.h) (revision 3d69f9a417c8473a16cc32f37db9b2c96faf7f6a) +++ firmware/App/Controllers/DialysatePumps.h (.../DialysatePumps.h) (revision 788a88e8e9f58c60d3b753ef0ae32b6c7a0757e6) @@ -36,7 +36,7 @@ #define MAX_DIALYSATE_PUMP_RPM 2650 ///< Maximum RPM target for D12 pump and D48 Diener 2000 pump. #define D48_DIENER_1000_MIN_RPM 134 ///< Minimum RPM for D48 Diener 1000 pump (test config enabled). -#define D48_DIENER_1000_MAX_RPM 2770 ///< Maximum RPM for D48 Diener 1000 pump (test config enabled). +#define D48_DIENER_1000_MAX_RPM 2770 ///< Maximum RPM for D48 Diener 1000 pump (test config enabled). #define DEGAS_PUMP_TARGET_PRES_ADJ_THRESHOLD -1.0F ///< Dialysate Pump(D12) target pressure threshold adjustment factor. Index: firmware/App/Modes/ModeGenDialysate.c =================================================================== diff -u -reda9f25c54f9a4dd0d4180c494038475a821c8c2 -r788a88e8e9f58c60d3b753ef0ae32b6c7a0757e6 --- firmware/App/Modes/ModeGenDialysate.c (.../ModeGenDialysate.c) (revision eda9f25c54f9a4dd0d4180c494038475a821c8c2) +++ firmware/App/Modes/ModeGenDialysate.c (.../ModeGenDialysate.c) (revision 788a88e8e9f58c60d3b753ef0ae32b6c7a0757e6) @@ -675,13 +675,13 @@ if ( TRUE == getTestConfigStatus( TEST_CONFIG_DD_ENABLE_DIENER_2000_PUMP ) ) { - slope = PUMP_SPEED_SLOPE_FACTOR_DIENER_1000; - intercept = PUMP_SPEED_INTERCEPT_FACTOR_DIENER_1000; + slope = PUMP_SPEED_SLOPE_FACTOR_DIENER_2000; + intercept = PUMP_SPEED_INTERCEPT_FACTOR_DIENER_2000; } else { - slope = PUMP_SPEED_SLOPE_FACTOR_DIENER_2000; - intercept = PUMP_SPEED_INTERCEPT_FACTOR_DIENER_2000; + slope = PUMP_SPEED_SLOPE_FACTOR_DIENER_1000; + intercept = PUMP_SPEED_INTERCEPT_FACTOR_DIENER_1000; } // Calculate nominal speed from Qd. Index: firmware/App/Services/FpgaDD.c =================================================================== diff -u -r3d69f9a417c8473a16cc32f37db9b2c96faf7f6a -r788a88e8e9f58c60d3b753ef0ae32b6c7a0757e6 --- firmware/App/Services/FpgaDD.c (.../FpgaDD.c) (revision 3d69f9a417c8473a16cc32f37db9b2c96faf7f6a) +++ firmware/App/Services/FpgaDD.c (.../FpgaDD.c) (revision 788a88e8e9f58c60d3b753ef0ae32b6c7a0757e6) @@ -143,9 +143,9 @@ #define PUMP_SPEED_OFFSET 168.7F ///< Speed Scale adjustment intercept factor #define PUMP_SPEED_FULL_SCALE 3187.0F ///< Speed scale adjustment slope factor -#define DIENER_1000_PUMP_SLOPE 0.000296F -#define DIENER_1000_PUMP_INTERCEPT 0.07040F -#define DIENER_1000_PUMP_SPEED_FULL_SCALE 3150 +#define DIENER_1000_PUMP_SLOPE 0.000296F ///< Speed adjustment slope factor (Diener 1000 pump) +#define DIENER_1000_PUMP_INTERCEPT 0.07040F ///< Speed adjustment intercept factor (Diener 1000 pump) +#define DIENER_1000_PUMP_SPEED_FULL_SCALE 3150 ///< Maximum speed factor (Diener 1000 pump) #pragma pack(push,1) /// FPGA header struct.