Introduction
The National Institute of Standards and Technology (NIST) has published the data of several thermocouples as NIST ITS-90 Thermocouple Database.
The data consists of three parts for each thermocouple:
-
table of the thermoelectromotive forces with respect to 0 degree Celsius for each 1 degree Celsius of temperature difference
-
(coefficients for) approximate formula for conversion from temperature to thermoelectromotive force
-
(coefficients for) approximate formula for conversion from thermoelectromotive force to temperature
This library provides functions based on 2. and 3. above. This allows mutual conversion between the emf (electromotive force) of the thermocouple and temperature with respect to $0\,\degree\mathrm{C}$.
Functions
The following functions are provided in this library.
Replace X in the function name with the thermocouple types (B, E, …).
-
FLOAT temp2emf_X(FLOAT temperature) -
Calculates the emf from the given
temperature. It returnsNAN(not a number) if the specifiedtemperatureis out of range, -
FLOAT emf2temp_X(FLOAT emf) -
Calculates the temperature from the given
emf(with respect to $0\,\degree\mathrm{C}$). It returnsNAN(not a number) ifemfis out of range,
Type
The FLOAT type is defined as double if NIST_ITS90_USE_DOUBLE is
defined at compile time, otherwise it is defined as float.
Units
The unit for temperature is $\degree\mathrm{C}$, and the unit for emf is mV.
How to use
First, retrieve the files from the repository.
git clone https://github.com/TPKato/nist-its90The minimum file requirements are as follows:
-
nist-its90.c -
nist-its90-X.c(Xshould be replaced by the thermocouple type (B, E, …)) -
nist-its90.h -
nist-its90-config.h
If you use this library with your C source code(s):
-
Edit
nist-its90-config.has necessary. -
Add following lines in your code:
#include <math.h> /* Only for type K (which requires exp()) */ #include "nist-its90.h" -
The compilation procedure is as follows:
gcc -c nist-its90.c gcc -c nist-its90-K.c gcc -o [execfile] [your source].c nist-its90.o nist-its90-K.o -lm
For Arduino, the procedure is almost the same.
-
Copy the necessary files to the project directory.
-
Edit
nist-its90-config.hif necessary. -
Add the following line to the
.inofile.#include "nist-its90.h"
Example
To calculate the measuring junction temperature t from the obtained
the electromotive force emf and the cold junction temperature
t_amb in the measurement using the K-type thermocouple:
t = emf2temp_K(emf + temp2emf_K(t_amb));Files
This library consists of the following files.
-
Makefile -
This file is used to generate
nist-its90-*.candnist-its90.hfrom the NIST database. -
nistcoeff.pl -
A Script to generate
nist-its90-*.candnist-its90.hfrom the NIST database -
nist-test.pl -
Test of generated programs
-
nist-its90.c -
Compute polynomials (using the Horner method)
The following are the files generated by nistcoeff.pl.
These files can be generated using the above files, but you usually do
not need to generate them by yourself, since they are included in the
repository.
-
nist-its90-B.c -
nist-its90-E.c -
nist-its90-J.c -
nist-its90-K.c -
nist-its90-N.c -
nist-its90-R.c -
nist-its90-S.c -
nist-its90-T.c -
nist-its90.h
How to make
Follow the steps below if you want to make these files by yourself.
Since the database file of NIST is not included in this repository,
you need to download
All Thermocouple Types
from the Download Tables
page of
NIST ITS-90 Thermocouple Database.
Then, run:
make
make test(make test is optional).
See also
See Correcting Temperature Data of MAX31855 for information on how to use this library with MAX31855 (Cold-Junction Compensated Thermocouple-to-Digital Converter by Maxim Integrated).
Repository
License
-
MIT License