Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: TMP006.cpp
- Revision:
- 3:f632c66b30df
- Parent:
- 2:97a7f871b612
- Child:
- 4:56398c14bf1f
--- a/TMP006.cpp Mon Dec 10 14:51:03 2018 +0000 +++ b/TMP006.cpp Mon Dec 10 16:29:14 2018 +0000 @@ -488,6 +488,49 @@ /** + * @brief TMP006_CalculateSensorVoltage ( TMP006_data_t* ) + * + * @details It calculates the real sensor voltage ( V_SENSOR ) value. + * + * @param[in] SensorVoltageResultRegister: Raw sensor voltage value. + * + * @param[out] myV_sensor: Real sensor voltage value. + * + * + * @return Status of TMP006_CalculateSensorVoltage. + * + * + * @author Manuel Caballero + * @date 10/December/2018 + * @version 10/December/2018 The ORIGIN + * @pre N/A. + * @warning TMP006_GetRawSensorVoltage function must be called first. + */ +TMP006::TMP006_status_t TMP006::TMP006_CalculateSensorVoltage ( TMP006_data_t* myV_sensor ) +{ + uint16_t aux = 0U; + + aux = myV_sensor->SensorVoltageResultRegister; + + /* Check if the sensor voltage value is negative, MSB = 1 */ + if ( ( aux & 0x8000 ) == 0x8000 ) + { + aux = ~aux; + aux += 1U; + } + + + /* Parse the data */ + myV_sensor->V_Sensor = (float)( aux * SVOL_1LSB / 1000000000.0 ); + + + + return TMP006_SUCCESS; +} + + + +/** * @brief TMP006_CalculateTemperature ( TMP006_data_t* ) * * @details It calculates the real temperature ( T_DIE ) value. @@ -557,13 +600,13 @@ float f_v_obj = 0.0; /* Claculate the sensitivity of the thermopile sensor */ - s = myObjTemperature->s0 * ( 1 + A1 * ( myObjTemperature->TemperatureK - T_REF ) + A2 * pow( (double)( myObjTemperature->TemperatureK - T_REF ), (double)2U ) ); + s = myObjTemperature->s0 * ( 1.0 + A1 * ( myObjTemperature->TemperatureK - T_REF ) + A2 * pow( (double)( myObjTemperature->TemperatureK - T_REF ), (double)2U ) ); /* Calculate the offset voltage */ v_os = B0 + B1 * ( myObjTemperature->TemperatureK - T_REF ) + B2 * pow( (double)( myObjTemperature->TemperatureK - T_REF ), (double)2U ); /* Model the Seebeck coefficients of the thermopile */ - f_v_obj = ( myObjTemperature->SensorVoltageResultRegister - v_os ) + C2 * pow( (double)( myObjTemperature->SensorVoltageResultRegister - v_os ), (double)2U ); + f_v_obj = ( myObjTemperature->V_Sensor - v_os ) + C2 * pow( (double)( myObjTemperature->V_Sensor - v_os ), (double)2U ); /* Relates the radiant transfer of IR energy between the target object and the TMP006 and the conducted heat in the thermopile in the TMP006 */ myObjTemperature->ObjectTemperatureK = sqrt( sqrt( pow( (double)myObjTemperature->TemperatureK, (double)4U ) + ( f_v_obj / s ) ) );