Ver código fonte

otp538u: Initial implementation

This module was tested on the Grove non-contact IR Temperature
Sensor.  The tables included are only valid for a distance of 9cm.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Zion Orent <zorent@ics.com>
Signed-off-by: John Van Drasek <john.r.van.drasek@intel.com>
Jon Trulson 10 anos atrás
pai
commit
f13216752e

+ 3
- 0
examples/CMakeLists.txt Ver arquivo

@@ -85,6 +85,7 @@ add_executable (cjq4435-example cjq4435.cxx)
85 85
 add_executable (adxl335-example adxl335.cxx)
86 86
 add_executable (hmtrp-example hmtrp.cxx)
87 87
 add_executable (nunchuck-example nunchuck.cxx)
88
+add_executable (otp538u-example otp538u.cxx)
88 89
 
89 90
 include_directories (${PROJECT_SOURCE_DIR}/src/hmc5883l)
90 91
 include_directories (${PROJECT_SOURCE_DIR}/src/grove)
@@ -155,6 +156,7 @@ include_directories (${PROJECT_SOURCE_DIR}/src/cjq4435)
155 156
 include_directories (${PROJECT_SOURCE_DIR}/src/adxl335)
156 157
 include_directories (${PROJECT_SOURCE_DIR}/src/hmtrp)
157 158
 include_directories (${PROJECT_SOURCE_DIR}/src/nunchuck)
159
+include_directories (${PROJECT_SOURCE_DIR}/src/otp538u)
158 160
 
159 161
 target_link_libraries (hmc5883l-example hmc5883l ${CMAKE_THREAD_LIBS_INIT})
160 162
 target_link_libraries (groveled-example grove ${CMAKE_THREAD_LIBS_INIT})
@@ -243,3 +245,4 @@ target_link_libraries (cjq4435-example cjq4435 ${CMAKE_THREAD_LIBS_INIT})
243 245
 target_link_libraries (adxl335-example adxl335 ${CMAKE_THREAD_LIBS_INIT})
244 246
 target_link_libraries (hmtrp-example hmtrp ${CMAKE_THREAD_LIBS_INIT})
245 247
 target_link_libraries (nunchuck-example nunchuck ${CMAKE_THREAD_LIBS_INIT})
248
+target_link_libraries (otp538u-example otp538u ${CMAKE_THREAD_LIBS_INIT})

+ 64
- 0
examples/javascript/otp538u.js Ver arquivo

@@ -0,0 +1,64 @@
1
+/*jslint node:true, vars:true, bitwise:true, unparam:true */
2
+/*jshint unused:true */
3
+
4
+/*
5
+* Author: Zion Orent <zorent@ics.com>
6
+* Copyright (c) 2015 Intel Corporation.
7
+*
8
+* Permission is hereby granted, free of charge, to any person obtaining
9
+* a copy of this software and associated documentation files (the
10
+* "Software"), to deal in the Software without restriction, including
11
+* without limitation the rights to use, copy, modify, merge, publish,
12
+* distribute, sublicense, and/or sell copies of the Software, and to
13
+* permit persons to whom the Software is furnished to do so, subject to
14
+* the following conditions:
15
+*
16
+* The above copyright notice and this permission notice shall be
17
+* included in all copies or substantial portions of the Software.
18
+*
19
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22
+* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
23
+* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
24
+* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
25
+* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26
+*/
27
+
28
+// analog voltage, usually 3.3 or 5.0
29
+var OTP538U_AREF = 5.0;
30
+
31
+var tempIRSensor_lib = require('jsupm_otp538u');
32
+
33
+// Instantiate a OTP538U on analog pins A0 and A1
34
+// A0 is used for the Ambient Temperature and A1 is used for the
35
+// Object temperature.
36
+var tempIRSensor_obj = new tempIRSensor_lib.OTP538U(0, 1, OTP538U_AREF);
37
+
38
+
39
+function checkTemp()
40
+{
41
+	var outputStr = "Ambient temp: " +
42
+		roundNum(tempIRSensor_obj.ambientTemperature(), 2) +
43
+		" C, Object temp: " +
44
+		roundNum(tempIRSensor_obj.objectTemperature(), 2) +
45
+		" C";
46
+	console.log(outputStr);
47
+}
48
+
49
+var myInterval = setInterval(checkTemp, 1000);
50
+
51
+function roundNum(num, decimalPlaces)
52
+{
53
+	var extraNum = (1 / (Math.pow(10, decimalPlaces) * 1000));
54
+	return (Math.round((num + extraNum) *
55
+		(Math.pow(10, decimalPlaces))) / Math.pow(10, decimalPlaces));
56
+}
57
+
58
+// When exiting: clear interval and print message
59
+process.on('SIGINT', function()
60
+{
61
+	clearInterval(myInterval);
62
+	console.log("Exiting...");
63
+	process.exit(0);
64
+});

