Index: firmware/App/Controllers/ConductivitySensors.c =================================================================== diff -u -r025612ad77fe630889a364586de54bffe5262d56 -rde9033912212f6af3a2f33321d948ce5aabac358 --- firmware/App/Controllers/ConductivitySensors.c (.../ConductivitySensors.c) (revision 025612ad77fe630889a364586de54bffe5262d56) +++ firmware/App/Controllers/ConductivitySensors.c (.../ConductivitySensors.c) (revision de9033912212f6af3a2f33321d948ce5aabac358) @@ -51,8 +51,8 @@ #define MAX_CONDUCTIVITY_SENSOR_FAILURE_WINDOW_MS ( 60 * MS_PER_SECOND ) ///< Conductivity sensor error window. #define RO_REJECTION_RATIO_OUT_OF_RANGE_VALUE 1.0 ///< Out of range value for RO rejection ratio when CPi conductivity is zero. -#define MAX_RO_REJECTION_RATIO_ALLOW 0.1 ///< Maximum RO rejection ratio. -#define MAX_CPO_CONDUCTIVITY_ALLOW 15.0 ///< Maximum CPo sensor conductivity value. +#define MAX_RO_REJECTION_RATIO_ALLOW 0.15 ///< Maximum RO rejection ratio. +#define MAX_CPO_CONDUCTIVITY_ALLOW 30.0 ///< Maximum CPo sensor conductivity value. #define COND_SENSOR_PERSISTENCE_PERIOD ( 5 * MS_PER_SECOND ) ///< Persistence period for conductivity sensor out of range error. #define RO_REJECTION_RATIO_PERSISTENCE_PERIOD ( 10 * MS_PER_SECOND ) ///< Persistence period for RO rejection ratio. Index: firmware/App/Controllers/TemperatureSensors.c =================================================================== diff -u -r025612ad77fe630889a364586de54bffe5262d56 -rde9033912212f6af3a2f33321d948ce5aabac358 --- firmware/App/Controllers/TemperatureSensors.c (.../TemperatureSensors.c) (revision 025612ad77fe630889a364586de54bffe5262d56) +++ firmware/App/Controllers/TemperatureSensors.c (.../TemperatureSensors.c) (revision de9033912212f6af3a2f33321d948ce5aabac358) @@ -55,9 +55,12 @@ #define SHIFT_BITS_BY_2_FOR_AVERAGING 2U ///< Shift the ADCs of the temperature sensors by 2 to average them. #define INLET_WATER_TEMPERATURE_PERSISTENCE_PERIOD ( 5 * MS_PER_SECOND ) ///< Persistence period for temperature sensors out of range error period. -#define MIN_WATER_INPUT_TEMPERATURE 22U ///< Minimum water input temperature. -#define MAX_WATER_INPUT_TEMPERATURE 35U ///< Maximum water input temperature. +#define MAX_WATER_HIGH_INPUT_TEMPERATURE 39U ///< Maximum water input high temperature. +#define MIN_WATER_HIGH_INPUT_TEMPERATURE 37U ///< Minimum water input high temperature. +#define MAX_WATER_LOW_INPUT_TEMPERATURE 24U ///< Maximum water input low temperature. +#define MIN_WATER_LOW_INPUT_TEMPERATURE 22U ///< Minimum water input low temperature. + #define HEATERS_INTERNAL_TEMPERTURE_CALCULATION_INTERVAL 20U ///< Time interval that is used to calculate the heaters internal temperature. #define HEATERS_INTERNAL_TC_ADC_TO_TEMP_CONVERSION_COEFF 0.25 ///< Heaters internal temperature sensors ADC to temperature conversion coefficient. #define HEATERS_COLD_JUNCTION_ADC_TO_TEMP_CONVERSION_COEFF 0.0625 ///< Heaters cold junction temperature sensors ADC to temperature conversion coefficient. @@ -350,11 +353,28 @@ { #ifndef DISABLE_WATER_QUALITY_CHECK F32 const temperature = getTemperatureValue( TEMPSENSORS_INLET_PRIMARY_HEATER ); - BOOL const isWaterTempTooHigh = temperature > MAX_WATER_INPUT_TEMPERATURE; - BOOL const isWaterTempTooLow = temperature < MIN_WATER_INPUT_TEMPERATURE; - checkPersistentAlarm( ALARM_ID_INLET_WATER_HIGH_TEMPERATURE, isWaterTempTooHigh, temperature, MAX_WATER_INPUT_TEMPERATURE ); - checkPersistentAlarm( ALARM_ID_INLET_WATER_LOW_TEMPERATURE, isWaterTempTooLow, temperature, MIN_WATER_INPUT_TEMPERATURE ); + BOOL isWaterTempTooHigh = ( temperature >= MIN_WATER_HIGH_INPUT_TEMPERATURE ) && + ( temperature <= MAX_WATER_HIGH_INPUT_TEMPERATURE ) ? TRUE : FALSE; + + BOOL isWaterTempTooLow = ( temperature >= MIN_WATER_LOW_INPUT_TEMPERATURE ) && + ( temperature <= MAX_WATER_LOW_INPUT_TEMPERATURE ) ? TRUE : FALSE; + + BOOL isWaterOutOfRange = ( temperature < MIN_WATER_LOW_INPUT_TEMPERATURE ) && + ( temperature > MAX_WATER_HIGH_INPUT_TEMPERATURE ) ? TRUE : FALSE; + + if ( TRUE == isWaterTempTooHigh ) + { + checkPersistentAlarm( ALARM_ID_INLET_WATER_HIGH_TEMPERATURE, isWaterTempTooHigh, temperature, MAX_WATER_HIGH_INPUT_TEMPERATURE ); + } + else if ( TRUE == isWaterTempTooLow ) + { + checkPersistentAlarm( ALARM_ID_INLET_WATER_LOW_TEMPERATURE, isWaterTempTooLow, temperature, MIN_WATER_LOW_INPUT_TEMPERATURE ); + } + else if ( TRUE == isWaterOutOfRange ) + { + checkPersistentAlarm( ALARM_ID_INLET_WATER_LOW_TEMPERATURE, isWaterOutOfRange, temperature, MAX_WATER_HIGH_INPUT_TEMPERATURE ); + } #endif } Index: firmware/App/Modes/ModeFill.c =================================================================== diff -u -ref4bc1eaa0f019b678b4d49011a5d23ebe558ad8 -rde9033912212f6af3a2f33321d948ce5aabac358 --- firmware/App/Modes/ModeFill.c (.../ModeFill.c) (revision ef4bc1eaa0f019b678b4d49011a5d23ebe558ad8) +++ firmware/App/Modes/ModeFill.c (.../ModeFill.c) (revision de9033912212f6af3a2f33321d948ce5aabac358) @@ -106,7 +106,7 @@ static F32 totalROFlowRateMLPM; ///< Total RO flow rate over period of time. static F32 acidConductivityTotal; ///< Total of acid conductivity during fill. -static F32 dialysateConductivityTotal; ///< Total of dialysate conductivity during fill. +static F32 bicarbConductivityTotal; ///< Total of bicard conductivity during fill. static U32 conductivitySampleCount; ///< Sample count of conductivity during fill. static F32 averageBicardConductivity; ///< Average bicard conductivity over 30 seconds. @@ -152,7 +152,7 @@ * @details Inputs: none * @details Outputs: fillState, dialysateFillStartTime, reservoirBaseWeight, * totalROFlowRateMLPM, concentrateTestStartTime, acidConductivityTotal, - * dialysateConductivityTotal, conductivitySampleCount, + * bicarbConductivityTotal, conductivitySampleCount, * concentratePumpPrimeCount * @return none *************************************************************************/ @@ -164,7 +164,7 @@ totalROFlowRateMLPM = 0.0; concentrateTestStartTime = 0; acidConductivityTotal = 0.0; - dialysateConductivityTotal = 0.0; + bicarbConductivityTotal = 0.0; conductivitySampleCount = 0; concentratePumpPrimeCount = 0; pumpSpeedIndex = 0; @@ -581,7 +581,7 @@ /*********************************************************************//** * @brief - * The handleDialysateProductionState function executes the dialysate production + * The handleProduceDialysateState function executes the dialysate production * state of the fill mode state machine. * @details Inputs: inlet water quality and dialysate temperature * @details Outputs: none @@ -631,17 +631,16 @@ *************************************************************************/ static DG_FILL_MODE_STATE_T handleDeliverDialysateState( void ) { - F32 integratedVolumeML; - + DG_FILL_MODE_STATE_T result = DG_FILL_MODE_STATE_DELIVER_DIALYSATE; + F32 integratedVolumeML; F32 measuredROFlowRateMLPM = getMeasuredROFlowRateLPM() * ML_PER_LITER; F32 acidConductivity = getConductivityValue( CONDUCTIVITYSENSORS_CD1_SENSOR ); - F32 dialysateConductivity = getConductivityValue( CONDUCTIVITYSENSORS_CD2_SENSOR ); + F32 bicarbConductivity = getConductivityValue( CONDUCTIVITYSENSORS_CD2_SENSOR ); BOOL isAcidConductivityOutOfRange = ( acidConductivity <= MIN_ACID_CONCENTRATE_CONDUCTIVITY ) || ( acidConductivity >= MAX_ACID_CONCENTRATE_CONDUCTIVITY ) ? TRUE : FALSE; - BOOL isDialysateConductivityOutOfRange = ( dialysateConductivity <= MIN_BICARB_CONCENTRATE_CONDUCTIVITY ) || - ( dialysateConductivity >= MAX_BICARB_CONCENTRATE_CONDUCTIVITY ) ? TRUE : FALSE; + BOOL isBicarbConductivityOutOfRange = ( bicarbConductivity <= MIN_BICARB_CONCENTRATE_CONDUCTIVITY ) || + ( bicarbConductivity >= MAX_BICARB_CONCENTRATE_CONDUCTIVITY ) ? TRUE : FALSE; - DG_FILL_MODE_STATE_T result = DG_FILL_MODE_STATE_DELIVER_DIALYSATE; DG_RESERVOIR_ID_T inactiveReservoir = getInactiveReservoir(); // Set concentrate pumps speed based off RO pump flow rate @@ -653,7 +652,7 @@ usedBicarbVolumeML.data += getMeasuredPumpSpeed( CONCENTRATEPUMPS_CP2_BICARB ) * FLOW_INTEGRATOR; acidConductivityTotal += acidConductivity; - dialysateConductivityTotal += dialysateConductivity; + bicarbConductivityTotal += bicarbConductivity; conductivitySampleCount++; // DG is delivering dialysate keep collecting the sample counter and the measured flow @@ -679,7 +678,7 @@ result = DG_FILL_MODE_STATE_PAUSED; } - if ( TRUE == isPersistentAlarmTriggered( ALARM_ID_BICARB_CONDUCTIVITY_OUT_OF_RANGE, isDialysateConductivityOutOfRange ) ) + if ( TRUE == isPersistentAlarmTriggered( ALARM_ID_BICARB_CONDUCTIVITY_OUT_OF_RANGE, isBicarbConductivityOutOfRange ) ) { usedBicarbVolumeML.data = 0.0; requestConcentratePumpOff( CONCENTRATEPUMPS_CP1_ACID ); @@ -705,7 +704,7 @@ F32 filledVolumeML = getReservoirWeight( inactiveReservoir ) - reservoirBaseWeight; F32 integratedVolumeToLoadCellReadingPercent = fabs( 1 - ( filledVolumeML / integratedVolumeML ) ); F32 avgAcidConductivity = acidConductivityTotal / conductivitySampleCount; // TODO - should we be checking this below? - F32 avgDialysateConductivity = dialysateConductivityTotal / conductivitySampleCount; + F32 avgDialysateConductivity = bicarbConductivityTotal / conductivitySampleCount; if ( integratedVolumeToLoadCellReadingPercent > FLOW_INTEGRATED_VOLUME_CHECK_TOLERANCE ) { @@ -838,7 +837,7 @@ F32 valueMax = baseValue + percentValue; F32 valueMin = baseValue - percentValue; - if( ( testValue >= valueMin ) && ( testValue <= valueMax ) ) + if ( ( testValue >= valueMin ) && ( testValue <= valueMax ) ) { testFlag = TRUE; }