Index: firmware/App/Controllers/ConductivitySensors.c =================================================================== diff -u -r986abcfcf047822cad1a10c1ee0924a80dd5f512 -r60e0810fec7299b2c280fd26817ddb1202957fcb --- firmware/App/Controllers/ConductivitySensors.c (.../ConductivitySensors.c) (revision 986abcfcf047822cad1a10c1ee0924a80dd5f512) +++ firmware/App/Controllers/ConductivitySensors.c (.../ConductivitySensors.c) (revision 60e0810fec7299b2c280fd26817ddb1202957fcb) @@ -91,6 +91,7 @@ static U08 readCount[ NUM_OF_CONDUCTIVITY_SENSORS ]; ///< Read count for conductivity readings. static U32 internalErrorCount[ NUM_OF_CONDUCTIVITY_SENSORS ]; ///< Internal error count for conductivity readings. static OVERRIDE_F32_T compensatedConductivityValues[ NUM_OF_CONDUCTIVITY_SENSORS ]; ///< Latest compensated conductivity values. +static OVERRIDE_F32_T rawConductivityValues[ NUM_OF_CONDUCTIVITY_SENSORS ]; ///< Latest raw conductivity values. static F32 roRejectionRatio; ///< Latest RO rejection ratio. static OVERRIDE_U32_T conductivityDataPublishInterval = { COND_SENSOR_REPORT_PERIOD, @@ -135,6 +136,11 @@ compensatedConductivityValues[ i ].ovData = 0.0; compensatedConductivityValues[ i ].ovInitData = 0.0; compensatedConductivityValues[ i ].override = OVERRIDE_RESET; + + rawConductivityValues[ i ].data = 0.0; + rawConductivityValues[ i ].ovData = 0.0; + rawConductivityValues[ i ].ovInitData = 0.0; + rawConductivityValues[ i ].override = OVERRIDE_RESET; } setFPGACPiProbeType( COND_CPI_SENSOR_PROBE_TYPE ); @@ -182,6 +188,11 @@ data.cd1 = getConductivityValue( CONDUCTIVITYSENSORS_CD1_SENSOR ); data.cd2 = getConductivityValue( CONDUCTIVITYSENSORS_CD2_SENSOR ); + data.cpiRaw = getRawConductivityValue( CONDUCTIVITYSENSORS_CPI_SENSOR ); + data.cpoRaw = getRawConductivityValue( CONDUCTIVITYSENSORS_CPO_SENSOR ); + data.cd1Raw = getRawConductivityValue( CONDUCTIVITYSENSORS_CD1_SENSOR ); + data.cd2Raw = getRawConductivityValue( CONDUCTIVITYSENSORS_CD2_SENSOR ); + broadcastData( MSG_ID_DG_CONDUCTIVITY_DATA, COMM_BUFFER_OUT_CAN_DG_BROADCAST, (U08*)&data, sizeof( CONDUCTIVITY_DATA_T ) ); } } @@ -279,6 +290,31 @@ /*********************************************************************//** * @brief + * The getRawConductivityValue function gets the raw conductivity + * value for a given conductivity sensor id. + * @details Inputs: rawConductivityValues[] + * @details Outputs: none + * @param sensorId conductivity sensor id + * @return raw conductivity + *************************************************************************/ +F32 getRawConductivityValue( U32 sensorId ) +{ + F32 result = 0.0; + + if ( sensorId < NUM_OF_CONDUCTIVITY_SENSORS ) + { + result = getF32OverrideValue( &rawConductivityValues[ sensorId ] ); + } + else + { + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DG_SOFTWARE_FAULT, SW_FAULT_ID_INVALID_CONDUCTIVITY_SENSOR_ID, sensorId ); + } + + return result; +} + +/*********************************************************************//** + * @brief * The calcCompensatedConductivity function calculates the compensated * conductivity based on given temperature and conductivity taken at * reference temperature of 25 Celcius. @@ -291,7 +327,7 @@ static F32 calcCompensatedConductivity( F32 conductivity, F32 temperature ) { // EC = EC_25 * (1 + temp_coef * (temperature - 25)) - F32 const compensatedCoef = ( 1.0 + ( COND_SENSOR_TEMPERATURE_COEF * ( temperature - COND_SENSOR_REFERENCE_TEMPERATURE ) ) ); + F32 const compensatedCoef = ( 1.0 + ( COND_SENSOR_TEMPERATURE_COEF * ( COND_SENSOR_REFERENCE_TEMPERATURE - temperature ) ) ); return conductivity * compensatedCoef; } @@ -344,6 +380,7 @@ readCount[ sensorId ] = fpgaReadCount; internalErrorCount[ sensorId ] = 0; compensatedConductivityValues[ sensorId ].data = getCalibrationAppliedConductivityValue( sensorId, compensatedCond ); + rawConductivityValues[ sensorId ].data = conductivity; } else { @@ -586,6 +623,59 @@ /*********************************************************************//** * @brief + * The testSetConductivityOverride function overrides the raw + * conductivity value of given sensor id. + * @details Inputs: rawConductivityValues[] + * @details Outputs: rawConductivityValues[] + * @param sensorId conductivity sensor id + * @param value override raw conductivity value + * @return TRUE if override successful, FALSE if not + *************************************************************************/ +BOOL testSetRawConductivityOverride( U32 sensorId, F32 value ) +{ + BOOL result = FALSE; + + if ( sensorId < NUM_OF_CONDUCTIVITY_SENSORS ) + { + if ( isTestingActivated() ) + { + result = TRUE; + rawConductivityValues[ sensorId ].ovData = value; + rawConductivityValues[ sensorId ].override = OVERRIDE_KEY; + } + } + + return result; +} + +/*********************************************************************//** + * @brief + * The testResetConductivityOverride function resets the override of the + * raw conductivity sensor value. + * @details Inputs: rawConductivityValues[] + * @details Outputs: rawConductivityValues[] + * @param sensorId conductivity sensor id + * @return TRUE if reset successful, FALSE if not + *************************************************************************/ +BOOL testResetRawConductivityOverride( U32 sensorId ) +{ + BOOL result = FALSE; + + if ( sensorId < NUM_OF_CONDUCTIVITY_SENSORS ) + { + if ( isTestingActivated() ) + { + result = TRUE; + rawConductivityValues[ sensorId ].ovData = rawConductivityValues[ sensorId ].ovInitData; + rawConductivityValues[ sensorId ].override = OVERRIDE_RESET; + } + } + + return result; +} + +/*********************************************************************//** + * @brief * The testSetConductivityDataPublishIntervalOverride function overrides * the conductivity data publish interval. * @details Inputs: conductivityDataPublishInterval