+ 71
- 0
examples/otp538u.cxx Ver arquivo

@@ -0,0 +1,71 @@
1
+/*
2
+ * Author: Jon Trulson <jtrulson@ics.com>
3
+ * Copyright (c) 2014 Intel Corporation.
4
+ *
5
+ * Permission is hereby granted, free of charge, to any person obtaining
6
+ * a copy of this software and associated documentation files (the
7
+ * "Software"), to deal in the Software without restriction, including
8
+ * without limitation the rights to use, copy, modify, merge, publish,
9
+ * distribute, sublicense, and/or sell copies of the Software, and to
10
+ * permit persons to whom the Software is furnished to do so, subject to
11
+ * the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be
14
+ * included in all copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
+ */
24
+
25
+#include <unistd.h>
26
+#include <iostream>
27
+#include <iomanip>
28
+#include <signal.h>
29
+#include "otp538u.h"
30
+
31
+using namespace std;
32
+
33
+bool shouldRun = true;
34
+
35
+// analog voltage, usually 3.3 or 5.0
36
+#define OTP538U_AREF   5.0
37
+
38
+void sig_handler(int signo)
39
+{
40
+  if (signo == SIGINT)
41
+    shouldRun = false;
42
+}
43
+
44
+int main()
45
+{
46
+  signal(SIGINT, sig_handler);
47
+
48
+//! [Interesting]
49
+
50
+  // Instantiate a OTP538U on analog pins A0 and A1
51
+  // A0 is used for the Ambient Temperature and A1 is used for the
52
+  // Object tempewrature.
53
+  upm::OTP538U *temps = new upm::OTP538U(0, 1, OTP538U_AREF);
54
+  
55
+  // Output ambient and object temperatures
56
+  while (shouldRun)
57
+    {
58
+      cout << "Ambient temp: " << std::fixed << setprecision(2) 
59
+           << temps->ambientTemperature() 
60
+           << " C, Object temp: " << temps->objectTemperature() 
61
+           << " C" << endl;
62
+      
63
+      sleep(1);
64
+    }
65
+//! [Interesting]
66
+
67
+  cout << "Exiting" << endl;
68
+
69
+  delete temps;
70
+  return 0;
71
+}

+ 5
- 0
src/otp538u/CMakeLists.txt Ver arquivo

@@ -0,0 +1,5 @@
1
+set (libname "otp538u")
2
+set (libdescription "upm otp538u IR temperature sensor")
3
+set (module_src ${libname}.cxx)
4
+set (module_h ${libname}.h)
5
+upm_module_init()

+ 8
- 0
src/otp538u/jsupm_otp538u.i Ver arquivo

@@ -0,0 +1,8 @@
1
+%module jsupm_otp538u
2
+%include "../upm.i"
3
+
4
+%{
5
+    #include "otp538u.h"
6
+%}
7
+
8
+%include "otp538u.h"

+ 189
- 0
src/otp538u/otp538u.cxx Ver arquivo

