A collection of Analog Devices drivers for the mbed platform
For additional information check out the mbed page of the Analog Devices wiki: https://wiki.analog.com/resources/tools-software/mbed-drivers-all
Diff: libraries/Thermocouple/Thermocouple_core_cpp.txt
- Revision:
- 33:c3ec596a29c2
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libraries/Thermocouple/Thermocouple_core_cpp.txt Mon Nov 07 16:27:12 2016 +0200
@@ -0,0 +1,43 @@
+#include "thermocouple.h"
+
+// http://srdata.nist.gov/its90/download/allcoeff.tab
+
+Thermocouple::Thermocouple(){}
+Thermocouple::~Thermocouple() {}
+
+float Thermocouple::lookup(const int32_t *lut, float voltage, uint16_t size, int16_t offset) {
+ uint16_t first = 0;
+ uint16_t last = size - 1;
+ uint16_t middle = (first + last) / 2;
+ int32_t integer_voltage = int32_t(voltage*1000);
+ while (first <= last) {
+ if (lut[middle] < integer_voltage)
+ first = middle + 1;
+ else if (lut[middle] == integer_voltage) {
+ return static_cast<float>(middle + offset);
+ } else
+ last = middle - 1;
+
+ middle = (first + last) / 2;
+ }
+ if (first > last)
+ return static_cast<float>(first+offset);
+
+ return 0; // should never get here
+}
+
+float Thermocouple::convert(float voltage, const thermocouple_poly_subrange range[], const int n) {
+ int range_id = 0;
+ float temperature=0;
+ for(range_id = 0 ; range_id<n;range_id++)
+ {
+ if(voltage > range[range_id].min_voltage_range && voltage <= range[range_id].max_voltage_range)
+ break;
+ }
+
+ for (int i = 0; i < range[range_id].n; i++) {
+ temperature += (range[range_id].coef[i] * pow(10,range[range_id].power[i])) * pow(voltage, i);
+ }
+ return temperature;
+}
+
CN0357 - Toxic gas measurement
CN0216 - Weight Scale