Index: firmware/App/Controllers/Heaters.c =================================================================== diff -u -ra140769de454d638730bbfd1fabdf6ce2b949d35 -rea58258093207cb49785aa04ab1e19065166cac6 --- firmware/App/Controllers/Heaters.c (.../Heaters.c) (revision a140769de454d638730bbfd1fabdf6ce2b949d35) +++ firmware/App/Controllers/Heaters.c (.../Heaters.c) (revision ea58258093207cb49785aa04ab1e19065166cac6) @@ -57,11 +57,13 @@ #define ADJ_DELTA_TEMP_STEP 2.0F ///< Adjust target temperature based on D28 feedback per cycle. #define MAX_ADJ_DELTA_TEMP_C 7.0F ///< Maximum adjusted delta temperature to add/remove from calculated target temperature #define D5_HEAT_TX_INIT_FEED_FORWARD 0.0F ///< Initial Feed forward term for heater control -#define D5_HEAT_TX_P_COEFFICIENT 0.017F ///< P Term for AC primary heater control during treatment mode. -#define D5_HEAT_TX_I_COEFFICIENT 0.002F ///< I Term for AC primary heater control during treatment mode. +#define D5_HEAT_TX_P_COEFFICIENT 0.05F ///< P Term for AC primary heater control during treatment mode. +#define D5_HEAT_TX_I_COEFFICIENT 0.001F ///< I Term for AC primary heater control during treatment mode. -#define D45_HEAT_P_COEFFICIENT 0.20F ///< P Term for trimmer heater control. -#define D45_HEAT_I_COEFFICIENT 0.05F ///< I Term for trimmer heater control. +//#define D45_HEAT_P_COEFFICIENT 0.20F ///< P Term for trimmer heater control. +//#define D45_HEAT_I_COEFFICIENT 0.05F ///< I Term for trimmer heater control. +#define D45_HEAT_P_COEFFICIENT 0.05F ///< P Term for trimmer heater control. +#define D45_HEAT_I_COEFFICIENT 0.02F ///< I Term for trimmer heater control. #define D45_HEAT_TX_INIT_FEED_FORWARD 0.0F ///< Initial Feed forward term for heater control #define HEATERS_DATA_PUBLISH_INTERVAL ( MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) ///< Heaters data publish interval. @@ -112,6 +114,26 @@ #define D5_HEAT_OUT_DEADBAND_CONTROL 0.1F ///< Heater outer loop dead band range for control. #define HIGH_DIAL_FLOW_RATE 300.0F ///< Decide outer loop heater control based on the dialysate flow rate +#define B1B2_HEAT_DIS_FIRST_COEFF 0.00000000487858F ///< First coefficient for Heat loss dissipation calculation from D4 to D28(cubic equation). +#define B1B2_HEAT_DIS_SEC_COEFF 0.0000063124F ///< Second coefficient for Heat loss dissipation calculation from D4 to D28. +#define B1B2_HEAT_DIS_THIRD_COEFF 0.00258513F ///< Third coefficient for Heat loss dissipation calculation from D4 to D28. +#define B1B2_HEAT_DIS_FOURTH_COEFF 0.242013F ///< Fourth coefficient for Heat loss dissipation calculation from D4 to D28. +#define B3_HEAT_DIS_FIRST_COEFF 0.0000000067756F ///< First coefficient for Heat loss dissipation calculation from D28 to Dialyzer(cubic equation). +#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.000000000005212F ///< First coefficient for Heat loss dissipation calculation from D4 to D28(Beta2.0 quartic equation). +#define BETA2_0_B1B2_HEAT_DIS_SEC_COEFF 0.000000009754882F ///< Second coefficient for Heat loss dissipation calculation from D4 to D28. +#define BETA2_0_B1B2_HEAT_DIS_THIRD_COEFF 0.000006714979798F ///< Third coefficient for Heat loss dissipation calculation from D4 to D28. +#define BETA2_0_B1B2_HEAT_DIS_FOURTH_COEFF 0.002289024242423F ///< Fourth coefficient for Heat loss dissipation calculation from D4 to D28. +#define BETA2_0_B1B2_HEAT_DIS_FIFTH_COEFF 0.317550545454563F ///< Fifth coefficient for Heat loss dissipation calculation from D4 to D28. +#define BETA2_0_B3_HEAT_DIS_FIRST_COEFF -0.0000000000389F ///< First coefficient for Heat loss dissipation calculation from D28 to Dialyzer(Beta2.0 quartic equation). +#define BETA2_0_B3_HEAT_DIS_SEC_COEFF 0.0000000619946F ///< Second coefficient for Heat loss dissipation calculation from D28 to Dialyzer. +#define BETA2_0_B3_HEAT_DIS_THIRD_COEFF 0.0000359241717F ///< Third coefficient for Heat loss dissipation calculation from D28 to Dialyzer. +#define BETA2_0_B3_HEAT_DIS_FOURTH_COEFF 0.0092543272727F ///< Fourth coefficient for Heat loss dissipation calculation from D28 to Dialyzer. +#define BETA2_0_B3_HEAT_DIS_FIFTH_COEFF 1.079412363636F ///< Fifth coefficient for Heat loss dissipation calculation from D28 to Dialyzer. + //static const F32 HEATERS_VOLTAGE_TOLERANCE_V = HEATERS_MAX_OPERATING_VOLTAGE_V * HEATERS_MAX_VOLTAGE_OUT_OF_RANGE_TOL; ///< Heaters voltage tolerance in volts. /// Heaters data structure @@ -170,6 +192,11 @@ static HEATERS_STATE_T handleHeaterStateControlToTarget( DD_HEATERS_T heater ); static HEATERS_STATE_T handleHeaterStateControlToDisinfectTarget( DD_HEATERS_T heater ); static void updatePrimaryHeaterTargetTemp( void ); +static F32 calculateBeta2HeatDissipationB1andB2( void ); +static F32 calculateBeta2HeatDissipationB3( void ); +static F32 calculateHeatDissipationB1andB2( void ); +static F32 calculateHeatDissipationB3( void ); +static F32 calculateInitialTemp( F32 targetTemp, F32 heatDissipation ); static F32 calculateDutyCycle( F32 flowrate, F32 deltaTemp, F32 power, F32 efficiency, F32 min, F32 max ); static void setHeaterControl( DD_HEATERS_T heater ); @@ -416,6 +443,67 @@ /*********************************************************************//** * @brief + * The calculateTargetDialysateTemp function calculate the delta temperature + * required for dialysate temperature to meet the set temperature at dialyzer. + * @details \b Inputs: Qd and target temperature. + * @details \b Outputs: Adjusted Target temperature + * @return none. + *************************************************************************/ +void calculateTargetDialysateTemp( void ) +{ + // Get the dialysate flow rate from TD + F32 dialFlowrate = getTDDialysateFlowrate(); + F32 deltaTemp = 0.0F; + F32 heatDissipation_b1b2 = 0.0F; + F32 heatDissipation_b3 = 0.0F; + F32 targetTemp = getTDTargetDialysateTemperature(); + F32 targetTempAtD28 = 0.0F; + F32 targetTempAtD4 = 0.0F; + +#ifndef __REVISED_HEATER_MODEL__ + if ( dialFlowrate >= LOW_DIAL_FLOW_RATE ) + { + // linear relationship seen against high dialysate flowrate Vs DeltaTemp + // deltaTemp = (-0.0029 * Qd) + 3.47 + deltaTemp = ( LINEAR_SLOPE_FACTOR * dialFlowrate ) + LINEAR_INTERCEPT_FACTOR; + } + else + { + // deltaTemp = (0.0006 * Qd * Qd)-(0.1743*Qd) + 17.3 + deltaTemp = ( QUAD_FIRST_COEFFICIENT * dialFlowrate * dialFlowrate ) + + ( QUAD_SECOND_COEFFICIENT * dialFlowrate ) + QUAD_THIRD_COEFFICIENT; + } + // Adjust the D4 target temperature + targetTempAtD4 = getTDTargetDialysateTemperature() + deltaTemp; + setTargetHydChamberTemp( targetTempAtD4 ); +#else + // 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 + 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 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 ); + //Update target temperature + setTargetHydChamberTemp( targetTempAtD4 ); +#endif +} + +/*********************************************************************//** + * @brief * The updatePrimaryHeaterTargetTemp function adjusts the previosuly calcualted * target dialysate temperature * @details \b Inputs: Set Target Temperature, D28 Temp @@ -443,7 +531,6 @@ F32 deltaTempC = targetTempfromTD - measuredTempAtDialyzer; F32 capDeltaTempC = MIN( fabs(deltaTempC), ADJ_DELTA_TEMP_STEP ); F32 ctrl = 0.0F; - F32 updatedTarget = 0.0F; #if 0 //Assign the initial calcualted temp for adjsutment if ( FALSE == isTargetTempAdjusted ) @@ -973,6 +1060,130 @@ /*********************************************************************//** * @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.000000000005212*x4)+(0.000000009754882*x3)-(0.000006714979798*x2)+(0.002289024242423*x)-0.317550545454563 + 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.0000000000389*x4)+(0.0000000619946*x3)-(0.0000359241717*x2)+(0.0092543272727*x)-1.079412363636 + 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. + * @details \b Inputs: Qd. + * @details \b Outputs: none + * @return the calculated heat dissipation constants. + *************************************************************************/ +static F32 calculateHeatDissipationB1andB2( void ) +{ + // Get the dialysate flow rate from TD + F32 b1b2 = 0.0F; + F32 qd = getTDDialysateFlowrate(); + F32 firstPart = B1B2_HEAT_DIS_FIRST_COEFF * qd * qd * qd; + F32 secondPart = B1B2_HEAT_DIS_SEC_COEFF * qd * qd; + F32 thirdPart = B1B2_HEAT_DIS_THIRD_COEFF * qd; + + // B1B2 = 4.87858E-09x3 - 6.31264E-06x2 + 2.58513E-03x - 2.42013E-01 + b1b2 = firstPart - secondPart + thirdPart - B1B2_HEAT_DIS_FOURTH_COEFF; + + return b1b2; +} + +/*********************************************************************//** + * @brief + * The calculateHeatDissipationB3 function calculates the heat dissipation + * constants called B3 that describes the heat loss between D28 to dialyzer in + * the PID flow path. + * @details \b Inputs: Qd. + * @details \b Outputs: none + * @return the calculated heat dissipation constant. + *************************************************************************/ +static F32 calculateHeatDissipationB3( void ) +{ + // Get the dialysate flow rate from TD + F32 b3 = 0.0F; + F32 qd = getTDDialysateFlowrate(); + F32 firstPart = B3_HEAT_DIS_FIRST_COEFF * qd * qd * qd; + F32 secondPart = B3_HEAT_DIS_SEC_COEFF * qd * qd; + F32 thirdPart = B3_HEAT_DIS_THIRD_COEFF * qd; + + // B3 = 6.7756E-09x3 - 8.5278E-06x2 + 3.5126E-03x - 6.3893E-01 + b3 = firstPart - secondPart + thirdPart - B3_HEAT_DIS_FOURTH_COEFF; + + return b3; +} + +/*********************************************************************//** + * @brief + * The calculateInitialTemp function calculates the initial temperature + * required to get the target temperature considering heat loss. + * @details \b Inputs: ambient temperature + * @details \b Outputs: none + * @param targetTemp the target/final temperature + * @param heatDissipation the heat dissipation constant + * @return the calculated initial temperature. + *************************************************************************/ +static F32 calculateInitialTemp( F32 targetTemp, F32 heatDissipation ) +{ + // Get the ambient temperature from TD + //TODO : replace once amb temp is in place. using board temperature + // to make use of feeding the value via dialin + F32 ambTemp = getTemperatureValue( BRD_TEMP ); + F32 expB = exp(-heatDissipation); + F32 tempDiff = targetTemp - ambTemp; + F32 T0 = 0.0F; + + // T0 = Tamb + (Tf -Tamb)e^-B + T0 = ambTemp + ( tempDiff * expB ); + + return T0; +} + +/*********************************************************************//** + * @brief * The calculateDutyCycle function calculates the heater's duty cycle * based on the delta temperature, flowrate and power applied to the heater. * @details \b Inputs: none Index: firmware/App/Modes/ModeGenDialysate.c =================================================================== diff -u -r2396d4a37bda6655349756098a5315cdd54a3803 -rea58258093207cb49785aa04ab1e19065166cac6 --- firmware/App/Modes/ModeGenDialysate.c (.../ModeGenDialysate.c) (revision 2396d4a37bda6655349756098a5315cdd54a3803) +++ firmware/App/Modes/ModeGenDialysate.c (.../ModeGenDialysate.c) (revision ea58258093207cb49785aa04ab1e19065166cac6) @@ -69,26 +69,7 @@ #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). #define PUMP_SPEED_INTERCEPT_FACTOR_DIENER_1000 25.956F ///< D48 Diener 1000 pump speed intercept. -#define B1B2_HEAT_DIS_FIRST_COEFF 0.00000000487858F ///< First coefficient for Heat loss dissipation calculation from D4 to D28(cubic equation). -#define B1B2_HEAT_DIS_SEC_COEFF 0.0000063124F ///< Second coefficient for Heat loss dissipation calculation from D4 to D28. -#define B1B2_HEAT_DIS_THIRD_COEFF 0.00258513F ///< Third coefficient for Heat loss dissipation calculation from D4 to D28. -#define B1B2_HEAT_DIS_FOURTH_COEFF 0.242013F ///< Fourth coefficient for Heat loss dissipation calculation from D4 to D28. -#define B3_HEAT_DIS_FIRST_COEFF 0.0000000067756F ///< First coefficient for Heat loss dissipation calculation from D28 to Dialyzer(cubic equation). -#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 BICARB_CHAMBER_FILL_TIMEOUT ( 1 * MS_PER_SECOND ) ///< Bicarb chamber fill timeout. //Testing @@ -128,15 +109,9 @@ static DD_GEND_MODE_STATE_T handleGenDBicarbChamberFillState( void ); static DD_GEND_MODE_STATE_T handleGenDIsolatedUFState( void ); static F32 getGenDialysateTargetTemperature( void ); -static void calculateTargetDialysateTemp( void ); 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 ); static void publishGenDialysateModeData( void ); static U32 getFreshDialPumpInitialRpm( void ); @@ -662,43 +637,6 @@ /*********************************************************************//** * @brief - * The calculateUpdatedD28TargetDialysateTemp function calculate the delta temperature - * required for dialysate temperature to meet the set temperature at dialyzer. - * @details \b Inputs: Qd and target temperature. - * @details \b Outputs: Adjusted D28 Target temperature - * @return none. - *************************************************************************/ -F32 calculateUpdatedD28TargetDialysateTemp( void ) -{ - // Get the dialysate flow rate from TD - F32 dialFlowrate = getTDDialysateFlowrate(); - F32 deltaTemp = 0.0F; - F32 heatDissipation_b3 = 0.0F; - F32 targetTemp = getTDTargetDialysateTemperature(); - 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 - 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 target temp at D28 to get the target dialyzer temperature - targetTempAtD28 = calculateInitialTemp( targetTemp, heatDissipation_b3 ); - - return targetTempAtD28; -} - -/*********************************************************************//** - * @brief * The monitorChamberLevelStatus function checks the spent chamber and bicarb * chamber level status and updates the corrosponding flags. * @details \b Inputs: Spent and bicarb chamber levels. @@ -723,190 +661,6 @@ /*********************************************************************//** * @brief - * The calculateTargetDialysateTemp function calculate the delta temperature - * required for dialysate temperature to meet the set temperature at dialyzer. - * @details \b Inputs: Qd and target temperature. - * @details \b Outputs: Adjusted Target temperature - * @return none. - *************************************************************************/ -static void calculateTargetDialysateTemp( void ) -{ - // Get the dialysate flow rate from TD - F32 dialFlowrate = getTDDialysateFlowrate(); - F32 deltaTemp = 0.0F; - F32 heatDissipation_b1b2 = 0.0F; - F32 heatDissipation_b3 = 0.0F; - F32 targetTemp = getTDTargetDialysateTemperature(); - F32 targetTempAtD28 = 0.0F; - F32 targetTempAtD4 = 0.0F; - -#ifndef __REVISED_HEATER_MODEL__ - if ( dialFlowrate >= LOW_DIAL_FLOW_RATE ) - { - // linear relationship seen against high dialysate flowrate Vs DeltaTemp - // deltaTemp = (-0.0029 * Qd) + 3.47 - deltaTemp = ( LINEAR_SLOPE_FACTOR * dialFlowrate ) + LINEAR_INTERCEPT_FACTOR; - } - else - { - // deltaTemp = (0.0006 * Qd * Qd)-(0.1743*Qd) + 17.3 - deltaTemp = ( QUAD_FIRST_COEFFICIENT * dialFlowrate * dialFlowrate ) + - ( QUAD_SECOND_COEFFICIENT * dialFlowrate ) + QUAD_THIRD_COEFFICIENT; - } - // Adjust the D4 target temperature - targetHydChamberFluidTemp.data = getTDTargetDialysateTemperature() + deltaTemp; -#else - // 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 - 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 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 = 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. - * @details \b Inputs: Qd. - * @details \b Outputs: none - * @return the calculated heat dissipation constants. - *************************************************************************/ -static F32 calculateHeatDissipationB1andB2( void ) -{ - // Get the dialysate flow rate from TD - F32 b1b2 = 0.0F; - F32 qd = getTDDialysateFlowrate(); - F32 firstPart = B1B2_HEAT_DIS_FIRST_COEFF * qd * qd * qd; - F32 secondPart = B1B2_HEAT_DIS_SEC_COEFF * qd * qd; - F32 thirdPart = B1B2_HEAT_DIS_THIRD_COEFF * qd; - - // B1B2 = 4.87858E-09x3 - 6.31264E-06x2 + 2.58513E-03x - 2.42013E-01 - b1b2 = firstPart - secondPart + thirdPart - B1B2_HEAT_DIS_FOURTH_COEFF; - - return b1b2; -} - -/*********************************************************************//** - * @brief - * The calculateHeatDissipationB3 function calculates the heat dissipation - * constants called B3 that describes the heat loss between D28 to dialyzer in - * the PID flow path. - * @details \b Inputs: Qd. - * @details \b Outputs: none - * @return the calculated heat dissipation constant. - *************************************************************************/ -static F32 calculateHeatDissipationB3( void ) -{ - // Get the dialysate flow rate from TD - F32 b3 = 0.0F; - F32 qd = getTDDialysateFlowrate(); - F32 firstPart = B3_HEAT_DIS_FIRST_COEFF * qd * qd * qd; - F32 secondPart = B3_HEAT_DIS_SEC_COEFF * qd * qd; - F32 thirdPart = B3_HEAT_DIS_THIRD_COEFF * qd; - - // B3 = 6.7756E-09x3 - 8.5278E-06x2 + 3.5126E-03x - 6.3893E-01 - b3 = firstPart - secondPart + thirdPart - B3_HEAT_DIS_FOURTH_COEFF; - - return b3; -} - -/*********************************************************************//** - * @brief - * The calculateInitialTemp function calculates the initial temperature - * required to get the target temperature considering heat loss. - * @details \b Inputs: ambient temperature - * @details \b Outputs: none - * @param targetTemp the target/final temperature - * @param heatDissipation the heat dissipation constant - * @return the calculated initial temperature. - *************************************************************************/ -static F32 calculateInitialTemp( F32 targetTemp, F32 heatDissipation ) -{ - // Get the ambient temperature from TD - //TODO : replace once amb temp is in place. using board temperature - // to make use of feeding the value via dialin - F32 ambTemp = getTemperatureValue( BRD_TEMP ); - F32 expB = exp(-heatDissipation); - F32 tempDiff = targetTemp - ambTemp; - F32 T0 = 0.0F; - - // T0 = Tamb + (Tf -Tamb)e^-B - T0 = ambTemp + ( tempDiff * expB ); - - return T0; -} - -/*********************************************************************//** - * @brief * The getCalculatedD48PumpSpeedForBCFill function returns the D48 pump speed * calculated from dialysate flow rate (Qd) for continuous delivery. * @details \b Inputs: Qd from TD, test config TEST_CONFIG_DD_ENABLE_DIENER_1000_PUMP. @@ -1219,6 +973,20 @@ /*********************************************************************//** * @brief + * The setTargetHydChamberTemp function updates the target hydraulics temperature + * for D5 heater control + * @details \b Inputs: none + * @details \b Outputs: targetHydChamberFluidTemp + * @param temperature The target temperature for D5 heater control + * @return none + *************************************************************************/ +void setTargetHydChamberTemp( F32 temperature ) +{ + targetHydChamberFluidTemp.data = temperature; +} + +/*********************************************************************//** + * @brief * The updateTreatmentSettings function updates the switching rate post the * treatement parameters updated during treatement. * @details \b Inputs: isTreatmentParamUpdated Index: firmware/App/Monitors/Temperature.c =================================================================== diff -u -r4053bb88fd83acda93e7b6a27480658e82814609 -rea58258093207cb49785aa04ab1e19065166cac6 --- firmware/App/Monitors/Temperature.c (.../Temperature.c) (revision 4053bb88fd83acda93e7b6a27480658e82814609) +++ firmware/App/Monitors/Temperature.c (.../Temperature.c) (revision ea58258093207cb49785aa04ab1e19065166cac6) @@ -40,10 +40,7 @@ #define TEMP_SENSORS_DATA_PUBLISH_INTERVAL ( MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) ///< Temperature sensors publish data time interval. #define TEMP_SENSORS_FPGA_ERROR_TIMEOUT_MS ( 2 * MS_PER_SECOND ) ///< Temperature sensors FPGA error timeout in milliseconds. -#define D4_TEMP_MOVING_AVG_NUM_OF_SAMPLES 50 ///< D4 temperature sensor moving average number of samples. -#define D50_TEMP_MOVING_AVG_NUM_OF_SAMPLES 50 ///< D50 temperature sensor moving average number of samples. -#define D99_TEMP_MOVING_AVG_NUM_OF_SAMPLES 50 ///< D99 temperature sensor moving average number of samples -#define D78_TEMP_MOVING_AVG_NUM_OF_SAMPLES 50 ///< D99 temperature sensor moving average number of samples +#define TEMP_MOVING_AVG_NUM_OF_SAMPLES 50 ///< temperature sensor moving average number of samples. #define DATA_PUBLISH_COUNTER_START_COUNT 30 ///< Data publish counter start count. #define DIAL_TEMP_MOVING_AVG_NUM_OF_SAMPLES 30 ///< Dialysate temperature sensors moving average number of samples. #define D28_D30_DATA_COLLECTION_TIME_MS ( 1 * MS_PER_SECOND ) ///< Dialysate temperature sensors data collection time in milliseconds. @@ -68,6 +65,15 @@ NUM_OF_TEMPSENSORS_EXEC_STATES, ///< Total number of exec states } TEMPSENSORS_EXEC_STATES_T; +/// Filter temperature readings record. +typedef struct +{ + F32 temperatureReadings[ TEMP_MOVING_AVG_NUM_OF_SAMPLES ]; ///< Holds temperature sample rolling average. + U32 temperatureReadingsIdx; ///< Index for next sample in rolling average array. + F32 temperatureReadingsTotal; ///< Rolling total - used to calc average. + U32 temperatureReadingsCount; ///< Number of samples in rolling average buffer +} FILTER_TEMPERATURE_READINGS_T; + /// Dialysate temperature moving average structure typedef struct { @@ -86,35 +92,11 @@ static BOOL tempDriftEventCheck; ///< Temperature sensor drift event boolean. static DIAL_TEMP_MOVING_AVG_DATA_T dialTempMovingAvgData[ NUM_OF_DIAL_TEMPS ]; ///< Dialysate temperature moving average data. -static F32 d4TempAvgC; ///< D4 temperature average in C. -static F32 d4TempRunningSumC; ///< D4 temperature running sum in C. -static F32 d4TempSamplesC[ D4_TEMP_MOVING_AVG_NUM_OF_SAMPLES ]; ///< D4 temperature samples array in C. -static U32 d4TempSamplesNextIndex; ///< D4 temperature sample next index number. -static U32 d4TempCount; ///< D4 Number of samples in average buffer. +static FILTER_TEMPERATURE_READINGS_T filteredTemperatureReadings[NUM_OF_TEMPERATURE_SENSORS]; ///< Filtered temperature reading for temperature sensors. +static OVERRIDE_F32_T filteredcurrentTemperatureReadings[ NUM_OF_TEMPERATURE_SENSORS ]; ///< filtered current temperature sensor temperature readings (overrideable). static U32 tempDataCollectionTimeInterval; ///< Temperature data collection time interval in milliseconds. -static U32 d4TempSampleIntervalCounter; ///< D4 temperature sensor sample collection timer counter. -static U32 d50TempSampleIntervalCounter; ///< D50 temperature sensor sample collection timer counter. +static U32 TempSampleIntervalCounter; ///< temperature sensor sample collection timer counter. -static F32 d50TempAvgC; ///< D50 temperature average in C. -static F32 d50TempRunningSumC; ///< D50 temperature running sum in C. -static F32 d50TempSamplesC[ D50_TEMP_MOVING_AVG_NUM_OF_SAMPLES ]; ///< D50 temperature samples array in C. -static U32 d50TempSamplesNextIndex; ///< D50 temperature sample next index number. -static U32 d50TempCount; ///< D50 Number of samples in average buffer. - -static F32 d99TempAvgC; ///< D99 temperature average in C. -static F32 d99TempRunningSumC; ///< D99 temperature running sum in C. -static F32 d99TempSamplesC[ D99_TEMP_MOVING_AVG_NUM_OF_SAMPLES ]; ///< D99 temperature samples array in C. -static U32 d99TempSamplesNextIndex; ///< D99 temperature sample next index number. -static U32 d99TempCount; ///< D99 Number of samples in average buffer. -static U32 d99TempSampleIntervalCounter; ///< D99 temperature sensor sample collection timer counter. - -static F32 d78TempAvgC; ///< D78 temperature average in C. -static F32 d78TempRunningSumC; ///< D78 temperature running sum in C. -static F32 d78TempSamplesC[ D99_TEMP_MOVING_AVG_NUM_OF_SAMPLES ]; ///< D78 temperature samples array in C. -static U32 d78TempSamplesNextIndex; ///< D78 temperature sample next index number. -static U32 d78TempCount; ///< D78 Number of samples in average buffer. -static U32 d78TempSampleIntervalCounter; ///< D78 temperature sensor sample collection timer counter. - static U32 ddTempDataPublicationTimerCounter; ///< DD Temperature sensors data publish timer counter. static U32 fpTempDataPublicationTimerCounter; ///< FP Temperature sensors data publish timer counter. static OVERRIDE_U32_T ddTempSensorsPublishInterval; ///< DD Temperature sensors publish time interval override. @@ -138,33 +120,30 @@ *************************************************************************/ void initTemperature( void ) { + TEMPERATURE_SENSORS_T sensor; + startTime = 0; tempSensorsExecState = TEMPSENSORS_EXEC_STATE_START; ddTempDataPublicationTimerCounter = DATA_PUBLISH_COUNTER_START_COUNT; fpTempDataPublicationTimerCounter = DATA_PUBLISH_COUNTER_START_COUNT; - d4TempRunningSumC = 0.0F; - d4TempAvgC = 0.0F; - d4TempSamplesNextIndex = 0; - d4TempCount = 0; - d50TempRunningSumC = 0.0F; - d50TempAvgC = 0.0F; - d50TempSamplesNextIndex = 0; - d50TempCount = 0; - d99TempRunningSumC = 0.0F; - d99TempAvgC = 0.0F; - d99TempSamplesNextIndex = 0; - d99TempCount = 0; - d78TempRunningSumC = 0.0F; - d78TempAvgC = 0.0F; - d78TempSamplesNextIndex = 0; - d78TempCount = 0; - d4TempSampleIntervalCounter = 0; - d50TempSampleIntervalCounter = 0; - d99TempSampleIntervalCounter = 0; - d78TempSampleIntervalCounter = 0; + + TempSampleIntervalCounter = 0; tempDataCollectionTimeInterval = 0; tempDriftEventCheck = FALSE; + // Initialize override structures for each temperature sensor + for ( sensor = TEMPSENSORS_FIRST; sensor < NUM_OF_TEMPERATURE_SENSORS; sensor++ ) + { + filteredcurrentTemperatureReadings[ sensor ].data = 0.0F; + filteredcurrentTemperatureReadings[ sensor ].ovData = 0.0F; + filteredcurrentTemperatureReadings[ sensor ].ovInitData = 0.0F; + filteredcurrentTemperatureReadings[ sensor ].override = OVERRIDE_RESET; + + filteredTemperatureReadings[ sensor ].temperatureReadingsIdx = 0; + filteredTemperatureReadings[ sensor ].temperatureReadingsTotal = 0.0F; + filteredTemperatureReadings[ sensor ].temperatureReadingsCount = 0; + } + dialTempMovingAvgData[ DIAL_TEMP_D28 ].dialTempColHasTimerBeenSet = FALSE; dialTempMovingAvgData[ DIAL_TEMP_D30 ].dialTempColHasTimerBeenSet = FALSE; @@ -318,82 +297,28 @@ *************************************************************************/ static void filterTemperatureReadings( void ) { - F32 d4Temp = 0.0F; - F32 d50Temp = 0.0F; - F32 d99Temp = 0.0F; - F32 d78Temp = 0.0F; + TEMPERATURE_SENSORS_T sensor; + F32 rawTemp = 0.0F; - // Moving average sample collection interval varies based on the dialysate flow rate - if ( ++d4TempSampleIntervalCounter >= tempDataCollectionTimeInterval ) + if ( ++TempSampleIntervalCounter >= tempDataCollectionTimeInterval ) { - // Filter D4 Temperature for AC heater - if ( d4TempCount >= D4_TEMP_MOVING_AVG_NUM_OF_SAMPLES ) + for ( sensor = TEMPSENSORS_FIRST; sensor < NUM_OF_TEMPERATURE_SENSORS; sensor++ ) { - d4TempRunningSumC -= d4TempSamplesC[ d4TempSamplesNextIndex ]; - } + rawTemp = getTemperatureValue ( sensor ); - d4Temp = getTemperatureValue( D4_TEMP ); - d4TempSamplesC[ d4TempSamplesNextIndex ] = d4Temp; - d4TempRunningSumC += d4Temp; - d4TempSamplesNextIndex = INC_WRAP( d4TempSamplesNextIndex, 0, D4_TEMP_MOVING_AVG_NUM_OF_SAMPLES - 1 ); - d4TempCount = INC_CAP( d4TempCount, D4_TEMP_MOVING_AVG_NUM_OF_SAMPLES ); - d4TempAvgC = d4TempRunningSumC / (F32)d4TempCount; - d4TempSampleIntervalCounter = 0; - } - - // Moving average sample collection interval varies based on the dialysate flow rate - if ( ++d50TempSampleIntervalCounter >= tempDataCollectionTimeInterval ) - { - if ( d50TempCount >= D50_TEMP_MOVING_AVG_NUM_OF_SAMPLES ) - { - d50TempRunningSumC -= d50TempSamplesC[ d50TempSamplesNextIndex ]; + if ( filteredTemperatureReadings[ sensor ].temperatureReadingsCount >= TEMP_MOVING_AVG_NUM_OF_SAMPLES ) + { + filteredTemperatureReadings[ sensor ].temperatureReadingsTotal -= filteredTemperatureReadings[ sensor ].temperatureReadings[ filteredTemperatureReadings[ sensor ].temperatureReadingsIdx ]; + } + filteredTemperatureReadings[ sensor ].temperatureReadings[ filteredTemperatureReadings[ sensor ].temperatureReadingsIdx ] = rawTemp; + filteredTemperatureReadings[ sensor ].temperatureReadingsTotal += rawTemp; + filteredTemperatureReadings[ sensor ].temperatureReadingsIdx = INC_WRAP( filteredTemperatureReadings[ sensor ].temperatureReadingsIdx, 0, TEMP_MOVING_AVG_NUM_OF_SAMPLES - 1 ); + filteredTemperatureReadings[ sensor ].temperatureReadingsCount = INC_CAP( filteredTemperatureReadings[ sensor ].temperatureReadingsCount, TEMP_MOVING_AVG_NUM_OF_SAMPLES ); + filteredcurrentTemperatureReadings[ sensor ].data = filteredTemperatureReadings[ sensor ].temperatureReadingsTotal / (F32)filteredTemperatureReadings[ sensor ].temperatureReadingsCount; } - - d50Temp = getTemperatureValue( D50_TEMP ); - d50TempSamplesC[ d50TempSamplesNextIndex ] = d50Temp; - d50TempRunningSumC += d50Temp; - d50TempSamplesNextIndex = INC_WRAP( d50TempSamplesNextIndex, 0, D50_TEMP_MOVING_AVG_NUM_OF_SAMPLES - 1 ); - d50TempCount = INC_CAP( d50TempCount, D50_TEMP_MOVING_AVG_NUM_OF_SAMPLES ); - d50TempAvgC = d50TempRunningSumC / (F32)d50TempCount; - d50TempSampleIntervalCounter = 0; + TempSampleIntervalCounter = 0; } - // Moving average sample collection interval varies based on the dialysate flow rate - if ( ++d99TempSampleIntervalCounter >= tempDataCollectionTimeInterval ) - { - - // Filter D99 Temperature for fresh dialysate temperature - if ( d99TempCount >= D99_TEMP_MOVING_AVG_NUM_OF_SAMPLES ) - { - d99TempRunningSumC -= d99TempSamplesC[ d99TempSamplesNextIndex ]; - } - - d99Temp = getTemperatureValue( D99_TEMP ); - d99TempSamplesC[ d99TempSamplesNextIndex ] = d99Temp; - d99TempRunningSumC += d99Temp; - d99TempSamplesNextIndex = INC_WRAP( d99TempSamplesNextIndex, 0, D99_TEMP_MOVING_AVG_NUM_OF_SAMPLES - 1 ); - d99TempCount = INC_CAP( d99TempCount, D99_TEMP_MOVING_AVG_NUM_OF_SAMPLES ); - d99TempAvgC = d99TempRunningSumC / (F32)d99TempCount; - } - - // Moving average sample collection interval varies based on the dialysate flow rate - if ( ++d78TempSampleIntervalCounter >= tempDataCollectionTimeInterval ) - { - - // Filter D78 Temperature for fresh dialysate temperature - if ( d78TempCount >= D78_TEMP_MOVING_AVG_NUM_OF_SAMPLES ) - { - d78TempRunningSumC -= d78TempSamplesC[ d78TempSamplesNextIndex ]; - } - - d78Temp = getTemperatureValue( D78_TEMP ); - d78TempSamplesC[ d78TempSamplesNextIndex ] = d78Temp; - d78TempRunningSumC += d78Temp; - d78TempSamplesNextIndex = INC_WRAP( d78TempSamplesNextIndex, 0, D78_TEMP_MOVING_AVG_NUM_OF_SAMPLES - 1 ); - d78TempCount = INC_CAP( d78TempCount, D78_TEMP_MOVING_AVG_NUM_OF_SAMPLES ); - d78TempAvgC = d78TempRunningSumC / (F32)d78TempCount; - } - // dailysate temperature moving average filterDialTemperatureReadings(); } @@ -486,52 +411,60 @@ * @brief * The getD4AverageTemperature function returns the average temperature * for D4 temp sensor. - * @details \b Inputs: none + * @details \b Inputs: filteredcurrentTemperatureReadings * @details \b Outputs: none * @return the D4 average temperature *************************************************************************/ F32 getD4AverageTemperature( void ) { - return d4TempAvgC; + F32 temperature = getF32OverrideValue( &filteredcurrentTemperatureReadings[ D4_TEMP ] ); + + return temperature; } /*********************************************************************//** * @brief * The getD50AverageTemperature function returns the average temperature * for D50 temp sensor. - * @details \b Inputs: none + * @details \b Inputs: filteredcurrentTemperatureReadings * @details \b Outputs: none * @return the D50 average temperature *************************************************************************/ F32 getD50AverageTemperature( void ) { - return d50TempAvgC; + F32 temperature = getF32OverrideValue( &filteredcurrentTemperatureReadings[ D50_TEMP ] ); + + return temperature; } /*********************************************************************//** * @brief * The getD99AverageTemperature function returns the average temperature * for D99 temperature sensor. - * @details \b Inputs: none + * @details \b Inputs: filteredcurrentTemperatureReadings * @details \b Outputs: none * @return the D99 average temperature *************************************************************************/ F32 getD99AverageTemperature( void ) { - return d99TempAvgC; + F32 temperature = getF32OverrideValue( &filteredcurrentTemperatureReadings[ D99_TEMP ] ); + + return temperature; } /*********************************************************************//** * @brief * The getD78AverageTemperature function returns the average temperature * for D78 temperature sensor. - * @details \b Inputs: none + * @details \b Inputs: filteredcurrentTemperatureReadings * @details \b Outputs: none * @return the D78 average temperature *************************************************************************/ F32 getD78AverageTemperature( void ) { - return d78TempAvgC; + F32 temperature = getF32OverrideValue( &filteredcurrentTemperatureReadings[ D78_TEMP ] ); + + return temperature; } /*********************************************************************//** @@ -547,7 +480,7 @@ { F32 period = (F32)SEC_PER_MIN / ( getTDDialysateFlowrate() / BAL_CHAMBER_FILL_VOLUME_ML ) ; - U32 sampleInterval = (U32)( ( period / (F32)D4_TEMP_MOVING_AVG_NUM_OF_SAMPLES ) * MS_PER_SECOND ); + U32 sampleInterval = (U32)( ( period / (F32)TEMP_MOVING_AVG_NUM_OF_SAMPLES ) * MS_PER_SECOND ); tempDataCollectionTimeInterval = (U32) ( sampleInterval / TASK_PRIORITY_INTERVAL ); } @@ -657,6 +590,30 @@ /*********************************************************************//** * @brief + * The testDDTemperatureSensorFilteredReadingsOverride function overrides the + * filtered value of the specified DD temperature sensor with a given value. + * @details \b Inputs: none + * @details \b Outputs: filteredcurrentTemperatureReadings[] + * @param message Override message from Dialin which includes a sensor + * ID and override value of the temperature value for that sensor. + * @return TRUE if override successful, FALSE if not + *************************************************************************/ +BOOL testDDTemperatureSensorFilteredReadingsOverride( MESSAGE_T *message ) +{ + BOOL result = FALSE; + TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; + OVERRIDE_TYPE_T ovType = getOverrideArrayPayloadFromMessage( message, &payload ); + + if ( payload.index <= NUM_OF_TEMPERATURE_SENSORS ) + { + result = f32ArrayOverride( message, &filteredcurrentTemperatureReadings[0], NUM_OF_TEMPERATURE_SENSORS - 1 ); + } + + return result; +} + +/*********************************************************************//** + * @brief * The testIOFPTemperatureSensorsDataPublishIntervalOverride function * overrides the IOFP temperature sensors data publish interval. * @details \b Inputs: none Index: firmware/App/Monitors/Temperature.h =================================================================== diff -u -r4053bb88fd83acda93e7b6a27480658e82814609 -rea58258093207cb49785aa04ab1e19065166cac6 --- firmware/App/Monitors/Temperature.h (.../Temperature.h) (revision 4053bb88fd83acda93e7b6a27480658e82814609) +++ firmware/App/Monitors/Temperature.h (.../Temperature.h) (revision ea58258093207cb49785aa04ab1e19065166cac6) @@ -73,9 +73,10 @@ F32 p16Temp; ///< Temperature RO outlet F32 p7InternalTemp; ///< P7 internal Temperature F32 p16InternalTemp; ///< P16 internal Temperature - } TEMPERATURE_SENSORS_FP_DATA_T; + + // ********** public function prototypes ********** void initTemperature( void ); @@ -89,6 +90,7 @@ BOOL testDDTemperatureSensorsDataPublishIntervalOverride( MESSAGE_T *message ); BOOL testIOFPTemperatureSensorsDataPublishIntervalOverride( MESSAGE_T *message ); +BOOL testDDTemperatureSensorFilteredReadingsOverride( MESSAGE_T *message ); /**@}*/ Index: firmware/App/Services/Messaging.c =================================================================== diff -u -rf0aec0f46d5e85250430ecc95e4654200cf2ed83 -rea58258093207cb49785aa04ab1e19065166cac6 --- firmware/App/Services/Messaging.c (.../Messaging.c) (revision f0aec0f46d5e85250430ecc95e4654200cf2ed83) +++ firmware/App/Services/Messaging.c (.../Messaging.c) (revision ea58258093207cb49785aa04ab1e19065166cac6) @@ -284,6 +284,7 @@ { MSG_ID_DD_ACID_DOSE_VOL_CONTROL_KP_GAIN_COEFF_OVERRIDE_REQUEST, &testDryBiCartAcidDoseVolControlKpGainOverride }, { MSG_ID_DD_ACID_DOSE_VOL_CONTROL_KI_GAIN_COEFF_OVERRIDE_REQUEST, &testDryBiCartAcidDoseVolControlKiGainOverride }, { MSG_ID_FP_SET_OPERATION_SUB_MODE_REQUEST, &testSetFPOperationSubMode }, + { MSG_ID_DD_FILTERED_TEMPERATURE_SENSOR_OVERRIDE_REQUEST, &testDDTemperatureSensorFilteredReadingsOverride }, }; /// Calculation for number of entries in the incoming message function handler look-up table.