Index: firmware/App/Controllers/BalancingChamber.c =================================================================== diff -u -r9ff57b5ab7490ee5bbc2c51b25f738ee6c569ec1 -r4a80b214d221c1f64feb215d828a10d8fddbaf4d --- firmware/App/Controllers/BalancingChamber.c (.../BalancingChamber.c) (revision 9ff57b5ab7490ee5bbc2c51b25f738ee6c569ec1) +++ firmware/App/Controllers/BalancingChamber.c (.../BalancingChamber.c) (revision 4a80b214d221c1f64feb215d828a10d8fddbaf4d) @@ -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" @@ -63,6 +64,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 +109,7 @@ isBalChamberFillInProgress = FALSE; currentBalChamberSwitchingCounter = 0; isPressureStalbilizedDuringFill = FALSE; + lastTdDialysateFlowrate = 0.0F; balChamberDataPublicationTimerCounter = 0; } @@ -134,18 +137,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 + } } /*********************************************************************//**