Index: firmware/App/Modes/ModeHeatDisinfect.c =================================================================== diff -u -r73796a0e50450e4958407c4ce42337e257277faa -re66857bf3bbc6be73802ca6596cbb9444541e21f --- firmware/App/Modes/ModeHeatDisinfect.c (.../ModeHeatDisinfect.c) (revision 73796a0e50450e4958407c4ce42337e257277faa) +++ firmware/App/Modes/ModeHeatDisinfect.c (.../ModeHeatDisinfect.c) (revision e66857bf3bbc6be73802ca6596cbb9444541e21f) @@ -65,21 +65,22 @@ #define NUM_OF_TEMP_SENSORS_TO_AVG 4.0 ///< Number of temperature sensors to average to check the difference. // Flush and drain R1 and R2 -#define RSRVRS_FULL_VOL_ML 1900.0 ///< Reservoirs 1 & 2 full volume in mL. +#define RSRVRS_FULL_VOL_ML 1800.0 ///< Reservoirs 1 & 2 full volume in mL. TODo original value was 1900 #define RSRVRS_PARTIAL_FILL_VOL_ML 500.0 ///< Reservoirs 1 & 2 partial volume in mL. +#define RSRVRS_FULL_STABLE_TIME_COUNT ( ( 4 * MS_PER_SECOND ) / TASK_GENERAL_INTERVAL ) ///< Reservoirs 1 & 2 full stable time in counts. #define RSRVRS_FILL_UP_TIMEOUT_MS ( 5 * 60 * MS_PER_SECOND ) ///< Reservoirs 1 & 2 full fill up timeout in ms. #define RSRVRS_500ML_FILL_UP_TIMEOUT_MS ( 2 * 60 * MS_PER_SECOND ) ///< Reservoirs 1 & 2 partial fill up timeout in ms. #define RSRVRS_DRAIN_TIMEOUT_MS ( 2 * 60 * MS_PER_SECOND ) ///< Reservoirs 1 & 2 drain timeout in ms. // Fill and heat water -#define HEAT_DISINFECT_TARGET_TEMPERATURE_C 85.0 ///< Heat disinfect target water temperature in C. TODO original temperature was 85.0 -#define HEAT_DISINFECT_START_TEMPERATURE_C 81.0 ///< Heat disinfect minimum acceptable temperature in C. TODO original temperature was 81.0 +#define HEAT_DISINFECT_TARGET_TEMPERATURE_C 25.0 ///< Heat disinfect target water temperature in C. TODO original temperature was 85.0 +#define HEAT_DISINFECT_START_TEMPERATURE_C 21.0 ///< Heat disinfect minimum acceptable temperature in C. TODO original temperature was 81.0 // R1 to R2 & R2 to R1 heat disinfect circulation #define HEAT_DISINFECT_TARGET_RO_FLOW_LPM 0.9 ///< Heat disinfect target RO flow rate in L/min. TODO original value was 0.8 #define HEAT_DISINFECT_MAX_RO_PRESSURE_PSI 30 ///< Heat disinfect maximum RO pressure in psi. #define HEAT_DISINFECT_TARGET_DRAIN_PRES_PSI 5.0 ///< Heat disinfect target drain outlet pressure in psi. -#define HEAT_DISINFECT_TIME_MS ( 3 * 60 * MS_PER_SECOND ) ///< Heat disinfect time for each section in milliseconds. TODO original time was 10 minutes +#define HEAT_DISINFECT_TIME_MS ( 1 * 60 * MS_PER_SECOND ) ///< Heat disinfect time for each section in milliseconds. TODO original time was 10 minutes #define HEAT_DISINFECT_START_TEMP_TIMOUT_MS ( 3 * 60 * 60 * MS_PER_SECOND ) ///< Heat disinfect reaching to minimum temperature timeout in milliseconds. TODO figure out this timeout #define RSRVRS_TARGET_VOL_OUT_TIMEOUT_MS ( 0.5 * 60 * MS_PER_SECOND ) ///< Reservoirs 1 & 2 maximum volume out of range timeout during heat disnfect. #define RSRVRS_MAX_TARGET_VOL_CHANGE_ML 100.0 ///< Reservoirs 1 & 2 maximum allowed volume change when full during heat disinfect. @@ -141,6 +142,7 @@ static BOOL hasPostHeatDisinfectWaitStarted = FALSE; ///< Final delay at the end of heat disinfect and before flush flag. static U32 dataPublishCounter = 0; ///< Heat Disinfect data publish counter. static CANCELLATION_MODES_T cancellationMode = CANCELLATION_MODE_NONE; ///< Cancellation mode. +static U32 rsrvrFillStableTimeCounter = 0; ///< Reservoirs fill stable time counter. // ********** private function prototypes ********** @@ -199,6 +201,7 @@ hasPostHeatDisinfectWaitStarted = FALSE; overallHeatDisinfectTimer = 0; cancellationMode = CANCELLATION_MODE_NONE; + rsrvrFillStableTimeCounter = 0; } /*********************************************************************//** @@ -402,6 +405,7 @@ setValveState( VRD, VALVE_STATE_R1_C_TO_NC ); setDrainPumpTargetRPM( DRAIN_PUMP_TARGET_RPM ); + rsrvrFillStableTimeCounter = 0; // Assume reservoir 1 is full and drain it rsrvr1Status = RESERVOIR_STATUS_FULL; stateTimer = getMSTimerCount(); @@ -843,8 +847,8 @@ // Get the current volumes of R1 & R2. These values will be used to make sure the reservoirs' // volume does not change more than a certain amount during the actual heat disinfect cycle - R1HeatDisinfectVol = getLoadCellSmallFilteredWeight( LOAD_CELL_RESERVOIR_1_PRIMARY ); - R2HeatDisinfectVol = getLoadCellSmallFilteredWeight( LOAD_CELL_RESERVOIR_2_PRIMARY ); + R1HeatDisinfectVol = getLoadCellLargeFilteredWeight( LOAD_CELL_RESERVOIR_1_PRIMARY ); + R2HeatDisinfectVol = getLoadCellLargeFilteredWeight( LOAD_CELL_RESERVOIR_2_PRIMARY ); stateTimer = getMSTimerCount(); rsrvrsVolMonitorTimer = getMSTimerCount(); @@ -884,7 +888,10 @@ setValveState( VRD, VALVE_STATE_R1_C_TO_NC ); setValveState( VRI, VALVE_STATE_R1_C_TO_NO ); setValveState( VRF, VALVE_STATE_R2_C_TO_NO ); + // Although there is fluid in both reservoirs, but they are set to empty + // to begin the transition of hot water from R1 to R2. rsrvr2Status = RESERVOIR_STATUS_EMPTY; + rsrvr1Status = RESERVOIR_STATUS_EMPTY; stateTimer = getMSTimerCount(); state = DG_HEAT_DISINFECT_STATE_FILL_R2_WITH_HOT_WATER; break; @@ -907,20 +914,28 @@ // In this state, R2 is fully filled up and R1 is partially filled up with hot water // So waiting for R1 to get to the level of defined partially full - BOOL isR1PartiallyFull = fabs( getLoadCellSmallFilteredWeight( LOAD_CELL_RESERVOIR_1_PRIMARY ) - RSRVRS_PARTIAL_FILL_VOL_ML ) < - RSRVRS_MAX_TARGET_VOL_CHANGE_ML; + //BOOL isR1PartiallyFull = fabs( getLoadCellSmallFilteredWeight( LOAD_CELL_RESERVOIR_1_PRIMARY ) - RSRVRS_PARTIAL_FILL_VOL_ML ) < + // RSRVRS_MAX_TARGET_VOL_CHANGE_ML; - rsrvr2Status = getRsrvrFillStatus( DG_RESERVOIR_2, RSRVRS_FULL_VOL_ML, RSRVRS_FILL_UP_TIMEOUT_MS, DG_HEAT_DISINFECT_STATE_CANCEL_WATER_PATH ); - - if ( rsrvr2Status == RESERVOIR_STATUS_FULL && isR1PartiallyFull ) + // First reservoir 1 must be partially full + if ( rsrvr1Status == RESERVOIR_STATUS_EMPTY ) { - // Get the current volumes to be monitored during R2 to R1 heat disinfect state - R1HeatDisinfectVol = getLoadCellSmallFilteredWeight( LOAD_CELL_RESERVOIR_1_PRIMARY ); - R2HeatDisinfectVol = getLoadCellSmallFilteredWeight( LOAD_CELL_RESERVOIR_2_PRIMARY ); + rsrvr1Status = getRsrvrFillStatus( DG_RESERVOIR_1, RSRVRS_PARTIAL_FILL_VOL_ML, RSRVRS_500ML_FILL_UP_TIMEOUT_MS, DG_HEAT_DISINFECT_STATE_CANCEL_WATER_PATH ); + } + else if ( rsrvr1Status == RESERVOIR_STATUS_FULL ) + { + rsrvr2Status = getRsrvrFillStatus( DG_RESERVOIR_2, RSRVRS_FULL_VOL_ML, RSRVRS_FILL_UP_TIMEOUT_MS, DG_HEAT_DISINFECT_STATE_CANCEL_WATER_PATH ); - //TODO turn on CP1 and CP2 + if ( rsrvr2Status == RESERVOIR_STATUS_FULL /*&& isR1PartiallyFull*/ ) + { + // Get the current volumes to be monitored during R2 to R1 heat disinfect state + R1HeatDisinfectVol = getLoadCellLargeFilteredWeight( LOAD_CELL_RESERVOIR_1_PRIMARY ); + R2HeatDisinfectVol = getLoadCellLargeFilteredWeight( LOAD_CELL_RESERVOIR_2_PRIMARY ); - state = DG_HEAT_DISINFECT_STATE_DISINFECT_R2_TO_R1; + //TODO turn on CP1 and CP2 + + state = DG_HEAT_DISINFECT_STATE_DISINFECT_R2_TO_R1; + } } return state; @@ -1275,7 +1290,10 @@ // The drain is set to start from reservoir 2 since all the actuators have been de-energized // Start the drain pump - setDrainPumpTargetRPM( DRAIN_PUMP_TARGET_RPM ); + // TODO for testing only remove + //setDrainPumpTargetRPM( DRAIN_PUMP_TARGET_RPM ); + state = DG_HEAT_DISINFECT_STATE_COMPLETE; + //TODo for testing only remove // Start the timer for drain timeout stateTimer = getMSTimerCount(); @@ -1389,9 +1407,10 @@ } // Check the volume of the reservoir against the target volume - if ( volume >= targetVol ) + if ( volume >= targetVol && ++rsrvrFillStableTimeCounter >= RSRVRS_FULL_STABLE_TIME_COUNT ) { status = RESERVOIR_STATUS_FULL; + rsrvrFillStableTimeCounter = 0; // Set the state timer in case it needs to be used for another timeout check stateTimer = getMSTimerCount(); }