Index: firmware/App/Controllers/PermeateTank.c =================================================================== diff -u -r6a4cee4d44890c9af3fea923e55e92bccd987d92 -r3b38773ea822bb860a0fd3af416d2380a095b499 --- firmware/App/Controllers/PermeateTank.c (.../PermeateTank.c) (revision 6a4cee4d44890c9af3fea923e55e92bccd987d92) +++ firmware/App/Controllers/PermeateTank.c (.../PermeateTank.c) (revision 3b38773ea822bb860a0fd3af416d2380a095b499) @@ -35,11 +35,11 @@ #define PERMEATE_TANK_PUMP_DATA_PUB_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) for permeate tank broadcast #define PERMEATE_TANK_PUBLISH_COUNTER_START_COUNT 9 ///< Publishing counter offset #define PERMEATE_TANK_FULL_SWITCH_MS ( 1 * MS_PER_SECOND ) ///< State switch timeout in full state (in ms) -#define PERMEATE_TANK_EMPTY_LEVEL_VOL_ML 957 ///< Permeate tank volume in empty level ( in ml ) +#define PERMEATE_TANK_EMPTY_LEVEL_VOL_ML 0 ///< Permeate tank volume in empty level ( in ml ) #define PERMEATE_TANK_LOW_LEVEL_VOL_ML 957 ///< Permeate tank volume in low level ( in ml ) #define PERMEATE_TANK_HIGH_LEVEL_VOL_ML 1345 ///< Permeate tank volume in high level ( in ml ) #define PERMEATE_TANK_FULL_LEVEL_VOL_ML 1532 ///< Permeate tank volume in full level ( in ml ) -#define TWO_WIRE_RINSE_PUMP_TARGET_FLOW 228.89 ///< Two wire rinse pump rate //TODO use get function call once implemented +#define TWO_WIRE_RINSE_PUMP_TARGET_FLOW 228.89 ///< Two wire rinse pump rate // ********** private data ********** Index: firmware/App/Modes/FPModes/FlushConcentrate.c =================================================================== diff -u -r97f657d47a01b765b72e5193c434dd959c3a3f35 -r3b38773ea822bb860a0fd3af416d2380a095b499 --- firmware/App/Modes/FPModes/FlushConcentrate.c (.../FlushConcentrate.c) (revision 97f657d47a01b765b72e5193c434dd959c3a3f35) +++ firmware/App/Modes/FPModes/FlushConcentrate.c (.../FlushConcentrate.c) (revision 3b38773ea822bb860a0fd3af416d2380a095b499) @@ -47,26 +47,26 @@ #define CONCENTRATE_FLUSH_VOLUME_THRESHOLD CONCENTRATE_FLUSH_VOLUME_THRESHOLD_ML * CONCENTRATE_FLUSH_VOLUME_THRESHOLD_PCT ///< alarm threshold for integrated volume #define CONCENTRATE_FLUSH_WAIT_FOR_TANK_FULL_TIMEOUT ( 60 * MS_PER_SECOND ) ///< Concentrate flush wait for tank full timer (in ms) #define CONCENTRATE_FLUSH_WAIT_FOR_TANK_FULL_TGT_FLOW 700 ///< target flow rate for waiting for tank state +#define CONCENTRATE_FLUSH_BOOST_PUMP_TGT_PSI 25 ///< Pressure target in PSI for the boost pump during concentrate flush. +#define MIN_BOOST_PUMP_DUTY_CYCLE_PCT 0.5F ///< Minimum duty cycle value for boost pump during open loop control + // ********** private data ********** -static const F32 CONCENTRATE_FLOW_INTEGRATOR = 1.0F / (F32)( SEC_PER_MIN * ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ); ///< Multiplier to convert flow (mL/min) into volume (mL) for period of general task interval. static FP_CONC_FLUSH_STATE_T concentrateFlushState; ///< Currently active Concentrate flush state. static U32 concentrateFlushDataPublicationTimerCounter; ///< Used to schedule Concentrate flush data publication to CAN bus. static OVERRIDE_U32_T concentrateFlushDataPublishInterval; ///< Concentrate Flush mode data publish interval. static OVERRIDE_U32_T concentrateFlushTimeout; ///< Concentrate Flush timeout value static U32 concentrateFlushTimer; ///< Concentrate Flush timeout timer -static U32 concentrateFlushTankFullTimer; ///< Concentrate Flush timeout timer static BOOL pendingStartConcentrateFlushRequest; ///< signal to start flushing. static BOOL isFlushComplete; ///< Concentrate Flush complete BOOL -static F32 cumulativeConcentrateVolume_mL; ///< cumulative concentrate volume for integrated volume +static BOOL isTankFilled; ///< Concentrate tank filled in permeate flush state // ********** private function prototypes ********** static void publishConcentrateFlushData( void ); static FP_CONC_FLUSH_STATE_T handleConcentrateFlushProgressState( void ); static FP_CONC_FLUSH_STATE_T handleConcentrateFlushPausedState( void ); -static FP_CONC_FLUSH_STATE_T handleConcentrateFlushWaitForTankFullState( void ); static void setConcentrateFlushTransition( FP_CONC_FLUSH_STATE_T state ); static U32 getConcentrateFlushTimeout( void ); static U32 getConcentrateFlushPublishInterval( void ); @@ -93,8 +93,7 @@ concentrateFlushTimer = 0; isFlushComplete = FALSE; pendingStartConcentrateFlushRequest = FALSE; - cumulativeConcentrateVolume_mL = 0.0F; - concentrateFlushTankFullTimer = 0; + isTankFilled = FALSE; } /*********************************************************************//** @@ -116,10 +115,6 @@ concentrateFlushState = handleConcentrateFlushProgressState(); break; - case CONC_FLUSH_WAIT_FOR_TANK_FULL: - concentrateFlushState = handleConcentrateFlushWaitForTankFullState(); - break; - case CONC_FLUSH_PAUSED: concentrateFlushState = handleConcentrateFlushPausedState(); break; @@ -148,6 +143,7 @@ static FP_CONC_FLUSH_STATE_T handleConcentrateFlushProgressState( void ) { FP_CONC_FLUSH_STATE_T state = CONC_FLUSH_IN_PROGRESS; + LEVEL_STATE_T level = getLevelStatus( P25_LEVL ); // if ( TRUE == 1 ) )// TODO Alarm and Stop State Rework // { @@ -159,32 +155,26 @@ isFlushComplete = TRUE; state = CONC_FLUSH_PAUSED; } - - return state; -} - -/*********************************************************************//** - * @brief - * The handleConcentrateFlushWaitForTankFullState handles the wait for - * tank full state of Concentrate flush - * @details \b Inputs: concentrateFlushTankFullTimer - * @details \b Outputs: none - * @return the next state of Concentrate flush state - *************************************************************************/ -static FP_CONC_FLUSH_STATE_T handleConcentrateFlushWaitForTankFullState( void ) -{ - FP_CONC_FLUSH_STATE_T state = CONC_FLUSH_WAIT_FOR_TANK_FULL; - - if ( LEVEL_STATE_HIGH == getLevelStatus( P25_LEVL ) ) + // Manual control of Permeate tank to prevent over fill. + if ( LEVEL_STATE_HIGH == level ) { - state = CONC_FLUSH_IN_PROGRESS; + setValveState( M4_VALV, VALVE_STATE_CLOSED ); + if ( TRUE == isBoostPumpInstalled() ) + { + F32 currentDutyCyclePct = getCurrentBoostPumpDutyCyclePCT() > MIN_BOOST_PUMP_DUTY_CYCLE_PCT ? getCurrentBoostPumpDutyCyclePCT(): MIN_BOOST_PUMP_DUTY_CYCLE_PCT; + + setBoostPumpTargetDutyCycle( currentDutyCyclePct ); + isTankFilled = TRUE; + } } - else + else if ( LEVEL_STATE_LOW == level ) { - if ( TRUE == didTimeout( concentrateFlushTankFullTimer, CONCENTRATE_FLUSH_WAIT_FOR_TANK_FULL_TIMEOUT ) ) + setValveState( M4_VALV, VALVE_STATE_OPEN ); + // set boost pump to closed loop when M4 closed. Added Tank fill check to avoid reset during initial transition + if ( ( TRUE == isBoostPumpInstalled() ) && ( TRUE == isTankFilled ) ) { - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_FP_CONCENTRATE_FLUSH_TANK_FULL_TIMEOUT, concentrateFlushTankFullTimer, getPermeateTankState() ); - state = CONC_FLUSH_PAUSED; + setBoostPumpTargetPressure( CONCENTRATE_FLUSH_BOOST_PUMP_TGT_PSI ); + isTankFilled = FALSE; } } @@ -206,7 +196,7 @@ { isFlushComplete = FALSE; pendingStartConcentrateFlushRequest = FALSE; - state = CONC_FLUSH_WAIT_FOR_TANK_FULL; + state = CONC_FLUSH_IN_PROGRESS; } return state; @@ -243,23 +233,6 @@ concentrateFlushTimer = getMSTimerCount(); break; - case CONC_FLUSH_WAIT_FOR_TANK_FULL: - setValveState( M4_VALV, VALVE_STATE_OPEN ); - setValveState( M12_VALV, VALVE_STATE_CLOSED ); - setValveState( P6_VALV, VALVE_STATE_CLOSED ); - setValveState( P11_VALV, VALVE_STATE_OPEN ); - setValveState( P33_VALV, VALVE_STATE_CLOSED ); - setValveState( P34_VALV, VALVE_STATE_CLOSED ); - setValveState( P37_VALV, VALVE_STATE_CLOSED ); - setValveState( P39_VALV, VALVE_STATE_CLOSED ); - concentrateFlushTankFullTimer = getMSTimerCount(); - if ( TRUE == isBoostPumpInstalled() ) - { - setBoostPumpTargetPressure( CONCENTRATE_FLUSH_BOOST_PUMP_TGT_PSI ); - } - setROPumpTargetFlowRateMLPM( CONCENTRATE_FLUSH_WAIT_FOR_TANK_FULL_TGT_FLOW, TRUE ); - break; - case CONC_FLUSH_PAUSED: // Stop pumps and close only if we alarm ( pause ) during flush. if ( FALSE == isConcentrateFlushComplete() ) Index: firmware/App/Modes/FPModes/FlushFilter.c =================================================================== diff -u -r72314cea6ecb88b4863be7cb376c92a594ec5c8d -r3b38773ea822bb860a0fd3af416d2380a095b499 --- firmware/App/Modes/FPModes/FlushFilter.c (.../FlushFilter.c) (revision 72314cea6ecb88b4863be7cb376c92a594ec5c8d) +++ firmware/App/Modes/FPModes/FlushFilter.c (.../FlushFilter.c) (revision 3b38773ea822bb860a0fd3af416d2380a095b499) @@ -24,6 +24,7 @@ #include "TaskGeneral.h" #include "Timers.h" #include "Valves.h" +#include "WaterQualityMonitor.h" /** * @addtogroup FPFilterFlush Index: firmware/App/Modes/FPModes/FlushPermeate.c =================================================================== diff -u -r45c1fb3332d132a9c438e50224013b52967e762c -r3b38773ea822bb860a0fd3af416d2380a095b499 --- firmware/App/Modes/FPModes/FlushPermeate.c (.../FlushPermeate.c) (revision 45c1fb3332d132a9c438e50224013b52967e762c) +++ firmware/App/Modes/FPModes/FlushPermeate.c (.../FlushPermeate.c) (revision 3b38773ea822bb860a0fd3af416d2380a095b499) @@ -161,7 +161,7 @@ // TODO update the default min duty cycle value after testing F32 currentDutyCyclePct = getCurrentBoostPumpDutyCyclePCT() > MIN_BOOST_PUMP_DUTY_CYCLE_PCT ? getCurrentBoostPumpDutyCyclePCT(): MIN_BOOST_PUMP_DUTY_CYCLE_PCT; - setBoostPumpTargetDutyCycle( currentDutyCyclePct ); + setBoostPumpTargetDutyCycle( currentDutyCyclePct ); isTankFilled = TRUE; } } Index: firmware/App/Modes/FPModes/ModeGenPermeateDefeatured.c =================================================================== diff -u -r72314cea6ecb88b4863be7cb376c92a594ec5c8d -r3b38773ea822bb860a0fd3af416d2380a095b499 --- firmware/App/Modes/FPModes/ModeGenPermeateDefeatured.c (.../ModeGenPermeateDefeatured.c) (revision 72314cea6ecb88b4863be7cb376c92a594ec5c8d) +++ firmware/App/Modes/FPModes/ModeGenPermeateDefeatured.c (.../ModeGenPermeateDefeatured.c) (revision 3b38773ea822bb860a0fd3af416d2380a095b499) @@ -24,6 +24,7 @@ #include "TaskGeneral.h" #include "Timers.h" #include "Valves.h" +#include "WaterQualityMonitor.h" /** * @addtogroup FPGenPermeateDefeaturedMode Index: firmware/App/Modes/FPModes/ModePreGenPermeate.c =================================================================== diff -u -r7f54a204787abc0840b3593101c8be64de3b8e65 -r3b38773ea822bb860a0fd3af416d2380a095b499 --- firmware/App/Modes/FPModes/ModePreGenPermeate.c (.../ModePreGenPermeate.c) (revision 7f54a204787abc0840b3593101c8be64de3b8e65) +++ firmware/App/Modes/FPModes/ModePreGenPermeate.c (.../ModePreGenPermeate.c) (revision 3b38773ea822bb860a0fd3af416d2380a095b499) @@ -199,6 +199,7 @@ setValveState( P34_VALV, VALVE_STATE_CLOSED ); // Current set to Medium recovery for alpha HW setValveState( P37_VALV, VALVE_STATE_CLOSED ); setValveState( P39_VALV, VALVE_STATE_OPEN ); + startPermeateTankControl(); if ( TRUE == isBoostPumpInstalled() ) {