Index: firmware/App/Modes/ModeFill.c =================================================================== diff -u -receb190a5d66fdbee779478ac8bb50a846ed9241 -r6530db1926d689b51c2f5fcd6ae928c40ebf5f42 --- firmware/App/Modes/ModeFill.c (.../ModeFill.c) (revision eceb190a5d66fdbee779478ac8bb50a846ed9241) +++ firmware/App/Modes/ModeFill.c (.../ModeFill.c) (revision 6530db1926d689b51c2f5fcd6ae928c40ebf5f42) @@ -1,14 +1,14 @@ /************************************************************************** * -* Copyright (c) 2019-2022 Diality Inc. - All Rights Reserved. +* Copyright (c) 2019-2023 Diality Inc. - All Rights Reserved. * * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. * * @file ModeFill.c * * @author (last) Michael Garthwaite -* @date (last) 21-Nov-2022 +* @date (last) 16-Mar-2023 * * @author (original) Leonardo Baloa * @date (original) 19-Nov-2019 @@ -74,6 +74,10 @@ #define CONCENTRATE_TEST_TIME_OUT_MS ( 30 * MS_PER_SECOND ) ///< Concentrate test time out period in ms. #define DELAY_FMP_CHECK_START_BY_MS ( 10 * MS_PER_SECOND ) ///< Delay start of FMP check during dialysate deliver state by this amount of time (in ms). +#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. #define PRIME_CONCENTRATE_LINES_TIME_OUT_MS ( 95 * MS_PER_SECOND ) ///< Time required to prime the concentrate lines. @@ -129,6 +133,10 @@ static F32 totalBicarbConductivity; ///< Total bicarb conductivity over 30 seconds. static F32 totalAcidConductivity; ///< Total acid conductivity over 30 seconds. +static F32 sumFillCPoConductivity; ///< Sum of CPo conductivity readings over course of a fill to calculate an average at end of fill. +static F32 sumFillRejRatio; ///< Sum of Rejection Ratio values over course of a fill to calculate an average at end of fill. +static U32 fillCPoConductivitySampleCnt; ///< Number of samples in sum of CPo and Rej. Ratio conductivity readings for fill. + static U32 pumpSpeedIndex; ///< Index used to access the desired pump speed in roPumpFlushBubblesSpeed table. static BOOL havePauseActuatorsBeenSet; ///< Flag to indicate the actuators have been set to pause for the first time. static OVERRIDE_F32_T usedAcidVolumeML = { 0.0, 0.0, 0.0, 0.0 }; ///< The integrated acid concentration volume has been used in mL. @@ -186,6 +194,9 @@ totalBicarbConductivity = 0.0F; totalAcidConductivity = 0.0F; havePauseActuatorsBeenSet = FALSE; + sumFillCPoConductivity = 0.0F; + sumFillRejRatio = 0.0F; + fillCPoConductivitySampleCnt = 0; } /*********************************************************************//** @@ -226,7 +237,6 @@ *************************************************************************/ U32 execFillMode( void ) { - checkRORejectionRatio(); checkDialysateTemperatureSensors(); setHeaterTargetTemperature( DG_PRIMARY_HEATER, getPrimaryHeaterTargetTemperature() ); @@ -531,9 +541,9 @@ if ( TRUE == didTimeout( flushBubblesStartTime, FLUSH_BUBBLES_PUMP_TIME_OUT_MS ) ) { - if ( pumpSpeedIndex < RO_PUMP_LOOKUP_TABLE_SIZE ) + if ( pumpSpeedIndex < RO_PUMP_LOOKUP_TABLE_SIZE - 1 ) { - setROPumpTargetFlowRateLPM( RO_PUMP_FLUSH_BUBBLES_FLOWS[ pumpSpeedIndex++ ] / MILLILITERS_PER_LITER, TARGET_RO_PRESSURE_PSI ); + setROPumpTargetFlowRateLPM( RO_PUMP_FLUSH_BUBBLES_FLOWS[ ++pumpSpeedIndex ] / MILLILITERS_PER_LITER, TARGET_RO_PRESSURE_PSI ); flushBubblesStartTime = getMSTimerCount(); } else @@ -723,7 +733,6 @@ setValveState( VPO, VALVE_STATE_FILL_C_TO_NC ); dialysateFillStartTime = getMSTimerCount(); - fillStatus.isThisFirstFill = FALSE; result = DG_FILL_MODE_STATE_DELIVER_DIALYSATE; } @@ -750,6 +759,9 @@ F32 acidConductivity = getConductivityValue( CONDUCTIVITYSENSORS_CD1_SENSOR ); F32 bicarbConductivity = getConductivityValue( CONDUCTIVITYSENSORS_CD2_SENSOR ); F32 inletTemperature = getTemperatureValue( (U32)TEMPSENSORS_CONDUCTIVITY_SENSOR_2 ); + F32 cpi = getConductivityValue( CONDUCTIVITYSENSORS_CPI_SENSOR ); + F32 cpo = getConductivityValue( CONDUCTIVITYSENSORS_CPO_SENSOR ); + F32 rejRatio = RO_REJECTION_RATIO_OUT_OF_RANGE_VALUE; // default 1:1 before calculation in case can't divide by zero. #ifndef _RELEASE_ if ( ( HW_CONFIG_BETA == getHardwareConfigStatus() ) || @@ -768,6 +780,15 @@ // Set concentrate pumps speed based on the RO pump flow rate handleDialysateMixing( getMeasuredFlowRateLPM( RO_FLOW_SENSOR ) * ML_PER_LITER, acidMix, bicarbMix ); + // Sum conductivity readings for CPo and RR checks + if ( fabs(cpi) >= NEARLY_ZERO ) + { + rejRatio = cpo / cpi; + } + sumFillCPoConductivity += cpo; + sumFillRejRatio += rejRatio; + fillCPoConductivitySampleCnt++; + // Delay start of FMP check, then begin integrating flow to a volume if ( TRUE == didTimeout( dialysateFillStartTime, DELAY_FMP_CHECK_START_BY_MS ) ) { @@ -808,7 +829,31 @@ F32 acidNormalConductivity = acid.acidConcentrate[ CAL_DATA_ACID_CONCENTRATE_1 ].acidConductivityUSPerCM; F32 bicarbNormalConductivity = bicarb.bicarbConcentrate[ CAL_DATA_BICARB_CONCENTRATE_1 ].bicarbConductivityUSPerCM; + // Check RO filter #ifndef _RELEASE_ + if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_RO_RATIO_CHECK ) != SW_CONFIG_ENABLE_VALUE ) +#endif + { + if ( getTargetFillVolumeML() > MIN_FILL_TARGET_TO_CHECK_RO_AND_CPO_ML ) + { + 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 ); + } + } + } + + // Check FMP vs. LC +#ifndef _RELEASE_ if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_FLOW_VS_LOAD_CELL_CHECK_IN_FILL ) != SW_CONFIG_ENABLE_VALUE ) #endif { @@ -818,6 +863,7 @@ } } + // Check mixing via avg. conductivities #ifndef _RELEASE_ if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_MIXING_IN_FILL ) != SW_CONFIG_ENABLE_VALUE ) #endif @@ -882,7 +928,6 @@ if ( FALSE == areInletWaterConditionsAlarmsActive() ) { - setValveState( VPO, VALVE_STATE_FILL_C_TO_NC ); havePauseActuatorsBeenSet = FALSE; result = DG_FILL_MODE_STATE_START; } @@ -907,10 +952,13 @@ checkInletWaterPressure(); // Check if any of the alarms are active - if ( ( TRUE == isAlarmActive( ALARM_ID_INLET_WATER_CONDUCTIVITY_IN_LOW_RANGE ) ) || - ( TRUE == isAlarmActive( ALARM_ID_INLET_WATER_CONDUCTIVITY_IN_HIGH_RANGE ) ) || - ( TRUE == isAlarmActive( ALARM_ID_INLET_WATER_TEMPERATURE_IN_HIGH_RANGE ) ) || - ( TRUE == isAlarmActive( ALARM_ID_INLET_WATER_TEMPERATURE_IN_LOW_RANGE ) ) || + if ( ( TRUE == isAlarmActive( ALARM_ID_INLET_WATER_CONDUCTIVITY_IN_LOW_RANGE ) ) || + ( TRUE == isAlarmActive( ALARM_ID_INLET_WATER_CONDUCTIVITY_IN_HIGH_RANGE ) ) || + ( TRUE == isAlarmActive( ALARM_ID_INLET_WATER_TEMPERATURE_IN_HIGH_RANGE ) ) || + ( TRUE == isAlarmActive( ALARM_ID_INLET_WATER_TEMPERATURE_IN_LOW_RANGE ) ) || + ( TRUE == isAlarmActive( ALARM_ID_DG_OUTLET_PRIMARY_CONDUCTIVITY_OUT_OF_RANGE ) ) || + ( TRUE == isAlarmActive( ALARM_ID_RO_REJECTION_RATIO_OUT_OF_RANGE ) ) || + ( TRUE == isAlarmActive( ALARM_ID_INLET_WATER_PRESSURE_IN_HIGH_RANGE ) ) || ( TRUE == isAlarmActive( ALARM_ID_INLET_WATER_PRESSURE_IN_LOW_RANGE ) ) ) { status = TRUE; @@ -1176,15 +1224,15 @@ * @param: value integrated volume in mL * @return TRUE if override successful, FALSE if not *************************************************************************/ -BOOL testSetIntegratedVolumeOverride( U32 value ) +BOOL testSetIntegratedVolumeOverride( F32 value ) { BOOL result = FALSE; if ( TRUE == isTestingActivated() ) { integratedVolumeML.ovData = value; integratedVolumeML.override = OVERRIDE_KEY; - result = TRUE; + result = TRUE; } return result; @@ -1206,7 +1254,7 @@ { integratedVolumeML.override = OVERRIDE_RESET; integratedVolumeML.ovData = integratedVolumeML.ovInitData; - result = TRUE; + result = TRUE; } return result;