Index: firmware/App/Modes/ModeRecirculate.c =================================================================== diff -u -r847478dd75aac2edfe27df454ac5a644b6f30040 -r47c41046beba8affaaaa13a4f222a7b99bd193f1 --- firmware/App/Modes/ModeRecirculate.c (.../ModeRecirculate.c) (revision 847478dd75aac2edfe27df454ac5a644b6f30040) +++ firmware/App/Modes/ModeRecirculate.c (.../ModeRecirculate.c) (revision 47c41046beba8affaaaa13a4f222a7b99bd193f1) @@ -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.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. -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,20 +87,31 @@ 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 ); setValveState( VPO, VALVE_STATE_NOFILL_C_TO_NO ); - setROPumpTargetFlowRate( TARGET_RO_FLOW_RATE_L, TARGET_RO_PRESSURE_PSI ); +#ifndef V_2_SYSTEM + setValveStateDelayed( VRD1, VALVE_STATE_CLOSED, 0 ); + setValveStateDelayed( VRD2, VALVE_STATE_CLOSED, 0 ); +#endif signalDrainPumpHardStop(); requestConcentratePumpsOff( CONCENTRATEPUMPS_CP1_ACID ); requestConcentratePumpsOff( CONCENTRATEPUMPS_CP2_BICARB ); - // UV on + // UV reactors on turnOnUVReactor( INLET_UV_REACTOR ); turnOnUVReactor( OUTLET_UV_REACTOR ); + // NOTE: The target flow rate should be set prior to setting the start primary heater + // because the initial guess in the heaters driver needs the target flow to calculate + // the new PWMs for the main and small primary heaters + setROPumpTargetFlowRate( TARGET_FLUSH_LINES_RO_FLOW_RATE_L, TARGET_RO_PRESSURE_PSI ); + startPrimaryHeater(); + #ifndef _VECTORCAST_ { // TODO - test code to start the fan since we're turning the heater on F32 fanPWM = 0.25; @@ -112,9 +123,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 ) @@ -155,6 +168,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 @@ -167,11 +209,11 @@ 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() ) { setValveState( VDR, VALVE_STATE_RECIRC_C_TO_NC ); setROPumpTargetFlowRate( TARGET_RO_FLOW_RATE_L, TARGET_RO_PRESSURE_PSI ); @@ -211,33 +253,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; -} - /**@}*/