Index: firmware/App/Modes/ModeGenDialysate.c =================================================================== diff -u -rd31e9b40e9d56df8fa3551bbba63f6bec3a72811 -r9d2242ea86f1e311f6ccc16bb00b203afceb91a8 --- firmware/App/Modes/ModeGenDialysate.c (.../ModeGenDialysate.c) (revision d31e9b40e9d56df8fa3551bbba63f6bec3a72811) +++ firmware/App/Modes/ModeGenDialysate.c (.../ModeGenDialysate.c) (revision 9d2242ea86f1e311f6ccc16bb00b203afceb91a8) @@ -73,6 +73,18 @@ #define B3_HEAT_DIS_SEC_COEFF 0.0000085278F ///< Second coefficient for Heat loss dissipation calculation from D28 to Dialyzer. #define B3_HEAT_DIS_THIRD_COEFF 0.0035126F ///< Third coefficient for Heat loss dissipation calculation from D28 to Dialyzer. #define B3_HEAT_DIS_FOURTH_COEFF 0.63893F ///< Fourth coefficient for Heat loss dissipation calculation from D28 to Dialyzer. + +#define BETA2_0_B1B2_HEAT_DIS_FIRST_COEFF 0.0000000000323F ///< First coefficient for Heat loss dissipation calculation from D4 to D28(Beta2.0 quartic equation). +#define BETA2_0_B1B2_HEAT_DIS_SEC_COEFF 0.0000000557449F ///< Second coefficient for Heat loss dissipation calculation from D4 to D28. +#define BETA2_0_B1B2_HEAT_DIS_THIRD_COEFF 0.0000358378838F ///< Third coefficient for Heat loss dissipation calculation from D4 to D28. +#define BETA2_0_B1B2_HEAT_DIS_FOURTH_COEFF 0.01072756717F ///< Fourth coefficient for Heat loss dissipation calculation from D4 to D28. +#define BETA2_0_B1B2_HEAT_DIS_FIFTH_COEFF 1.28454963635F ///< Fifth coefficient for Heat loss dissipation calculation from D4 to D28. +#define BETA2_0_B3_HEAT_DIS_FIRST_COEFF 0.000000000109F ///< First coefficient for Heat loss dissipation calculation from D28 to Dialyzer(Beta2.0 quartic equation). +#define BETA2_0_B3_HEAT_DIS_SEC_COEFF 0.000000188979F ///< Second coefficient for Heat loss dissipation calculation from D28 to Dialyzer. +#define BETA2_0_B3_HEAT_DIS_THIRD_COEFF 0.000120516848F ///< Third coefficient for Heat loss dissipation calculation from D28 to Dialyzer. +#define BETA2_0_B3_HEAT_DIS_FOURTH_COEFF 0.033806726263F ///< Fourth coefficient for Heat loss dissipation calculation from D28 to Dialyzer. +#define BETA2_0_B3_HEAT_DIS_FIFTH_COEFF 3.691985090908F ///< Fifth coefficient for Heat loss dissipation calculation from D28 to Dialyzer. + #define PUMP_SPEED_SLOPE_FACTOR_DIENER_2000 1.24F ///< D48 Diener 2000 pump speed slope (y = 1.24x + 30). #define PUMP_SPEED_INTERCEPT_FACTOR_DIENER_2000 30.0F ///< D48 Diener 2000 pump speed intercept. #define PUMP_SPEED_SLOPE_FACTOR_DIENER_1000 2.869F ///< D48 Diener 1000 pump speed slope (y = 2.869x + 25.956). @@ -120,6 +132,8 @@ static void updateDialysateToDialyzerFlowRate( void ); static void checkDialysateTemperature( void ); static void monitorChamberLevelStatus( void ); +static F32 calculateBeta2HeatDissipationB1andB2( void ); +static F32 calculateBeta2HeatDissipationB3( void ); static F32 calculateHeatDissipationB1andB2( void ); static F32 calculateHeatDissipationB3( void ); static F32 calculateInitialTemp( F32 targetTemp, F32 heatDissipation ); @@ -629,18 +643,26 @@ F32 deltaTemp = 0.0F; F32 heatDissipation_b3 = 0.0F; F32 targetTemp = getTDTargetDialysateTemperature(); - F32 initialTempAtD28 = 0.0F; + F32 targetTempAtD28 = 0.0F; // Heat loss model predicts the heat loss ( B3) in the DD flow path and // finds the delta temperature to be added with the target temperature // to maintain the target temperature at dialyzer. //Lets calculate B3 heat dissipation factor - heatDissipation_b3 = calculateHeatDissipationB3(); + if ( TRUE == getTestConfigStatus( TEST_CONFIG_DD_FP_ENABLE_BETA_2_0_HW ) ) + { + // based on Beta2.0 heat loss model + heatDissipation_b3 = calculateBeta2HeatDissipationB3(); + } + else + { + heatDissipation_b3 = calculateHeatDissipationB3(); + } - // Reverse calculation of Initial temp at D28 to get the target dialyzer temperature - initialTempAtD28 = calculateInitialTemp( targetTemp, heatDissipation_b3 ); + // Reverse calculation of target temp at D28 to get the target dialyzer temperature + targetTempAtD28 = calculateInitialTemp( targetTemp, heatDissipation_b3 ); - return initialTempAtD28; + return targetTempAtD28; } /*********************************************************************//** @@ -683,8 +705,8 @@ F32 heatDissipation_b1b2 = 0.0F; F32 heatDissipation_b3 = 0.0F; F32 targetTemp = getTDTargetDialysateTemperature(); - F32 initialTempAtD28 = 0.0F; - F32 initialTempAtD4 = 0.0F; + F32 targetTempAtD28 = 0.0F; + F32 targetTempAtD4 = 0.0F; #ifndef __REVISED_HEATER_MODEL__ if ( dialFlowrate >= LOW_DIAL_FLOW_RATE ) @@ -705,21 +727,80 @@ // Heat loss model predicts the heat loss ( B1,B2 and B3) in the DD flow path and // finds the delta temperature to be added with the target temperature // to maintain the target temperature at dialyzer. - //Lets calculate the B1,B2 and B3 heat dissipation factors - heatDissipation_b3 = calculateHeatDissipationB3(); - heatDissipation_b1b2 = calculateHeatDissipationB1andB2(); + // Lets calculate the B1,B2 and B3 heat dissipation factors + if ( TRUE == getTestConfigStatus( TEST_CONFIG_DD_FP_ENABLE_BETA_2_0_HW ) ) + { + // based on Beta2.0 heat loss model + heatDissipation_b3 = calculateBeta2HeatDissipationB3(); + heatDissipation_b1b2 = calculateBeta2HeatDissipationB1andB2(); + } + else + { + heatDissipation_b3 = calculateHeatDissipationB3(); + heatDissipation_b1b2 = calculateHeatDissipationB1andB2(); + } - // Reverse calculation of Initial temp at D28 to get the target dialyzer temperature - initialTempAtD28 = calculateInitialTemp( targetTemp, heatDissipation_b3 ); - // calculation of Initial temp at D4 to get the target temp at D28 level - initialTempAtD4 = calculateInitialTemp( initialTempAtD28, heatDissipation_b1b2 ); + // Reverse calculation of target temp at D28 to get the target dialyzer temperature + targetTempAtD28 = calculateInitialTemp( targetTemp, heatDissipation_b3 ); + // calculation of target temp at D4 to get the target temp at D28 level + targetTempAtD4 = calculateInitialTemp( targetTempAtD28, heatDissipation_b1b2 ); - targetHydChamberFluidTemp.data = initialTempAtD4; + targetHydChamberFluidTemp.data = targetTempAtD4; #endif } /*********************************************************************//** * @brief + * The calculateBeta2HeatDissipationB1andB2 function calculates the heat dissipation + * constants called B1 and B2 that describes the heat loss between D4 to D28 in + * the PID flow path for Beta2.0 hardware. + * @details \b Inputs: Qd. + * @details \b Outputs: none + * @return the calculated heat dissipation constants. + *************************************************************************/ +static F32 calculateBeta2HeatDissipationB1andB2( void ) +{ + // Get the dialysate flow rate from TD + F32 b1b2 = 0.0F; + F32 qd = getTDDialysateFlowrate(); + F32 firstPart = BETA2_0_B1B2_HEAT_DIS_FIRST_COEFF * qd * qd * qd * qd; + F32 secondPart = BETA2_0_B1B2_HEAT_DIS_SEC_COEFF * qd * qd * qd; + F32 thirdPart = BETA2_0_B1B2_HEAT_DIS_THIRD_COEFF * qd * qd; + F32 fourthPart = BETA2_0_B1B2_HEAT_DIS_FOURTH_COEFF * qd; + + // B1B2 = 0.0000000000323x4-0.0000000557449x3+0.0000358378838x2-0.01072756717x + 1.28454963635 + b1b2 = firstPart - secondPart + thirdPart - fourthPart + BETA2_0_B1B2_HEAT_DIS_FIFTH_COEFF; + + return b1b2; +} + +/*********************************************************************//** + * @brief + * The calculateBeta2HeatDissipationB3 function calculates the heat dissipation + * constants called B3 that describes the heat loss between D28 to dialyzer in + * the PID flow path for Beta2.0 hardware. + * @details \b Inputs: Qd. + * @details \b Outputs: none + * @return the calculated heat dissipation constant. + *************************************************************************/ +static F32 calculateBeta2HeatDissipationB3( void ) +{ + // Get the dialysate flow rate from TD + F32 b3 = 0.0F; + F32 qd = getTDDialysateFlowrate(); + F32 firstPart = BETA2_0_B3_HEAT_DIS_FIRST_COEFF * qd * qd * qd * qd; + F32 secondPart = BETA2_0_B3_HEAT_DIS_SEC_COEFF * qd * qd * qd; + F32 thirdPart = BETA2_0_B3_HEAT_DIS_THIRD_COEFF * qd * qd; + F32 fourthPart = BETA2_0_B3_HEAT_DIS_FOURTH_COEFF * qd; + + // B3 = 0.000000000109x4-0.000000188979x3+0.000120516848x2-0.033806726263x+3.691985090908 + b3 = firstPart - secondPart + thirdPart - fourthPart + BETA2_0_B3_HEAT_DIS_FIFTH_COEFF; + + return b3; +} + +/*********************************************************************//** + * @brief * The calculateHeatDissipationB1andB2 function calculates the heat dissipation * constants called B1 and B2 that describes the heat loss between D4 to D28 in * the PID flow path.