Index: firmware/App/Controllers/BalancingChamber.c =================================================================== diff -u -re0102a0a08c0d83bcc8e959551079063e2e60d9f -racb534a5d5921959493304a26dbc21d2b03338e0 --- firmware/App/Controllers/BalancingChamber.c (.../BalancingChamber.c) (revision e0102a0a08c0d83bcc8e959551079063e2e60d9f) +++ firmware/App/Controllers/BalancingChamber.c (.../BalancingChamber.c) (revision acb534a5d5921959493304a26dbc21d2b03338e0) @@ -39,6 +39,8 @@ // ********** private definitions ********** #define BAL_CHAMBER_DATA_PUBLISH_INTERVAL ( 250 / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the balancing chamber data published. +#define BAL_CHAMBER_FILL_PRES_DROP_MS ( 200 / TASK_GENERAL_INTERVAL ) ///< Time (ms/tasktime) to confirm the balancing chamber filling started and corrosponding valves opened. +#define BAL_CHAMBER_FILL_COMPLETE_MS ( 300 / TASK_GENERAL_INTERVAL ) ///< Time (ms/tasktime) to confirm the balancing chamber fill completed and pressure is within range /// Payload record structure for balancing chamber switch only request typedef struct @@ -59,6 +61,8 @@ static BOOL isPressureDroppedDuringFill; ///< Flag indicating that the pressure is dropped due to BC fill (state 1 or state 2) in progress condition. static BAL_CHAMBER_SW_STATE_T balChamberSWState; ///< Current balancing chamber switching state ( state 1 or state 2). static U32 balChamberDataPublicationTimerCounter; ///< Used to schedule balancing chamber data publication to CAN bus. +static U32 balChamberFillPressureDropCounter; ///< Counter to check balancing chamber valves opened and there by pressure drop is seen. +static U32 balChamberFillCompleteStablePressureCounter; ///< Counter to check balancing chamber fill complete and stable pressure is met. static OVERRIDE_U32_T balChamberDataPublishInterval; ///< Balancing chamber data publish interval. static BOOL balanceChamberSwitchingOnly; ///< Balancing chamber switching without any pressure check and dosing delivery. static OVERRIDE_F32_T acidDoseVolume; ///< Acid concentrate volume in ml ( overrideable). @@ -110,6 +114,8 @@ isPressureStalbilizedDuringFill = FALSE; lastTdDialysateFlowrate = 0.0F; balChamberDataPublicationTimerCounter = 0; + balChamberFillPressureDropCounter = 0; + balChamberFillCompleteStablePressureCounter = 0; } /*********************************************************************//** @@ -392,10 +398,10 @@ F32 bicarbVolume = getF32OverrideValue( &bicarbDoseVolume ); // Check fresh and spent dialysate pressure in range or BC switch only flag set //TODO : comment the pressure check - if ( 1 ) - //if ( ( ( freshDialPressure >= FRESH_DIAL_PRESSURE_MIN_PSIG ) && ( freshDialPressure <= FRESH_DIAL_PRESSURE_MAX_PSIG ) ) && - // ( ( spentDialPressure >= SPENT_DIAL_PRESSURE_MIN_PSIG ) && ( spentDialPressure <= SPENT_DIAL_PRESSURE_MAX_PSIG ) ) || - // ( TRUE == getBalChamberSwitchingOnlyStatus() ) ) + //if ( 1 ) + if ( ( ( freshDialPressure >= FRESH_DIAL_PRESSURE_MIN_PSIG ) && ( freshDialPressure <= FRESH_DIAL_PRESSURE_MAX_PSIG ) ) && + ( ( spentDialPressure >= SPENT_DIAL_PRESSURE_MIN_PSIG ) && ( spentDialPressure <= SPENT_DIAL_PRESSURE_MAX_PSIG ) ) || + ( TRUE == getBalChamberSwitchingOnlyStatus() ) ) { //Valve control for state 1 fill valveControlForBCState1FillStart(); @@ -417,10 +423,10 @@ } else { -#ifdef ENABLE_ALARM_2 +//#ifdef ENABLE_ALARM_2 //Alarm when pressure is not in range SET_ALARM_WITH_2_F32_DATA( ALARM_ID_DD_BC_STATE1_FILL_START_PRESSURE_OUT_OF_RANGE, freshDialPressure, spentDialPressure ); -#endif +//#endif } return state; @@ -442,17 +448,19 @@ F32 spentDialPressure = getFilteredPressure( D51_PRES ); // Pressure drop check during fill process helps to find if there is any issue with valves opening - if ( ( freshDialPressure <= BC_FILL_PRESSURE_MIN_PSIG ) && ( spentDialPressure <= BC_FILL_PRESSURE_MIN_PSIG ) ) + if ( ( freshDialPressure <= BC_FRESH_FILL_PRESSURE_PSIG ) && ( spentDialPressure <= BC_SPENT_FILL_PRESSURE_PSIG ) ) { - isPressureDroppedDuringFill = TRUE; + if ( ++balChamberFillPressureDropCounter >= BAL_CHAMBER_FILL_PRES_DROP_MS ) + { + isPressureDroppedDuringFill = TRUE; + } } // On dosing completion, transition to next state based on the current switching state - // TODO : Need an updated FPGA to perform this check. For now commenting this check. -// if ( ( ( TRUE == isConcentratePumpDosingCompleted( D11_PUMP ) ) && -// ( TRUE == isConcentratePumpDosingCompleted( D10_PUMP ) ) ) || -// ( TRUE == getBalChamberSwitchingOnlyStatus() ) ) -// { + if ( ( ( TRUE == isConcentratePumpDosingCompleted( D11_PUMP ) ) && + ( TRUE == isConcentratePumpDosingCompleted( D10_PUMP ) ) ) || + ( TRUE == getBalChamberSwitchingOnlyStatus() ) ) + { if ( BAL_CHAMBER_SW_STATE1 == balChamberSWState ) { state = BAL_CHAMBER_STATE1_FILL_END; @@ -461,7 +469,7 @@ { state = BAL_CHAMBER_STATE2_FILL_END; } -// } + } return state; } @@ -488,18 +496,21 @@ // Check fresh and spent dialysate pressure back in range to indicate fill complete. //TODO : comment the pressure check //if ( 1 ) - if ( currentBalChamberSwitchingCounter >= balChamberValveClosePeriod ) - //if ( ( ( freshDialPressure >= FRESH_DIAL_PRESSURE_MIN_PSIG ) && ( freshDialPressure <= FRESH_DIAL_PRESSURE_MAX_PSIG ) ) && - // ( ( spentDialPressure >= SPENT_DIAL_PRESSURE_MIN_PSIG ) && ( spentDialPressure <= SPENT_DIAL_PRESSURE_MAX_PSIG ) ) ) + //if ( currentBalChamberSwitchingCounter >= balChamberValveClosePeriod ) + if ( ( ( freshDialPressure >= FRESH_DIAL_PRESSURE_MIN_PSIG ) && ( freshDialPressure <= FRESH_DIAL_PRESSURE_MAX_PSIG ) ) && + ( ( spentDialPressure >= SPENT_DIAL_PRESSURE_MIN_PSIG ) && ( spentDialPressure <= SPENT_DIAL_PRESSURE_MAX_PSIG ) ) ) { - // stabilized pressure indicating fill is complete - isPressureStalbilizedDuringFill = TRUE; - isBalChamberFillInProgress = FALSE; + if ( ++balChamberFillCompleteStablePressureCounter >= BAL_CHAMBER_FILL_COMPLETE_MS ) + { + // stabilized pressure indicating fill is complete + isPressureStalbilizedDuringFill = TRUE; + isBalChamberFillInProgress = FALSE; + } // isPressureStalbilizedDuringFill = FALSE; } // Switching time met or pressure in range, close valves - if ( ( currentBalChamberSwitchingCounter >= balChamberSwitchingPeriod ) || + if ( ( currentBalChamberSwitchingCounter >= balChamberValveClosePeriod ) || ( TRUE == isPressureStalbilizedDuringFill ) ) { // close the state 1 opened valves @@ -509,21 +520,24 @@ // On completion of cycle time, transition to next state if ( currentBalChamberSwitchingCounter >= balChamberSwitchingPeriod ) { + balChamberFillPressureDropCounter = 0; + balChamberFillCompleteStablePressureCounter = 0; + if ( TRUE != getBalChamberSwitchingOnlyStatus() ) { if ( TRUE != isPressureDroppedDuringFill ) { -#ifdef ENABLE_ALARM_2 +//#ifdef ENABLE_ALARM_2 // When fill initiated, pressure is not dropped to the expected range, possible valve failures. SET_ALARM_WITH_2_F32_DATA( ALARM_ID_DD_BC_STATE1_FILL_PRESSURE_DROP_OUT_OF_RANGE, freshDialPressure, spentDialPressure ); -#endif +//#endif } else if ( TRUE != isPressureStalbilizedDuringFill ) { -#ifdef ENABLE_ALARM_2 +//#ifdef ENABLE_ALARM_2 // Alarm when switching time expired, but still pressure not in range which indicates fill is not yet completed. SET_ALARM_WITH_2_F32_DATA( ALARM_ID_DD_BC_STATE1_FILL_END_PRESSURE_OUT_OF_RANGE, freshDialPressure, spentDialPressure ); -#endif +//#endif } else { @@ -532,7 +546,7 @@ } //TODO : Temporarily allow to proceed next state even though pressure is not stabilized. - state = BAL_CHAMBER_STATE2_FILL_START; + //state = BAL_CHAMBER_STATE2_FILL_START; } else { @@ -569,10 +583,10 @@ // Check fresh and spent dialysate pressure in range //TODO : comment the pressure check - if ( 1 ) - //if ( ( ( freshDialPressure >= FRESH_DIAL_PRESSURE_MIN_PSIG ) && ( freshDialPressure <= FRESH_DIAL_PRESSURE_MAX_PSIG ) ) && - // ( ( spentDialPressure >= SPENT_DIAL_PRESSURE_MIN_PSIG ) && ( spentDialPressure <= SPENT_DIAL_PRESSURE_MAX_PSIG ) ) || - // ( TRUE == getBalChamberSwitchingOnlyStatus() ) ) + //if ( 1 ) + if ( ( ( freshDialPressure >= FRESH_DIAL_PRESSURE_MIN_PSIG ) && ( freshDialPressure <= FRESH_DIAL_PRESSURE_MAX_PSIG ) ) && + ( ( spentDialPressure >= SPENT_DIAL_PRESSURE_MIN_PSIG ) && ( spentDialPressure <= SPENT_DIAL_PRESSURE_MAX_PSIG ) ) || + ( TRUE == getBalChamberSwitchingOnlyStatus() ) ) { // Valve control for state 2 fill valveControlForBCState2FillStart(); @@ -594,10 +608,10 @@ } else { -#ifdef ENABLE_ALARM_2 +//#ifdef ENABLE_ALARM_2 //Alarm when pressure is not in range SET_ALARM_WITH_2_F32_DATA( ALARM_ID_DD_BC_STATE2_FILL_START_PRESSURE_OUT_OF_RANGE, freshDialPressure, spentDialPressure ); -#endif +//#endif } return state; } @@ -624,18 +638,21 @@ // Check fresh and spent dialysate pressure back in range to indicate fill complete. //TODO : comment the pressure check //if ( 1 ) - if ( currentBalChamberSwitchingCounter >= balChamberValveClosePeriod ) - //if ( ( ( freshDialPressure >= FRESH_DIAL_PRESSURE_MIN_PSIG ) && ( freshDialPressure <= FRESH_DIAL_PRESSURE_MAX_PSIG ) ) && - // ( ( spentDialPressure >= SPENT_DIAL_PRESSURE_MIN_PSIG ) && ( spentDialPressure <= SPENT_DIAL_PRESSURE_MAX_PSIG ) ) ) + //if ( currentBalChamberSwitchingCounter >= balChamberValveClosePeriod ) + if ( ( ( freshDialPressure >= FRESH_DIAL_PRESSURE_MIN_PSIG ) && ( freshDialPressure <= FRESH_DIAL_PRESSURE_MAX_PSIG ) ) && + ( ( spentDialPressure >= SPENT_DIAL_PRESSURE_MIN_PSIG ) && ( spentDialPressure <= SPENT_DIAL_PRESSURE_MAX_PSIG ) ) ) { - // stabilized pressure indicating fill is complete - isPressureStalbilizedDuringFill = TRUE; - isBalChamberFillInProgress = FALSE; + if ( ++balChamberFillCompleteStablePressureCounter >= BAL_CHAMBER_FILL_COMPLETE_MS ) + { + // stabilized pressure indicating fill is complete + isPressureStalbilizedDuringFill = TRUE; + isBalChamberFillInProgress = FALSE; + } //isPressureStalbilizedDuringFill = FALSE; } // Check switching cycle time or pressure check for valve closure - if ( ( currentBalChamberSwitchingCounter >= balChamberSwitchingPeriod ) || + if ( ( currentBalChamberSwitchingCounter >= balChamberValveClosePeriod ) || ( TRUE == isPressureStalbilizedDuringFill ) ) { // close the valves @@ -645,22 +662,25 @@ // On completion of cycle time, transition to next state if ( currentBalChamberSwitchingCounter >= balChamberSwitchingPeriod ) { + balChamberFillPressureDropCounter = 0; + balChamberFillCompleteStablePressureCounter = 0; + // Pressure alarm check if ( TRUE != getBalChamberSwitchingOnlyStatus() ) { if ( TRUE != isPressureDroppedDuringFill ) { -#ifdef ENABLE_ALARM_2 +//#ifdef ENABLE_ALARM_2 // When fill initiated, pressure is not dropped to the expected range, possible valve failures. SET_ALARM_WITH_2_F32_DATA( ALARM_ID_DD_BC_STATE2_FILL_PRESSURE_DROP_OUT_OF_RANGE, freshDialPressure, spentDialPressure ); -#endif +//#endif } else if ( TRUE != isPressureStalbilizedDuringFill ) { -#ifdef ENABLE_ALARM_2 +//#ifdef ENABLE_ALARM_2 // Alarm when switching time expired, but still pressure not in range which indicates fill is not completed. SET_ALARM_WITH_2_F32_DATA( ALARM_ID_DD_BC_STATE2_FILL_END_PRESSURE_OUT_OF_RANGE, freshDialPressure, spentDialPressure ); -#endif +//#endif } else { @@ -669,7 +689,7 @@ } //TODO : Temporarily allow to proceed next state even though pressure is not stabilized. - state = BAL_CHAMBER_STATE1_FILL_START; + //state = BAL_CHAMBER_STATE1_FILL_START; } else { Index: firmware/App/Controllers/BalancingChamber.h =================================================================== diff -u -r1781335a8c1833fad17b275bf44c7f6675e68423 -racb534a5d5921959493304a26dbc21d2b03338e0 --- firmware/App/Controllers/BalancingChamber.h (.../BalancingChamber.h) (revision 1781335a8c1833fad17b275bf44c7f6675e68423) +++ firmware/App/Controllers/BalancingChamber.h (.../BalancingChamber.h) (revision acb534a5d5921959493304a26dbc21d2b03338e0) @@ -31,12 +31,12 @@ // ********** public definitions ********** -#define FRESH_DIAL_PRESSURE_MIN_PSIG 21.0F ///< Minimum fresh dialysate pressure (D18) limit for balancing chamber fill operations. -#define FRESH_DIAL_PRESSURE_MAX_PSIG 27.0F ///< Maximum fresh dialysate pressure (D18) limit for balancing chamber fill operations. -#define SPENT_DIAL_PRESSURE_MIN_PSIG 27.0F ///< Minimum spent dialysate pressure (D51) limit for balancing chamber fill operations. -#define SPENT_DIAL_PRESSURE_MAX_PSIG 31.0F ///< Maximum spent dialysate pressure (D51) limit for balancing chamber fill operations. -#define BC_FILL_PRESSURE_MIN_PSIG 13.0F ///< Minimum pressure (drop) during balancing chamber switching, indicates fill has been started / in progress. -#define BC_FILL_PRESSURE_MAX_PSIG 9.0F ///< Maximum pressure (drop) during balancing chamber switching, indicates fill has been started / in progress. +#define FRESH_DIAL_PRESSURE_MIN_PSIG 22.0F ///< Minimum fresh dialysate pressure (D18) limit for balancing chamber fill operations. +#define FRESH_DIAL_PRESSURE_MAX_PSIG 28.0F ///< Maximum fresh dialysate pressure (D18) limit for balancing chamber fill operations. +#define SPENT_DIAL_PRESSURE_MIN_PSIG 33.0F ///< Minimum spent dialysate pressure (D51) limit for balancing chamber fill operations. +#define SPENT_DIAL_PRESSURE_MAX_PSIG 37.0F ///< Maximum spent dialysate pressure (D51) limit for balancing chamber fill operations. +#define BC_FRESH_FILL_PRESSURE_PSIG 13.0F ///< Fresh side pressure (drop) during balancing chamber switching, indicates fill has been started / in progress. +#define BC_SPENT_FILL_PRESSURE_PSIG 26.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. /// balancing chamber data structure Index: firmware/App/Controllers/ConcentratePumps.c =================================================================== diff -u -re0102a0a08c0d83bcc8e959551079063e2e60d9f -racb534a5d5921959493304a26dbc21d2b03338e0 --- firmware/App/Controllers/ConcentratePumps.c (.../ConcentratePumps.c) (revision e0102a0a08c0d83bcc8e959551079063e2e60d9f) +++ firmware/App/Controllers/ConcentratePumps.c (.../ConcentratePumps.c) (revision acb534a5d5921959493304a26dbc21d2b03338e0) @@ -152,6 +152,7 @@ static OVERRIDE_F32_T measuredPumpSpeed[ NUM_OF_CONCENTRATE_PUMPS ]; ///< Measured concentrate pump speed (mL/min). static OVERRIDE_U32_T parked[ NUM_OF_CONCENTRATE_PUMPS ]; ///< Concentrate pump is currently parked (T/F). static OVERRIDE_U32_T parkFaulted[ NUM_OF_CONCENTRATE_PUMPS ]; ///< Concentrate pump park command has faulted (T/F). +static BOOL isDosingCompleted[ NUM_OF_CONCENTRATE_PUMPS ]; ///< Flag indicating dosing completed status (T/F). //static DD_ACID_CONCENTRATES_RECORD_T acidConcentrateCalRecord; ///< Acid concentrate calibration record. //static DD_BICARB_CONCENTRATES_RECORD_T bicarbConcentrateCalRecord; ///< Bicarb concentrate calibration record. @@ -223,6 +224,7 @@ concentratePumps[ pumpId ].controlSet = CONCENTRATE_PUMP_CONTROL_FORWARD; concentratePumps[ pumpId ].isConcPumpParkInProgress = FALSE; stopConcentratePump( pumpId ); + isDosingCompleted[ pumpId ] = FALSE; } initPersistentAlarm( ALARM_ID_DD_D11_PUMP_SPEED_CONTROL_ERROR, 0, CONCENTRATE_PUMP_SPEED_OUT_OF_RANGE_TIMEOUT_MS ); @@ -547,14 +549,17 @@ if ( D11_PUMP == pumpId ) { setFPGAD11PumpRevolutionCount( getConcPumpTargetRevolutionCount( pumpId ) ); + isDosingCompleted [ D11_PUMP ] = FALSE; } else if ( D10_PUMP == pumpId ) { setFPGAD10PumpRevolutionCount( getConcPumpTargetRevolutionCount( pumpId ) ); + isDosingCompleted [ D10_PUMP ] = FALSE; } else { setFPGAD76PumpRevolutionCount( getConcPumpTargetRevolutionCount( pumpId ) ); + isDosingCompleted [ D76_PUMP ] = FALSE; } } @@ -619,15 +624,7 @@ *************************************************************************/ BOOL isConcentratePumpDosingCompleted( CONCENTRATE_PUMPS_T pumpId ) { - BOOL state = FALSE; - - //On dosing completion,state transition to off state - if ( CONCENTRATE_PUMP_OFF_STATE == concentratePumps[ pumpId ].execState ) - { - state = TRUE; - } - - return state; + return isDosingCompleted[ pumpId ]; } /*********************************************************************//** @@ -835,6 +832,7 @@ concentratePumps[ pumpId ].currentPumpSpeed = 0.0F; // set target rate to zero pumpTargetSpeed[ pumpId ].data = 0.0F; pumpTargetRevCnt[ pumpId ].data = 0; + isDosingCompleted [ pumpId ] = TRUE; // Disable the motor when stopping, to take next revolution count // Send zero rate command to stop the pump Index: firmware/App/DDCommon.h =================================================================== diff -u -r734bf9d37fee349983baba56e3590600b4606241 -racb534a5d5921959493304a26dbc21d2b03338e0 --- firmware/App/DDCommon.h (.../DDCommon.h) (revision 734bf9d37fee349983baba56e3590600b4606241) +++ firmware/App/DDCommon.h (.../DDCommon.h) (revision acb534a5d5921959493304a26dbc21d2b03338e0) @@ -43,7 +43,7 @@ //#define __PITEST__ 1 //Uncomment below if diener concentrate pump used -//#define __DIENER_CONC_PUMP__ 1 +#define __DIENER_CONC_PUMP__ 1 //Uncomment below if beta hardware is used //#define __BETA_HW_VER__ 1 Index: firmware/App/Modes/ModeGenDialysate.c =================================================================== diff -u -re0102a0a08c0d83bcc8e959551079063e2e60d9f -racb534a5d5921959493304a26dbc21d2b03338e0 --- firmware/App/Modes/ModeGenDialysate.c (.../ModeGenDialysate.c) (revision e0102a0a08c0d83bcc8e959551079063e2e60d9f) +++ firmware/App/Modes/ModeGenDialysate.c (.../ModeGenDialysate.c) (revision acb534a5d5921959493304a26dbc21d2b03338e0) @@ -60,7 +60,7 @@ #define LOW_DIAL_FLOW_RATE 150.0F ///< Dialysate flow rate lesser than 150 considered to be low Qds. //Testing -#define DELAY_BC_SWITCHING_AT_START_UP ( 3 * MS_PER_SECOND ) ///< Provide a balancing chamber switching start up delay to stabilize pump speed etc., +#define DELAY_BC_SWITCHING_AT_START_UP ( 10 * MS_PER_SECOND ) ///< Provide a balancing chamber switching start up delay to stabilize pump speed etc., /// Payload record structure for Gen dialysate execution state set request typedef struct {