Index: firmware/App/Controllers/SpentChamberFill.c =================================================================== diff -u -rc7dcaa774c66053bcf0a52d56068d1960187bae1 -r0a74bcce6674271e35d5154003dd6c25011f80f9 --- firmware/App/Controllers/SpentChamberFill.c (.../SpentChamberFill.c) (revision c7dcaa774c66053bcf0a52d56068d1960187bae1) +++ firmware/App/Controllers/SpentChamberFill.c (.../SpentChamberFill.c) (revision 0a74bcce6674271e35d5154003dd6c25011f80f9) @@ -47,13 +47,17 @@ static U32 currentSpentChamberFillSwitchingCounter; ///< Counter (in task interval) to monitor the timing spent during spent chamber fill operation. static U32 totalSpentChamberfillCounter; ///< Counter (in task interval) to monitor the total number of spent chamber fill operation. static U32 spentChamberFillDataPublicationTimerCounter; ///< Used to schedule spent chamber fill data publication to CAN bus. +static F32 acidDoseVolume; ///< Acid concentrate volume in ml +static F32 bicarbDoseVolume; ///< Bicarb concentrate volume in ml static OVERRIDE_U32_T spentChamberFillDataPublishInterval; ///< Spent chamber fill data publish interval. // ********** private function prototypes ********** static SPENT_CHAMBER_FILL_EXEC_STATE_T handleSpentChamberFillState1FillStart( void ); +static SPENT_CHAMBER_FILL_EXEC_STATE_T handleSpentChamberState1DosingControl( void ); static SPENT_CHAMBER_FILL_EXEC_STATE_T handleSpentChamberFillState1FillEnd(void); static SPENT_CHAMBER_FILL_EXEC_STATE_T handleSpentChamberFillState2FillStart( void ); +static SPENT_CHAMBER_FILL_EXEC_STATE_T handleSpentChamberState2DosingControl( void ); static SPENT_CHAMBER_FILL_EXEC_STATE_T handleSpentChamberFillState2FillEnd(void); static void publishSpentChamberFillData( void ); @@ -71,6 +75,8 @@ spentChamberFillDataPublishInterval.ovData = SPENT_CHAMBER_FILL_DATA_PUBLISH_INTERVAL; spentChamberFillDataPublishInterval.ovInitData = 0; spentChamberFillDataPublishInterval.override = OVERRIDE_RESET; + acidDoseVolume = DEFAULT_ACID_VOLUME_ML; + bicarbDoseVolume = DEFAULT_BICARB_VOLUME_ML; spentChamberFillSwitchingPeriod = 0; currentSpentChamberFillSwitchingCounter = 0; spentChamberFillDataPublicationTimerCounter = 0; @@ -119,6 +125,10 @@ spentChamberFillExecState = handleSpentChamberFillState1FillStart(); break; + case SPENT_CHAMBER_FILL_STATE1_DOSING_CNTRL: + spentChamberFillExecState = handleSpentChamberState1DosingControl(); + break; + case SPENT_CHAMBER_FILL_STATE1_FILL_END: spentChamberFillExecState = handleSpentChamberFillState1FillEnd(); break; @@ -127,6 +137,10 @@ spentChamberFillExecState = handleSpentChamberFillState2FillStart(); break; + case SPENT_CHAMBER_FILL_STATE2_DOSING_CNTRL: + spentChamberFillExecState = handleSpentChamberState2DosingControl(); + break; + case SPENT_CHAMBER_FILL_STATE2_FILL_END: spentChamberFillExecState = handleSpentChamberFillState2FillEnd(); break; @@ -195,7 +209,7 @@ * state 1 fill operations. * @details \b Inputs: fresh and spent dialysate pressure * @details \b Outputs: valve states,current spent chamber fill state - * @details \b Alarm: ALARM_ID_DD_BC_STATE1_FILL_START_PRESSURE_OUT_OF_RANGE + * @details \b Alarm: ALARM_ID_DD_SC_STATE1_FILL_START_PRESSURE_OUT_OF_RANGE * when pressure is not in range during balacing chamber fill start. * @return next spent chamber fill state. *************************************************************************/ @@ -213,8 +227,11 @@ { //Valve control for state 1 spent chamber fill valveControlForSCFillState1FillStart(); + // start acid and bicarb pump with the expected quantity + setConcentratePumpTargetSpeed( D11_PUMP, CONCENTRATE_PUMP_MAX_SPEED, acidDoseVolume ); + setConcentratePumpTargetSpeed( D10_PUMP, CONCENTRATE_PUMP_MAX_SPEED, bicarbDoseVolume ); - state = SPENT_CHAMBER_FILL_STATE1_FILL_END; + state = SPENT_CHAMBER_FILL_STATE1_DOSING_CNTRL; } else { @@ -227,6 +244,28 @@ /*********************************************************************//** * @brief + * The handleSpentChamberState1DosingControl function checks the completion of + * the Acid and Bicarb concentrate dosing. + * @details \b Inputs: Dosing pump completion status + * @details \b Outputs: state + * @return next spent chamber fill state. + *************************************************************************/ +static SPENT_CHAMBER_FILL_EXEC_STATE_T handleSpentChamberState1DosingControl( void ) +{ + SPENT_CHAMBER_FILL_EXEC_STATE_T state = SPENT_CHAMBER_FILL_STATE1_DOSING_CNTRL; + + // On dosing completion, transition to next state + if ( ( TRUE == isConcentratePumpDosingCompleted( D11_PUMP ) ) && + ( TRUE == isConcentratePumpDosingCompleted( D10_PUMP ) ) ) + { + state = SPENT_CHAMBER_FILL_STATE1_FILL_END; + } + + return state; +} + +/*********************************************************************//** + * @brief * The handleSpentChamberFillState1FillEnd function check for the spent chamber * fill switching period and tranistion to next state. * @details \b Inputs: currentSpentChamberFillSwitchingCounter,spentChamberFillSwitchingPeriod @@ -257,7 +296,7 @@ * state 2 fill operations. * @details \b Inputs: fresh and spent dialysate pressure * @details \b Outputs: balancing chamber valves state - * @details \b Alarm: ALARM_ID_DD_BC_STATE2_FILL_START_PRESSURE_OUT_OF_RANGE + * @details \b Alarm: ALARM_ID_DD_SC_STATE2_FILL_START_PRESSURE_OUT_OF_RANGE * when pressure is not in range during balacing chamber state 2 fill start. * @return next spent chamber fill state. *************************************************************************/ @@ -275,8 +314,11 @@ { // Valve control for state 2 fill valveControlForSCFillState2FillStart(); + // start acid and bicarb pump with the expected quantity + setConcentratePumpTargetSpeed( D11_PUMP, CONCENTRATE_PUMP_MAX_SPEED, acidDoseVolume ); + setConcentratePumpTargetSpeed( D10_PUMP, CONCENTRATE_PUMP_MAX_SPEED, bicarbDoseVolume ); - state = SPENT_CHAMBER_FILL_STATE2_FILL_END; + state = SPENT_CHAMBER_FILL_STATE2_DOSING_CNTRL; } else { @@ -288,6 +330,28 @@ /*********************************************************************//** * @brief + * The handleSpentChamberState2DosingControl function checks the completion of + * the Acid and Bicarb concentrate dosing. + * @details \b Inputs: Dosing pump completion status + * @details \b Outputs: state + * @return next spent chamber fill state. + *************************************************************************/ +static SPENT_CHAMBER_FILL_EXEC_STATE_T handleSpentChamberState2DosingControl( void ) +{ + SPENT_CHAMBER_FILL_EXEC_STATE_T state = SPENT_CHAMBER_FILL_STATE2_DOSING_CNTRL; + + // On dosing completion, transition to next state + if ( ( TRUE == isConcentratePumpDosingCompleted( D11_PUMP ) ) && + ( TRUE == isConcentratePumpDosingCompleted( D10_PUMP ) ) ) + { + state = SPENT_CHAMBER_FILL_STATE2_FILL_END; + } + + return state; +} + +/*********************************************************************//** + * @brief * The handleSpentChamberFillState2FillEnd function check for the spent chamber * switching period complete and transition to next state. * @details \b Inputs: currentSpentChamberFillSwitchingCounter,spentChamberFillSwitchingPeriod