@@ -0,0 +1,189 @@
1
+/*
2
+ * Author: Jon Trulson <jtrulson@ics.com>
3
+ * Copyright (c) 2015 Intel Corporation.
4
+ *
5
+ * Permission is hereby granted, free of charge, to any person obtaining
6
+ * a copy of this software and associated documentation files (the
7
+ * "Software"), to deal in the Software without restriction, including
8
+ * without limitation the rights to use, copy, modify, merge, publish,
9
+ * distribute, sublicense, and/or sell copies of the Software, and to
10
+ * permit persons to whom the Software is furnished to do so, subject to
11
+ * the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be
14
+ * included in all copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
+ */
24
+
25
+#include <iostream>
26
+
27
+#include "otp538u.h"
28
+
29
+#include "thermopile_vt_table.h"
30
+#include "thermister_rt_table.h"
31
+
32
+using namespace upm;
33
+using namespace std;
34
+
35
+OTP538U::OTP538U(int pinA, int pinO, float aref)
36
+{
37
+  // this is the internal voltage reference on the Grove IR temp
38
+  // sensor module
39
+  m_vref = 2.5;
40
+
41
+  // analog reference in use
42
+  m_aref = aref;
43
+
44
+  // This is the value of the output resistor of the Grove IR
45
+  // temp sensor's SIG2 output (ambient)
46
+  m_vResistance = 2000000;      // 2M ohms
47
+
48
+  // This was the default offset voltage in the seeedstudio code.  You
49
+  // can adjust as neccessary depending on your calibration.
50
+  m_offsetVoltage = 0.014;
51
+
52
+  // We need around 1mV resolution, so use 12 bit resolution (4096)
53
+  // with a default aref of 5.0.
54
+  m_adcResolution = 4096;
55
+
56
+  if ( !(m_aioA = mraa_aio_init(pinA)) )
57
+    {
58
+      cerr << __FUNCTION__ << ": mraa_aio_init() failed" << endl;
59
+      return;
60
+    }
61
+
62
+  // enable 12 bit resolution
63
+  mraa_aio_set_bit(m_aioA, 12);
64
+
65
+  if ( !(m_aioO = mraa_aio_init(pinO)) )
66
+    {
67
+      cerr << __FUNCTION__ << ": mraa_aio_init() failed" << endl;
68
+      return;
69
+    }
70
+
71
+  // enable 12 bit resolution
72
+  mraa_aio_set_bit(m_aioO, 12);
73
+}
74
+
75
+OTP538U::~OTP538U()
76
+{
77
+  mraa_aio_close(m_aioA);
78
+  mraa_aio_close(m_aioO);
79
+}
80
+
81
+float OTP538U::ambientTemperature()
82
+{
83
+  const int samples = 5;
84
+  int val = 0;
85
+  float temp = 0;
86
+  float res;
87
+
88
+  for (int i=0; i<samples; i++)
89
+    {
90
+      val = mraa_aio_read(m_aioA);
91
+      temp += val;
92
+      usleep(10000);
93
+    }
94
+
95
+  temp = temp / samples;
96
+  temp = temp * m_aref / m_adcResolution;
97
+
98
+  // compute the resistance of the thermistor
99
+  res = m_vResistance * temp / (m_vref - temp);
100
+
101
+  // look it up in the thermistor (RT) resistence/temperature table
102
+  int rawslot;
103
+  int j;
104
+  for (j=0; j<otp538u_rt_table_max; j++)
105
+    if (otp538u_rt_table[j] < res)
106
+      {
107
+        rawslot = j;
108
+        break;
109
+      }
110
+
111
+  if (j >= otp538u_rt_table_max)
112
+    { 
113
+      cerr << __FUNCTION__ << ": ambient temperature out of range." << endl;
114
+      return 0;
115
+    }
116
+
117
+  // we need to compensate for the fact that we are supporting
118
+  // temperature values less than 0 (-20C), so adjust correspondingly
119
+  // so that we obtain the correct temperature 'slot'.  This will be
120
+  // our base temperature.
121
+  int slot = rawslot - 20;
122
+  
123
+  // too cold
124
+  if (slot < 0)
125
+    {
126
+      cerr << __FUNCTION__ << ": ambient temperature out of range." << endl;
127
+      return 0;
128
+    }
129
+
130
+  // now compute the ambient temperature
131
+  float ambientTemp = slot - 1 +
132
+    (otp538u_rt_table[rawslot - 1]-res) / (otp538u_rt_table[rawslot - 1] - 
133
+                                           otp538u_rt_table[rawslot]);
134
+  
135
+  return ambientTemp;
136
+}
137
+
138
+float OTP538U::objectTemperature()
139
+{
140
+  const int samples = 5;
141
+  const float reference_vol= 0.5; // what is this value? (from seeedstudio)
142
+  const float tempIncrement=10;
143
+  int val = 0;
144
+  float temp = 0;
145
+  float ambTemp = ambientTemperature();
146
+  
147
+  for (int i=0; i<samples; i++)
148
+    {
149
+      val = mraa_aio_read(m_aioO);
150
+      temp += val;
151
+      usleep(10000);
152
+    }
153
+
154
+  temp = temp / samples;
155
+
156
+  float temp1 = temp * m_aref / m_adcResolution;
157
+  float sensorVolts = temp1 - (reference_vol + m_offsetVoltage);
158
+  // cout << "Sensor Voltage: " << sensorVolts << endl;
159
+
160
+  // search the VT (voltage/temperature) table to find the object
161
+  // temperature.
162
+  int slot;
163
+  // add +2 to compensate for the -20C and -10C slots below zero
164
+  int voltOffset = int(ambTemp / 10) + 1 + 2;
165
+  float voltage = sensorVolts * 10.0;
166
+  for (slot=0; slot<otp538u_vt_table_max; slot++)		
167
+    {
168
+      if ( (voltage > otp538u_vt_table[slot][voltOffset]) &&
169
+           (voltage < otp538u_vt_table[slot+1][voltOffset]) )
170
+        {
171
+          break;
172
+        }
173
+    }
174
+
175
+  if (slot >= (otp538u_vt_table_max - 1))
176
+    {
177
+      cerr << __FUNCTION__ << ": object temperature out of range." << endl;
178
+      return 0;
179
+    }
180
+
181
+  float objTemp = (float(tempIncrement) * voltage) /
182
+    ( otp538u_vt_table[slot + 1][voltOffset] - 
183
+      otp538u_vt_table[slot][voltOffset] );    
184
+
185
+  //  cout << "TABLE VALUE [" << slot << "][" <<
186
+  //    voltOffset << "] = " << otp538u_vt_table[slot][voltOffset] << endl;
187
+
188
+  return (ambTemp + objTemp);
189
+}

