Index: firmware/App/Modes/FPModes/ModePreGenPermeate.c =================================================================== diff -u -rd79faa7118db6d048ce3433224b3e5a478c97a98 -r50144ec3e96785cf76d5bfd22ee65029c82e732b --- firmware/App/Modes/FPModes/ModePreGenPermeate.c (.../ModePreGenPermeate.c) (revision d79faa7118db6d048ce3433224b3e5a478c97a98) +++ firmware/App/Modes/FPModes/ModePreGenPermeate.c (.../ModePreGenPermeate.c) (revision 50144ec3e96785cf76d5bfd22ee65029c82e732b) @@ -1,36 +1,37 @@ /************************************************************************** * -* Copyright (c) 2020-2025 Diality Inc. - All Rights Reserved. +* Copyright (c) 2025-2026 Diality Inc. - All Rights Reserved. * * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. * * @file ModePreGenPermeate.c * -* @author (last) Michael Garthwaite -* @date (last) 28-Feb-2025 +* @author (last) Varshini Nagabooshanam +* @date (last) 27-Jan-2026 * * @author (original) Michael Garthwaite -* @date (original) 28-Feb-2025 +* @date (original) 08-Sep-2025 * ***************************************************************************/ #include "BoostPump.h" -#include "FlushFilter.h" -#include "FlushPermeate.h" -#include "FlushConcentrate.h" #include "FPModeStandby.h" #include "FPOperationModes.h" -#include "InletPressureCheck.h" #include "MessageSupport.h" #include "Messaging.h" #include "ModeGenPermeate.h" #include "ModePreGenPermeate.h" #include "PermeateTank.h" #include "ROPump.h" +#include "StateFlushConcentrate.h" +#include "StateFlushFilter.h" +#include "StateFlushPermeate.h" +#include "StateInletPressureCheck.h" #include "TaskGeneral.h" #include "Timers.h" #include "Valves.h" +#include "WaterQualityMonitor.h" /** * @addtogroup FPPreGenPermeateMode @@ -40,9 +41,10 @@ // ********** private definitions ********** #define PRE_GENP_DATA_PUBLISH_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the pre gen Permeate mode data published. -#define VERIFY_WATER_RO_PUMP_TGT_FLOW_ML 700 ///< Target flow rate for RO pump in ml/min +#define VERIFY_WATER_RO_PUMP_TGT_FLOW_ML 750 ///< Target flow rate for RO pump in ml/min #define VERIFY_WATER_BOOST_PUMP_TGT_PSI 25 ///< Target pressure for boost pump in psi. #define VERIFY_WATER_TIMEOUT_MS ( 30 * MS_PER_SECOND ) ///< Verify Water timer ( in ms ) +#define FLOW_CONTROL_STABLIZED_TIMEOUT_MS ( 25 * MS_PER_SECOND ) ///< Flow control stablized time ( in ms ) // ********** private data ********** @@ -113,6 +115,7 @@ U32 execPreGenPMode( void ) { FP_PRE_GENP_MODE_STATE_T previouspreGenPState = preGenPState; + // execute current pre gen Permeate state switch ( preGenPState ) { @@ -145,7 +148,7 @@ break; } - if( previouspreGenPState != preGenPState ) + if ( previouspreGenPState != preGenPState ) { setModePreGenPTransition( preGenPState ); SEND_EVENT_WITH_2_U32_DATA( FP_EVENT_PRE_GEN_CHANGE, preGenPState, previouspreGenPState ) @@ -194,11 +197,13 @@ 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() ) { setBoostPumpTargetPressure( VERIFY_WATER_BOOST_PUMP_TGT_PSI ); } + //TODO change target flow to 750 + rinse pump rate setROPumpTargetFlowRateMLPM( VERIFY_WATER_RO_PUMP_TGT_FLOW_ML, TRUE ); verifyWaterTimer = getMSTimerCount(); break; @@ -228,20 +233,13 @@ // state = FP_PRE_GENP_PAUSED; // } - if ( FALSE == isBoostPumpInstalled() ) + execInletPressureCheck(); + + if ( TRUE == isInletPressureCheckCompleted() ) { signalStartFilterFlush(); state = FP_PRE_GENP_FILTER_FLUSH; } - else - { - execInletPressureCheck(); - if ( TRUE == isInletPressureCheckCompleted() ) - { - signalStartFilterFlush(); - state = FP_PRE_GENP_FILTER_FLUSH; - } - } return state; } @@ -261,14 +259,21 @@ // state = FP_PRE_GENP_PAUSED; // } - execFilterFlush(); - - if( TRUE == isFilterFlushComplete() ) + if ( TRUE == getTestConfigStatus( TEST_CONFIG_FP_SKIP_PRE_GEN_FLUSH ) ) { - signalStartPermeateFlush(); - state = FP_PRE_GENP_PERMEATE_FLUSH; + state = FP_PRE_GENP_VERIFY_WATER; } + else + { + execFilterFlush(); + if ( TRUE == isFilterFlushComplete() ) + { + signalStartPermeateFlush(); + state = FP_PRE_GENP_PERMEATE_FLUSH; + } + } + return state; } @@ -291,7 +296,7 @@ execPermeateFlush(); - if( TRUE == isPermeateFlushComplete() ) + if ( TRUE == isPermeateFlushComplete() ) { signalStartConcentrateFlush(); state = FP_PRE_GENP_CONCENTRATE_FLUSH; @@ -319,7 +324,7 @@ execConcentrateFlush(); - if( TRUE == isConcentrateFlushComplete() ) + if ( TRUE == isConcentrateFlushComplete() ) { state = FP_PRE_GENP_VERIFY_WATER; } @@ -340,12 +345,43 @@ FP_PRE_GENP_MODE_STATE_T state = FP_PRE_GENP_VERIFY_WATER; F32 roCurrentDutyCycle = getCurrentROPumpDutyCyclePCT(); + checkROInletPressure(); + + //Stay in this state for 25 seconds to stablize flow control + if ( TRUE == didTimeout( verifyWaterTimer, FLOW_CONTROL_STABLIZED_TIMEOUT_MS ) ) + { + // check next 5 seconds for water quality + // check permeate high flow rate is within range + checkPermeateHighFlow(); + + // check low flow rate is within range + checkPermeateLowFlow(); + + // check inlet conductivity is within range + checkInletConductivity(); + + // check permeate conductivity is within range + checkOutletConductivity(); + + // check RO duty cycle in range + checkRODutyCycle(); + + // check p21 is set to 15 PSI + checkPressureRelief(); + + // check RO rejection ratio + checkRORejectionRatio(); + + // check RO pressure (p13) + checkROPressures(); + } + // if ( TRUE == 1 ))// TODO Alarm and Stop State Rework // { // state = FP_PRE_GENP_PAUSED; // } - - if( TRUE == didTimeout( verifyWaterTimer, VERIFY_WATER_TIMEOUT_MS ) ) + // wait 30 second before moving to water generation mode + if ( TRUE == didTimeout( verifyWaterTimer, VERIFY_WATER_TIMEOUT_MS ) ) { transitionToGenPermeateMode(); requestGenWaterStart(); // transition function will clear start flag