Index: firmware/App/Controllers/Ultrafiltration.c =================================================================== diff -u -r5d60262836ddc8f80ac98f07f2cfd6707a5b7b79 -r48c4d25d6918813d93165fe4e7fee3bf0c247b7c --- firmware/App/Controllers/Ultrafiltration.c (.../Ultrafiltration.c) (revision 5d60262836ddc8f80ac98f07f2cfd6707a5b7b79) +++ firmware/App/Controllers/Ultrafiltration.c (.../Ultrafiltration.c) (revision 48c4d25d6918813d93165fe4e7fee3bf0c247b7c) @@ -97,16 +97,31 @@ * @details \b Outputs: ufExecState * @details \b Alarm: ALARM_ID_DD_SOFTWARE_FAULT when wrong ultrafiltration * state invoked. + * @details Warning: The compensated UF should be caclulated first and then + * call 'updateUFRequest' function. * @return current state. *************************************************************************/ U32 execUFControl( void ) { + // Trimmer heater enabled, hence UF temp compensation is optional + if ( getTestConfigStatus( TEST_CONFIG_DD_DISABLE_UF_TEMP_COMPENSATION ) != TRUE ) + { + // Compensate balancing error at defined interval + UpdateUFCompensation(); + } + else if ( TRUE == isUFRateUpdated ) + { + //get updated UF rate + compUFrate = getTDUFRate(); + + // Update UF rate + setConcentratePumpTargetSpeed( D76_PUMP, compUFrate, DOSING_CONT_VOLUME ); + isUFRateUpdated = FALSE; + } + // Calculate UF volume and determine UF pause/run updateUFRequest(); - // Compensate balancing error at defined interval - UpdateUFCompensation(); - // execute current ultrafiltration exec state switch ( ufExecState ) { @@ -181,17 +196,16 @@ /*********************************************************************//** * @brief - * The updateUFRequest function updates the ultrafiltration rate per iteration - * and of the ultrafiltration. - * @details \b Inputs: TD Uf rate, TD Dialysate flow rate and bypass flag - * @details \b Outputs: ufVolumeperIteration , isUltrafiltrationRequested + * The updateUFRequest function updates the ultrafiltration requested + * flag to true or false based on the compensated UF rate. + * @details \b Inputs: compensated UF + * @details \b Outputs: isUltrafiltrationRequested * @return none. *************************************************************************/ static void updateUFRequest( void ) { // update latest UF run/pause request - if ( ( getTDUFRate() > ZERO_RATE ) && ( TRUE != getTDDialyzerBypass() ) && - ( getTDDialysateFlowrate() > ZERO_RATE ) ) + if ( compUFrate > ZERO_RATE ) { isUltrafiltrationRequested = TRUE; } @@ -226,12 +240,26 @@ { 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 - F32 compFreshFlowrate = getTDDialysateFlowrate() * freshDensity; // Qd * fresh density - F32 compSpentFlowrate = getTDDialysateFlowrate() * spentDensity; // Qd * spent density - F32 balancingError = compFreshFlowrate - compSpentFlowrate; // Error in g/min + F32 freshDensity = 0.0F; + F32 spentDensity = 0.0F; + F32 compFreshFlowrate = 0.0F; + F32 compSpentFlowrate = 0.0F; + F32 balancingError = 0.0F; + // Fresh side dialysate density + if ( getTestConfigStatus( TEST_CONFIG_DD_FP_ENABLE_BETA_1_0_HW ) == TRUE ) + { + freshDensity = ( COMP_SLOPE * getD4AverageTemperature() ) + COMP_INTERCEPT; + } + else + { + freshDensity = ( COMP_SLOPE * getD99AverageTemperature() ) + COMP_INTERCEPT; + } + spentDensity = ( COMP_SLOPE * getD50AverageTemperature() ) + COMP_INTERCEPT; // spent side dialysate density + compFreshFlowrate = getTDDialysateFlowrate() * freshDensity; // Qd * fresh density + compSpentFlowrate = getTDDialysateFlowrate() * spentDensity; // Qd * spent density + balancingError = compFreshFlowrate - compSpentFlowrate; // Error in g/min + //Update compensate UF rate with the balancing chamber error compUFrate = getTDUFRate() + balancingError;