+ 141
- 0
src/otp538u/otp538u.h Ver arquivo

@@ -0,0 +1,141 @@
1
+/*
2
+ * Author: Jon Trulson <jtrulson@ics.com>
3
+ * Copyright (c) 2015 Intel Corporation.
4
+ *
5
+ * Permission is hereby granted, free of charge, to any person obtaining
6
+ * a copy of this software and associated documentation files (the
7
+ * "Software"), to deal in the Software without restriction, including
8
+ * without limitation the rights to use, copy, modify, merge, publish,
9
+ * distribute, sublicense, and/or sell copies of the Software, and to
10
+ * permit persons to whom the Software is furnished to do so, subject to
11
+ * the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be
14
+ * included in all copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
+ */
24
+#pragma once
25
+
26
+#include <string>
27
+#include <mraa/aio.h>
28
+
29
+namespace upm {
30
+
31
+  /**
32
+   * @brief C++ API for the OTP538U IR Temperature Sensor
33
+   *
34
+   * UPM module for the OTP538U IR Temperature Sensor
35
+   *
36
+   * This module was tested with the Grove IR non-contact temperature
37
+   * sensor.
38
+   *
39
+   * The sensor provides 2 analog outputs - one for the thermistor
40
+   * that measures ambient temperature, and another for the thermopile
41
+   * that measures object temperature.
42
+   *
43
+   * Much of the code depends on analyzing the SeeedStudio examples
44
+   * and circuit design.  As a result, there are several 'magic'
45
+   * numbers that were derived from their circuit design.  By default,
46
+   * these values will be used.
47
+   *
48
+   * The tables used came from the datasheets "538U VT
49
+   * Table__20_200(v1.3).pdf" and "538RT_table.pdf".
50
+   *
51
+   * These tables assume the object to be measured is 9cm (3.54
52
+   * inches) from the sensor.
53
+   *
54
+   * @ingroup grove analog
55
+   * @defgroup otp538u libupm-otp538u
56
+   * @snippet otp538u.cxx Interesting
57
+   */
58
+  class OTP538U {
59
+  public:
60
+    /**
61
+     * OTP538U sensor constructor
62
+     *
63
+     * @param pinA analog pin to use for Ambient temperature
64
+     * @param pinO analog pin to use for Object temperature
65
+     * @param aref analog reference voltage, default 5.0
66
+     */
67
+    OTP538U(int pinA, int pinO, float aref = 5.0);
68
+
69
+    /**
70
+     * OTP538U Destructor
71
+     */
72
+    ~OTP538U();
73
+
74
+    /**
75
+     * Get the ambient temperature in C
76
+     *
77
+     * @return the ambient temperature
78
+     */
79
+    float ambientTemperature();
80
+
81
+    /**
82
+     * Get the object temperature in C
83
+     *
84
+     * @return the object's temperature
85
+     */
86
+    float objectTemperature();
87
+
88
+    /**
89
+     * Set the offset voltage
90
+     *
91
+     * The Seeedstudio wiki gives an example on calibrating the sensor
92
+     * and calculating the offset voltage to apply.  Currently, the
93
+     * default value is set, but you can use the function to set one
94
+     * of your own.
95
+     *
96
+     * @param vOffset the desired offset voltage
97
+     */
98
+    void setVoltageOffset(float vOffset) { m_offsetVoltage = vOffset; };
99
+
100
+    /**
101
+     * Set the output resistance value
102
+     *
103
+     * The Seeedstudio wiki example uses a value, 2000000 in one of
104
+     * the equations used to calculate a voltage.  The value is the
105
+     * resistance of a resistor they use in the output stage of their
106
+     * SIG2 output.  This was 'decoded' by looking at the eagle files
107
+     * containing their schematics for this device.
108
+     *
109
+     * @param outResistance value of output resistor, default 2M Ohm.
110
+     */
111
+    void setOutputResistence(int outResistance) { 
112
+      m_vResistance = outResistance; };
113
+
114
+    /**
115
+     * Set the voltage reference of the internal seedstudio voltage
116
+     * regulator on the sensor board.
117
+     *
118
+     * The Seeedstudio wiki example uses a value, 2.5 in one of the
119
+     * equations used to calculate the resistance of the ambient
120
+     * thermistor.  The value is the voltage of an internal voltage
121
+     * regulator used in the sensor board.  This was 'decoded' by
122
+     * looking at the eagle files containing their schematics for this
123
+     * device.
124
+     *
125
+     * @param vref internal sensor voltage reference, default 2.5
126
+     */
127
+    void setVRef(float vref) { m_vref = vref; };
128
+
129
+
130
+  private:
131
+    float m_vref;
132
+    float m_aref;
133
+    int m_vResistance;
134
+    float m_offsetVoltage;
135
+    int m_adcResolution;
136
+    mraa_aio_context m_aioA;
137
+    mraa_aio_context m_aioO;
138
+  };
139
+}
140
+
141
+

