Expand description
Thermocouple routines.
Provides a sense_temperature
method to convert thermoelectric
potential to temperature. The following thermocouple types are supported:
- Nickel-alloy thermocouples: Type E, J, K, N, T
- Platinum/rhodium-alloy thermocouples: Type B, R, S
This library includes newtype types, or wrapper types, to help with using the proper units when doing calculations. I investigated using a dimensional analysis crate such as uom or dimensioned instead of making my own newtype types. However after experimentation, I found this to be difficult to use and not at all lightweight.
The underlying storage type is either f64
(default) or f32
. For the
f64
storage type, the results from this crate match the NIST ITS-90
Thermocouple Database exactly.
§Usage
Add this to your Cargo.toml
:
[dependencies]
thermocouple = "0.1.3"
and this to your crate root:
extern crate thermocouple;
The temperature of a thermocouple can be calcuated from a voltage reading.
use thermocouple::{prelude::*, KType};
// Assuming reference junction at 25ºC
let temperature: Celsius = KType::new().sense_temperature(Millivolts(1.1));
The reference junction temperature can be set explicitly.
use thermocouple::{prelude::*, KType};
// Reference junction at 0ºC
let thermocouple =
KType::new().with_reference_temperature(Celsius(0.0));
let temperature: Celsius =
thermocouple.sense_temperature(Millivolts(2.0));
§Tests
The tests check against every value provided in the NIST ITS-90 Thermocouple Database (DOI: http://dx.doi.org/10.18434/T4S888)
For a f64
base storage type, they should match the table
exactly. Re-formatted versions of the tables for the automatic tests can be
found in the nist
directory.
Modules§
- prelude
- A convenience wrapper to allow the user to import all the traits and structures required.
Structs§
- BType
- Type B thermocouple (platinum/rhodium alloy)
- Celsius
- Unit of thermodynamic temperature
- EType
- Type E thermocouple (chromel-constantan)
- Fahrenheit
- Unit of thermodynamic temperature
- JType
- Type J thermocouple (iron-constantan)
- KType
- Type K thermocouple (chromel-alumel)
- Kelvin
- Unit of thermodynamic temperature, defined as the fraction of 1/273.16 of the thermodynamic temperature of the triple point of water
- Millivolts
- Unit of electric potential, 1/1000 of the SI Base Unit Volt
- NType
- Type N thermocouple (nicrosil-nisil)
- RType
- Type R thermocouple (platinum/rhodium alloy)
- Rankine
- Unit of thermodynamic temperature
- Reaumur
- Unit of thermodynamic temperature
- SType
- Type S thermocouple (platinum/rhodium alloy)
- TType
- Type T thermocouple (copper-constantan)
Traits§
- FPExt
- Extension trait that adds convenience methods to the
FP
type - Thermocouple
Core - Trait for thermocouple functionality
Type Aliases§
- FP
- Underlying storage type:
f64