Index: firmware/App/Controllers/Ultrafiltration.c =================================================================== diff -u -rd748813399d38ef5b71d760e327e368cc82d7a38 -rb14374d1a56e47fdb79c913950a5cd17a403c4ac --- firmware/App/Controllers/Ultrafiltration.c (.../Ultrafiltration.c) (revision d748813399d38ef5b71d760e327e368cc82d7a38) +++ firmware/App/Controllers/Ultrafiltration.c (.../Ultrafiltration.c) (revision b14374d1a56e47fdb79c913950a5cd17a403c4ac) @@ -97,15 +97,14 @@ * @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 ) { - // Calculate UF volume and determine UF pause/run - updateUFRequest(); - // Trimmer heater enabled, hence UF temp compensation is optional - if ( getTestConfigStatus( TEST_CONFIG_DD_ENABLE_UF_TEMP_COMPENSATION ) == TRUE ) + if ( getTestConfigStatus( TEST_CONFIG_DD_DISABLE_UF_TEMP_COMPENSATION ) != TRUE ) { // Compensate balancing error at defined interval UpdateUFCompensation(); @@ -120,6 +119,9 @@ isUFRateUpdated = FALSE; } + // Calculate UF volume and determine UF pause/run + updateUFRequest(); + // execute current ultrafiltration exec state switch ( ufExecState ) { @@ -195,16 +197,15 @@ /*********************************************************************//** * @brief * The updateUFRequest function updates the ultrafiltration requested - * flag to true or false based on the conditions. - * @details \b Inputs: TD Uf rate, TD Dialysate flow rate and bypass flag + * 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; } @@ -239,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; Index: firmware/App/Monitors/Temperature.h =================================================================== diff -u -r2a85af53e9b2ee2cf79f832167c9723a886d1ab9 -rb14374d1a56e47fdb79c913950a5cd17a403c4ac --- firmware/App/Monitors/Temperature.h (.../Temperature.h) (revision 2a85af53e9b2ee2cf79f832167c9723a886d1ab9) +++ firmware/App/Monitors/Temperature.h (.../Temperature.h) (revision b14374d1a56e47fdb79c913950a5cd17a403c4ac) @@ -82,6 +82,7 @@ void execTemperatureSensors( void ); F32 getD4AverageTemperature( void ); F32 getD50AverageTemperature( void ); +F32 getD99AverageTemperature( void ); void checkDialysateTemperatureSensors( void ); BOOL testDDTemperatureSensorsDataPublishIntervalOverride( MESSAGE_T *message );