Index: firmware/App/Controllers/BalancingChamber.c =================================================================== diff -u -r5422509f9d8db102b62952ba9f5923e832d6b2fa -r9e6e86f604c8cce7c1704ae55d1e026de3422782 --- firmware/App/Controllers/BalancingChamber.c (.../BalancingChamber.c) (revision 5422509f9d8db102b62952ba9f5923e832d6b2fa) +++ firmware/App/Controllers/BalancingChamber.c (.../BalancingChamber.c) (revision 9e6e86f604c8cce7c1704ae55d1e026de3422782) @@ -20,6 +20,7 @@ #include "ConcentratePumps.h" #include "DialysatePumps.h" #include "FpgaDD.h" +#include "Heaters.h" #include "ModeStandby.h" #include "Messaging.h" #include "OperationModes.h" @@ -37,7 +38,6 @@ // ********** private definitions ********** -#define BAL_CHAMBER_FILL_VOLUME_ML 30.0F ///< Balancing chamber fill/drain volume per batch operation. #define BAL_CHAMBER_DATA_PUBLISH_INTERVAL ( 250 / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the balancing chamber data published. /// Payload record structure for balancing chamber switch only request @@ -63,6 +63,7 @@ static BOOL balanceChamberSwitchingOnly; ///< Balancing chamber switching without any pressure check and dosing delivery. 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 // ********** private function prototypes ********** @@ -107,6 +108,7 @@ isBalChamberFillInProgress = FALSE; currentBalChamberSwitchingCounter = 0; isPressureStalbilizedDuringFill = FALSE; + lastTdDialysateFlowrate = 0.0F; balChamberDataPublicationTimerCounter = 0; } @@ -134,18 +136,29 @@ *************************************************************************/ void updateBalChamberSwitchingPeriod( void ) { - // update the balancing chamber switching frequency - balChamberSwitchingFreq.data = getTDDialysateFlowrate() / BAL_CHAMBER_FILL_VOLUME_ML; + F32 tdDialysateFlowrate = getTDDialysateFlowrate(); - //update the switching period in task interval for balancing chamber fill timeout check - balChamberSwitchingPeriod = (U32)( (F32)SEC_PER_MIN / getBalChamberSwitchingFreq() * ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ); + if ( lastTdDialysateFlowrate != tdDialysateFlowrate ) + { + // update the balancing chamber switching frequency + balChamberSwitchingFreq.data = tdDialysateFlowrate / BAL_CHAMBER_FILL_VOLUME_ML; - // finish the balancing chamber fill 50 ms prior completing the regular cycle time. - balChamberSwitchingPeriod -= 1; + //update the switching period in task interval for balancing chamber fill timeout check + balChamberSwitchingPeriod = (U32)( (F32)SEC_PER_MIN / getBalChamberSwitchingFreq() * ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ); - //Testing - balChamberValveClosePeriod = balChamberSwitchingPeriod; - balChamberValveClosePeriod -= 1; // Close valves prior 50 msecond for testing + // finish the balancing chamber fill 50 ms prior completing the regular cycle time. + balChamberSwitchingPeriod -= 1; + + //Update last td dialysate flow rate + lastTdDialysateFlowrate = tdDialysateFlowrate; + + //Update heater control on dialysate flow change + signalHeaterControlOnQDUpdate( D5_HEAT ); + + //Testing + balChamberValveClosePeriod = balChamberSwitchingPeriod; + balChamberValveClosePeriod -= 1; // Close valves prior 50 msecond for testing + } } /*********************************************************************//** @@ -404,8 +417,10 @@ } else { +#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 } return state; @@ -433,10 +448,11 @@ } // On dosing completion, transition to next state based on the current switching state - if ( ( ( TRUE == isConcentratePumpDosingCompleted( D11_PUMP ) ) && - ( TRUE == isConcentratePumpDosingCompleted( D10_PUMP ) ) ) || - ( TRUE == getBalChamberSwitchingOnlyStatus() ) ) - { + // 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 ( BAL_CHAMBER_SW_STATE1 == balChamberSWState ) { state = BAL_CHAMBER_STATE1_FILL_END; @@ -445,7 +461,7 @@ { state = BAL_CHAMBER_STATE2_FILL_END; } - } +// } return state; } @@ -497,13 +513,17 @@ { if ( TRUE != isPressureDroppedDuringFill ) { +#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 } else if ( TRUE != isPressureStalbilizedDuringFill ) { +#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 } else { @@ -574,8 +594,10 @@ } else { +#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 } return state; } @@ -628,13 +650,17 @@ { if ( TRUE != isPressureDroppedDuringFill ) { +#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 } else if ( TRUE != isPressureStalbilizedDuringFill ) { +#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 } else {