Index: firmware/App/Drivers/ConductivitySensors.c =================================================================== diff -u -r55addba733659d02ddabf09bfc0af7c8f69fd50a -r44d7a987b5c6b91396ddb2cc8163b36c21f59bde --- firmware/App/Drivers/ConductivitySensors.c (.../ConductivitySensors.c) (revision 55addba733659d02ddabf09bfc0af7c8f69fd50a) +++ firmware/App/Drivers/ConductivitySensors.c (.../ConductivitySensors.c) (revision 44d7a987b5c6b91396ddb2cc8163b36c21f59bde) @@ -104,6 +104,7 @@ // ********** private data ********** static CONDUCTIVITY_STATE_T currentConductivityState; ///< Current conductivity sensor state. +static OVERRIDE_F32_T currentUncompenstatedConductivityReadings[ NUM_OF_CONDUCTIVITY_SENSORS ]; ///< TODO: Get Vinay or Sean to tell me to remove this debug array in CR. static OVERRIDE_F32_T currentConductivityReadings[ NUM_OF_CONDUCTIVITY_SENSORS ]; ///< Current conductivity sensor conductivity readings (overrideable). static OVERRIDE_F32_T currentTemperatureReadings[ NUM_OF_CONDUCTIVITY_SENSORS ]; ///< Current conductivity sensor temperature readings (overrideable). static OVERRIDE_U32_T lastConductivityReadCounter[ NUM_OF_CONDUCTIVITY_SENSORS ]; ///< Last conductivity sensor read count (Overrideable). @@ -146,6 +147,11 @@ // Initialize override structures for each conductivity sensor for ( sensor = FIRST_DD_COND_SENSOR; sensor < NUM_OF_CONDUCTIVITY_SENSORS; sensor++ ) { + currentUncompenstatedConductivityReadings[ sensor ].data = 0.0F; + currentUncompenstatedConductivityReadings[ sensor ].ovData = 0.0F; + currentUncompenstatedConductivityReadings[ sensor ].ovInitData = 0.0F; + currentUncompenstatedConductivityReadings[ sensor ].override = OVERRIDE_RESET; + currentConductivityReadings[ sensor ].data = 0.0F; currentConductivityReadings[ sensor ].ovData = 0.0F; currentConductivityReadings[ sensor ].ovInitData = 0.0F; @@ -552,7 +558,7 @@ { isFPSensor = TRUE; } - + calculateConductivityUpdatedStandard( sensor, isFPSensor ); calculateConductivityUpdatedStandardTempCompensated( sensor, isFPSensor ); } @@ -887,6 +893,35 @@ /*********************************************************************//** * @brief + * The getUncompensatedConductivity function gets the conductivity + * value for a given conductivity sensor id. + * @details \b Inputs: currentUncompenstatedConductivityReadings[] + * @details \b Outputs: none + * @details \b Alarm: ALARM_ID_DD_SOFTWARE_FAULT if given sensor is invalid. + * @param sensorId conductivity sensor id + * @return conductivity value + *************************************************************************/ +F32 getUncompensatedConductivity( CONDUCTIVITY_SENSORS_T sensor ) +{ + F32 result = 0.0F; + + if ( sensor < NUM_OF_CONDUCTIVITY_SENSORS ) + { + result = currentUncompenstatedConductivityReadings[ sensor ].data; + if ( OVERRIDE_KEY == currentUncompenstatedConductivityReadings[ sensor ].override ) + { + result = currentUncompenstatedConductivityReadings[ sensor ].ovData; + } + } + else + { + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DD_SOFTWARE_FAULT, SW_FAULT_ID_INVALID_CONDUCTIVITY_SENSOR_ID, sensor ) + } + + return result; +} +/*********************************************************************//** + * @brief * The getConductivityTemperatureValue function gets the temperature * value for a given conductivity sensor id. * @details \b Inputs: currentTemperatureReadings[] Index: firmware/App/Drivers/ConductivitySensors.h =================================================================== diff -u -r3b64586791accd0b9e8d8978b40e2509bb86dfbe -r44d7a987b5c6b91396ddb2cc8163b36c21f59bde --- firmware/App/Drivers/ConductivitySensors.h (.../ConductivitySensors.h) (revision 3b64586791accd0b9e8d8978b40e2509bb86dfbe) +++ firmware/App/Drivers/ConductivitySensors.h (.../ConductivitySensors.h) (revision 44d7a987b5c6b91396ddb2cc8163b36c21f59bde) @@ -120,6 +120,7 @@ U08 getConductivityTemperatureReadCount( CONDUCTIVITY_SENSORS_T sensor ); F32 getConductivityRawResistance( CONDUCTIVITY_SENSORS_T sensor ); F32 getConductivityRawRTD( CONDUCTIVITY_SENSORS_T sensor ); +F32 getUncompensatedConductivity( CONDUCTIVITY_SENSORS_T sensor ); BOOL testConductivitySensorConductivityReadingsOverride( MESSAGE_T *message ); BOOL testConductivitySensorTemperatureReadingsOverride( MESSAGE_T *message ); Index: firmware/App/Monitors/Conductivity.c =================================================================== diff -u -r145fd716a856f864f39fb0f9884865f6e45b9256 -r44d7a987b5c6b91396ddb2cc8163b36c21f59bde --- firmware/App/Monitors/Conductivity.c (.../Conductivity.c) (revision 145fd716a856f864f39fb0f9884865f6e45b9256) +++ firmware/App/Monitors/Conductivity.c (.../Conductivity.c) (revision 44d7a987b5c6b91396ddb2cc8163b36c21f59bde) @@ -69,6 +69,8 @@ static U08 condPrevReadCount[ NUM_OF_CONDUCTIVITY_SENSORS ]; ///< Previous read count for conductivity per sensor static U08 condTempPrevReadCount[ NUM_OF_CONDUCTIVITY_SENSORS ]; ///< Previous read count for temperature per sensor. static FILTER_CONDUCTIVITY_READINGS_T filteredConductivityReadings[ NUM_OF_CONDUCTIVITY_SENSORS ]; ///< Filtered conductivity reading for conductivity sensors. +static FILTER_CONDUCTIVITY_READINGS_T filteredUConductivityReadings[ NUM_OF_CONDUCTIVITY_SENSORS ]; +static OVERRIDE_F32_T filteredcurrentUConductivityReadings[ NUM_OF_CONDUCTIVITY_SENSORS ]; static OVERRIDE_F32_T filteredcurrentConductivityReadings[ NUM_OF_CONDUCTIVITY_SENSORS ]; ///< filtered current conductivity sensor conductivity readings (overrideable). static FILTER_CONDUCTIVITY_TEMPERATURE_READINGS_T filteredConductivityTemperatureReadings[ NUM_OF_CONDUCTIVITY_SENSORS ]; ///< Filtered temperature reading for conductivity sensors. static OVERRIDE_F32_T filteredcurrentTemperatureReadings[ NUM_OF_CONDUCTIVITY_SENSORS ]; ///< filtered current conductivity sensor temperature readings (overrideable). @@ -135,6 +137,15 @@ // Initialize override structures for each conductivity sensor for ( sensor = FIRST_DD_COND_SENSOR; sensor < NUM_OF_CONDUCTIVITY_SENSORS; sensor++ ) { + filteredcurrentUConductivityReadings[ sensor ].data = 0.0F; + filteredcurrentUConductivityReadings[ sensor ].ovData = 0.0F; + filteredcurrentUConductivityReadings[ sensor ].ovInitData = 0.0F; + filteredcurrentUConductivityReadings[ sensor ].override = OVERRIDE_RESET; + + filteredUConductivityReadings[ sensor ].conductivityReadingsIdx = 0; + filteredUConductivityReadings[ sensor ].conductivityReadingsTotal = 0.0F; + filteredUConductivityReadings[ sensor ].conductivityReadingsCount = 0; + filteredcurrentConductivityReadings[ sensor ].data = 0.0F; filteredcurrentConductivityReadings[ sensor ].ovData = 0.0F; filteredcurrentConductivityReadings[ sensor ].ovInitData = 0.0F; @@ -259,6 +270,7 @@ { CONDUCTIVITY_SENSORS_T sensor; F32 calculatedConductivity = 0.0F; + F32 uncompenstatedConductivity = 0.0F; BOOL freshData = FALSE; for ( sensor = FIRST_DD_COND_SENSOR; sensor < NUM_OF_CONDUCTIVITY_SENSORS; sensor++ ) @@ -282,6 +294,7 @@ if ( condPrevReadCount[ sensor ] != getConductivityReadCount( sensor ) ) { calculatedConductivity = getConductivity( sensor ); + uncompenstatedConductivity = getUncompensatedConductivity( sensor ); condPrevReadCount[ sensor ] = getConductivityReadCount( sensor ); freshData = TRUE; } @@ -301,6 +314,17 @@ filteredConductivityReadings[ sensor ].conductivityReadingsIdx = INC_WRAP( filteredConductivityReadings[ sensor ].conductivityReadingsIdx, 0, SIZE_OF_COND_ROLLING_AVG - 1 ); filteredConductivityReadings[ sensor ].conductivityReadingsCount = INC_CAP( filteredConductivityReadings[ sensor ].conductivityReadingsCount, SIZE_OF_COND_ROLLING_AVG ); filteredcurrentConductivityReadings[ sensor ].data = filteredConductivityReadings[ sensor ].conductivityReadingsTotal / (F32)filteredConductivityReadings[ sensor ].conductivityReadingsCount; + + if ( filteredUConductivityReadings[ sensor ].conductivityReadingsCount >= SIZE_OF_COND_ROLLING_AVG ) + { + filteredUConductivityReadings[ sensor ].conductivityReadingsTotal -= filteredUConductivityReadings[ sensor ].conductivityReadings[ filteredUConductivityReadings[ sensor ].conductivityReadingsIdx ]; + } + filteredUConductivityReadings[ sensor ].conductivityReadings[ filteredUConductivityReadings[ sensor ].conductivityReadingsIdx ] = uncompenstatedConductivity; + filteredUConductivityReadings[ sensor ].conductivityReadingsTotal += uncompenstatedConductivity; + filteredUConductivityReadings[ sensor ].conductivityReadingsIdx = INC_WRAP( filteredUConductivityReadings[ sensor ].conductivityReadingsIdx, 0, SIZE_OF_COND_ROLLING_AVG - 1 ); + filteredUConductivityReadings[ sensor ].conductivityReadingsCount = INC_CAP( filteredUConductivityReadings[ sensor ].conductivityReadingsCount, SIZE_OF_COND_ROLLING_AVG ); + filteredcurrentUConductivityReadings[ sensor ].data = filteredUConductivityReadings[ sensor ].conductivityReadingsTotal / (F32)filteredUConductivityReadings[ sensor ].conductivityReadingsCount; + } } } Index: firmware/App/Monitors/Conductivity.h =================================================================== diff -u -r3b64586791accd0b9e8d8978b40e2509bb86dfbe -r44d7a987b5c6b91396ddb2cc8163b36c21f59bde --- firmware/App/Monitors/Conductivity.h (.../Conductivity.h) (revision 3b64586791accd0b9e8d8978b40e2509bb86dfbe) +++ firmware/App/Monitors/Conductivity.h (.../Conductivity.h) (revision 44d7a987b5c6b91396ddb2cc8163b36c21f59bde) @@ -81,6 +81,13 @@ F32 d74RTDResist; ///< D74 raw resistance value from RTD F32 p9RTDResist; ///< P9 raw resistance value from RTD F32 p18RTDResist; ///< P18 raw resistance value from RTD + F32 d17UncompCond; + F32 d27UncompCond; + F32 d29UncompCond; + F32 d43UncompCond; + F32 d74UncompCond; + F32 p9UncompCond; + F32 p18UncompCond; } CONDUCTIVITY_RESISTANCE_DATA_T; #pragma pack(pop)