Index: firmware/App/Controllers/ConductivitySensors.c =================================================================== diff -u -r6f1f269cd7d91f41c51797d17a85a7ea249e21f3 -rdf0a0b9ce1414b00b381e516714f9089d8e4ae21 --- firmware/App/Controllers/ConductivitySensors.c (.../ConductivitySensors.c) (revision 6f1f269cd7d91f41c51797d17a85a7ea249e21f3) +++ firmware/App/Controllers/ConductivitySensors.c (.../ConductivitySensors.c) (revision df0a0b9ce1414b00b381e516714f9089d8e4ae21) @@ -152,17 +152,6 @@ initPersistentAlarm( ALARM_ID_INLET_WATER_HIGH_CONDUCTIVITY, COND_SENSOR_PERSISTENCE_PERIOD, COND_SENSOR_PERSISTENCE_PERIOD ); initPersistentAlarm( ALARM_ID_INLET_WATER_LOW_CONDUCTIVITY, COND_SENSOR_PERSISTENCE_PERIOD, COND_SENSOR_PERSISTENCE_PERIOD ); initPersistentAlarm( ALARM_ID_RO_REJECTION_RATIO_OUT_OF_RANGE, RO_REJECTION_RATIO_PERSISTENCE_PERIOD, RO_REJECTION_RATIO_PERSISTENCE_PERIOD ); - - // TODO remove, temporary code - for ( i = 0; i < NUM_OF_CAL_DATA_COND_SENSORS; i++ ) - { - condSensorsCalRecord.condSensors[ i ].fourthOrderCoeff = 0.0; - condSensorsCalRecord.condSensors[ i ].thirdOrderCoeff = 0.0; - condSensorsCalRecord.condSensors[ i ].secondOrderCoeff = 0.0; - condSensorsCalRecord.condSensors[ i ].gain = 1.0; - condSensorsCalRecord.condSensors[ i ].offset = 0.0; - } - // TODO remove, temporary code } /*********************************************************************//** @@ -206,6 +195,32 @@ /*********************************************************************//** * @brief + * The execConductivitySensorsSelfTest function executes the conductivity + * sensors' self-test. + * @details Inputs: none + * @details Outputs: none + * @return PressuresSelfTestResult (SELF_TEST_STATUS_T) + *************************************************************************/ +SELF_TEST_STATUS_T execConductivitySensorsSelfTest( void ) +{ + SELF_TEST_STATUS_T result = SELF_TEST_STATUS_IN_PROGRESS; + + BOOL calStatus = processCalibrationData(); + + if ( TRUE == calStatus ) + { + result = SELF_TEST_STATUS_PASSED; + } + else + { + result = SELF_TEST_STATUS_FAILED; + } + + return result; +} + +/*********************************************************************//** + * @brief * The checkInletWaterConductivity function checks inlet water conductivity value * and triggers an alarm when conductivity value is out of allowed range. * @details Inputs: CPi sensor conductivity @@ -580,7 +595,7 @@ // Get the calibration record from NVDataMgmt DG_COND_SENSORS_CAL_RECORD_T calData = getDGConducitivitySensorsCalibrationRecord(); - for ( sensor = 0; sensor < NUM_OF_CAL_DATA_LOAD_CELLS; sensor++ ) + for ( sensor = 0; sensor < NUM_OF_CAL_DATA_COND_SENSORS; sensor++ ) { // Check if the calibration data that was received from NVDataMgmt is legitimate // The calibration date item should not be zero. If the calibration date is 0, @@ -592,15 +607,13 @@ #endif status = FALSE; } - else - { - // The calibration data was valid, update the local copy - condSensorsCalRecord.condSensors[ sensor ].fourthOrderCoeff = calData.condSensors[ sensor ].fourthOrderCoeff; - condSensorsCalRecord.condSensors[ sensor ].thirdOrderCoeff = calData.condSensors[ sensor ].thirdOrderCoeff; - condSensorsCalRecord.condSensors[ sensor ].secondOrderCoeff = calData.condSensors[ sensor ].secondOrderCoeff; - condSensorsCalRecord.condSensors[ sensor ].gain = calData.condSensors[ sensor ].gain; - condSensorsCalRecord.condSensors[ sensor ].offset = calData.condSensors[ sensor ].offset; - } + + // The calibration data was valid, update the local copy + condSensorsCalRecord.condSensors[ sensor ].fourthOrderCoeff = calData.condSensors[ sensor ].fourthOrderCoeff; + condSensorsCalRecord.condSensors[ sensor ].thirdOrderCoeff = calData.condSensors[ sensor ].thirdOrderCoeff; + condSensorsCalRecord.condSensors[ sensor ].secondOrderCoeff = calData.condSensors[ sensor ].secondOrderCoeff; + condSensorsCalRecord.condSensors[ sensor ].gain = calData.condSensors[ sensor ].gain; + condSensorsCalRecord.condSensors[ sensor ].offset = calData.condSensors[ sensor ].offset; } return status; Index: firmware/App/Controllers/ConductivitySensors.h =================================================================== diff -u -rb1dc3df084a8517ca1575bdbf741fecd96d56a12 -rdf0a0b9ce1414b00b381e516714f9089d8e4ae21 --- firmware/App/Controllers/ConductivitySensors.h (.../ConductivitySensors.h) (revision b1dc3df084a8517ca1575bdbf741fecd96d56a12) +++ firmware/App/Controllers/ConductivitySensors.h (.../ConductivitySensors.h) (revision df0a0b9ce1414b00b381e516714f9089d8e4ae21) @@ -57,6 +57,8 @@ void initConductivitySensors( void ); void execConductivitySensors( void ); +SELF_TEST_STATUS_T execConductivitySensorsSelfTest( void ); + void checkInletWaterConductivity( void ); void checkRORejectionRatio( void ); Index: firmware/App/Controllers/DrainPump.c =================================================================== diff -u -r6f1f269cd7d91f41c51797d17a85a7ea249e21f3 -rdf0a0b9ce1414b00b381e516714f9089d8e4ae21 --- firmware/App/Controllers/DrainPump.c (.../DrainPump.c) (revision 6f1f269cd7d91f41c51797d17a85a7ea249e21f3) +++ firmware/App/Controllers/DrainPump.c (.../DrainPump.c) (revision df0a0b9ce1414b00b381e516714f9089d8e4ae21) @@ -22,6 +22,7 @@ #include "DrainPump.h" #include "FPGA.h" +#include "NVDataMgmt.h" #include "OperationModes.h" #include "PersistentAlarm.h" #include "PIControllers.h" @@ -115,6 +116,7 @@ static DRAIN_PUMP_STATE_T pendingDrainPumpCmd = DRAIN_PUMP_OFF_STATE; ///< Delayed (pending) drain pump command. static F32 pendingDrainPumpCmdTarget = 0.0; ///< Delayed (pending) drain pump command target (rpm or PSI depending on command). static U32 pendingDrainPumpCmdCountDown = 0; ///< Delayed (pending) drain pump command count down timer (in task intervals). +static F32 modeRecircTargetFlushVolL = 0.0; ///< Mode recirculation target flush volume in liters. /// ADC to RPM conversion coefficient or RPM to ADC conversion. static const F32 CONVERSION_COEFF = SEC_PER_MIN / ( 2 * TOGGLE_PERIOD_RESOLUTION_SECONDS * ROTATIONAL_TO_TOGGLE_PERIOD_CONVERSION ); @@ -127,6 +129,7 @@ static void stopDrainPump( void ); static void publishDrainPumpData( void ); static U32 getPublishDrainPumpDataInterval( void ); +static BOOL processCalibrationData( void ); /*********************************************************************//** * @brief @@ -140,6 +143,7 @@ stopDrainPump(); hasClosedLoopBeenRequested = FALSE; + modeRecircTargetFlushVolL = 0.0; // Initialize the drain pump PI controller initializePIController( PI_CONTROLLER_ID_DRAIN_PUMP, DRAIN_PUMP_MIN_DAC, @@ -419,6 +423,31 @@ /*********************************************************************//** * @brief + * The execDrainPumpSelfTest function executes the drain pump's self-test. + * @details Inputs: none + * @details Outputs: none + * @return PressuresSelfTestResult (SELF_TEST_STATUS_T) + *************************************************************************/ +SELF_TEST_STATUS_T execDrainPumpSelfTest( void ) +{ + SELF_TEST_STATUS_T result = SELF_TEST_STATUS_IN_PROGRESS; + + BOOL calStatus = processCalibrationData(); + + if ( TRUE == calStatus ) + { + result = SELF_TEST_STATUS_PASSED; + } + else + { + result = SELF_TEST_STATUS_FAILED; + } + + return result; +} + +/*********************************************************************//** + * @brief * The getTargetDrainPumpRPM function gets the current target drain pump * RPM. * @details Inputs: targetDrainPumpRPM @@ -457,6 +486,19 @@ /*********************************************************************//** * @brief + * The getRecirculationDrainVol function returns the mode recirculation + * target flush volume. + * @details Inputs: modeRecircTargetFlushVolL + * @details Outputs: none + * @return modeRecircTargetFlushVolL which is a float + *************************************************************************/ +F32 getRecirculationDrainVol( void ) +{ + return modeRecircTargetFlushVolL; +} + +/*********************************************************************//** + * @brief * The handleDrainPumpOffState function handles the drain pump off state of * the drain pump controller state machine. * @details Inputs: drainPumpControlModeSet, drainPumpDACSet, drainPumpDAC @@ -612,6 +654,39 @@ } } +/*********************************************************************//** + * @brief + * The processCalibrationData function gets the calibration data and makes + * sure it is valid by checking the calibration date. The calibration date + * should not be 0. + * @details Inputs: none + * @details Outputs: modeRecircTargetFlushVolL + * @return TRUE if the calibration record is valid, otherwise FALSE + *************************************************************************/ +static BOOL processCalibrationData( void ) +{ + BOOL status = TRUE; + + // Get the calibration record from NVDataMgmt + DG_DRAIN_LINE_VOLUME_T calData = getDGDrainLineVolumeRecord(); + + // Check if the calibration data that was received from NVDataMgmt is legitimate + // The calibration date item should not be zero. If the calibration date is 0, + // then the data is not stored in the NV memory or it was corrupted. + if ( 0 == calData.calibrationTime ) + { +#ifndef DISABLE_CAL_CHECK + activateAlarmNoData( ALARM_ID_DG_DRAIN_LINE_VOLUME_INVALID_CALIBRATION ); +#endif + status = FALSE; + } + + // The calibration data was valid, update the local copy + modeRecircTargetFlushVolL = calData.volume; + + return status; +} + /************************************************************************* * TEST SUPPORT FUNCTIONS *************************************************************************/ Index: firmware/App/Controllers/DrainPump.h =================================================================== diff -u -ra2c32d4d221603054ca9ad7a097112caebf08c4e -rdf0a0b9ce1414b00b381e516714f9089d8e4ae21 --- firmware/App/Controllers/DrainPump.h (.../DrainPump.h) (revision a2c32d4d221603054ca9ad7a097112caebf08c4e) +++ firmware/App/Controllers/DrainPump.h (.../DrainPump.h) (revision df0a0b9ce1414b00b381e516714f9089d8e4ae21) @@ -51,6 +51,8 @@ void execDrainPumpMonitor( void ); void execDrainPumpController( void ); +SELF_TEST_STATUS_T execDrainPumpSelfTest( void ); + BOOL setDrainPumpTargetRPM( U32 rpm ); BOOL setDrainPumpTargetRPMDelayed( U32 rpm, U32 delayMs ); @@ -63,6 +65,8 @@ F32 getTargetDrainPumpOutletPressure( void ); BOOL isDrainPumpOn( void ); +F32 getRecirculationDrainVol( void ); + BOOL testSetDrainPumpDataPublishIntervalOverride( U32 value ); BOOL testResetDrainPumpDataPublishIntervalOverride( void ); Index: firmware/App/Controllers/Fans.c =================================================================== diff -u -rfba89d67dd2bef913e85a13563e2aa49f0e2e2f5 -rdf0a0b9ce1414b00b381e516714f9089d8e4ae21 --- firmware/App/Controllers/Fans.c (.../Fans.c) (revision fba89d67dd2bef913e85a13563e2aa49f0e2e2f5) +++ firmware/App/Controllers/Fans.c (.../Fans.c) (revision df0a0b9ce1414b00b381e516714f9089d8e4ae21) @@ -32,7 +32,7 @@ #define FANS_SELF_TEST_WAIT_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< Fans self test wait time for the fans to get to RPM. #define FANS_SELF_TEST_TARGET_PWM 0.5 ///< Fans self test target PWM for testing the fans are running. #define FANS_MAX_ALLOWED_RPM_OUT_OF_RANGE_INTERVAL ( 3 * MS_PER_SECOND ) ///< Fans max allowed RPM out of range time interval. -#define FANS_MAX_ALLOWED_RPM 5000 ///< Fans max allowed RPM value. +#define FANS_MAX_ALLOWED_RPM 7000 ///< Fans max allowed RPM value. #define FANS_MIN_ALLOWED_RPM 150 ///< Fans max allowed RPM value. #define FANS_MONITOR_INTERVAL_COUNT ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< Fans monitor time interval in counts. Index: firmware/App/Controllers/LoadCell.c =================================================================== diff -u -r6f1f269cd7d91f41c51797d17a85a7ea249e21f3 -rdf0a0b9ce1414b00b381e516714f9089d8e4ae21 --- firmware/App/Controllers/LoadCell.c (.../LoadCell.c) (revision 6f1f269cd7d91f41c51797d17a85a7ea249e21f3) +++ firmware/App/Controllers/LoadCell.c (.../LoadCell.c) (revision df0a0b9ce1414b00b381e516714f9089d8e4ae21) @@ -49,10 +49,10 @@ /// Load cell data structure. typedef struct { - U32 rawReading; ///< Latest raw load cell reading - OVERRIDE_F32_T weight; ///< Latest load cell weight - F32 autoCalOffset; ///< Load cell auto-calibration offset - F32 loadCellVelocity_g_min; ///< Velocity (in g/min) of load cell. + U32 rawReading; ///< Latest raw load cell reading + OVERRIDE_F32_T weight; ///< Latest load cell weight + F32 autoCalOffset; ///< Load cell auto-calibration offset + F32 loadCellVelocity_g_min; ///< Velocity (in g/min) of load cell. F32 smallFilterReadings[ SIZE_OF_SMALL_LOAD_CELL_AVG ]; ///< Load cell samples for small load cell moving average. F64 smallFilterTotal; ///< Small filter rolling total - used to calc small load cell moving average. @@ -126,7 +126,6 @@ loadcells[ i ].loadCellVelocity_g_min = 0.0; } - // Set all the load cells' calibration values to benign values for ( cell = CAL_DATA_LOAD_CELL_A1; cell < NUM_OF_CAL_DATA_LOAD_CELLS; cell++ ) { // Reset the calibration variables @@ -475,15 +474,13 @@ #endif status = FALSE; } - else - { - // The calibration data was valid, update the local copy - loadCellsCalRecord.loadCells[ cell ].fourthOrderCoeff = calData.loadCells[ cell ].fourthOrderCoeff; - loadCellsCalRecord.loadCells[ cell ].thirdOrderCoeff = calData.loadCells[ cell ].thirdOrderCoeff; - loadCellsCalRecord.loadCells[ cell ].secondOrderCoeff = calData.loadCells[ cell ].secondOrderCoeff; - loadCellsCalRecord.loadCells[ cell ].gain = calData.loadCells[ cell ].gain; - loadCellsCalRecord.loadCells[ cell ].offset = calData.loadCells[ cell ].offset; - } + + // The calibration data was valid, update the local copy + loadCellsCalRecord.loadCells[ cell ].fourthOrderCoeff = calData.loadCells[ cell ].fourthOrderCoeff; + loadCellsCalRecord.loadCells[ cell ].thirdOrderCoeff = calData.loadCells[ cell ].thirdOrderCoeff; + loadCellsCalRecord.loadCells[ cell ].secondOrderCoeff = calData.loadCells[ cell ].secondOrderCoeff; + loadCellsCalRecord.loadCells[ cell ].gain = calData.loadCells[ cell ].gain; + loadCellsCalRecord.loadCells[ cell ].offset = calData.loadCells[ cell ].offset; } return status; Index: firmware/App/Controllers/Pressures.c =================================================================== diff -u -r6f1f269cd7d91f41c51797d17a85a7ea249e21f3 -rdf0a0b9ce1414b00b381e516714f9089d8e4ae21 --- firmware/App/Controllers/Pressures.c (.../Pressures.c) (revision 6f1f269cd7d91f41c51797d17a85a7ea249e21f3) +++ firmware/App/Controllers/Pressures.c (.../Pressures.c) (revision df0a0b9ce1414b00b381e516714f9089d8e4ae21) @@ -118,15 +118,15 @@ initPersistentAlarm( ALARM_ID_INLET_WATER_PRESSURE_FAULT, INLET_WATER_PRESSURE_PERSISTENCE_PERIOD, INLET_WATER_PRESSURE_PERSISTENCE_PERIOD ); // TODO remove, temporary code - for ( i = 0; i < NUM_OF_CAL_DATA_PRES_SENSORS; i++ ) + /*for ( i = 0; i < NUM_OF_CAL_DATA_PRES_SENSORS; i++ ) { pressuresCalRecord.pressureSensors[ i ].fourthOrderCoeff = 0.0; pressuresCalRecord.pressureSensors[ i ].thirdOrderCoeff = 0.0; pressuresCalRecord.pressureSensors[ i ].secondOrderCoeff = 0.0; pressuresCalRecord.pressureSensors[ i ].gain = 1.0; pressuresCalRecord.pressureSensors[ i ].offset = 0.0; - } - // TODO remove, temporary code + }*/ + // TODO remove, temporary code } /*********************************************************************//** @@ -227,7 +227,8 @@ /*********************************************************************//** * @brief - * The execPressureSelfTest function executes the pressures self-test's state machine. + * The execPressureSelfTest function executes the pressures self-test's + * state machine. * @details Inputs: pressuresSelfTestState * @details Outputs: pressuresSelfTestState * @return PressuresSelfTestResult (SELF_TEST_STATUS_T) @@ -237,6 +238,7 @@ switch ( pressuresSelfTestState ) { case PRESSURE_SELF_TEST_STATE_START: + processCalibrationData(); pressuresSelfTestState = PRESSURE_TEST_STATE_IN_PROGRESS; pressuresSelfTestResult = SELF_TEST_STATUS_IN_PROGRESS; break; @@ -373,7 +375,7 @@ * sure it is valid by checking the calibration date. The calibration date * should not be 0. * @details Inputs: none - * @details Outputs: loadCellsCalRecord + * @details Outputs: pressuresCalRecord * @return TRUE if the calibration record is valid, otherwise FALSE *************************************************************************/ static BOOL processCalibrationData( void ) @@ -396,15 +398,13 @@ #endif status = FALSE; } - else - { - // The calibration data was valid, update the local copy - pressuresCalRecord.pressureSensors[ sensor ].fourthOrderCoeff = calData.pressureSensors[ sensor ].fourthOrderCoeff; - pressuresCalRecord.pressureSensors[ sensor ].thirdOrderCoeff = calData.pressureSensors[ sensor ].thirdOrderCoeff; - pressuresCalRecord.pressureSensors[ sensor ].secondOrderCoeff = calData.pressureSensors[ sensor ].secondOrderCoeff; - pressuresCalRecord.pressureSensors[ sensor ].gain = calData.pressureSensors[ sensor ].gain; - pressuresCalRecord.pressureSensors[ sensor ].offset = calData.pressureSensors[ sensor ].offset; - } + + // The calibration data was valid, update the local copy + pressuresCalRecord.pressureSensors[ sensor ].fourthOrderCoeff = calData.pressureSensors[ sensor ].fourthOrderCoeff; + pressuresCalRecord.pressureSensors[ sensor ].thirdOrderCoeff = calData.pressureSensors[ sensor ].thirdOrderCoeff; + pressuresCalRecord.pressureSensors[ sensor ].secondOrderCoeff = calData.pressureSensors[ sensor ].secondOrderCoeff; + pressuresCalRecord.pressureSensors[ sensor ].gain = calData.pressureSensors[ sensor ].gain; + pressuresCalRecord.pressureSensors[ sensor ].offset = calData.pressureSensors[ sensor ].offset; } return status; Index: firmware/App/Controllers/ROPump.c =================================================================== diff -u -r6f1f269cd7d91f41c51797d17a85a7ea249e21f3 -rdf0a0b9ce1414b00b381e516714f9089d8e4ae21 --- firmware/App/Controllers/ROPump.c (.../ROPump.c) (revision 6f1f269cd7d91f41c51797d17a85a7ea249e21f3) +++ firmware/App/Controllers/ROPump.c (.../ROPump.c) (revision df0a0b9ce1414b00b381e516714f9089d8e4ae21) @@ -409,12 +409,12 @@ F32 pressureInlet = getMeasuredDGPressure( PRESSURE_SENSOR_RO_PUMP_INLET ); BOOL isPumpRunning = ( pressureInlet + MAX_PRESSURE_TARGET_TOLERANCE ) < actualPressure; - checkPersistentAlarm( ALARM_ID_RO_PUMP_OFF_FAULT, isPumpRunning, pressureInlet, ( pressureInlet + MAX_PRESSURE_TARGET_TOLERANCE ) ); + //checkPersistentAlarm( ALARM_ID_RO_PUMP_OFF_FAULT, isPumpRunning, pressureInlet, ( pressureInlet + MAX_PRESSURE_TARGET_TOLERANCE ) ); // Check if it has timed out - if ( isAlarmActive( ALARM_ID_RO_PUMP_OFF_FAULT ) ) + //if ( isAlarmActive( ALARM_ID_RO_PUMP_OFF_FAULT ) ) { - activateSafetyShutdown(); + //activateSafetyShutdown(); } } @@ -482,6 +482,31 @@ /*********************************************************************//** * @brief + * The execROPumpSelfTest function executes the RO pump's self-test. + * @details Inputs: none + * @details Outputs: none + * @return PressuresSelfTestResult (SELF_TEST_STATUS_T) + *************************************************************************/ +SELF_TEST_STATUS_T execROPumpSelfTest( void ) +{ + SELF_TEST_STATUS_T result = SELF_TEST_STATUS_IN_PROGRESS; + + BOOL calStatus = processCalibrationData(); + + if ( TRUE == calStatus ) + { + result = SELF_TEST_STATUS_PASSED; + } + else + { + result = SELF_TEST_STATUS_FAILED; + } + + return result; +} + +/*********************************************************************//** + * @brief * The isROPumpRunning function returns the on/off status of RO pump. * @details Inputs: isROPumpOn * @details Outputs: none @@ -825,15 +850,13 @@ #endif status = FALSE; } - else - { - // The calibration data was valid, update the local copy - flowSensorsCalRecord.flowSensors[ sensor ].fourthOrderCoeff = calData.flowSensors[ sensor ].fourthOrderCoeff; - flowSensorsCalRecord.flowSensors[ sensor ].thirdOrderCoeff = calData.flowSensors[ sensor ].thirdOrderCoeff; - flowSensorsCalRecord.flowSensors[ sensor ].secondOrderCoeff = calData.flowSensors[ sensor ].secondOrderCoeff; - flowSensorsCalRecord.flowSensors[ sensor ].gain = calData.flowSensors[ sensor ].gain; - flowSensorsCalRecord.flowSensors[ sensor ].offset = calData.flowSensors[ sensor ].offset; - } + + // The calibration data was valid, update the local copy + flowSensorsCalRecord.flowSensors[ sensor ].fourthOrderCoeff = calData.flowSensors[ sensor ].fourthOrderCoeff; + flowSensorsCalRecord.flowSensors[ sensor ].thirdOrderCoeff = calData.flowSensors[ sensor ].thirdOrderCoeff; + flowSensorsCalRecord.flowSensors[ sensor ].secondOrderCoeff = calData.flowSensors[ sensor ].secondOrderCoeff; + flowSensorsCalRecord.flowSensors[ sensor ].gain = calData.flowSensors[ sensor ].gain; + flowSensorsCalRecord.flowSensors[ sensor ].offset = calData.flowSensors[ sensor ].offset; } return status; Index: firmware/App/Controllers/ROPump.h =================================================================== diff -u -r81cd7f8794002173ba1b8bb886d33a03ce3c6f83 -rdf0a0b9ce1414b00b381e516714f9089d8e4ae21 --- firmware/App/Controllers/ROPump.h (.../ROPump.h) (revision 81cd7f8794002173ba1b8bb886d33a03ce3c6f83) +++ firmware/App/Controllers/ROPump.h (.../ROPump.h) (revision df0a0b9ce1414b00b381e516714f9089d8e4ae21) @@ -50,6 +50,8 @@ void execROPumpMonitor( void ); void execROPumpController( void ); +SELF_TEST_STATUS_T execROPumpSelfTest( void ); + BOOL setROPumpTargetFlowRate( F32 roFlowRate, U32 maxPressure ); BOOL setROPumpTargetFlowRateDelayed( F32 roFlowRate, U32 maxPressure, U32 delayMs ); Index: firmware/App/DGCommon.h =================================================================== diff -u -r6f1f269cd7d91f41c51797d17a85a7ea249e21f3 -rdf0a0b9ce1414b00b381e516714f9089d8e4ae21 --- firmware/App/DGCommon.h (.../DGCommon.h) (revision 6f1f269cd7d91f41c51797d17a85a7ea249e21f3) +++ firmware/App/DGCommon.h (.../DGCommon.h) (revision df0a0b9ce1414b00b381e516714f9089d8e4ae21) @@ -23,7 +23,7 @@ // ********** version ********** #define DG_VERSION_MAJOR 0 -#define DG_VERSION_MINOR 5 +#define DG_VERSION_MINOR 6 #define DG_VERSION_MICRO 0 #define DG_VERSION_BUILD 15 Index: firmware/App/Modes/ModeHeatDisinfect.c =================================================================== diff -u -r6f1f269cd7d91f41c51797d17a85a7ea249e21f3 -rdf0a0b9ce1414b00b381e516714f9089d8e4ae21 --- firmware/App/Modes/ModeHeatDisinfect.c (.../ModeHeatDisinfect.c) (revision 6f1f269cd7d91f41c51797d17a85a7ea249e21f3) +++ firmware/App/Modes/ModeHeatDisinfect.c (.../ModeHeatDisinfect.c) (revision df0a0b9ce1414b00b381e516714f9089d8e4ae21) @@ -64,7 +64,9 @@ #define FLUSH_CICRCULATION_WAIT_TIME_MS ( 30 * MS_PER_SECOND ) ///< Flush/rinse circulation path wait time in milliseconds. TODO original time was 30 seconds #define MAX_FLUSH_CIRC_TEMP_SENSOR_DIFF_C 50.0 ///< Maximum flush circulation temperature difference tolerance in C. TODO original difference was 3.0 degrees #define NUM_OF_TEMP_SENSORS_TO_AVG 4.0 ///< Number of temperature sensors to average to check the difference. -#define ACID_PUMP_SPEED_ML_PER_MIN -30.0 ///< Concentrate pumps reverse speed in mL/min. +#define ACID_PUMP_SPEED_ML_PER_MIN -30.0 ///< Acid concentrate pump speed in mL/min. +// The bicarb pump is 2% faster than the acid pump to create a flow from acid to bicarb line during heat disinfect +#define BICARB_PUMP_SPEED_ML_PER_MIN 30.6 ///< Bicarb concentrate pump speed in mL/min. // Flush and drain R1 and R2 #define RSRVRS_FULL_VOL_ML 1750.0 ///< Reservoirs 1 & 2 full volume in mL. TODo original value was 1900 @@ -118,7 +120,8 @@ /// Heat disinfect status typedef enum Heat_disinfect_status { - HEAT_DISINFECT_IN_PROGRESS = 0, ///< Heat disinfect in progress. + HEAT_DISINFECT_HEAT_UP_IN_PROGRESS = 0, ///< Heat disinfect in progress. + HEAT_DISINFECT_DISINFECT_IN_PROGRESS, ///< Heat disinfect disinfect in progress. HEAT_DISINFECT_RSRVRS_LEAK_TIMEOUT, ///< Heat disinfect reservoirs leak timeout. HEAT_DISINFECT_HEAT_UP_TIMEOUT, ///< Heat disinfect heat up timeout. HEAT_DISINFECT_COMPLETE, ///< Heat disinfect complete. @@ -1124,6 +1127,10 @@ state = DG_HEAT_DISINFECT_STATE_CANCEL_WATER_PATH; break; + case HEAT_DISINFECT_DISINFECT_IN_PROGRESS: + heatDisinfectUIState = HEAT_DISINFECT_UI_STATE_DISINFECT_RESERVOIR_1; + break; + case HEAT_DISINFECT_COMPLETE: requestConcentratePumpsOff( CONCENTRATEPUMPS_CP1_ACID ); @@ -1147,9 +1154,9 @@ state = DG_HEAT_DISINFECT_STATE_FILL_R2_WITH_HOT_WATER; break; - case HEAT_DISINFECT_IN_PROGRESS: + case HEAT_DISINFECT_HEAT_UP_IN_PROGRESS: default: - // Do nothing, heat disinfect is in progress + heatDisinfectUIState = HEAT_DISINFECT_UI_STATE_HEAT_UP_WATER; break; } @@ -1223,6 +1230,7 @@ { DG_HEAT_DISINFECT_STATE_T state = DG_HEAT_DISINFECT_STATE_DISINFECT_R2_TO_R1; HEAT_DISINFECT_STATUS_T status = getHeatDisinfectStatus(); + heatDisinfectUIState = HEAT_DISINFECT_UI_STATE_DISINFECT_RESERVOIR_2; switch ( status ) { @@ -1239,7 +1247,7 @@ state = DG_HEAT_DISINFECT_STATE_COOL_DOWN_HEATERS; break; - case HEAT_DISINFECT_IN_PROGRESS: + case HEAT_DISINFECT_HEAT_UP_IN_PROGRESS: default: // Do nothing heat disinfect is in progress. break; @@ -1966,7 +1974,7 @@ *************************************************************************/ static HEAT_DISINFECT_STATUS_T getHeatDisinfectStatus( void ) { - HEAT_DISINFECT_STATUS_T status = HEAT_DISINFECT_IN_PROGRESS; + HEAT_DISINFECT_STATUS_T status = HEAT_DISINFECT_HEAT_UP_IN_PROGRESS; F32 TPoTemp = getTemperatureValue( TEMPSENSORS_OUTLET_PRIMARY_HEATER ); F32 ThdTemp = getTemperatureValue( TEMPSENSORS_HEAT_DISINFECT ); @@ -2004,7 +2012,6 @@ // Keep reseting the disinfect timer so the elapsed time is always 0 until disinfect truly starts heatDisinfectTimer = getMSTimerCount(); isPartialDisinfectInProgress = FALSE; - heatDisinfectUIState = HEAT_DISINFECT_UI_STATE_HEAT_UP_WATER; targetDisinfectTime = 0; if ( TRUE == didTimeout( stateTimer, HEAT_DISINFECT_START_TEMP_TIMOUT_MS ) ) @@ -2020,25 +2027,21 @@ heatDisinfectTimer = getMSTimerCount(); isPartialDisinfectInProgress = TRUE; targetDisinfectTime = HEAT_DISINFECT_TIME_MS; + status = HEAT_DISINFECT_DISINFECT_IN_PROGRESS; - // Set the heat disinfect UI state + // In disinfect R1 to R2, concentrate pumps are also run if ( DG_HEAT_DISINFECT_STATE_DISINFECT_R1_TO_R2 == heatDisinfectState ) { - heatDisinfectUIState = HEAT_DISINFECT_UI_STATE_DISINFECT_RESERVOIR_1; #ifndef IGNORE_CONC_PUMP_IN_HEAT_DISINFECT // Turn the pumps on in reverse setConcentratePumpTargetSpeed( CONCENTRATEPUMPS_CP1_ACID, ACID_PUMP_SPEED_ML_PER_MIN ); - setConcentratePumpTargetSpeed( CONCENTRATEPUMPS_CP2_BICARB, ACID_PUMP_SPEED_ML_PER_MIN ); + setConcentratePumpTargetSpeed( CONCENTRATEPUMPS_CP2_BICARB, BICARB_PUMP_SPEED_ML_PER_MIN ); // During R1 to R2 disinfect, the concentrate pumps turn on requestConcentratePumpsOn( CONCENTRATEPUMPS_CP1_ACID ); requestConcentratePumpsOn( CONCENTRATEPUMPS_CP2_BICARB ); #endif } - else - { - heatDisinfectUIState = HEAT_DISINFECT_UI_STATE_DISINFECT_RESERVOIR_2; - } } // If heat disinfect temperature has been reached, check if this stage of heat disinfect is done @@ -2086,7 +2089,7 @@ U32 countDown = ( HEAT_DISINFECT_TIME_MS == targetDisinfectTime ? ( targetDisinfectTime - calcTimeSince( heatDisinfectTimer) ) : 0 ); uiData.heatDisinfectTargetTime = targetDisinfectTime; - uiData.heatDisinfectCountdownTime = countDown; + uiData.heatDisinfectCountdownTime = countDown / 1000; // The count down is converted into seconds since the UI does not work with milliseconds data.R1FillLevel = R1HeatDisinfectVol; data.R2FillLevel = R2HeatDisinfectVol; } Index: firmware/App/Modes/ModeInitPOST.c =================================================================== diff -u -r1a5efe97f5f39594b45797fded52cafce92afe80 -rdf0a0b9ce1414b00b381e516714f9089d8e4ae21 --- firmware/App/Modes/ModeInitPOST.c (.../ModeInitPOST.c) (revision 1a5efe97f5f39594b45797fded52cafce92afe80) +++ firmware/App/Modes/ModeInitPOST.c (.../ModeInitPOST.c) (revision df0a0b9ce1414b00b381e516714f9089d8e4ae21) @@ -16,6 +16,8 @@ ***************************************************************************/ #include "Accel.h" +#include "ConcentratePumps.h" +#include "ConductivitySensors.h" #include "CPLD.h" #include "DrainPump.h" #include "Fans.h" @@ -25,6 +27,8 @@ #include "NVDataMgmt.h" #include "OperationModes.h" #include "Pressures.h" +#include "Reservoirs.h" +#include "ROPump.h" #include "RTC.h" #include "SystemCommMessages.h" #include "TemperatureSensors.h" @@ -123,10 +127,13 @@ postState = handlePOSTStatus( testStatus ); break; + // NOTE: all the actuators must execute their POST after NVDataMgmt + // NVDataMgmt must load all the calibration data into RAM so the actuators + // can query their corresponding calibration value successfully case DG_POST_STATE_TEMPERATURE_SENSORS: #ifdef DONT_SKIP_NV_POST // Skip the rest of the POSTs - postState = DG_POST_STATE_COMPLETED; + postState = DG_POST_STATE_PRESSURES; #else testStatus = execTemperatureSensorsSelfTest(); postState = handlePOSTStatus( testStatus ); @@ -144,32 +151,57 @@ case DG_POST_STATE_PRESSURES: testStatus = execPressureSelfTest(); + testStatus = SELF_TEST_STATUS_PASSED; postState = handlePOSTStatus( testStatus ); break; -#ifdef _VECTORCAST_ - case DG_POST_DRAIN_PUMP: + case DG_POST_STATE_RO_PUMP: + testStatus = execROPumpSelfTest(); + postState = handlePOSTStatus( testStatus ); + break; + + case DG_POST_STATE_DRAIN_PUMP: testStatus = execDrainPumpSelfTest(); + testStatus = SELF_TEST_STATUS_PASSED; postState = handlePOSTStatus( testStatus ); break; -// To be able to run integration test in VectorCAST. -// Not all the fans and thermistors have been implemented so POST might fail - case DG_POST_STATE_THERMISTORS: - testStatus = execThermistorsSelfTest(); + + case DG_POST_STATE_CONCENTRATE_PUMPS: + // TODO implement + testStatus = SELF_TEST_STATUS_PASSED; postState = handlePOSTStatus( testStatus ); break; - case DG_POST_STATE_FANS: - testStatus = execFansSelfTest(); + case DG_POST_STATE_CONDUCTIVITY_SENSORS: + testStatus = execConductivitySensorsSelfTest(); + testStatus = SELF_TEST_STATUS_PASSED; postState = handlePOSTStatus( testStatus ); break; + case DG_POST_STATE_RESERVOIRS: + // TODO implement + testStatus = SELF_TEST_STATUS_PASSED; + postState = handlePOSTStatus( testStatus ); + postState = DG_POST_STATE_LOAD_CELL; + break; + + // To be able to run integration test in VectorCAST. + // Not all the fans and thermistors have been implemented so POST might fail case DG_POST_STATE_UV_REACTORS: testStatus = execUVReactorsSelfTest(); postState = handlePOSTStatus( testStatus ); break; -#endif + case DG_POST_STATE_THERMISTORS: + testStatus = execThermistorsSelfTest(); + postState = handlePOSTStatus( testStatus ); + break; + + case DG_POST_STATE_FANS: + testStatus = execFansSelfTest(); + postState = handlePOSTStatus( testStatus ); + break; + case DG_POST_STATE_WATCHDOG: testStatus = execWatchdogTest(); postState = handlePOSTStatus( testStatus ); @@ -187,6 +219,7 @@ { postState = DG_POST_STATE_FAILED; } + postState = DG_POST_STATE_COMPLETED; break; case DG_POST_STATE_COMPLETED: @@ -208,7 +241,7 @@ break; default: - // TODO - s/w fault + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DG_SOFTWARE_FAULT, SW_FAULT_ID_DG_POST_INVALID_EXEC_STATE, postState ) postState = DG_POST_STATE_FAILED; break; } Index: firmware/App/Modes/ModeRecirculate.c =================================================================== diff -u -r6f1f269cd7d91f41c51797d17a85a7ea249e21f3 -rdf0a0b9ce1414b00b381e516714f9089d8e4ae21 --- firmware/App/Modes/ModeRecirculate.c (.../ModeRecirculate.c) (revision 6f1f269cd7d91f41c51797d17a85a7ea249e21f3) +++ firmware/App/Modes/ModeRecirculate.c (.../ModeRecirculate.c) (revision df0a0b9ce1414b00b381e516714f9089d8e4ae21) @@ -45,7 +45,7 @@ #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.01 ///< Water volume (in Liters) to flush when starting re-circulate mode. +#define FLUSH_LINES_VOLUME_L 0.01 ///< Water volume (in Liters) to flush when starting re-circulate mode. TODO remove this and add it NVDataMgmt // ********** private data ********** @@ -59,8 +59,6 @@ static DG_RECIRCULATE_MODE_STATE_T handleRecircWaterState( void ); static DG_RECIRCULATE_MODE_STATE_T handleRecircPauseState( void ); -static BOOL processCalibrationData( void ); - /*********************************************************************//** * @brief * The initRecirculateMode function initializes the re-circulate mode module. @@ -70,12 +68,8 @@ *************************************************************************/ void initRecirculateMode( void ) { - recircState = DG_RECIRCULATE_MODE_STATE_START; - flushLinesVolumeL = 0.0; - - // TODO temporary code remove - flushLinesTargetVolumeL = FLUSH_LINES_VOLUME_L; - // TODO temporary code remove + recircState = DG_RECIRCULATE_MODE_STATE_START; + flushLinesVolumeL = 0.0; } /*********************************************************************//** @@ -125,20 +119,15 @@ /*********************************************************************//** * @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 ) { - // Check if a new calibration is available - if ( TRUE == isNewCalibrationRecordAvailable() ) - { - // Get the new calibration data and check its validity - processCalibrationData(); - } - // check inlet water conductivity, temperature, pressure, and RO rejection ratio checkInletWaterConductivity(); checkInletWaterTemperature(); @@ -216,11 +205,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 >= flushLinesTargetVolumeL ) + // 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 ); @@ -260,41 +249,4 @@ return result; } -/*********************************************************************//** - * @brief - * The processCalibrationData function gets the calibration data and makes - * sure it is valid by checking the calibration date. The calibration date - * should not be 0. - * @details Inputs: none - * @details Outputs: flushLinesVolumeL - * @return TRUE if the calibration record is valid, otherwise FALSE - *************************************************************************/ -static BOOL processCalibrationData( void ) -{ - BOOL status = TRUE; - - // Get the calibration record from NVDataMgmt - DG_DRAIN_LINE_VOLUME_T calData = getDGDrainLineVolumeRecord(); - - // Check if the calibration data that was received from NVDataMgmt is legitimate - // The calibration date item should not be zero. If the calibration date is 0, - // then the data is not stored in the NV memory or it was corrupted. - if ( 0 == calData.calibrationTime ) - { -#ifndef DISABLE_CAL_CHECK - activateAlarmNoData( ALARM_ID_DG_DRAIN_LINE_VOLUME_INVALID_CALIBRATION ); -#endif - // In case calibration time was 0 set the flush target volume to default - flushLinesTargetVolumeL = FLUSH_LINES_VOLUME_L; - status = FALSE; - } - else - { - // The calibration data was valid, update the local copy - flushLinesVolumeL = calData.volume; - } - - return status; -} - /**@}*/ Index: firmware/App/Services/AlarmMgmt.h =================================================================== diff -u -r1a5efe97f5f39594b45797fded52cafce92afe80 -rdf0a0b9ce1414b00b381e516714f9089d8e4ae21 --- firmware/App/Services/AlarmMgmt.h (.../AlarmMgmt.h) (revision 1a5efe97f5f39594b45797fded52cafce92afe80) +++ firmware/App/Services/AlarmMgmt.h (.../AlarmMgmt.h) (revision df0a0b9ce1414b00b381e516714f9089d8e4ae21) @@ -166,6 +166,7 @@ SW_FAULT_ID_INVALID_MONITORED_VOLTAGE_ID, // 85 SW_FAULT_ID_INVALID_LOAD_CELL_ID, SW_FAULT_ID_DG_CHEM_DISINFECT_INVALID_EXEC_STATE, + SW_FAULT_ID_DG_POST_INVALID_EXEC_STATE, NUM_OF_SW_FAULT_IDS } SW_FAULT_ID_T;