Index: firmware/App/DGCommon.h =================================================================== diff -u -r379f78f1fad668d741b3ccf1e78c69f3fccc45b5 -r654c5598765bb862c00a0175bdac95604c6c9b24 --- firmware/App/DGCommon.h (.../DGCommon.h) (revision 379f78f1fad668d741b3ccf1e78c69f3fccc45b5) +++ firmware/App/DGCommon.h (.../DGCommon.h) (revision 654c5598765bb862c00a0175bdac95604c6c9b24) @@ -55,7 +55,7 @@ #define DISABLE_MIXING 1 #define DISABLE_WATER_QUALITY_CHECK 1 #define DISABLE_RTC_CONFIG 1 - #define V_2_SYSTEM 1 + //#define V_2_SYSTEM 1 #include #include #endif Index: firmware/App/Modes/ModeChemicalDisinfect.c =================================================================== diff -u -r379f78f1fad668d741b3ccf1e78c69f3fccc45b5 -r654c5598765bb862c00a0175bdac95604c6c9b24 --- firmware/App/Modes/ModeChemicalDisinfect.c (.../ModeChemicalDisinfect.c) (revision 379f78f1fad668d741b3ccf1e78c69f3fccc45b5) +++ firmware/App/Modes/ModeChemicalDisinfect.c (.../ModeChemicalDisinfect.c) (revision 654c5598765bb862c00a0175bdac95604c6c9b24) @@ -1382,7 +1382,20 @@ return state; } - +/*********************************************************************//** + * @brief + * The handleChemicalDisinfectRinseR2ToR1AndDrainR1State function handles + * the chemical disinfect rinse R2 to R1 and drain R1 state. The state + * rinses reservoir 2 and drains reservoir 1 at the same time. If the drain + * process times out, it transitions to basic cancellation state, and + * if the rinse times out, it transitions to water cancellation state. + * If the drain and rinse are completed within the define time, it + * transitions to the next state. + * @details Inputs: rsrvr1Status, rsrvr2Status + * @details Outputs: stateTimer, rsrvr1Status, rsrvr2Status, + * prevChemDisinfectState, alarmDetectedPendingTrigger + * @return next state of the chemical disinfect state machine + *************************************************************************/ static DG_CHEM_DISINFECT_STATE_T handleChemicalDisinfectRinseR2ToR1AndDrainR1State( void ) { DG_CHEM_DISINFECT_STATE_T state = DG_CHEM_DISINFECT_STATE_RINSE_R2_TO_R1_AND_DRAIN_R1; @@ -1455,8 +1468,6 @@ // Turn on the drain pump to drain R2 setDrainPumpTargetRPM( DRAIN_PUMP_TARGET_RPM ); - // This is the last drain of heat disinfect cycle - isThisLastDrain = TRUE; stateTimer = getMSTimerCount(); // Set the reservoir status rsrvr2Status = DG_RESERVOIR_ABOVE_TARGET; @@ -1478,7 +1489,83 @@ } static DG_CHEM_DISINFECT_STATE_T handleChemicalDisinfectRinseR1ToR2AndDrainR2State( void ) { + DG_CHEM_DISINFECT_STATE_T state = DG_CHEM_DISINFECT_STATE_RINSE_R1_TO_R2_AND_DRAIN_R2; + if ( DG_RESERVOIR_ABOVE_TARGET == rsrvr2Status ) + { + rsrvr2Status = getRsrvrDrainStatus( DG_RESERVOIR_2, DRAIN_WEIGHT_UNCHANGE_TIMEOUT, RSRVRS_INITIAL_DRAIN_TIME_OUT_MS ); + } + else if ( DG_RESERVOIR_REACHED_TARGET == rsrvr2Status ) + { + // Done with draining R2 + signalDrainPumpHardStop(); +#ifndef V_2_SYSTEM + setValveState( VRD2, VALVE_STATE_CLOSED ); +#endif + } + else if ( DG_RESERVOIR_NOT_REACHED_TARGET == rsrvr2Status ) + { + prevChemDisinfectState = state; + state = DG_CHEM_DISINFECT_STATE_CANCEL_BASIC_PATH; + } + + // First reservoir 1 must be completely full + if ( DG_RESERVOIR_BELOW_TARGET == rsrvr1Status ) + { + rsrvr2Status = getRsrvrFillStatus( DG_RESERVOIR_1, RSRVRS_FULL_VOL_ML, RSRVRS_FILL_UP_TIMEOUT_MS ); + + U32 drainPumpRPM = getTargetDrainPumpRPM(); + // Keep monitoring the status of reservoir 2 as the same time + F32 volume = getLoadCellSmallFilteredWeight( LOAD_CELL_RESERVOIR_2_PRIMARY ); + // Reservoir 1 cannot be filled before reservoir 2 is filled and is overflowing to reservoir 1. If reservoir 1 has already + // reached to target volume, it means reservoir 2's load cell might be reading incorrect values. This situation might continue + // until reservoir 1 is filled up and the tubing might expand or leak. + // Before checking whether reservoir 1 is filled pre-maturely, we have to make sure reservoir 1 is drained completely to make + // sure the extra volume that is read is not because of previous water that is being drained currently and it is above 500 mL + if ( ( volume > RSRVRS_PARTIAL_FILL_VOL_ML ) && ( 0 == drainPumpRPM ) ) + { + prevChemDisinfectState = state; + alarmDetectedPendingTrigger = ALARM_ID_DG_INVALID_LOAD_CELL_VALUE; + state = DG_CHEM_DISINFECT_STATE_CANCEL_WATER_PATH; + } + } + // Once reservoir 1 is completely full, monitor reservoir 2 + else if ( DG_RESERVOIR_REACHED_TARGET == rsrvr2Status ) + { + rsrvr2Status = getRsrvrFillStatus( DG_RESERVOIR_2, RSRVRS_PARTIAL_FILL_VOL_ML, RSRVRS_500ML_FILL_UP_TIMEOUT_MS ); + + if ( DG_RESERVOIR_REACHED_TARGET == rsrvr2Status ) + { + // Done with filling, turn off the RO pump + signalROPumpHardStop(); + +#ifndef V_2_SYSTEM + setValveState( VRD2, VALVE_STATE_OPEN ); +#else + setValveState( VRD, VALVE_STATE_R2_C_TO_NO ); +#endif + + // Turn on the drain pump to drain R2 + setDrainPumpTargetRPM( DRAIN_PUMP_TARGET_RPM ); + + stateTimer = getMSTimerCount(); + // Set the reservoir status + rsrvr2Status = DG_RESERVOIR_ABOVE_TARGET; + state = DG_CHEM_DISINFECT_STATE_RINSE_R1_TO_R2_AND_DRAIN_R2; + } + else if ( DG_RESERVOIR_NOT_REACHED_TARGET == rsrvr1Status ) + { + prevChemDisinfectState = state; + state = DG_CHEM_DISINFECT_STATE_CANCEL_WATER_PATH; + } + } + else if ( DG_RESERVOIR_NOT_REACHED_TARGET == rsrvr2Status ) + { + prevChemDisinfectState = state; + state = DG_CHEM_DISINFECT_STATE_CANCEL_WATER_PATH; + } + + return state; } static DG_CHEM_DISINFECT_STATE_T handleChemicalDisinfectRinseCirculationState( void ) { Index: firmware/App/Modes/ModeDrain.c =================================================================== diff -u -r379f78f1fad668d741b3ccf1e78c69f3fccc45b5 -r654c5598765bb862c00a0175bdac95604c6c9b24 --- firmware/App/Modes/ModeDrain.c (.../ModeDrain.c) (revision 379f78f1fad668d741b3ccf1e78c69f3fccc45b5) +++ firmware/App/Modes/ModeDrain.c (.../ModeDrain.c) (revision 654c5598765bb862c00a0175bdac95604c6c9b24) @@ -82,10 +82,10 @@ { setValveState( VRD2, VALVE_STATE_OPEN ); } -#else +#endif + // set initial actuator states setValveState( VDR, VALVE_STATE_DRAIN_C_TO_NO ); -#endif setDrainPumpTargetRPM( TARGET_DRAIN_PUMP_RPM ); setROPumpTargetFlowRate( TARGET_RO_FLOW_RATE_L, TARGET_RO_PRESSURE_PSI ); @@ -139,20 +139,14 @@ DG_RESERVOIR_ID_T inactiveReservoir = getInactiveReservoir(); // if we have reached our target drain to volume (by weight) or cannot drain anymore, we are done draining - go back to re-circ mode - if ( hasTargetDrainVolumeBeenReached( inactiveReservoir, DRAIN_WEIGHT_UNCHANGE_TIMEOUT ) ) + if ( TRUE == hasTargetDrainVolumeBeenReached( inactiveReservoir, DRAIN_WEIGHT_UNCHANGE_TIMEOUT ) ) { setDrainPumpTargetRPM( 0 ); requestNewOperationMode( DG_MODE_CIRC ); #ifndef V_2_SYSTEM - if ( DG_RESERVOIR_1 == inactiveReservoir ) - { - setValveState( VRD1, VALVE_STATE_CLOSED ); - } - else if ( DG_RESERVOIR_2 == inactiveReservoir ) - { - setValveState( VRD2, VALVE_STATE_CLOSED ); - } + setValveState( VRD1, VALVE_STATE_CLOSED ); + setValveState( VRD2, VALVE_STATE_CLOSED ); #endif } Index: firmware/App/Modes/ModeFill.c =================================================================== diff -u -r6835f89b10dfac6fa12d27b357a85670fdcde088 -r654c5598765bb862c00a0175bdac95604c6c9b24 --- firmware/App/Modes/ModeFill.c (.../ModeFill.c) (revision 6835f89b10dfac6fa12d27b357a85670fdcde088) +++ firmware/App/Modes/ModeFill.c (.../ModeFill.c) (revision 654c5598765bb862c00a0175bdac95604c6c9b24) @@ -20,6 +20,7 @@ #include "FPGA.h" #include "Heaters.h" #include "LoadCell.h" +#include "ModeFault.h" #include "ModeFill.h" #include "OperationModes.h" #include "PersistentAlarm.h" Index: firmware/App/Modes/ModeFlush.c =================================================================== diff -u -r379f78f1fad668d741b3ccf1e78c69f3fccc45b5 -r654c5598765bb862c00a0175bdac95604c6c9b24 --- firmware/App/Modes/ModeFlush.c (.../ModeFlush.c) (revision 379f78f1fad668d741b3ccf1e78c69f3fccc45b5) +++ firmware/App/Modes/ModeFlush.c (.../ModeFlush.c) (revision 654c5598765bb862c00a0175bdac95604c6c9b24) @@ -41,7 +41,7 @@ #define FLUSH_DATA_PUB_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< Mode flush data publish interval in counts. #define RO_PUMP_TARGET_FLOW_RATE_LPM 0.8 ///< RO pump target flow rate during flush/fill in L/min. TODO original flow was 0.8 #define RO_PUMP_MAX_PRESSURE_PSI 130 ///< Maximum RO pump pressure during flush/fill states in psi. -#define DRAIN_PUMP_TARGET_RPM 1800 ///< Drain pump target RPM during drain. +#define DRAIN_PUMP_TARGET_RPM 2200 ///< Drain pump target RPM during drain. // Drain R1 & R2 states defines #define DRAIN_WEIGHT_UNCHANGE_TIMEOUT ( 6 * MS_PER_SECOND ) ///< Time period of unchanged weight during draining before timeout. Index: firmware/App/Modes/ModeStandby.c =================================================================== diff -u -r379f78f1fad668d741b3ccf1e78c69f3fccc45b5 -r654c5598765bb862c00a0175bdac95604c6c9b24 --- firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision 379f78f1fad668d741b3ccf1e78c69f3fccc45b5) +++ firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision 654c5598765bb862c00a0175bdac95604c6c9b24) @@ -19,6 +19,7 @@ #include "CPLD.h" #include "DrainPump.h" #include "Heaters.h" +#include "ModeFault.h" #include "ModeStandby.h" #include "OperationModes.h" #include "Reservoirs.h" @@ -94,6 +95,8 @@ // re-initialize standby mode each time we transition to standby mode initStandbyMode(); + //deenergizeActuators(); + // set initial actuator states setValveState( VRF, VALVE_STATE_R2_C_TO_NO ); setValveState( VRI, VALVE_STATE_R1_C_TO_NO ); Index: firmware/App/Services/Reservoirs.c =================================================================== diff -u -r379f78f1fad668d741b3ccf1e78c69f3fccc45b5 -r654c5598765bb862c00a0175bdac95604c6c9b24 --- firmware/App/Services/Reservoirs.c (.../Reservoirs.c) (revision 379f78f1fad668d741b3ccf1e78c69f3fccc45b5) +++ firmware/App/Services/Reservoirs.c (.../Reservoirs.c) (revision 654c5598765bb862c00a0175bdac95604c6c9b24) @@ -132,7 +132,7 @@ cmdResponse.rejected = FALSE; setValveState( VRF, VALVE_STATE_R2_C_TO_NO ); #ifndef V_2_SYSTEM - setValveState( VRD1, VALVE_STATE_OPEN ); + setValveState( VRD1, VALVE_STATE_CLOSED ); #else setValveState( VRD, VALVE_STATE_R2_C_TO_NO ); #endif @@ -145,7 +145,7 @@ cmdResponse.rejected = FALSE; setValveState( VRF, VALVE_STATE_R1_C_TO_NC ); #ifndef V_2_SYSTEM - setValveState( VRD2, VALVE_STATE_OPEN ); + setValveState( VRD2, VALVE_STATE_CLOSED ); #else setValveState( VRD, VALVE_STATE_R1_C_TO_NC ); #endif