Index: firmware/App/Controllers/DrainPump.c =================================================================== diff -u -recc3eef231cd2527274969e057d9b4763caa273f -r2b47dd2e7974618d8899527cdbff80fa93ebc9fa --- firmware/App/Controllers/DrainPump.c (.../DrainPump.c) (revision ecc3eef231cd2527274969e057d9b4763caa273f) +++ firmware/App/Controllers/DrainPump.c (.../DrainPump.c) (revision 2b47dd2e7974618d8899527cdbff80fa93ebc9fa) @@ -8,7 +8,7 @@ * @file DrainPump.c * * @author (last) Dara Navaei -* @date (last) 15-Feb-2023 +* @date (last) 06-Mar-2023 * * @author (original) Sean * @date (original) 08-Apr-2020 @@ -944,17 +944,13 @@ { BOOL status = FALSE; - // Check if the requested drain pump RPM is within range - if ( ( value >= MIN_DRAIN_PUMP_RPM ) && ( value <= MAX_DRAIN_PUMP_RPM ) ) + // Check if the user is logged in + if ( TRUE == isTestingActivated() ) { - // Check if the user is logged in - if ( TRUE == isTestingActivated() ) - { - drainPumpMeasuredRPM.ovData = value; - drainPumpMeasuredRPM.override = OVERRIDE_KEY; - drainPumpMeasuredRPM.ovInitData = drainPumpMeasuredRPM.data; - status = TRUE; - } + drainPumpMeasuredRPM.ovData = value; + drainPumpMeasuredRPM.override = OVERRIDE_KEY; + drainPumpMeasuredRPM.ovInitData = drainPumpMeasuredRPM.data; + status = TRUE; } return status; Index: firmware/App/Modes/ModeChemicalDisinfect.c =================================================================== diff -u -r135b257c835e406f036dfbdec1d8cd9c51e1c526 -r2b47dd2e7974618d8899527cdbff80fa93ebc9fa --- firmware/App/Modes/ModeChemicalDisinfect.c (.../ModeChemicalDisinfect.c) (revision 135b257c835e406f036dfbdec1d8cd9c51e1c526) +++ firmware/App/Modes/ModeChemicalDisinfect.c (.../ModeChemicalDisinfect.c) (revision 2b47dd2e7974618d8899527cdbff80fa93ebc9fa) @@ -130,16 +130,6 @@ #define MIN_DRP_VOLUME_CONTROL_RPM 350.0F ///< Minimum DRP RPM for volume control. The minimum value allowed by the pump driver is 300 RPM #define MAX_DRP_VOLUME_CONTROL_RPM 1500.0F ///< Maximum DRP RPM for volume control. The maximum recommended value is 2400 RPM -/// Cancellation paths -typedef enum Cancellation_modes -{ - CANCELLATION_MODE_NONE = 0, ///< Cancellation mode none. - CANCELLATION_MODE_BASIC, ///< Cancellation mode basic. - CANCELLATION_MODE_WATER, ///< Cancellation mode water. - CANCELLATION_MODE_CHEMICAL, ///< Cancellation mode chemical. - NUM_OF_CANCELLATION_MODES ///< Number of cancellation modes. -} CANCELLATION_MODE_T; - /// Non-volatile write structure typedef struct { Index: firmware/App/Modes/ModeChemicalDisinfectFlush.c =================================================================== diff -u -r2e56064726838bfb626ec3ea40132c4e3681639a -r2b47dd2e7974618d8899527cdbff80fa93ebc9fa --- firmware/App/Modes/ModeChemicalDisinfectFlush.c (.../ModeChemicalDisinfectFlush.c) (revision 2e56064726838bfb626ec3ea40132c4e3681639a) +++ firmware/App/Modes/ModeChemicalDisinfectFlush.c (.../ModeChemicalDisinfectFlush.c) (revision 2b47dd2e7974618d8899527cdbff80fa93ebc9fa) @@ -8,7 +8,7 @@ * @file ModeChemicalDisinfectFlush.c * * @author (last) Dara Navaei -* @date (last) 18-Jan-2023 +* @date (last) 27-Feb-2023 * * @author (original) Dara Navaei * @date (original) 15-Nov-2022 @@ -163,7 +163,7 @@ { chemDisinfectFlushState = DG_CHEM_DISINFECT_FLUSH_STATE_START; prevChemDisinfectFlushState = DG_CHEM_DISINFECT_FLUSH_STATE_START; - stateTimer = 0; + stateTimer = getMSTimerCount(); isThisLastDrain = FALSE; rsrvr1Status = NUM_OF_DG_RESERVOIR_STATUS; rsrvr2Status = NUM_OF_DG_RESERVOIR_STATUS; Index: firmware/App/Modes/ModeFill.c =================================================================== diff -u -recc3eef231cd2527274969e057d9b4763caa273f -r2b47dd2e7974618d8899527cdbff80fa93ebc9fa --- firmware/App/Modes/ModeFill.c (.../ModeFill.c) (revision ecc3eef231cd2527274969e057d9b4763caa273f) +++ firmware/App/Modes/ModeFill.c (.../ModeFill.c) (revision 2b47dd2e7974618d8899527cdbff80fa93ebc9fa) @@ -8,7 +8,7 @@ * @file ModeFill.c * * @author (last) Dara Navaei -* @date (last) 07-Feb-2023 +* @date (last) 01-Mar-2023 * * @author (original) Leonardo Baloa * @date (original) 19-Nov-2019 @@ -76,6 +76,7 @@ #define MAX_RO_REJECTION_RATIO_ALLOW 0.10F ///< Maximum RO rejection ratio. #define MAX_CPO_CONDUCTIVITY_ALLOW 100.0F ///< Maximum CPo sensor conductivity value. +#define MIN_FILL_TARGET_TO_CHECK_RO_AND_CPO_ML 550 ///< Minimum fill target to check the RO and CPo alarms in milliliters. // 2m long tubing to cap = 19.5 mL (acid line) + 7.92 mL/m * 2 m (tubing to cap) + 20.82 mL (straw) = 56.15 mL // Prime time in seconds = ( 56.15 mL / 48 mL/min ) x 60 second/min + 25 seconds margin time = 95 seconds. @@ -835,19 +836,22 @@ if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_RO_RATIO_CHECK ) != SW_CONFIG_ENABLE_VALUE ) #endif { - F32 avgCPo = sumFillCPoConductivity / (F32)fillCPoConductivitySampleCnt; // sample count incremented above w/o condition so no need for divide by zero checks - F32 avgRR = sumFillRejRatio / (F32)fillCPoConductivitySampleCnt; - - if ( avgCPo > MAX_CPO_CONDUCTIVITY_ALLOW ) + if ( getTargetFillVolumeML() > MIN_FILL_TARGET_TO_CHECK_RO_AND_CPO_ML ) { - // Fault alarm per PRS 483 - SET_ALARM_WITH_2_F32_DATA( ALARM_ID_DG_OUTLET_PRIMARY_CONDUCTIVITY_OUT_OF_RANGE, avgCPo, MAX_CPO_CONDUCTIVITY_ALLOW ); + F32 avgCPo = sumFillCPoConductivity / (F32)fillCPoConductivitySampleCnt; // sample count incremented above w/o condition so no need for divide by zero checks + F32 avgRR = sumFillRejRatio / (F32)fillCPoConductivitySampleCnt; + + if ( avgCPo > MAX_CPO_CONDUCTIVITY_ALLOW ) + { + // Fault alarm per PRS 483 + SET_ALARM_WITH_2_F32_DATA( ALARM_ID_DG_OUTLET_PRIMARY_CONDUCTIVITY_OUT_OF_RANGE, avgCPo, MAX_CPO_CONDUCTIVITY_ALLOW ); + } + if ( avgRR > MAX_RO_REJECTION_RATIO_ALLOW ) + { + // Fault alarm per PRS 483 + SET_ALARM_WITH_2_F32_DATA( ALARM_ID_RO_REJECTION_RATIO_OUT_OF_RANGE, avgRR, MAX_RO_REJECTION_RATIO_ALLOW ); + } } - if ( avgRR > MAX_RO_REJECTION_RATIO_ALLOW ) - { - // Fault alarm per PRS 483 - SET_ALARM_WITH_2_F32_DATA( ALARM_ID_RO_REJECTION_RATIO_OUT_OF_RANGE, avgRR, MAX_RO_REJECTION_RATIO_ALLOW ); - } } // Check FMP vs. LC Index: firmware/App/Modes/ModeHeatDisinfect.c =================================================================== diff -u -r135b257c835e406f036dfbdec1d8cd9c51e1c526 -r2b47dd2e7974618d8899527cdbff80fa93ebc9fa --- firmware/App/Modes/ModeHeatDisinfect.c (.../ModeHeatDisinfect.c) (revision 135b257c835e406f036dfbdec1d8cd9c51e1c526) +++ firmware/App/Modes/ModeHeatDisinfect.c (.../ModeHeatDisinfect.c) (revision 2b47dd2e7974618d8899527cdbff80fa93ebc9fa) @@ -67,7 +67,7 @@ #define MAX_FLUSH_CIRC_TEMP_SENSOR_DIFF_C 3.0F ///< Maximum flush circulation temperature difference tolerance in C. #define NUM_OF_TEMP_SENSORS_TO_AVG 3.0F ///< Number of temperature sensors to average to check the difference. #define ACID_PUMP_SPEED_ML_PER_MIN 30.6F ///< Acid concentrate pump speed in mL/min. -// The bicarb pump is 2% faster than the acid pump to create a flow from acid to bicarb line during heat disinfect +// The acid pump is 2% faster than the acid pump to create a flow from acid to bicarb line during heat disinfect #define BICARB_PUMP_SPEED_ML_PER_MIN -30.0F ///< Bicarb concentrate pump speed in mL/min. // Flush and drain R1 and R2 @@ -117,16 +117,6 @@ #define NELSON_SUPPORT_INOCULATE_TIME_MS ( 30 * SEC_PER_MIN * MS_PER_SECOND ) // Nelson support inoculate time in milliseconds. #endif -/// Cancellation paths -typedef enum Cancellation_modes -{ - CANCELLATION_MODE_NONE = 0, ///< Cancellation mode none. - CANCELLATION_MODE_BASIC, ///< Cancellation mode basic. - CANCELLATION_MODE_HOT, ///< Cancellation mode hot. - CANCELLATION_MODE_COLD, ///< Cancellation mode cold. - NUM_OF_CANCELLATION_MODES ///< Number of cancellation modes. -} CANCELLATION_MODE_T; - /// Heat disinfect status typedef enum Heat_disinfect_status { Index: firmware/App/Services/Reservoirs.c =================================================================== diff -u -recc3eef231cd2527274969e057d9b4763caa273f -r2b47dd2e7974618d8899527cdbff80fa93ebc9fa --- firmware/App/Services/Reservoirs.c (.../Reservoirs.c) (revision ecc3eef231cd2527274969e057d9b4763caa273f) +++ firmware/App/Services/Reservoirs.c (.../Reservoirs.c) (revision 2b47dd2e7974618d8899527cdbff80fa93ebc9fa) @@ -8,7 +8,7 @@ * @file Reservoirs.c * * @author (last) Dara Navaei -* @date (last) 08-Feb-2023 +* @date (last) 07-Mar-2023 * * @author (original) Sean * @date (original) 18-Mar-2020 @@ -73,6 +73,7 @@ F32 tempRsrvr0ActualTrimmer; ///< Temperature actual reservoir in C. F32 tempFillMixAvgTrimmer; ///< Temperature fill mix average trimmer in C. F32 tempRsrvrEndFillTrimmer; ///< Temperature reservoir end fill trimmer in C. + BOOL usePriTargetTempEquation; ///< Use primary heater target temperature enquation flag. } HEATERS_TEMPERATURE_CALC_DATA_T; /// Reservoirs previous status @@ -624,6 +625,7 @@ heatersTempCalc.timeReservoirFillMS = params.timeReservoirFillMS; heatersTempCalc.tempTargetTrimmer = params.trimmerTargetTemperature; heatersTempCalc.flowTargetDialysateLPM = params.dialysateFlowLPM; + heatersTempCalc.usePriTargetTempEquation = params.usePriTargetTempEquation; // Check if this is the first time that the dialysate heating parameters are set in DG if ( TRUE == isThisTheFirstCycle ) @@ -643,41 +645,54 @@ *************************************************************************/ F32 getPrimaryHeaterTargetTemperature( void ) { - // TODO once the equations are solidified, add the equations as comments to the lines - F32 tempTarget = 0.0; - F32 priTargetTemp = 0.0; + F32 tempTargetC = heatersTempCalc.tempTargetTrimmer; + F32 priTargetTempC = 0.0F; F32 targetFillVolML = getTargetFillVolumeML(); - F32 UFTimeConstant = 0.0; + F32 UFTimeConstant = 0.0F; F32 tempLastFill = getLastFillTemperature(); F32 UFTauCPerMS = heatingConstsCalRecord.ultrafilterTempTauCPerMin / ( SEC_PER_MIN * MS_PER_SECOND ); F32 RsrvrTauCPerMS = heatingConstsCalRecord.reservoirTempTauCPerMin / ( SEC_PER_MIN * MS_PER_SECOND ); F32 targetROFlowLPM = getTargetROPumpFlowRateLPM(); - F32 tgtAicdFlowLPM = getConcentratePumpTargetFlowMLPM( CONCENTRATEPUMPS_CP1_ACID ) / ML_PER_LITER; + F32 tgtAcidFlowLPM = getConcentratePumpTargetFlowMLPM( CONCENTRATEPUMPS_CP1_ACID ) / ML_PER_LITER; F32 tgtBicarbFlowLPM = getConcentratePumpTargetFlowMLPM( CONCENTRATEPUMPS_CP2_BICARB ) / ML_PER_LITER; - F32 tgtTotalFlowLPM = targetROFlowLPM + tgtAicdFlowLPM + tgtBicarbFlowLPM; + F32 tgtTotalFlowLPM = targetROFlowLPM + tgtAcidFlowLPM + tgtBicarbFlowLPM; - if ( FALSE == isThisTheFirstFill() ) + if ( TRUE == heatersTempCalc.usePriTargetTempEquation ) { - F32 tempTargetNumerator; - F32 targetTempDenominator; - F32 tempReservoirUse; + if ( FALSE == isThisTheFirstFill() ) + { + F32 tempTargetNumerator; + F32 tempTargetDenominator; + F32 tempReservoirUse; - tempReservoirUse = heatersTempCalc.tempTargetTrimmer + RESERVOIR_EXTRA_TEMPERATURE; - heatersTempCalc.tempReservoirEndFill = tempReservoirUse - ( heatersTempCalc.timeReservoirFill2SwitchMS * RsrvrTauCPerMS ); - heatersTempCalc.tempReservoir0 = heatersTempCalc.tempReservoirEndFill - ( ( heatersTempCalc.timeReservoirFillMS * HALF ) * RsrvrTauCPerMS ); + /* + * 1. T_rsrvr_use = T_target + * 2. T_rsrvr_end_fill = T_rsrvr_use - (t_rsrvr_fill_2_switch * Tau_rsrvr) + * 3. T_rsrvr_0 = T_rsrvr_end_fill - (t_rsrvr_fill/2 * Tau_rsrvr) + * 4. T_UF_fill = T_last_fill + [(t_rsrvr_cycle - t_rsrvr_fill) * Tau_UF] + * 5. T_numerator = T_rsrvr_0 - [(V_UF / V_fill) * T_UF_fill] + * 6. T_denominator = (V_fill - V_UF) / V_fill + * 7. T_mix_target = T_numerator / T_denominator + * 8. T_primary_target = T_mix_target * (Q_total / Q_RO) - (Q_acid / Q_RO) * T_acid - (Q_bicarb / Q_RO) * T_bicarb + */ - heatersTempCalc.timeUFDecayMS = (F32)heatersTempCalc.timeReservoirCycleMS - heatersTempCalc.timeReservoirFillMS; - UFTimeConstant = heatersTempCalc.timeUFDecayMS * UFTauCPerMS; - heatersTempCalc.tempUFFill = tempLastFill + UFTimeConstant; + tempReservoirUse = heatersTempCalc.tempTargetTrimmer; + heatersTempCalc.tempReservoirEndFill = tempReservoirUse - ( heatersTempCalc.timeReservoirFill2SwitchMS * RsrvrTauCPerMS ); + heatersTempCalc.tempReservoir0 = heatersTempCalc.tempReservoirEndFill - ( ( heatersTempCalc.timeReservoirFillMS * HALF ) * RsrvrTauCPerMS ); - tempTargetNumerator = heatersTempCalc.tempReservoir0 - ( ( heatingConstsCalRecord.ultrafilterVolmL / targetFillVolML ) * heatersTempCalc.tempUFFill ); - targetTempDenominator = ( ( targetFillVolML - heatingConstsCalRecord.ultrafilterVolmL ) / targetFillVolML ); - tempTarget = tempTargetNumerator / targetTempDenominator; + heatersTempCalc.timeUFDecayMS = (F32)heatersTempCalc.timeReservoirCycleMS - heatersTempCalc.timeReservoirFillMS; + UFTimeConstant = heatersTempCalc.timeUFDecayMS * UFTauCPerMS; + heatersTempCalc.tempUFFill = tempLastFill + UFTimeConstant; + + tempTargetNumerator = heatersTempCalc.tempReservoir0 - ( ( heatingConstsCalRecord.ultrafilterVolmL / targetFillVolML ) * heatersTempCalc.tempUFFill ); + tempTargetDenominator = ( ( targetFillVolML - heatingConstsCalRecord.ultrafilterVolmL ) / targetFillVolML ); + tempTargetC = tempTargetNumerator / tempTargetDenominator; + } + else + { + tempTargetC = heatersTempCalc.tempTargetTrimmer + RESERVOIR_EXTRA_TEMPERATURE; + } } - else - { - tempTarget = heatersTempCalc.tempTargetTrimmer + RESERVOIR_EXTRA_TEMPERATURE; - } if ( targetROFlowLPM > 0 ) { @@ -689,17 +704,17 @@ // the target temperature is calculated by estimating the temperature of the dialysates and volume that is being mixed into the RO water F32 acidTemperature = acidConcentrateCalRecord.acidConcentrate[ CAL_DATA_ACID_CONCENTRATE_1 ].acidBottleTemperature; F32 bicarbTemperature = bicarbConcentrateCalRecord.bicarbConcentrate[ CAL_DATA_BICARB_CONCENTRATE_1 ].bicarbBottleTemperature; - priTargetTemp = ( tempTarget * ( tgtTotalFlowLPM / targetROFlowLPM ) ) - ( acidTemperature * ( tgtAicdFlowLPM / targetROFlowLPM ) ) - + priTargetTempC = ( tempTargetC * ( tgtTotalFlowLPM / targetROFlowLPM ) ) - ( acidTemperature * ( tgtAcidFlowLPM / targetROFlowLPM ) ) - ( bicarbTemperature * ( tgtBicarbFlowLPM / targetROFlowLPM ) ); } else #endif { - priTargetTemp = tempTarget; + priTargetTempC = tempTargetC; } } - return priTargetTemp; + return priTargetTempC; } /*********************************************************************//** Index: firmware/App/Services/Reservoirs.h =================================================================== diff -u -recc3eef231cd2527274969e057d9b4763caa273f -r2b47dd2e7974618d8899527cdbff80fa93ebc9fa --- firmware/App/Services/Reservoirs.h (.../Reservoirs.h) (revision ecc3eef231cd2527274969e057d9b4763caa273f) +++ firmware/App/Services/Reservoirs.h (.../Reservoirs.h) (revision 2b47dd2e7974618d8899527cdbff80fa93ebc9fa) @@ -8,7 +8,7 @@ * @file Reservoirs.h * * @author (last) Dara Navaei -* @date (last) 08-Nov-2022 +* @date (last) 07-Mar-2023 * * @author (original) Sean * @date (original) 18-Mar-2020 @@ -34,7 +34,7 @@ // ********** public definitions ********** #define MAX_RESERVOIR_VOLUME_ML 2000 ///< Maximum reservoir volume in mL. -#define RESERVOIR_EXTRA_TEMPERATURE 0.0F ///< Reservoirs extra margin temperature. +#define RESERVOIR_EXTRA_TEMPERATURE 2.0F ///< Reservoirs extra margin temperature. /// Fill command data structure. typedef struct @@ -61,16 +61,6 @@ U32 rejectCode; ///< Reason code for rejecting the command } DG_CMD_RESPONSE_T; -/// Dialysate heating parameters -typedef struct -{ - F32 trimmerTargetTemperature; ///< Trimmer Target temperature - U32 timeReservoirCycleMS; ///< Reservoir cycle time in milliseconds - F32 timeReservoirFillMS; ///< Reservoir fill time in milliseconds - U32 timeReservoirWait2SwitchMS; ///< Wait to switch active reservoir time in milliseconds - F32 dialysateFlowLPM; ///< Dialysate flow rate in L/min -} DG_CMD_DIALYSATE_HEATING_PARAMS_T; - /// HD mode and HD submode typedef struct {