Index: firmware/App/Controllers/PermeateTank.c =================================================================== diff -u -r37ffdfd87147f589397a5f8c8f5421630ee4d879 -r30c175a7e10411efadb9b2b0f8b68528705e0621 --- firmware/App/Controllers/PermeateTank.c (.../PermeateTank.c) (revision 37ffdfd87147f589397a5f8c8f5421630ee4d879) +++ firmware/App/Controllers/PermeateTank.c (.../PermeateTank.c) (revision 30c175a7e10411efadb9b2b0f8b68528705e0621) @@ -32,10 +32,10 @@ // ********** private definitions ********** #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 -#define PERMEATE_TANK_FILL_SWITCH_MS ( 6 * MS_PER_SECOND ) -#define PERMEATE_TANK_FULL_SWITCH_MS ( 1 * MS_PER_SECOND ) ///< state switch timeout (in ms) -#define PERMEATE_TANK_FULL_TIMEOUT_MS ( 60 * MS_PER_SECOND ) +#define PERMEATE_TANK_PUBLISH_COUNTER_START_COUNT 9 ///< Publishing counter offset +#define PERMEATE_TANK_FILL_SWITCH_MS ( 10 * MS_PER_SECOND ) ///< state switch timeout in fill state ( in ms ) +#define PERMEATE_TANK_FULL_SWITCH_MS ( 1 * MS_PER_SECOND ) ///< state switch timeout in full state (in ms) +#define PERMEATE_TANK_FULL_TIMEOUT_MS ( 60 * MS_PER_SECOND ) ///< timeout being in full state too long ( in ms ) // ********** private data ********** @@ -289,9 +289,12 @@ pendingStopPermeateTankController = FALSE; state = PERMEATE_TANK_MANUAL_CONTROL_STATE; } - else if ( ( level == LEVEL_STATE_LOW ) && ( TRUE == didTimeout( tankFullDelayTime, PERMEATE_TANK_FULL_SWITCH_MS ) ) ) + else if ( level == LEVEL_STATE_LOW ) { - state = PERMEATE_TANK_FILL_STATE; + if ( TRUE == didTimeout( tankFullDelayTime, PERMEATE_TANK_FULL_SWITCH_MS ) ) + { + state = PERMEATE_TANK_FILL_STATE; + } } return state; @@ -334,8 +337,8 @@ setValveState( M7_VALV, VALVE_STATE_CLOSED ); setValveState( P6_VALV, VALVE_STATE_CLOSED ); setValveState( P11_VALV, VALVE_STATE_OPEN ); - setValveState( P33_VALV, VALVE_STATE_OPEN ); // TODO - Determine if we will allow RO rejection configs - setValveState( P34_VALV, VALVE_STATE_OPEN ); // to take precedence over tank control. + setValveState( P33_VALV, VALVE_STATE_OPEN ); + setValveState( P34_VALV, VALVE_STATE_OPEN ); setValveState( P37_VALV, VALVE_STATE_CLOSED ); setValveState( P39_VALV, VALVE_STATE_CLOSED ); setValveState( P20_VALV, VALVE_STATE_CLOSED ); Index: firmware/App/Controllers/ROPump.c =================================================================== diff -u -re612f511d155d68e2b00cfccce740b3143964b9f -r30c175a7e10411efadb9b2b0f8b68528705e0621 --- firmware/App/Controllers/ROPump.c (.../ROPump.c) (revision e612f511d155d68e2b00cfccce740b3143964b9f) +++ firmware/App/Controllers/ROPump.c (.../ROPump.c) (revision 30c175a7e10411efadb9b2b0f8b68528705e0621) @@ -39,25 +39,24 @@ #define RO_PUMP_DATA_PUB_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the RO Pump data is published on the CAN bus. #define ROP_CONTROL_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the RO pump is controlled. -#define ROP_FLOW_CONTROL_P_COEFFICIENT 0.1F ///< P term for RO pump flow control. -#define ROP_FLOW_CONTROL_I_COEFFICIENT 0.8F ///< I term for RO pump flow control. +#define ROP_FLOW_CONTROL_P_COEFFICIENT 0.1F ///< P term for RO pump flow control. +#define ROP_FLOW_CONTROL_I_COEFFICIENT 0.8F ///< I term for RO pump flow control. #define ROP_MIN_FLOW_TO_CONTROL_PCT 0.75F #define ROP_PRESSURE_CONTROL_P_COEFFICIENT 0.15F ///< P term for RO pump pressure control. #define ROP_PRESSURE_CONTROL_I_COEFFICIENT 0.65F ///< I term for RO pump pressure control. -#define ROP_FLOW_TO_PWM_SLOPE 155.31F ///< Slope of flow to PWM line equation. -#define ROP_FLOW_TO_PWM_INTERCEPT -699.99F ///< Intercept of flow to PWM line equation. -#define ROP_PRESSURE_TO_PWM_SLOPE 0.5F ///< Slope of pressure to PWM line equation. +#define ROP_FLOW_TO_PWM_SLOPE 155.31F ///< Slope of flow to PWM line equation. +#define ROP_FLOW_TO_PWM_INTERCEPT -699.99F ///< Intercept of flow to PWM line equation. +#define ROP_PRESSURE_TO_PWM_SLOPE 0.5F ///< Slope of pressure to PWM line equation. #define ROP_PRESSURE_TO_PWM_INTERCEPT 0.0F ///< Intercept of pressure to PWM line equation. #define DATA_PUBLISH_COUNTER_START_COUNT 10 ///< Data publish counter start count. #define ROP_PRESSURE_TO_PWM_PCT(pres) ( ( ROP_PRESSURE_TO_PWM_SLOPE * pres + ROP_PRESSURE_TO_PWM_INTERCEPT ) / MAX_FLUID_PUMP_PWM_DUTY_CYCLE ) ///< PWM line equation for pressure. converted to percentage. -#define ROP_FLOW_TO_PWM_PCT(flow) ( ( ROP_FLOW_TO_PWM_SLOPE * log(flow) + ROP_FLOW_TO_PWM_INTERCEPT ) / MAX_FLUID_PUMP_PWM_DUTY_CYCLE ) ///< PWM line equation for flow converted to percentage. -#define ROP_FLOW_TO_PWM(flow) ( ROP_FLOW_TO_PWM_SLOPE * log(flow) + ROP_FLOW_TO_PWM_INTERCEPT ) ///< PWM line equation for flow converted to percentage. +#define ROP_FLOW_TO_PWM_PCT(flow) ( ( ROP_FLOW_TO_PWM_SLOPE * log(flow) + ROP_FLOW_TO_PWM_INTERCEPT ) / MAX_FLUID_PUMP_PWM_DUTY_CYCLE ) ///< PWM line equation for flow converted to percentage. +#define ROP_FLOW_TO_PWM(flow) ( ROP_FLOW_TO_PWM_SLOPE * log(flow) + ROP_FLOW_TO_PWM_INTERCEPT ) ///< PWM line equation for flow converted to percentage. - // ********** private data ********** static RO_PUMP_STATE_T roPumpState; ///< Current state of pump controller state machine. @@ -71,7 +70,7 @@ static OVERRIDE_F32_T targetROPumpPressure; ///< Target RO max allowed pressure (in PSI). static F32 roPumpDutyCyclePctSet; ///< Currently set RO pump PWM duty cycle. static OVERRIDE_F32_T roPumpOpenLoopTargetDutyCycle; ///< Target RO pump open loop PWM. -static BOOL roPumpStartControl; +static BOOL roPumpStartControl; ///< boolean to determine when closed loop flow control starts // ********** private function prototypes ********** @@ -112,7 +111,7 @@ stopPumpRequest = FALSE; roControlTimerCounter = 0; roPumpDutyCyclePctSet = 0.0F; - roPumpStartControl = FALSE; + roPumpStartControl = FALSE; roPumpDataPublicationTimerCounter = DATA_PUBLISH_COUNTER_START_COUNT; roPumpDataPublishInterval.data = RO_PUMP_DATA_PUB_INTERVAL; roPumpDataPublishInterval.ovData = RO_PUMP_DATA_PUB_INTERVAL; @@ -272,6 +271,7 @@ { RO_PUMP_STATE_T state = RO_PUMP_CONTROL_TO_TARGET_FLOW_STATE; F32 nexttgtflow = 0.0; + // Check if need to switch control modes if ( ( getTargetROPumpPressure() > 0.0F ) && ( PUMP_CONTROL_MODE_CLOSED_LOOP == roPumpControlMode ) ) { @@ -301,7 +301,7 @@ //setFluidPumpPctToPWMDutyCycle( P12_PUMP, roPumpDutyCyclePctSet ); nexttgtflow = runPIController( PI_CONTROLLER_ID_RO_PUMP_FLOW, (F32)getTargetROPumpFlowRateMLPM(), getFilteredFlow( P16_FLOW ) ); nexttgtflow = (U16)MIN( ROP_FLOW_TO_PWM( nexttgtflow ), ( MAX_FLUID_PUMP_PWM_DUTY_CYCLE * MAX_FLUID_PUMP_DUTY_CYCLE_PCT ) ); - setFluidPumpPctToPWMDutyCycle( P12_PUMP, nexttgtflow ); + setFluidPumpPWMDutyCycle( P12_PUMP, nexttgtflow ); if ( FALSE == roPumpStartControl ) { roPumpStartControl = TRUE; Index: firmware/App/Modes/FlushPermeate.c =================================================================== diff -u -rd163e3cc0ecff08015fdeaed6145169dbfacc501 -r30c175a7e10411efadb9b2b0f8b68528705e0621 --- firmware/App/Modes/FlushPermeate.c (.../FlushPermeate.c) (revision d163e3cc0ecff08015fdeaed6145169dbfacc501) +++ firmware/App/Modes/FlushPermeate.c (.../FlushPermeate.c) (revision 30c175a7e10411efadb9b2b0f8b68528705e0621) @@ -37,8 +37,8 @@ #define PERMEATE_FLUSH_MAX_TIMEOUT ( 600 * MS_PER_SECOND ) ///< Max override timeout for 10 minutes #define PERMEATE_FLUSH_DATA_PUBLISH_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the gen water mode data published. -#define PERMEATE_FLUSH_TIMEOUT ( 120 * MS_PER_SECOND ) ///< Permeate flush timer (in ms) -#define PERMEATE_FLUSH_ALARM_TIMEOUT ( 180 * MS_PER_SECOND ) ///< Permeate flush timer (in ms) +#define PERMEATE_FLUSH_TIMEOUT ( 120 * MS_PER_SECOND ) ///< Permeate flush timer (in ms) +#define PERMEATE_FLUSH_ALARM_TIMEOUT ( 180 * MS_PER_SECOND ) ///< Permeate flush alarm timer (in ms) #define PERMEATE_FLUSH_RO_PUMP_TGT_ML 700 ///< Pressure target in ml/min for the RO pump during permeate flush. #define PERMEATE_FLUSH_BOOST_PUMP_TGT_PSI 25 ///< Pressure target in PSI for the boost pump during permeate flush. #define PERMEATE_FLUSH_CONDUCTIVITY_THRESHOLD 200.0F ///< Conductivity alarm threshold for permeate flush. Index: firmware/App/Modes/InletPressureCheck.c =================================================================== diff -u -rf31d1727c5527fb3fa1745f2ca8a66f405d1bc63 -r30c175a7e10411efadb9b2b0f8b68528705e0621 --- firmware/App/Modes/InletPressureCheck.c (.../InletPressureCheck.c) (revision f31d1727c5527fb3fa1745f2ca8a66f405d1bc63) +++ firmware/App/Modes/InletPressureCheck.c (.../InletPressureCheck.c) (revision 30c175a7e10411efadb9b2b0f8b68528705e0621) @@ -22,6 +22,7 @@ #include "MessageSupport.h" #include "Messaging.h" #include "Pressure.h" +#include "ROPump.h" #include "TaskGeneral.h" #include "Timers.h" #include "Valves.h" Index: firmware/App/Modes/ModePreGenPermeate.c =================================================================== diff -u -rc0fe2abaa7b3d8cb7ded969c92b6f9074ed1e38e -r30c175a7e10411efadb9b2b0f8b68528705e0621 --- firmware/App/Modes/ModePreGenPermeate.c (.../ModePreGenPermeate.c) (revision c0fe2abaa7b3d8cb7ded969c92b6f9074ed1e38e) +++ firmware/App/Modes/ModePreGenPermeate.c (.../ModePreGenPermeate.c) (revision 30c175a7e10411efadb9b2b0f8b68528705e0621) @@ -43,7 +43,7 @@ #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_BOOST_PUMP_TGT_PSI 25 ///< Target pressure for boost pump in psi. -#define VERIFY_WATER_TIMEOUT_MS ( 30 * MS_PER_SECOND ) +#define VERIFY_WATER_TIMEOUT_MS ( 30 * MS_PER_SECOND ) ///< Verify Water timer ( in ms ) // ********** private data **********