Mahesh Phalke / tempsensors_prv
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ptxxx.cpp Source File

ptxxx.cpp

Go to the documentation of this file.
00001 /*!
00002  *****************************************************************************
00003   @file:  ptxxx.cpp
00004 
00005   @brief:
00006 
00007   @details:
00008  -----------------------------------------------------------------------------
00009  Copyright (c) 2018, 2020 Analog Devices, Inc.  All rights reserved.
00010 
00011  This software is proprietary to Analog Devices, Inc. and its licensors.
00012  By using this software you agree to the terms of the associated
00013  Analog Devices Software License Agreement.
00014 
00015 *****************************************************************************/
00016 
00017 #include <math.h>
00018 #include "ptxxx.h"
00019 
00020 #define PT1000_RESISTANCE_TO_TEMP(x) ((x-1000.0)/(0.385))
00021 
00022 
00023 // Forward function declarations
00024 float convertPT1000ToTemperature(const float resistance);
00025 
00026 //class member methods
00027 
00028 float PT100::convertResistanceToTemperature(float resistance)
00029 {
00030 
00031     return ( convertPT1000ToTemperature(resistance * 10) );
00032 }
00033 
00034 
00035 float PT1000::convertResistanceToTemperature(float resistance)
00036 {
00037 
00038     return ( convertPT1000ToTemperature(resistance) );
00039 }
00040 
00041 float convertPT1000ToTemperature(const float resistance)
00042 {
00043     float temperature = 25.0;
00044 
00045 #ifdef USE_LINEAR_RTD_TEMP_EQ
00046     temperature = PT1000_RESISTANCE_TO_TEMP(resistance);
00047 #else
00048 
00049 #define A (3.9083*pow(10,-3))
00050 #define B (-5.775*pow(10,-7))
00051     /*if(resistance < 100.0)
00052         temperature = -242.02 + 2.228 * resistance + (2.5859 * pow(10, -3)) * pow(resistance, 2) - (48260 * pow(10, -6)) * pow(resistance, 3) - (2.8183 * pow(10, -3)) * pow(resistance, 4) + (1.5243 * pow(10, -10)) * pow(resistance, 5);
00053     else*/
00054     temperature = ((-A + sqrt(double(pow(A,
00055                          2) - 4 * B * (1 - resistance / 1000.0))) ) / (2 * B));
00056 #endif
00057     return temperature;
00058 }
00059 
00060 
00061 
00062 
00063 
00064