Index: firmware/App/Modes/ModeRecirculate.c =================================================================== diff -u -r2fff37fa585181917705645494549b5fd4a4d522 -r67021fbc633259e8e1bce76749dbef7d0cb51998 --- firmware/App/Modes/ModeRecirculate.c (.../ModeRecirculate.c) (revision 2fff37fa585181917705645494549b5fd4a4d522) +++ firmware/App/Modes/ModeRecirculate.c (.../ModeRecirculate.c) (revision 67021fbc633259e8e1bce76749dbef7d0cb51998) @@ -24,6 +24,7 @@ #include "FPGA.h" #include "Heaters.h" #include "ModeRecirculate.h" +#include "NVDataMgmt.h" #include "OperationModes.h" #include "Pressures.h" #include "ROPump.h" @@ -44,12 +45,11 @@ #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.01 ///< 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. -static F32 flushLinesVolumeL = 0.0; ///< Volume of water pumped by RO pump during flush lines state. +static DG_RECIRCULATE_MODE_STATE_T recircState; ///< Currently active re-circulation state. +static F32 flushLinesVolumeL = 0.0; ///< Volume of water pumped by RO pump during flush lines state. // ********** private function prototypes ********** @@ -66,7 +66,7 @@ *************************************************************************/ void initRecirculateMode( void ) { - recircState = DG_RECIRCULATE_MODE_STATE_START; + recircState = DG_RECIRCULATE_MODE_STATE_START; flushLinesVolumeL = 0.0; } @@ -87,6 +87,8 @@ setValveState( VPI, VALVE_STATE_OPEN ); #ifndef V_2_SYSTEM setValveState( VPD, VALVE_STATE_OPEN_C_TO_NC ); + setValveState( VRD1, VALVE_STATE_CLOSED ); + setValveState( VRD2, VALVE_STATE_CLOSED ); #endif setValveState( VRC, VALVE_STATE_DRAIN_C_TO_NO ); setValveState( VDR, VALVE_STATE_DRAIN_C_TO_NO ); @@ -117,9 +119,11 @@ /*********************************************************************//** * @brief - * The execRecirculateMode function executes the re-circulate mode state machine. + * The execRecirculateMode function executes the re-circulate mode state + * machine. * @details Inputs: recircState - * @details Outputs: Check water quality, re-circulate mode state machine executed + * @details Outputs: Check water quality, re-circulate mode state machine + * executed * @return current state *************************************************************************/ U32 execRecirculateMode( void ) @@ -160,6 +164,35 @@ /*********************************************************************//** * @brief + * 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 ) +{ + BOOL result = TRUE; + + requestNewOperationMode( DG_MODE_STAN ); + + return result; +} + +/*********************************************************************//** + * @brief + * The getCurrentRecirculateState function returns the current state of the + * re-circulate mode. + * @details Inputs: recircState + * @details Outputs: none + * @return the current state of re-circulate mode + *************************************************************************/ +DG_RECIRCULATE_MODE_STATE_T getCurrentRecirculateState( void ) +{ + return recircState; +} + +/*********************************************************************//** + * @brief * The handleFlushLinesState function executes the flush lines state of the * re-circulate mode state machine. * @details Inputs: none @@ -172,15 +205,13 @@ F32 waterFlowRate = getMeasuredROFlowRate(); F32 waterVolume = ( ( waterFlowRate / SEC_PER_MIN ) / ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ); - // integrate volume of water moved through line + // Integrate volume of water moved through line flushLinesVolumeL += waterVolume; - // when enough water volume has flowed to flush the lines, transition to re-circ state - if ( flushLinesVolumeL >= FLUSH_LINES_VOLUME_L ) + // When enough water volume has flowed to flush the lines, transition to re-circ state + if ( flushLinesVolumeL >= getRecirculationDrainVol() ) { -#ifndef SKIP_RECIRC setValveState( VDR, VALVE_STATE_RECIRC_C_TO_NC ); -#endif setROPumpTargetFlowRate( TARGET_RO_FLOW_RATE_L, TARGET_RO_PRESSURE_PSI ); result = DG_RECIRCULATE_MODE_STATE_RECIRC_WATER; } @@ -218,33 +249,4 @@ return result; } -/*********************************************************************//** - * @brief - * 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 ) -{ - BOOL result = TRUE; - - requestNewOperationMode( DG_MODE_STAN ); - - return result; -} - -/*********************************************************************//** - * @brief - * The getCurrentRecirculateState function returns the current state of the - * re-circulate mode. - * @details Inputs: recircState - * @details Outputs: none - * @return the current state of re-circulate mode - *************************************************************************/ -DG_RECIRCULATE_MODE_STATE_T getCurrentRecirculateState( void ) -{ - return recircState; -} - /**@}*/