Index: firmware/App/Controllers/BalancingChamber.c =================================================================== diff -u -rf68d42f6972d7be8e994cc35ba52d72a275800f0 -r2a1296e1269e7c36dd07cb0f39b70b742f6de405 --- firmware/App/Controllers/BalancingChamber.c (.../BalancingChamber.c) (revision f68d42f6972d7be8e994cc35ba52d72a275800f0) +++ firmware/App/Controllers/BalancingChamber.c (.../BalancingChamber.c) (revision 2a1296e1269e7c36dd07cb0f39b70b742f6de405) @@ -69,13 +69,17 @@ static OVERRIDE_F32_T acidDoseVolume; ///< Acid concentrate volume in ml ( overrideable). static OVERRIDE_F32_T bicarbDoseVolume; ///< Bicarb concentrate volume in ml ( overrideable). static F32 lastTdDialysateFlowrate; ///< Previous TD dialysate flow rate +static F32 freshDialPressure; ///< Fresh side dialysate pressure +static F32 spentDialPressure; ///< Spent side dialysate pressure // ********** private function prototypes ********** static BAL_CHAMBER_EXEC_STATE_T handleBalChamberState1FillStart( void ); static BAL_CHAMBER_EXEC_STATE_T handleBalChamberConcentrateControl(void); +static BAL_CHAMBER_EXEC_STATE_T handleBalChamberState1ValvesClose( void ); static BAL_CHAMBER_EXEC_STATE_T handleBalChamberState1FillEnd(void); static BAL_CHAMBER_EXEC_STATE_T handleBalChamberState2FillStart( void ); +static BAL_CHAMBER_EXEC_STATE_T handleBalChamberState2ValvesClose( void ); static BAL_CHAMBER_EXEC_STATE_T handleBalChamberState2FillEnd(void); static void publishBalChamberData( void ); static U32 getBalChamberDataPublishInterval( void ); @@ -119,6 +123,8 @@ balChamberFillCompleteStablePressureCounter = 0; isFirstCycleBCSwitchingCompleted = FALSE; isPressureDroppedDuringFill = FALSE; + freshDialPressure = 0.0F; + spentDialPressure = 0.0F; } /*********************************************************************//** @@ -201,6 +207,10 @@ balChamberExecState = handleBalChamberConcentrateControl(); break; + case BAL_CHAMBER_STATE1_VALVES_CLOSE: + balChamberExecState = handleBalChamberState1ValvesClose(); + break; + case BAL_CHAMBER_STATE1_FILL_END: balChamberExecState = handleBalChamberState1FillEnd(); break; @@ -213,6 +223,10 @@ balChamberExecState = handleBalChamberConcentrateControl(); break; + case BAL_CHAMBER_STATE2_VALVES_CLOSE: + balChamberExecState = handleBalChamberState2ValvesClose(); + break; + case BAL_CHAMBER_STATE2_FILL_END: balChamberExecState = handleBalChamberState2FillEnd(); break; @@ -398,10 +412,10 @@ isPressureDroppedDuringFill = FALSE; balChamberSWState = BAL_CHAMBER_SW_STATE1; - F32 freshDialPressure = getFilteredPressure( D18_PRES ); - F32 spentDialPressure = getFilteredPressure( D51_PRES ); F32 acidVolume = getF32OverrideValue( &acidDoseVolume ); F32 bicarbVolume = getF32OverrideValue( &bicarbDoseVolume ); + freshDialPressure = getFilteredPressure( D18_PRES ); + spentDialPressure = getFilteredPressure( D51_PRES ); // Check fresh and spent dialysate pressure in range or BC switch only flag set #ifndef __BC_PRESSURE_ALARM__ @@ -452,8 +466,8 @@ static BAL_CHAMBER_EXEC_STATE_T handleBalChamberConcentrateControl( void ) { BAL_CHAMBER_EXEC_STATE_T state; - F32 freshDialPressure = getFilteredPressure( D18_PRES ); - F32 spentDialPressure = getFilteredPressure( D51_PRES ); + freshDialPressure = getFilteredPressure( D18_PRES ); + spentDialPressure = getFilteredPressure( D51_PRES ); if ( BAL_CHAMBER_SW_STATE1 == balChamberSWState ) { @@ -480,11 +494,11 @@ { if ( BAL_CHAMBER_SW_STATE1 == balChamberSWState ) { - state = BAL_CHAMBER_STATE1_FILL_END; + state = BAL_CHAMBER_STATE1_VALVES_CLOSE; } else { - state = BAL_CHAMBER_STATE2_FILL_END; + state = BAL_CHAMBER_STATE2_VALVES_CLOSE; } } @@ -493,22 +507,18 @@ /*********************************************************************//** * @brief - * The handleBalChamberState1FillEnd function check for the balancing chamber + * The handleBalChamberState1ValvesClose function check for the balancing chamber * fill complete and close the currently opened valves. - * @details \b Inputs: balChamberSWState, spent and fresh dialysate pressure + * @details \b Inputs: currentBalChamberSwitchingCounter, spent and fresh dialysate pressure * @details \b Outputs: isPressureStalbilizedDuringFill,isBalChamberFillInProgress - * @details \b Alarm: ALARM_ID_DD_BC_STATE1_FILL_PRESSURE_DROP_OUT_OF_RANGE - * when pressure drop is not in range during balacing chamber fill in progress. - * @details \b Alarm: ALARM_ID_DD_BC_STATE1_FILL_END_PRESSURE_OUT_OF_RANGE - * when pressure is not in range during balacing chamber fill complete. * @return next balancing chamber state. *************************************************************************/ -static BAL_CHAMBER_EXEC_STATE_T handleBalChamberState1FillEnd( void ) +static BAL_CHAMBER_EXEC_STATE_T handleBalChamberState1ValvesClose( void ) { - BAL_CHAMBER_EXEC_STATE_T state = BAL_CHAMBER_STATE1_FILL_END; + BAL_CHAMBER_EXEC_STATE_T state = BAL_CHAMBER_STATE1_VALVES_CLOSE; - F32 freshDialPressure = getFilteredPressure( D18_PRES ); - F32 spentDialPressure = getFilteredPressure( D51_PRES ); + freshDialPressure = getFilteredPressure( D18_PRES ); + spentDialPressure = getFilteredPressure( D51_PRES ); // Check fresh and spent dialysate pressure back in range to indicate fill complete. #ifdef __BC_PRESSURE_ALARM__ @@ -532,8 +542,30 @@ { // close the state 1 opened valves valveControlForBCState1FillEnd(); + + //Transition to next state + state = BAL_CHAMBER_STATE1_FILL_END; } + return state; +} + +/*********************************************************************//** + * @brief + * The handleBalChamberState1FillEnd function check for the balancing chamber + * switching period and tranistion to next state switching. + * @details \b Inputs: currentBalChamberSwitchingCounter, balChamberSwitchingPeriod + * @details \b Outputs: balChamberFillPressureDropCounter,balChamberFillCompleteStablePressureCounter + * @details \b Alarm: ALARM_ID_DD_BC_STATE1_FILL_PRESSURE_DROP_OUT_OF_RANGE + * when pressure drop is not in range during balacing chamber fill in progress. + * @details \b Alarm: ALARM_ID_DD_BC_STATE1_FILL_END_PRESSURE_OUT_OF_RANGE + * when pressure is not in range during balacing chamber fill complete. + * @return next balancing chamber state. + *************************************************************************/ +static BAL_CHAMBER_EXEC_STATE_T handleBalChamberState1FillEnd( void ) +{ + BAL_CHAMBER_EXEC_STATE_T state = BAL_CHAMBER_STATE1_FILL_END; + // On completion of cycle time, transition to next state if ( currentBalChamberSwitchingCounter >= balChamberSwitchingPeriod ) { @@ -591,10 +623,10 @@ isPressureDroppedDuringFill = FALSE; balChamberSWState = BAL_CHAMBER_SW_STATE2; - F32 freshDialPressure = getFilteredPressure( D18_PRES ); - F32 spentDialPressure = getFilteredPressure( D51_PRES ); F32 acidVolume = getF32OverrideValue( &acidDoseVolume ); F32 bicarbVolume = getF32OverrideValue( &bicarbDoseVolume ); + freshDialPressure = getFilteredPressure( D18_PRES ); + spentDialPressure = getFilteredPressure( D51_PRES ); // Check fresh and spent dialysate pressure in range #ifndef __BC_PRESSURE_ALARM__ @@ -635,22 +667,18 @@ /*********************************************************************//** * @brief - * The handleBalChamberState2FillEnd function check for the balancing chamber + * The handleBalChamberState2ValvesClose function check for the balancing chamber * fill complete and close the currently opened valves. - * @details \b Inputs: balChamberSWState, spent and fresh dialysate pressure + * @details \b Inputs: currentBalChamberSwitchingCounter, spent and fresh dialysate pressure * @details \b Outputs: isPressureStalbilizedDuringFill,isBalChamberFillInProgress - * @details \b Alarm: ALARM_ID_DD_BC_STATE2_FILL_PRESSURE_DROP_OUT_OF_RANGE - * when pressure is not in range during balacing chamber state 2 fill in progress. - * @details \b Alarm: ALARM_ID_DD_BC_STATE2_FILL_END_PRESSURE_OUT_OF_RANGE - * when pressure is not in range during balacing chamber state 2 fill complete. * @return next balancing chamber state. *************************************************************************/ -static BAL_CHAMBER_EXEC_STATE_T handleBalChamberState2FillEnd( void ) +static BAL_CHAMBER_EXEC_STATE_T handleBalChamberState2ValvesClose( void ) { - BAL_CHAMBER_EXEC_STATE_T state = BAL_CHAMBER_STATE2_FILL_END; + BAL_CHAMBER_EXEC_STATE_T state = BAL_CHAMBER_STATE2_VALVES_CLOSE; - F32 freshDialPressure = getFilteredPressure( D18_PRES ); - F32 spentDialPressure = getFilteredPressure( D51_PRES ); + freshDialPressure = getFilteredPressure( D18_PRES ); + spentDialPressure = getFilteredPressure( D51_PRES ); // Check fresh and spent dialysate pressure back in range to indicate fill complete. #ifdef __BC_PRESSURE_ALARM__ @@ -674,8 +702,30 @@ { // close the valves valveControlForBCState2FillEnd(); + + //Transition to next state + state = BAL_CHAMBER_STATE2_FILL_END; } + return state; +} + +/*********************************************************************//** + * @brief + * The handleBalChamberState2FillEnd function check for the balancing chamber + * switching period complete and transition to next state. + * @details \b Inputs: currentBalChamberSwitchingCounter, balChamberSwitchingPeriod + * @details \b Outputs: isPressureStalbilizedDuringFill,isBalChamberFillInProgress + * @details \b Alarm: ALARM_ID_DD_BC_STATE2_FILL_PRESSURE_DROP_OUT_OF_RANGE + * when pressure is not in range during balacing chamber state 2 fill in progress. + * @details \b Alarm: ALARM_ID_DD_BC_STATE2_FILL_END_PRESSURE_OUT_OF_RANGE + * when pressure is not in range during balacing chamber state 2 fill complete. + * @return next balancing chamber state. + *************************************************************************/ +static BAL_CHAMBER_EXEC_STATE_T handleBalChamberState2FillEnd( void ) +{ + BAL_CHAMBER_EXEC_STATE_T state = BAL_CHAMBER_STATE2_FILL_END; + // On completion of cycle time, transition to next state if ( currentBalChamberSwitchingCounter >= balChamberSwitchingPeriod ) { Index: firmware/App/DDCommon.h =================================================================== diff -u -r399c6b8efe0bf5ca7f5afb0aa0bc38c557fa36be -r2a1296e1269e7c36dd07cb0f39b70b742f6de405 --- firmware/App/DDCommon.h (.../DDCommon.h) (revision 399c6b8efe0bf5ca7f5afb0aa0bc38c557fa36be) +++ firmware/App/DDCommon.h (.../DDCommon.h) (revision 2a1296e1269e7c36dd07cb0f39b70b742f6de405) @@ -40,7 +40,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