Index: firmware/App/Monitors/Conductivity.c =================================================================== diff -u -r46a42611591cb92eef5f20c8d39964d406c5c8cc -rbc7dad193df69c64cf213db463e5115b1ba8a5f0 --- firmware/App/Monitors/Conductivity.c (.../Conductivity.c) (revision 46a42611591cb92eef5f20c8d39964d406c5c8cc) +++ firmware/App/Monitors/Conductivity.c (.../Conductivity.c) (revision bc7dad193df69c64cf213db463e5115b1ba8a5f0) @@ -102,11 +102,8 @@ { CONDUCTIVITY_SENSORS_T sensor; -#ifdef __TEENSY_CONDUCTIVITY_DRIVER__ initConductivityTeensy(); -#else initConductivitySensors(); -#endif ddConductivityPublishTimerCounter = DATA_PUBLISH_COUNTER_START_COUNT; fpConductivityPublishTimerCounter = DATA_PUBLISH_COUNTER_START_COUNT; @@ -175,19 +172,8 @@ void execConductivity( void ) { //read conductivity sensors raw value -#ifdef __TEENSY_CONDUCTIVITY_DRIVER__ execConductivityTeensy(); -#else - readConductivitySensors(); -#endif - //control conductivity sensor - // TODO : need more clarity on why and when to execute following control. -#if 0 - handleConductivitySensorsReset(); - handleConductivitySensorsInitProcedure(); - execConductivitySensorWrite(); - execConductivitySensorRead(); -#endif + execConductivitySensors(); filterConductivitySensors(); calcRORejectionRatio(); // TODO: should this be called here or inside filter function @@ -253,31 +239,28 @@ static void filterConductivitySensorReadings( void ) { CONDUCTIVITY_SENSORS_T sensor; - F32 rawCond = 0.0F; + F32 calculatedConductivity = 0.0F; for ( sensor = FIRST_DD_COND_SENSOR; sensor < NUM_OF_CONDUCTIVITY_SENSORS; sensor++ ) { -#ifdef __TEENSY_CONDUCTIVITY_DRIVER__ - if (sensor != D74_COND ) + + if ( getTestConfigStatus( TEST_CONFIG_DD_FP_ENABLE_BETA_2_0_HW ) != TRUE ) { - rawCond = getTeensyConductivityValue( sensor ); + calculatedConductivity = getTeensyConductivityValue( sensor ); } else { - rawCond = getConductivityValue( sensor ); + calculatedConductivity = getConductivity( sensor ); } -#else - rawCond = getConductivityValue( sensor ); -#endif // TODO - calibrate if ( filteredConductivityReadings[ sensor ].conductivityReadingsCount >= SIZE_OF_FLOW_ROLLING_AVG ) { filteredConductivityReadings[ sensor ].conductivityReadingsTotal -= filteredConductivityReadings[ sensor ].conductivityReadings[ filteredConductivityReadings[ sensor ].conductivityReadingsIdx ]; } - filteredConductivityReadings[ sensor ].conductivityReadings[ filteredConductivityReadings[ sensor ].conductivityReadingsIdx ] = rawCond; - filteredConductivityReadings[ sensor ].conductivityReadingsTotal += rawCond; + filteredConductivityReadings[ sensor ].conductivityReadings[ filteredConductivityReadings[ sensor ].conductivityReadingsIdx ] = calculatedConductivity; + filteredConductivityReadings[ sensor ].conductivityReadingsTotal += calculatedConductivity; filteredConductivityReadings[ sensor ].conductivityReadingsIdx = INC_WRAP( filteredConductivityReadings[ sensor ].conductivityReadingsIdx, 0, SIZE_OF_FLOW_ROLLING_AVG - 1 ); filteredConductivityReadings[ sensor ].conductivityReadingsCount = INC_CAP( filteredConductivityReadings[ sensor ].conductivityReadingsCount, SIZE_OF_FLOW_ROLLING_AVG ); filteredcurrentConductivityReadings[ sensor ].data = filteredConductivityReadings[ sensor ].conductivityReadingsTotal / (F32)filteredConductivityReadings[ sensor ].conductivityReadingsCount; @@ -325,31 +308,27 @@ static void filterConductivitySensorTemperatureReadings( void ) { CONDUCTIVITY_SENSORS_T sensor; - F32 rawTemp = 0.0F; + F32 calculatedTemperature = 0.0F; for ( sensor = FIRST_DD_COND_SENSOR; sensor < NUM_OF_CONDUCTIVITY_SENSORS; sensor++ ) { - -#ifdef __TEENSY_CONDUCTIVITY_DRIVER__ - if (sensor != D74_COND ) + if ( getTestConfigStatus( TEST_CONFIG_DD_FP_ENABLE_BETA_2_0_HW ) != TRUE ) { - rawTemp = getTeensyConductivityTemperatureValue( sensor ); + calculatedTemperature = getTeensyConductivityTemperatureValue( sensor ); } else { - rawTemp = getConductivityTemperatureValue( sensor ); + calculatedTemperature = getConductivityTemperature( sensor ); } -#else - rawTemp = getConductivityTemperatureValue( sensor ); -#endif + // TODO - calibrate if ( filteredConductivityTemperatureReadings[sensor].conductivityTempReadingsCount >= SIZE_OF_FLOW_ROLLING_AVG ) { filteredConductivityTemperatureReadings[sensor].conductivityTempReadingsTotal -= filteredConductivityTemperatureReadings[sensor].conductivityTempReadings[ filteredConductivityTemperatureReadings[sensor].conductivityTempReadingsIdx ]; } - filteredConductivityTemperatureReadings[sensor].conductivityTempReadings[ filteredConductivityTemperatureReadings[sensor].conductivityTempReadingsIdx ] = rawTemp; - filteredConductivityTemperatureReadings[sensor].conductivityTempReadingsTotal += rawTemp; + filteredConductivityTemperatureReadings[sensor].conductivityTempReadings[ filteredConductivityTemperatureReadings[sensor].conductivityTempReadingsIdx ] = calculatedTemperature; + filteredConductivityTemperatureReadings[sensor].conductivityTempReadingsTotal += calculatedTemperature; filteredConductivityTemperatureReadings[sensor].conductivityTempReadingsIdx = INC_WRAP( filteredConductivityTemperatureReadings[sensor].conductivityTempReadingsIdx, 0, SIZE_OF_FLOW_ROLLING_AVG - 1 ); filteredConductivityTemperatureReadings[sensor].conductivityTempReadingsCount = INC_CAP( filteredConductivityTemperatureReadings[sensor].conductivityTempReadingsCount, SIZE_OF_FLOW_ROLLING_AVG ); filteredcurrentTemperatureReadings[sensor].data = filteredConductivityTemperatureReadings[sensor].conductivityTempReadingsTotal / (F32)filteredConductivityTemperatureReadings[sensor].conductivityTempReadingsCount; @@ -696,4 +675,77 @@ return result; } +/*********************************************************************//** + * @brief + * The testConductivitySensorReadingsOverride function overrides the value of the + * specified conductivity sensor with a given value and determines which driver + * override. + * @details \b Inputs: testConfig + * @details \b Outputs: none + * @param message Override message from Dialin which includes an sensor + * ID and override value of the conductivity sensor. + * @return TRUE if override successful, FALSE if not + *************************************************************************/ +BOOL testConductivitySensorReadingsOverride( MESSAGE_T *message ) +{ + BOOL result = FALSE; + TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; + OVERRIDE_TYPE_T ovType = getOverrideArrayPayloadFromMessage( message, &payload ); + + if ( getTestConfigStatus( TEST_CONFIG_DD_FP_ENABLE_BETA_2_0_HW ) != TRUE ) + { + + if ( payload.index != D74_COND ) + { + result = testTeensyConductivitySensorReadingsOverride( message ); + } + else + { + result = testConductivitySensorReadingsOverride( message ); + } + } + else + { + result = testConductivitySensorConductivityReadingsOverride( message ); + } + + return result; +} + +/*********************************************************************//** + * @brief + * The testConductivitySensorTemperatureOverride function overrides the value of the + * specified conductivity sensor with a given value and determines which driver + * override. + * @details \b Inputs: testConfig + * @details \b Outputs: none + * @param message Override message from Dialin which includes an sensor + * ID and override value of the conductivity sensor. + * @return TRUE if override successful, FALSE if not + *************************************************************************/ +BOOL testConductivitySensorTemperatureOverride( MESSAGE_T *message ) +{ + BOOL result = FALSE; + TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; + OVERRIDE_TYPE_T ovType = getOverrideArrayPayloadFromMessage( message, &payload ); + + if ( getTestConfigStatus( TEST_CONFIG_DD_FP_ENABLE_BETA_2_0_HW ) != TRUE ) + { + + if ( payload.index != D74_COND ) + { + result = testTeensyConductivitySensorTemperatureReadingsOverride( message ); + } + else + { + result = testConductivitySensorTemperatureReadingsOverride( message ); + } + } + else + { + result = testConductivitySensorTemperatureReadingsOverride( message ); + } + + return result; +} /**@}*/