Index: firmware/App/Modes/ModeRecirculate.c =================================================================== diff -u -rf308cc4c35eab630ebbbde405cfe47d049afeafb -ra1b8dbb69c4bd2f0cc22e62bede7015c9307d378 --- firmware/App/Modes/ModeRecirculate.c (.../ModeRecirculate.c) (revision f308cc4c35eab630ebbbde405cfe47d049afeafb) +++ firmware/App/Modes/ModeRecirculate.c (.../ModeRecirculate.c) (revision a1b8dbb69c4bd2f0cc22e62bede7015c9307d378) @@ -9,7 +9,7 @@ * @file ModeRecirculate.c * * @author (last) Quang Nguyen -* @date (last) 13-Aug-2020 +* @date (last) 24-Aug-2020 * * @author (original) Sean * @date (original) 04-Apr-2020 @@ -18,6 +18,7 @@ #include "etpwm.h" +#include "ConcentratePumps.h" #include "ConductivitySensors.h" #include "DrainPump.h" #include "FPGA.h" @@ -27,9 +28,10 @@ #include "Pressures.h" #include "ROPump.h" #include "TaskGeneral.h" +#include "TemperatureSensors.h" #include "Timers.h" +#include "UVReactors.h" #include "Valves.h" -#include "TemperatureSensors.h" /** * @addtogroup DGRecirculateMode @@ -38,9 +40,12 @@ // ********** private definitions ********** -#define TARGET_RO_PRESSURE_PSI 120 ///< Target pressure for RO pump. -#define FLUSH_LINES_VOLUME_L 0.1 ///< Water volume (in Liters) to flush when starting re-circulate mode. +#define TARGET_RO_PRESSURE_PSI 130 ///< Target pressure for RO pump. +#define TARGET_RO_FLOW_RATE_L 0.3 ///< Target flow rate for RO pump. +#define TARGET_FLUSH_LINES_RO_FLOW_RATE_L 0.6 ///< Target flow rate for RO pump. +#define FLUSH_LINES_VOLUME_L 0.1 ///< Water volume (in Liters) to flush when starting re-circulate mode. + // ********** private data ********** static DG_RECIRCULATE_MODE_STATE_T recircState; ///< Currently active re-circulation state. @@ -54,10 +59,9 @@ /*********************************************************************//** * @brief - * The initRecirculateMode function initializes the Fill Mode module. - * @details - * Inputs : none - * Outputs : Fill Mode module initialized. + * The initRecirculateMode function initializes the re-circulate mode module. + * @details Inputs: none + * @details Outputs: Re-circulate mode module initialized * @return none *************************************************************************/ void initRecirculateMode( void ) @@ -68,11 +72,9 @@ /*********************************************************************//** * @brief - * The transitionToRecirculateMode function prepares for transition to \n - * fill mode. - * @details - * Inputs : none - * Outputs : recircState + * The transitionToRecirculateMode function prepares for transition to re-circulate mode. + * @details Inputs: none + * @details Outputs: Re-initialized re-circulate mode * @return none *************************************************************************/ void transitionToRecirculateMode( void ) @@ -86,11 +88,16 @@ setValveState( VRC, VALVE_STATE_DRAIN_C_TO_NO ); setValveState( VDR, VALVE_STATE_DRAIN_C_TO_NO ); setValveState( VPO, VALVE_STATE_NOFILL_C_TO_NO ); - setROPumpTargetPressure( TARGET_RO_PRESSURE_PSI, PUMP_CONTROL_MODE_CLOSED_LOOP ); + setROPumpTargetFlowRate( TARGET_FLUSH_LINES_RO_FLOW_RATE_L, TARGET_RO_PRESSURE_PSI ); signalDrainPumpHardStop(); startPrimaryHeater(); + requestConcentratePumpsOff( CONCENTRATEPUMPS_CP1_ACID ); + requestConcentratePumpsOff( CONCENTRATEPUMPS_CP2_BICARB ); + // UV on - // conc. pumps off + turnOnUVReactor( INLET_UV_REACTOR ); + turnOnUVReactor( OUTLET_UV_REACTOR ); + #ifndef _VECTORCAST_ { // TODO - test code to start the fan since we're turning the heater on F32 fanPWM = 0.25; @@ -102,18 +109,18 @@ /*********************************************************************//** * @brief - * The execRecirculateMode function executes the Re-circulate Mode state machine. - * @details - * Inputs : recircState - * Outputs : recircState + * The execRecirculateMode function executes the re-circulate mode state machine. + * @details Inputs: recircState + * @details Outputs: Check water quality, re-circulate mode state machine executed * @return current state *************************************************************************/ U32 execRecirculateMode( void ) { - // check inlet water conductivity, temperature, and pressure - checkInletWaterConductivity( recircState ); + // check inlet water conductivity, temperature, pressure, and RO rejection ratio + checkInletWaterConductivity(); checkInletWaterTemperature(); checkInletPressure(); + checkRORejectionRatio(); // execute current re-circulate state switch ( recircState ) @@ -135,7 +142,7 @@ break; default: - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DG_SOFTWARE_FAULT, 0, recircState ) // TODO - add s/w fault enum to 1st data param + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DG_SOFTWARE_FAULT, SW_FAULT_ID_RECIRC_MODE_INVALID_EXEC_STATE, recircState ) recircState = DG_RECIRCULATE_MODE_STATE_START; break; } @@ -145,11 +152,10 @@ /*********************************************************************//** * @brief - * The handleCheckInletWaterState function executes the flush lines \n - * state of the Re-circulate Mode state machine. - * @details - * Inputs : none - * Outputs : + * The handleFlushLinesState function executes the flush lines state of the + * re-circulate mode state machine. + * @details Inputs: none + * @details Outputs: Integrate volume of water moved through line * @return the next state *************************************************************************/ static DG_RECIRCULATE_MODE_STATE_T handleFlushLinesState( void ) @@ -165,6 +171,7 @@ if ( flushLinesVolumeL >= FLUSH_LINES_VOLUME_L ) { setValveState( VDR, VALVE_STATE_RECIRC_C_TO_NC ); + setROPumpTargetFlowRate( TARGET_RO_FLOW_RATE_L, TARGET_RO_PRESSURE_PSI ); result = DG_RECIRCULATE_MODE_STATE_RECIRC_WATER; } @@ -173,11 +180,10 @@ /*********************************************************************//** * @brief - * The handleRecircProductWaterState function executes the re-circulate \n - * water state of the Re-circulate Mode state machine. - * @details - * Inputs : none - * Outputs : + * The handleRecircWaterState function executes the re-circulate water state + * of the re-circulate mode state machine. + * @details Inputs: none + * @details Outputs: none * @return the next state *************************************************************************/ static DG_RECIRCULATE_MODE_STATE_T handleRecircWaterState( void ) @@ -189,11 +195,10 @@ /*********************************************************************//** * @brief - * The handleRecircPauseState function executes the pause state of the \n - * Re-circulate Mode state machine. - * @details - * Inputs : none - * Outputs : + * The handleRecircPauseState function executes the pause state of the + * re-circulate mode state machine. + * @details Inputs: none + * @details Outputs: none * @return the next state *************************************************************************/ static DG_RECIRCULATE_MODE_STATE_T handleRecircPauseState( void ) @@ -205,10 +210,9 @@ /*********************************************************************//** * @brief - * The requestDGStop function handles an HD request to stop (return to Standby mode). - * @details - * Inputs : none - * Outputs : DG standby mode requested + * The requestDGStop function handles an HD request to stop (return to standby mode). + * @details Inputs: none + * @details Outputs: DG standby mode requested * @return TRUE if request accepted, FALSE if not. *************************************************************************/ BOOL requestDGStop( void ) @@ -222,12 +226,11 @@ /*********************************************************************//** * @brief - * The getCurrentRecirculateState function returns the current state of the \n + * The getCurrentRecirculateState function returns the current state of the * re-circulate mode. - * @details - * Inputs : recircState - * Outputs : none - * @return the current state of re-circulate mode. + * @details Inputs: recircState + * @details Outputs: none + * @return the current state of re-circulate mode *************************************************************************/ DG_RECIRCULATE_MODE_STATE_T getCurrentRecirculateState( void ) {