Index: firmware/App/Modes/ModeFill.c =================================================================== diff -u -r7f64bdbf118609be8afc6fc7a3bd0ffe0cc2791a -r6e49f490cdfd0450c1477eeb903221937e0d567e --- firmware/App/Modes/ModeFill.c (.../ModeFill.c) (revision 7f64bdbf118609be8afc6fc7a3bd0ffe0cc2791a) +++ firmware/App/Modes/ModeFill.c (.../ModeFill.c) (revision 6e49f490cdfd0450c1477eeb903221937e0d567e) @@ -8,7 +8,7 @@ * @file ModeFill.c * * @author (last) Dara Navaei -* @date (last) 16-Aug-2023 +* @date (last) 18-Aug-2023 * * @author (original) Leonardo Baloa * @date (original) 19-Nov-2019 @@ -63,8 +63,8 @@ #define CONC_PUMPS_PRIME_AT_MAX_SPEED_TIME_OUT_MS ( 7 * MS_PER_SECOND ) ///< Concentrate pumps prime at maximum speed timeout in milliseconds. #define CONC_PUMPS_PRIME_CHECK_COND_SNSRS_TIME_OUT_MS ( 10 * MS_PER_SECOND ) ///< Concentrate pumps prime check conductivity sensors timeout in milliseconds. -#define CONC_PUMPS_PRIME_MAX_ALLOWED_PRIME_TIME_OUT_MS ( 25 * MS_PER_SECOND ) ///< Concentrate pumps prime maximum allowed timeout in prime in milliseconds. - +#define CONC_PUMPS_PRIME_MAX_ALLOWED_PRIME_TIME_OUT_MS ( 60 * MS_PER_SECOND ) ///< Concentrate pumps prime maximum allowed timeout in prime in milliseconds. +#define HUNDRED_PERCENT_FACTOR 1.00F ///< Hundred percent of expected conductivity when first time reaches it. #define FLOW_INTEGRATED_VOLUME_CHECK_TOLERANCE 0.1F ///< Flow integrated volume has 10% tolerance compare to load cell reading. #define FIVE_PERCENT_FACTOR 0.05F ///< 5.0 / 100.0 used to calculate conductivity within range of -/+ 5%. @@ -146,6 +146,7 @@ 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 BOOL didFillRecoverFromPause; ///< Flag to indicate whether the previous state was pause or not. static FILL_ACID_BICARB_TYPES_T chemicalsTypes; ///< Chemicals Types (acid and bicarb). static DG_CHEMICALS_FILL_COND_CAL_RECORD_T chemicalsCond; ///< Chemicals fill conductivity records. static F32 acidMixRatio; ///< Acid conductivity mix ratio. @@ -218,6 +219,7 @@ sumFillCPoConductivity = 0.0F; sumFillRejRatio = 0.0F; fillCPoConductivitySampleCnt = 0; + didFillRecoverFromPause = FALSE; } /*********************************************************************//** @@ -789,15 +791,18 @@ if ( TRUE == didTimeout( concPumpPrimeStartTimeMS, CONC_PUMPS_PRIME_CHECK_COND_SNSRS_TIME_OUT_MS ) ) { /* Once the time for priming the concentrate lines has elapsed, check the mixing conductivity of the sensors - * If the acid and bicarb conductivity values are at about 50% of the target concentrate during fill, transition to the next state - * If the acid and bicarb conductivity values are not at 50% but the maximum prime time has elapsed, transition to the next state + * If the acid and bicarb conductivity values are at about 100% of the target concentrate during fill, transition to the next state + * If the acid and bicarb conductivity values are not at 100% but the maximum prime time has elapsed, transition to the next state */ F32 acidConduSPerCM = getConductivityValue( CONDUCTIVITYSENSORS_CD1_SENSOR ); F32 bicarbConduSPerCM = getConductivityValue( CONDUCTIVITYSENSORS_CD2_SENSOR ); F32 acidFillConduSPerCM = chemicalsCond.fillCondValues[ chemicalsTypes.acidType ][ FILL_COND_NORMAL_OP ].acidConduSPerCM; F32 bicarbFillConduSPerCM = chemicalsCond.fillCondValues[ chemicalsTypes.acidType ][ FILL_COND_NORMAL_OP ].bicarbConduSPerCM; - if ( ( acidConduSPerCM >= ( acidFillConduSPerCM * HALF ) ) && ( bicarbConduSPerCM >= ( bicarbFillConduSPerCM * HALF ) ) ) + /* we are insisting conductivity reach 100% of expected level since signal is very noisy and peak noise will reach 100% when average is about 93%. + * if sensor noise is reduced, this level should also be reduced accordingly. + */ + if ( ( acidConduSPerCM >= ( acidFillConduSPerCM * HUNDRED_PERCENT_FACTOR ) ) && ( bicarbConduSPerCM >= ( bicarbFillConduSPerCM * HUNDRED_PERCENT_FACTOR ) ) ) { result = DG_FILL_MODE_STATE_DELIVER_DIALYSATE; setModeFillStateTransition( result ); @@ -967,7 +972,7 @@ * The handlePausedState function executes the paused state of the fill * mode state machine. * @details Inputs: havePauseActuatorsBeenSet - * @details Outputs: havePauseActuatorsBeenSet + * @details Outputs: havePauseActuatorsBeenSet, didFillRecoverFromPause * @return the next state *************************************************************************/ static DG_FILL_MODE_STATE_T handlePausedState( void ) @@ -978,6 +983,7 @@ if ( ( FALSE == areInletWaterConditionsAlarmsActive() ) && ( FALSE == areConductivityAlarmsActive() ) ) { + didFillRecoverFromPause = TRUE; havePauseActuatorsBeenSet = FALSE; result = DG_FILL_MODE_STATE_TEST_INLET_WATER; } @@ -989,11 +995,12 @@ * @brief * The setModeFillStateTransition function sets the actuators and variables * for the state transition in mode fill. - * @details Inputs: pumpSpeedIndex, havePauseActuatorsBeenSet + * @details Inputs: pumpSpeedIndex, havePauseActuatorsBeenSet, + * didFillRecoverFromPause * @details Outputs: concPumpPrimeStartTimeMS, fillStatus, pumpSpeedIndex, * concentratePrimingStartTime, totalBicarbConductivity, averageBicarbConductivity, * bicarbConductivitySampleCount, concentrateTestStartTime, fillStatus, - * havePauseActuatorsBeenSet, flushBubblesStartTime + * havePauseActuatorsBeenSet, flushBubblesStartTime, didFillRecoverFromPause * @param state mode fill state enum * @return none *************************************************************************/ @@ -1067,7 +1074,11 @@ case DG_FILL_MODE_STATE_DELIVER_DIALYSATE: setValveState( VPO, VALVE_STATE_FILL_C_TO_NC ); - dialysateFillStartTimeMS = getMSTimerCount(); + if ( didFillRecoverFromPause != TRUE ) + { + dialysateFillStartTimeMS = getMSTimerCount(); + } + didFillRecoverFromPause = FALSE; fillStatus.isThisFirstFill = FALSE; break;