+ 9
- 0
src/otp538u/pyupm_otp538u.i Ver arquivo

@@ -0,0 +1,9 @@
1
+%module pyupm_otp538u
2
+%include "../upm.i"
3
+
4
+%feature("autodoc", "3");
5
+
6
+%include "otp538u.h"
7
+%{
8
+    #include "otp538u.h"
9
+%}

+ 46
- 0
src/otp538u/thermister_rt_table.h Ver arquivo

@@ -0,0 +1,46 @@
1
+/*
2
+ * Author: Jon Trulson <jtrulson@ics.com>
3
+ * Copyright (c) 2015 Intel Corporation.
4
+ *
5
+ * Permission is hereby granted, free of charge, to any person obtaining
6
+ * a copy of this software and associated documentation files (the
7
+ * "Software"), to deal in the Software without restriction, including
8
+ * without limitation the rights to use, copy, modify, merge, publish,
9
+ * distribute, sublicense, and/or sell copies of the Software, and to
10
+ * permit persons to whom the Software is furnished to do so, subject to
11
+ * the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be
14
+ * included in all copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
+ */
24
+
25
+// This table was taken from the 538RT_table.pdf datasheet. It maps
26
+// resistance values to ambient temperatures starting at -20C and
27
+// going to 200C in increments of 1C
28
+
29
+static const int otp538u_rt_table_max = 121;
30
+
31
+static int otp538u_rt_table[otp538u_rt_table_max] = {
32
+  919730, 869299, 821942, 777454, 735644, 696336, 659365, 624578, 591834,
33
+  561002, 531958, 504588, 478788, 454457, 431504, 409843, 389394, 370082,
34
+  351839, 334598, 318300, 302903, 288329, 274533, 261471, 249100, 237381,
35
+  226276, 215750, 205768, 196300, 187316, 178788, 170691, 163002, 155700,
36
+  148766, 142183, 135936, 130012, 124400, 119038, 113928, 109059, 104420,
37
+  100000, 95788, 91775, 87950, 84305, 80830, 77517, 74357, 71342, 68466,
38
+  65720, 63098, 60595, 58202, 55916, 53730, 51645, 49652, 47746, 45924,
39
+  44180, 42511, 40912, 39380, 37910, 36500, 35155, 33866, 32631, 31446,
40
+  30311, 29222, 28177, 27175, 26213, 25290, 24403, 23554, 22738, 21955,
41
+  21202, 20479, 19783, 19115, 18472, 17854, 17260, 16688, 16138, 15608,
42
+  15098, 14608, 14135, 13680, 13242, 12819, 12412, 12020, 11642, 11278,
43
+  10926, 10587, 10260, 9945, 9641, 9347, 9063, 8789, 8525, 8270, 8023,
44
+  7785, 7555, 7333, 7118, 6911 
45
+};
46
+ 

