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: ptxxx.cpp
- Revision:
- 0:854742598c2c
diff -r 000000000000 -r 854742598c2c ptxxx.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/ptxxx.cpp Fri Feb 19 16:05:58 2021 +0530
@@ -0,0 +1,64 @@
+/*!
+ *****************************************************************************
+ @file: ptxxx.cpp
+
+ @brief:
+
+ @details:
+ -----------------------------------------------------------------------------
+ Copyright (c) 2018, 2020 Analog Devices, Inc. All rights reserved.
+
+ This software is proprietary to Analog Devices, Inc. and its licensors.
+ By using this software you agree to the terms of the associated
+ Analog Devices Software License Agreement.
+
+*****************************************************************************/
+
+#include <math.h>
+#include "ptxxx.h"
+
+#define PT1000_RESISTANCE_TO_TEMP(x) ((x-1000.0)/(0.385))
+
+
+// Forward function declarations
+float convertPT1000ToTemperature(const float resistance);
+
+//class member methods
+
+float PT100::convertResistanceToTemperature(float resistance)
+{
+
+ return ( convertPT1000ToTemperature(resistance * 10) );
+}
+
+
+float PT1000::convertResistanceToTemperature(float resistance)
+{
+
+ return ( convertPT1000ToTemperature(resistance) );
+}
+
+float convertPT1000ToTemperature(const float resistance)
+{
+ float temperature = 25.0;
+
+#ifdef USE_LINEAR_RTD_TEMP_EQ
+ temperature = PT1000_RESISTANCE_TO_TEMP(resistance);
+#else
+
+#define A (3.9083*pow(10,-3))
+#define B (-5.775*pow(10,-7))
+ /*if(resistance < 100.0)
+ 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);
+ else*/
+ temperature = ((-A + sqrt(double(pow(A,
+ 2) - 4 * B * (1 - resistance / 1000.0))) ) / (2 * B));
+#endif
+ return temperature;
+}
+
+
+
+
+
+