Index: firmware/App/Controllers/Ultrafiltration.c =================================================================== diff -u -r25dbc6221b63e20fe61b2af0ce9c9f56bf13e807 -rab9df65fbbb4f8387a5f2c0e7aa26bd234843150 --- firmware/App/Controllers/Ultrafiltration.c (.../Ultrafiltration.c) (revision 25dbc6221b63e20fe61b2af0ce9c9f56bf13e807) +++ firmware/App/Controllers/Ultrafiltration.c (.../Ultrafiltration.c) (revision ab9df65fbbb4f8387a5f2c0e7aa26bd234843150) @@ -45,6 +45,7 @@ static U32 currentUFCompCounter; ///< Counter (in task interval) to initiate the periodic ultrafiltration temperature compensation. static F32 compUFrate; ///< compensated UF rate static U32 ufDataPublicationTimerCounter; ///< Used to schedule ultrafiltration data publication to CAN bus. +static BOOL isUFRateUpdated; ///< flag indicating to update UF rate needed. static OVERRIDE_U32_T ufDataPublishInterval; ///< Ultrafiltration data publish interval. // ********** private function prototypes ********** @@ -73,6 +74,7 @@ currentUFCompCounter = 0; compUFrate = getTDUFRate(); ufDataPublicationTimerCounter = 0; + isUFRateUpdated = FALSE; } /*********************************************************************//** @@ -142,6 +144,10 @@ if ( TRUE == isUltrafiltrationRequested ) { + // start with TD UF rate + compUFrate = getTDUFRate(); + currentUFCompCounter = 0; + setConcentratePumpTargetSpeed( D76_PUMP, compUFrate, DOSING_CONT_VOLUME ); requestConcentratePumpOn( D76_PUMP ); @@ -169,11 +175,6 @@ requestConcentratePumpOff( D76_PUMP, FALSE ); state = DD_UF_PAUSED; } - else - { - // Get the updated rate if there is any change - setConcentratePumpTargetSpeed( D76_PUMP, compUFrate, DOSING_CONT_VOLUME ); - } return state; } @@ -202,6 +203,19 @@ /*********************************************************************//** * @brief + * The signalUFRateUpdate function sets the flag to udpate the + * UF rate. + * @details \b Inputs: none + * @details \b Outputs: isUFRateUpdated + * @return none. + *************************************************************************/ +void signalUFRateUpdate( void ) +{ + isUFRateUpdated = TRUE; +} + +/*********************************************************************//** + * @brief * The UpdateUFCompensation function updates the ultrafiltration rate * based on the dialysate temperature compensation. * @details \b Inputs: D4 and D50 temperature @@ -210,7 +224,7 @@ *************************************************************************/ static void UpdateUFCompensation( void ) { - if ( ++currentUFCompCounter >= UF_COMP_INTERVAL ) + if ( ( ++currentUFCompCounter >= UF_COMP_INTERVAL ) || ( TRUE == isUFRateUpdated ) ) { F32 freshDensity = ( COMP_SLOPE * getD4AverageTemperature() ) + COMP_INTERCEPT; // Fresh side dialysate density F32 spentDensity = ( COMP_SLOPE * getD50AverageTemperature() ) + COMP_INTERCEPT; // spent side dialysate density @@ -224,7 +238,11 @@ compUFrate = getTDUFRate() + balancingError; } + // Update UF rate + setConcentratePumpTargetSpeed( D76_PUMP, compUFrate, DOSING_CONT_VOLUME ); + currentUFCompCounter = 0; + isUFRateUpdated = FALSE; } }