+ 104
- 0
src/otp538u/thermopile_vt_table.h Ver arquivo

@@ -0,0 +1,104 @@
1
+/*
2
+ * Author: Jon Trulson <jtrulson@ics.com>
3
+ * Copyright (c) 2015 Intel Corporation.
4
+ *
5
+ * Permission is hereby granted, free of charge, to any person obtaining
6
+ * a copy of this software and associated documentation files (the
7
+ * "Software"), to deal in the Software without restriction, including
8
+ * without limitation the rights to use, copy, modify, merge, publish,
9
+ * distribute, sublicense, and/or sell copies of the Software, and to
10
+ * permit persons to whom the Software is furnished to do so, subject to
11
+ * the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be
14
+ * included in all copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
+ */
24
+
25
+// This table was taken from the 538U VT Table__20_200(v1.3).pdf
26
+// datasheet, but the 25C column has been removed for consistency.
27
+
28
+static const int otp538u_vt_table_max = 23;
29
+
30
+// Thermister temperature (C)
31
+// { -20 -10 0 10 20 30 40 50 60 70 80 90 100 }
32
+
33
+static float otp538u_vt_table[otp538u_vt_table_max][13] = {
34
+                                                  // object temp (C)  
35
+  {0.000, -0.246, -0.523, -0.832, -1.177, -1.559, // -20C 
36
+   -1.981, -2.446, -2.957, -3.516, -4.126, -4.791, -5.513},
37
+  
38
+  {0.243, 0.000, -0.274, -0.580, -0.922, -1.301, // -10
39
+   -1.721, -2.183, -2.691, -3.247, -3.854, -4.516, -5.236},
40
+  
41
+  {0.511, 0.271, 0.000, -0.303, -0.642, -1.018, // 0
42
+   -1.434, -1.894, -2.398, -2.951, -3.556, -4.215, -4.931},
43
+  
44
+  {0.804, 0.567, 0.300, 0.000, -0.335, -0.708, // 10
45
+   -1.121, -1.577, -2.078, -2.628, -3.229, -3.884, -4.597},
46
+  
47
+  {1.125, 0.891, 0.628, 0.331, 0.000, -0.369, // 20
48
+   -0.778, -1.230, -1.728, -2.274, -2.871, -3.523, -4.232},
49
+  
50
+  {1.474, 1.244, 0.985, 0.692, 0.365, 0.000, // 30
51
+   -0.405, -0.853, -1.347, -1.889, -2.482, -3.130, -3.835},
52
+  
53
+  {1.852, 1.628, 1.372, 1.084, 0.761, 0.401, // 40
54
+   0.000, -0.444, -0.933, -1.470, -2.059, -2.702, -3.403},
55
+  
56
+  {2.263, 2.043, 1.792, 1.509, 1.191, 0.835, // 50
57
+   0.439, 0.000, -0.484, -1.017, -1.601, -2.240, -2.936},
58
+  
59
+  {2.706, 2.491, 2.246, 1.968, 1.655, 1.304, // 60
60
+   0.913, 0.479, 0.000, -0.528, -1.107, -1.740, -2.431},
61
+  
62
+  {3.184, 2.975, 2.735, 2.462, 2.155, 1.809, // 70
63
+   1.424, 0.996, 0.522, 0.000, -0.573, -1.201, -1.887},
64
+  
65
+  {3.698, 3.495, 3.261, 2.994, 2.692, 2.353, // 80
66
+   1.974, 1.552, 1.084, 0.568, 0.000, -0.622, -1.301},
67
+  
68
+  {4.250, 4.053, 3.825, 3.565, 3.270, 2.937, // 90
69
+   2.564, 2.148, 1.687, 1.177, 0.616, 0.000, -0.673},
70
+  
71
+  {4.841, 4.651, 4.430, 4.177, 3.888, 3.562, // 100
72
+   3.196, 2.787, 2.332, 1.829, 1.275, 0.666, 0.000},
73
+  
74
+  {5.473, 5.290, 5.076, 4.830, 4.549, 4.231, // 110
75
+   3.872, 3.470, 3.023, 2.527, 1.980, 1.379, 0.720},
76
+  
77
+  {6.147, 5.972, 5.767, 5.528, 5.255, 4.944, // 120
78
+   4.593, 4.199, 3.760, 3.272, 2.733, 2.139, 1.488},
79
+  
80
+  {6.866, 6.699, 6.502, 6.272, 6.007, 5.705, // 130
81
+   5.362, 4.976, 4.545, 4.066, 3.535, 2.950, 2.307},
82
+  
83
+  {7.631, 7.473, 7.285, 7.064, 6.808, 6.514, // 140
84
+   6.180, 5.803, 5.381, 4.910, 4.388, 3.812, 3.178},
85
+  
86
+  {8.444, 8.295, 8.116, 7.905, 7.658, 7.373, // 150
87
+   7.049, 6.682, 6.269, 5.807, 5.295, 4.728, 4.103},
88
+  
89
+  {9.306, 9.167, 8.998, 8.796, 8.560, 8.285, // 160
90
+   7.971, 7.613, 7.211, 6.759, 6.257, 5.700, 5.085},
91
+  
92
+  {10.219, 10.091, 9.933, 9.741, 9.515, 9.251, // 170
93
+   8.947, 8.601, 8.208, 7.768, 7.276, 6.729, 6.125},
94
+  
95
+  {11.185, 11.068, 10.921, 10.741, 10.526, 10.274, // 180
96
+   9.981, 9.645, 9.264, 8.835, 8.354, 7.818, 7.226},
97
+  
98
+  {12.206, 12.101, 11.966, 11.798, 11.595, 11.354, // 190
99
+   11.073, 10.749, 10.380, 9.962, 9.493, 8.969, 8.388},
100
+  
101
+  {13.284, 13.191, 13.068, 12.913, 12.722, 12.494, // 200
102
+   12.225, 11.914, 11.557, 11.152, 10.695, 10.184, 9.616}
103
+};
104
+