Index: firmware/App/Modes/FPModes/ModeGenPermeate.c =================================================================== diff -u -r3094850a313096e5e41497c250089ce1ea9b07d9 -r76ede35cf15c9310c2915151f1d47998f22b71de --- firmware/App/Modes/FPModes/ModeGenPermeate.c (.../ModeGenPermeate.c) (revision 3094850a313096e5e41497c250089ce1ea9b07d9) +++ firmware/App/Modes/FPModes/ModeGenPermeate.c (.../ModeGenPermeate.c) (revision 76ede35cf15c9310c2915151f1d47998f22b71de) @@ -25,10 +25,12 @@ #include "ModeGenPermeate.h" #include "ModePreGenPermeate.h" #include "PermeateTank.h" +#include "PIControllers.h" #include "ROPump.h" #include "TaskGeneral.h" #include "Timers.h" #include "Valves.h" +#include "WaterQualityMonitor.h" /** * @addtogroup FPGenPermeateMode @@ -39,13 +41,26 @@ #define PRE_GEN_PERMEATE_DATA_PUBLISH_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the gen permeate mode data published. #define GEN_PERMEATE_BOOST_PUMP_TGT_PSI 25.0F ///< Pressure target in PSI for the boost pump during generate permeate mode. -#define GEN_PERMEATE_RO_PUMP_TGT_ML 700 ///< Flow target in ml/min for the ro pump during generate permeate mode. +#define GEN_PERMEATE_RO_PUMP_TGT_ML 750 ///< Flow target in ml/min for the ro pump during generate permeate mode. +#define PUMP_REST_TIMEOUT_MS ( 3 * MS_PER_SECOND ) ///< Verify Water timer ( in ms ) +#define RO_REJECTION_WAIT_TIME_MS ( 8 * MS_PER_SECOND ) ///< Verify Water timer ( in ms ) +#define MIN_SAMPLES_NEEDED_FOR_DUTY_CYCLE_AVG 10 ///< Minimum number for samples needed for calculating the average duty cycle // ********** private data ********** static FP_GENP_MODE_STATE_T genPermeateState; ///< Currently active generate Permeate state. static U32 genPermeateDataPublicationTimerCounter; ///< Used to schedule generate Permeate data publication to CAN bus. static OVERRIDE_U32_T genPermeateDataPublishInterval; ///< Generate permeate mode data publish interval. +static F32 fillDutySum; ///< Sum of duty cycle values for one fill cycle. +static U32 fillDutyCount; ///< Sample counts for one fill cycle. +static F32 prevFillAvgDutyCycle; ///< Average vale of duty cycle during previous fill state. +static BOOL isFillAvgValid; ///< Flag to check if the average fill duty cycle value is valid or not. +static F32 fullDutySum; ///< Sum of duty cycle values for one full cycle. +static U32 fullDutyCount; ///< Sample counts for one full cycle. +static F32 prevFullAvgDutyCycle; ///< Average vale of duty cycle during previous full state. +static BOOL isFullAvgValid; ///< Flag to check if the average full duty cycle value is valid or not. +static U32 timeInState; ///< Time to wait after reset before starting close loop control (temporary) +static BOOL stateTransitioned; ///< Flag to check if permeate tank state transitioned // ********** private function prototypes ********** @@ -54,6 +69,8 @@ static FP_GENP_MODE_STATE_T handleGenPTankFillState( void ); static void setModeGenPTransition( FP_GENP_MODE_STATE_T state ); static U32 getGenPermeateDataPublishInterval( void ); +static void updateDutyCycleAvg( FP_GENP_MODE_STATE_T state ); +static void calculateDutyCycleAvg( FP_GENP_MODE_STATE_T state ); /*********************************************************************//** * @brief @@ -70,6 +87,16 @@ genPermeateDataPublishInterval.ovInitData = 0; genPermeateDataPublishInterval.override = OVERRIDE_RESET; genPermeateDataPublicationTimerCounter = 0; + fillDutySum = 0.0F; + fillDutyCount = 0; + prevFillAvgDutyCycle = 0.0F; + isFillAvgValid = FALSE; + fullDutySum = 0.0F; + fullDutyCount = 0; + prevFullAvgDutyCycle = 0.0F; + isFullAvgValid = FALSE; + timeInState = 0; + stateTransitioned = FALSE; } /*********************************************************************//** @@ -107,10 +134,12 @@ switch ( genPermeateState ) { case FP_GENP_TANK_FILL_STATE: + updateDutyCycleAvg( FP_GENP_TANK_FILL_STATE ); genPermeateState = handleGenPTankFillState(); break; case FP_GENP_TANK_FULL_STATE: + updateDutyCycleAvg( FP_GENP_TANK_FULL_STATE ); genPermeateState = handleGenPTankFullState(); break; @@ -122,6 +151,8 @@ if ( prevState != genPermeateState ) { + stateTransitioned = TRUE; + calculateDutyCycleAvg( prevState ); setModeGenPTransition( genPermeateState ); SEND_EVENT_WITH_2_U32_DATA( FP_EVENT_GENP_CHANGE, genPermeateState, prevState ) } @@ -142,17 +173,24 @@ *************************************************************************/ static void setModeGenPTransition( FP_GENP_MODE_STATE_T state ) { + F32 initDutyCycle = 0.0F; // Execute on running state switch( state ) { case FP_GENP_TANK_FILL_STATE: + initDutyCycle = isFillAvgValid ? prevFillAvgDutyCycle : getCurrentROPumpDutyCyclePCT(); + setROPumpTargetDutyCycle( initDutyCycle, TRUE ); + timeInState = getMSTimerCount(); if ( TRUE == isBoostPumpInstalled() ) { setBoostPumpTargetPressure( GEN_PERMEATE_BOOST_PUMP_TGT_PSI ); } break; case FP_GENP_TANK_FULL_STATE: + initDutyCycle = isFullAvgValid ? prevFullAvgDutyCycle : getCurrentROPumpDutyCyclePCT(); + setROPumpTargetDutyCycle( initDutyCycle, TRUE ); + timeInState = getMSTimerCount(); if ( TRUE == isBoostPumpInstalled() ) { F32 currentDutyCyclePct = getCurrentBoostPumpDutyCyclePCT(); @@ -178,6 +216,16 @@ FP_GENP_MODE_STATE_T state = FP_GENP_TANK_FILL_STATE; PERMEATE_TANK_STATE_T permemeateTankState = getPermeateTankState(); + if ( TRUE == didTimeout( timeInState, PUMP_REST_TIMEOUT_MS ) && stateTransitioned == TRUE ) + { + stateTransitioned = FALSE; + setROPumpTargetFlowRateMLPM( GEN_PERMEATE_RO_PUMP_TGT_ML, TRUE ); + } + // Wait for RO rejection to stabilize after transition from full to fill + RO Rejection moving average duration + if ( TRUE == didTimeout( timeInState, RO_REJECTION_WAIT_TIME_MS ) ) + { + checkRORejectionRatio(); + } if ( permemeateTankState == PERMEATE_TANK_FULL_STATE ) { state = FP_GENP_TANK_FULL_STATE; @@ -198,6 +246,11 @@ FP_GENP_MODE_STATE_T state = FP_GENP_TANK_FULL_STATE; PERMEATE_TANK_STATE_T permemeateTankState = getPermeateTankState(); + if ( TRUE == didTimeout( timeInState, PUMP_REST_TIMEOUT_MS ) && stateTransitioned == TRUE ) + { + stateTransitioned = FALSE; + setROPumpTargetFlowRateMLPM( GEN_PERMEATE_RO_PUMP_TGT_ML, TRUE ); + } if ( permemeateTankState == PERMEATE_TANK_FILL_STATE ) { state = FP_GENP_TANK_FILL_STATE; @@ -208,6 +261,58 @@ /*********************************************************************//** * @brief + * The updateDutyCycleAvg function accumulates duty cycle samples for + * states in generate permeate mode. + * @details \b Inputs: none + * @details \b Outputs: none + * @param state genPermeateState enum + * @return none +*************************************************************************/ +static void updateDutyCycleAvg( FP_GENP_MODE_STATE_T state ) +{ + F32 duty = getCurrentROPumpDutyCyclePCT(); + + if ( state == FP_GENP_TANK_FILL_STATE ) + { + fillDutySum = duty; + fillDutyCount; + } + else if ( state == FP_GENP_TANK_FULL_STATE ) + { + fullDutySum = duty; + fullDutyCount; + } +} + +/*********************************************************************//** + * @brief + * The calculateDutyCycleAvg function computes the average duty cycle + * from the accumulated samples collected using updateDutyCyle. + * @details \b Inputs: none + * @details \b Outputs: none + * @param state genPermeateState enum + * @return none + *************************************************************************/ +static void calculateDutyCycleAvg( FP_GENP_MODE_STATE_T state ) +{ + if ( state == FP_GENP_TANK_FILL_STATE && fillDutyCount > MIN_SAMPLES_NEEDED_FOR_DUTY_CYCLE_AVG) + { + prevFillAvgDutyCycle = fillDutySum / (F32)fillDutyCount; + isFillAvgValid = TRUE; + fillDutySum = 0.0F; + fillDutyCount = 0; + } + else if ( state == FP_GENP_TANK_FULL_STATE && fullDutyCount > MIN_SAMPLES_NEEDED_FOR_DUTY_CYCLE_AVG ) + { + prevFullAvgDutyCycle = fullDutySum / (F32)fullDutyCount; + isFullAvgValid = TRUE; + fullDutySum = 0.0F; + fullDutyCount = 0; + } +} + +/*********************************************************************//** + * @brief * The getCurrentGenPermeateState function returns the current state of the * gen permeate mode. * @details \b Inputs: genPermeateState Index: firmware/App/Modes/FPModes/ModePreGenPermeate.c =================================================================== diff -u -rd79faa7118db6d048ce3433224b3e5a478c97a98 -r76ede35cf15c9310c2915151f1d47998f22b71de --- firmware/App/Modes/FPModes/ModePreGenPermeate.c (.../ModePreGenPermeate.c) (revision d79faa7118db6d048ce3433224b3e5a478c97a98) +++ firmware/App/Modes/FPModes/ModePreGenPermeate.c (.../ModePreGenPermeate.c) (revision 76ede35cf15c9310c2915151f1d47998f22b71de) @@ -40,7 +40,7 @@ // ********** 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 ) @@ -113,6 +113,7 @@ U32 execPreGenPMode( void ) { FP_PRE_GENP_MODE_STATE_T previouspreGenPState = preGenPState; + // execute current pre gen Permeate state switch ( preGenPState ) { Index: firmware/App/Monitors/Conductivity.c =================================================================== diff -u -ra8b1004967be1c3bd4d46e96ff5886a0ec1446cc -r76ede35cf15c9310c2915151f1d47998f22b71de --- firmware/App/Monitors/Conductivity.c (.../Conductivity.c) (revision a8b1004967be1c3bd4d46e96ff5886a0ec1446cc) +++ firmware/App/Monitors/Conductivity.c (.../Conductivity.c) (revision 76ede35cf15c9310c2915151f1d47998f22b71de) @@ -20,6 +20,7 @@ #include "Conductivity.h" #include "MessageSupport.h" #include "Messaging.h" +#include "ModeGenPermeate.h" #include "OperationModes.h" #include "TaskPriority.h" #include "Utilities.h" @@ -37,6 +38,8 @@ #define CONDUCTIVITY_TEMP_SAMPLE_FILTER_MS ( 500 ) ///< Filter conductivity temperature data for given time #define SIZE_OF_FLOW_ROLLING_AVG ( CONDUCTIVITY_SAMPLE_FILTER_MS / TASK_PRIORITY_INTERVAL ) ///< Filtered conductivity moving average sample count. #define SIZE_OF_FLOW_TEMP_ROLLING_AVG ( CONDUCTIVITY_TEMP_SAMPLE_FILTER_MS / TASK_PRIORITY_INTERVAL ) ///< Filtered conductivity temprature moving average sample count. +#define RO_RR_MOVING_AVG_NUM_OF_SAMPLES 300 ///< RO rejection ratio moving average number of samples. +#define FRACTION_TO_PERCENT_CONVERSION_FACTOR 100.0F ///< RO rejection ratio factor to percentage conversion factor value /// Filter conductivity readings record. typedef struct @@ -66,13 +69,25 @@ static OVERRIDE_U32_T ddConductivityDataPublishInterval; ///< DD Conductivity sensors publish time interval override. static U32 fpConductivityPublishTimerCounter; ///< FP Conductivity data publication counter. static OVERRIDE_U32_T fpConductivityDataPublishInterval; ///< FP Conductivity sensors publish time interval override. +static F32 roRejectionRatio; ///< All time RO rejection ratio. +static F32 roRejectionRatioTankFill; ///< RO rejection ratio during permeate tank fill state. +static U32 roRRPublishTimerCounter; ///< RO rejection ratio publication counter. +static OVERRIDE_U32_T roRRDataPublishInterval; ///< RO rejection ratio publish time interval override. +static OVERRIDE_F32_T roRRAvg; ///< Average RO rejection ratio. +static F32 roRRRunningSum; ///< RO rejection ratio running sum. +static F32 roRRSamples[ RO_RR_MOVING_AVG_NUM_OF_SAMPLES ]; ///< RO rejection ratio samples array. +static U32 roRRSamplesNextIndex; ///< RO rejection ratio sample next index number. +static U32 roRRCount; ///< RO rejection ratio Number of samples in average buffer. +static F32 roRRTankFillAvg; ///< Average RO rejection ratio during permeate tank fill state. // ********** private function prototypes ********** static void publishConductivitySensorsData( void ); static void filterConductivitySensors( void ); static void filterConductivitySensorReadings( void ); static void filterConductivitySensorTemperatureReadings( void ); +static void calcRORejectionRatio( void ); +static void filterRORejectionRatioReadings( void ); /*********************************************************************//** * @brief @@ -89,6 +104,16 @@ ddConductivityPublishTimerCounter = DATA_PUBLISH_COUNTER_START_COUNT; fpConductivityPublishTimerCounter = DATA_PUBLISH_COUNTER_START_COUNT; + roRejectionRatio = 0.0F; + roRejectionRatioTankFill = 0.0F; + roRRRunningSum = 0.0F; + roRRSamplesNextIndex = 0; + roRRCount = 0; + roRRTankFillAvg = 0.0F; + roRRAvg.data = 0.0F; + roRRAvg.ovData = 0.0F; + roRRAvg.ovInitData = 0.0F; + roRRAvg.override = OVERRIDE_RESET; // Initialize override structures for each conductivity sensor for ( sensor = FIRST_DD_COND_SENSOR; sensor < NUM_OF_CONDUCTIVITY_SENSORS; sensor++ ) @@ -121,6 +146,11 @@ fpConductivityDataPublishInterval.ovData = COND_SENSOR_REPORT_PERIOD; fpConductivityDataPublishInterval.ovInitData = 0; fpConductivityDataPublishInterval.override = OVERRIDE_RESET; + + roRRDataPublishInterval.data = COND_SENSOR_REPORT_PERIOD; + roRRDataPublishInterval.ovData = COND_SENSOR_REPORT_PERIOD; + roRRDataPublishInterval.ovInitData = 0; + roRRDataPublishInterval.override = OVERRIDE_RESET; } /*********************************************************************//** @@ -147,6 +177,8 @@ #endif filterConductivitySensors(); + calcRORejectionRatio(); // TODO: should this be called here or inside filter function + filterRORejectionRatioReadings(); // publish conductivity sensors publishConductivitySensorsData(); } @@ -289,6 +321,115 @@ /*********************************************************************//** * @brief + * The calcRORejectionRatio function calculates the RO rejection ratio using + * the P9 sensor conductivity value and P18 sensor conductivity value. + * @details Inputs: P9 sensor conductivity, P18 sensor conductivity + * @details Outputs: RO rejection ratio + * @return none + *************************************************************************/ +static void calcRORejectionRatio( void ) +{ + F32 feedConductivity = getFilteredConductivity( P9_COND ); + F32 permeateConductivity = getFilteredConductivity( P18_COND ); + + roRejectionRatio = RO_REJECTION_RATIO_OUT_OF_RANGE_VALUE; + + if ( fabs(feedConductivity) >= NEARLY_ZERO ) + { + roRejectionRatio = FRACTION_TO_PERCENT_CONVERSION_FACTOR * ( ( feedConductivity - permeateConductivity ) / feedConductivity ); + } + if ( getCurrentGenPermeateState() == FP_GENP_TANK_FILL_STATE ) + { + roRejectionRatioTankFill = roRejectionRatio; + } +} + +/*********************************************************************//** + * @brief + * The filterRORejectionRatioReadings function adds a new ro rejection ratio + * sample to the filters. + * @details \b Inputs: RO rejection ratio all time and during tank fill state + * @details \b Outputs: roRRRunningSumC, roRRSamples[], roRRSamplesNextIndex, + * roRRCount, roRRAvg, roRRTankFillAvg + * @return none + *************************************************************************/ +static void filterRORejectionRatioReadings( void ) +{ + // Filter RO rejection ratio + if ( roRRCount >= RO_RR_MOVING_AVG_NUM_OF_SAMPLES ) + { + roRRRunningSum -= roRRSamples[ roRRSamplesNextIndex ]; + } + + F32 roRR = getRORejectonRatio(); + roRRSamples[ roRRSamplesNextIndex ] = roRR; + roRRRunningSum = roRR; + roRRSamplesNextIndex = INC_WRAP( roRRSamplesNextIndex, 0, RO_RR_MOVING_AVG_NUM_OF_SAMPLES - 1 ); + roRRCount = INC_CAP( roRRCount, RO_RR_MOVING_AVG_NUM_OF_SAMPLES ); + roRRAvg.data = roRRRunningSum / (F32)roRRCount; + + // Update the Filter RO rejection ratio during tank fill if the tank is filling + if ( getCurrentGenPermeateState() == FP_GENP_TANK_FILL_STATE ) + { +// roRRTankFillAvg = getRORRAverage(); + roRRTankFillAvg = roRRAvg.data; + } +} + +/*********************************************************************//** + * @brief + * The getRORejectonRatio function returns the RO rejection ratio + * @details \b Inputs: none + * @details \b Outputs: none + * @return the RO rejection ratio in percentage + *************************************************************************/ +F32 getRORejectonRatio( void ) +{ + return roRejectionRatio; +} + +/*********************************************************************//** + * @brief + * The getTankFillRORejectionRatio function returns the RO rejection ratio + * during tank fill state + * @details \b Inputs: none + * @details \b Outputs: none + * @return the tank fill RO rejection ratio in percentage + *************************************************************************/ +F32 getTankFillRORejectionRatio( void ) +{ + return roRejectionRatioTankFill; +} + +/*********************************************************************//** + * @brief + * The getRORRAverage function returns the average RO rejection ratio + * @details \b Inputs: none + * @details \b Outputs: none + * @return the average RO rejection ratio in percentage + *************************************************************************/ +F32 getRORRAverage( void ) +{ + F32 avgRORR = getF32OverrideValue( &roRRAvg ); + + return avgRORR; +} + +/*********************************************************************//** + * @brief + * The getTankFillRORRAverage function returns the average RO rejection ratio + * during tank fill state + * @details \b Inputs: none + * @details \b Outputs: none + * @return the average tank fill RO rejection ratio in percentage + *************************************************************************/ +F32 getTankFillRORRAverage( void ) +{ + return roRRTankFillAvg; +} + +/*********************************************************************//** + * @brief * The publishConductivitySensorsData function publishes DD conductivity data * at a set interval. * @details \b Inputs: conductivityPublishTimerCounter @@ -325,6 +466,21 @@ broadcastData( MSG_ID_FP_CONDUCTIVITY_DATA, COMM_BUFFER_OUT_CAN_FP_BROADCAST, (U08*)&data, sizeof( FP_CONDUCTIVITY_DATA_T ) ); } + + // publish ro rejection ratio data on interval + if ( roRRPublishTimerCounter >= getU32OverrideValue( &roRRDataPublishInterval ) ) + { + RO_REJECTION_RATIO_DATA_T data; + + data.rawRORejectionRatio = getRORejectonRatio(); + data.rawRORejectionRatioTankFill = getTankFillRORejectionRatio(); + data.avgRORejectionRatio = getRORRAverage(); + data.avgRORejectionRatioTankFill = getTankFillRORRAverage(); + data.genPermeateState = (U32)getCurrentGenPermeateState(); + roRRPublishTimerCounter = 0; + + broadcastData( MSG_ID_FP_RO_REJECTION_RATIO_DATA, COMM_BUFFER_OUT_CAN_FP_BROADCAST, (U08*)&data, sizeof( RO_REJECTION_RATIO_DATA_T ) ); + } } @@ -465,4 +621,38 @@ return result; } +/*********************************************************************//** + * @brief + * The testRORejectionRatioDataPublishIntervalOverride function overrides the + * RO Rejection ratio data publish interval. + * @details \b Inputs: none + * @details \b Outputs: roRRDataPublishInterval + * @param message Override message from Dialin which includes the value + * that override valves states publish interval with (in ms) + * @return TRUE if override successful, FALSE if not + *************************************************************************/ +BOOL testRORejectionRatioDataPublishIntervalOverride( MESSAGE_T *message ) +{ + BOOL result = u32BroadcastIntervalOverride( message, &roRRDataPublishInterval, TASK_PRIORITY_INTERVAL ); + + return result; +} + +/*********************************************************************//** + * @brief + * The testRORejectionRatioFilteredOverride function + * overrides the filtered RO rejection value with a given value. + * @details \b Inputs: none + * @details \b Outputs: roRRAvg + * @param message Override message from Dialin which includes override value + * of the RO rejection ratio. + * @return TRUE if override successful, FALSE if not + *************************************************************************/ +BOOL testRORejectionRatioFilteredOverride( MESSAGE_T *message ) +{ + BOOL result = f32Override( message, &roRRAvg ); + + return result; +} + /**@}*/ Index: firmware/App/Monitors/Conductivity.h =================================================================== diff -u -r89f18a07a6d5837bf9b4559a69046e2b06f32c35 -r76ede35cf15c9310c2915151f1d47998f22b71de --- firmware/App/Monitors/Conductivity.h (.../Conductivity.h) (revision 89f18a07a6d5837bf9b4559a69046e2b06f32c35) +++ firmware/App/Monitors/Conductivity.h (.../Conductivity.h) (revision 76ede35cf15c9310c2915151f1d47998f22b71de) @@ -33,6 +33,8 @@ // ********** public definitions ********** +#define RO_REJECTION_RATIO_OUT_OF_RANGE_VALUE 100.0F ///< Out of range value for RO rejection ratio when CPi conductivity is zero. + /// Conductivity data struct. typedef struct { @@ -50,19 +52,35 @@ F32 p18Conductivity; ///< (P18) conductivity sensor value } FP_CONDUCTIVITY_DATA_T; +/// RO rejection ratio data struct. +typedef struct +{ + F32 rawRORejectionRatio; ///< ro rejection ratio during tank full and fill state + F32 rawRORejectionRatioTankFill; ///< ro rejection ratio during tank fill state + F32 avgRORejectionRatio; ///< ro rejection ratio average during tank full and fill state + F32 avgRORejectionRatioTankFill; ///< ro rejection ratio average during tank fill state + U32 genPermeateState; ///< permeate tank state +} RO_REJECTION_RATIO_DATA_T; + // ********** public function prototypes ********** void initConductivity( void ); void execConductivity( void ); F32 getFilteredConductivity( CONDUCTIVITY_SENSORS_T sensor ); F32 getFilteredConductivitySensorTemperature( CONDUCTIVITY_SENSORS_T sensor ); +F32 getRORejectonRatio( void ); +F32 getTankFillRORejectionRatio( void ); +F32 getRORRAverage( void ); +F32 getTankFillRORRAverage( void ); BOOL testDDConductivitySensorDataPublishIntervalOverride( MESSAGE_T *message ); BOOL testDDConductivitySensorFilteredReadingsOverride( MESSAGE_T *message ); BOOL testDDConductivitySensorFilteredTemperatureReadingsOverride( MESSAGE_T *message ); BOOL testFPConductivitySensorDataPublishIntervalOverride( MESSAGE_T *message ); BOOL testFPConductivitySensorFilteredReadingsOverride( MESSAGE_T *message ); BOOL testFPConductivitySensorFilteredTemperatureReadingsOverride( MESSAGE_T *message ); +BOOL testRORejectionRatioDataPublishIntervalOverride( MESSAGE_T *message ); +BOOL testRORejectionRatioFilteredOverride( MESSAGE_T *message ); /**@}*/ Index: firmware/App/Monitors/WaterQualityMonitor.c =================================================================== diff -u -r6fb6727e92ee4d4a6d78f0c5bee872014af1bcea -r76ede35cf15c9310c2915151f1d47998f22b71de --- firmware/App/Monitors/WaterQualityMonitor.c (.../WaterQualityMonitor.c) (revision 6fb6727e92ee4d4a6d78f0c5bee872014af1bcea) +++ firmware/App/Monitors/WaterQualityMonitor.c (.../WaterQualityMonitor.c) (revision 76ede35cf15c9310c2915151f1d47998f22b71de) @@ -58,6 +58,7 @@ #define INLET_WATER_COND_OUT_OF_RANGE_TIMEOUT_MS ( 5 * MS_PER_SECOND ) ///< Persistence period for conductivity out of range error in milliseconds. #define INLET_WATER_COND_OUT_OF_RANGE_CLEAR_MS ( 5 * MS_PER_SECOND ) ///< Persistence period for conductivity out of range clear in milliseconds. #define INLET_CONDUCTIVITY_HIGH_THRESHOLD_US 2000.0F ///< Maximum allowed outlet conductivity in uS/cm. +#define MIN_RO_REJECTION_RATIO_PCT 90.0F ///< Minimum RO rejection ration in percentage // ********** private data ********** @@ -261,6 +262,25 @@ checkPersistentAlarm( ALARM_ID_FP_RO_OUTLET_CONDUCTIVITY_HIGH_RANGE, isConductivityOutOfLowRange, conductivityP18, OUTLET_CONDUCTIVITY_HIGH_THRESHOLD_US ); } +/*********************************************************************//** + * @brief + * The checkRORejectionRatio function checks the RO rejection ratio + * alarm if the rejection ratio is out of range. + * @details \b Inputs: roRRAvg + * @details \b Outputs: none + * @details \b Alarms: ALARM_ID_FP_REJECTION_RATIO_LOW_RANGE when + * RO rejection ratio goes below allowed rejection ratio limit. + * @return none + *************************************************************************/ +void checkRORejectionRatio( void ) +{ + F32 avgRORR = getRORRAverage(); + // Alarm if the filtered average is less than allowed RO rejection limit + if ( avgRORR < MIN_RO_REJECTION_RATIO_PCT ) + { + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_FP_REJECTION_RATIO_LOW_RANGE, avgRORR, MIN_RO_REJECTION_RATIO_PCT) + } +} /************************************************************************* * TEST SUPPORT FUNCTIONS Index: firmware/App/Monitors/WaterQualityMonitor.h =================================================================== diff -u -rc9a16bd5cab11fef6078dac1dd1cf62ab59801f3 -r76ede35cf15c9310c2915151f1d47998f22b71de --- firmware/App/Monitors/WaterQualityMonitor.h (.../WaterQualityMonitor.h) (revision c9a16bd5cab11fef6078dac1dd1cf62ab59801f3) +++ firmware/App/Monitors/WaterQualityMonitor.h (.../WaterQualityMonitor.h) (revision 76ede35cf15c9310c2915151f1d47998f22b71de) @@ -43,5 +43,6 @@ void checkInletConductivity( void ); void checkOutletConductivity( void ); void checkPermeateFlow( void ); +void checkRORejectionRatio( void ); #endif Index: firmware/App/Services/Messaging.c =================================================================== diff -u -rdb4ababe9942a6c755ffc11d25af50f598e8dba6 -r76ede35cf15c9310c2915151f1d47998f22b71de --- firmware/App/Services/Messaging.c (.../Messaging.c) (revision db4ababe9942a6c755ffc11d25af50f598e8dba6) +++ firmware/App/Services/Messaging.c (.../Messaging.c) (revision 76ede35cf15c9310c2915151f1d47998f22b71de) @@ -239,6 +239,8 @@ { MSG_ID_FP_RO_PUMP_PUBLISH_INTERVAL_OVERRIDE_REQUEST, &testROPumpDataPublishIntervalOverride }, { MSG_ID_DD_RINSE_PUMP_DATA_PUBLISH_INTERVAL_OVERRIDE_REQUEST, &testRinsePumpDataPublishIntervalOverride }, { MSG_ID_FP_SET_START_STOP_OVERRIDE_REQUEST, &testSetGeneratePermeateSignal }, + { MSG_ID_FP_RO_REJECTION_RATIO_PUBLISH_INTERVAL_OVERRIDE_REQUEST, &testRORejectionRatioDataPublishIntervalOverride }, + { MSG_ID_FP_RO_FILTERED_REJECTION_RATIO_OVERRIDE_REQUEST, &testRORejectionRatioFilteredOverride }, }; /// Calculation for number of entries in the incoming message function handler look-up table.