STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
T7Convert.hpp
Go to the documentation of this file.
1#pragma once
2
3// T7 volts -> engineering units: psi for a PT, kg for a load cell, C for a type K thermocouple.
4// The same units, and the same Elodin field names, as the ESP32 boards' calibrated tables, so the
5// GUI can treat a T7 channel as one more PT / LC / TC.
6//
7// Every function returns NaN when it cannot produce a number (a missing parameter, a reading off
8// the end of a thermocouple curve); the caller publishes nothing rather than a plausible zero.
9
10#include "config/T7Config.hpp"
11
12namespace fsw {
13namespace t7 {
14
15/**
16 * The T7's internal temperature sensor (an LM94021 on AIN14) reads "Device temperature K =
17 * volts * -92.6 + 467.6" (T-series datasheet 18.0 Internal Temp Sensor; the same values are the
18 * nominal Temp_Slope / Temp_Offset in 20.0.1 T7 Calibration Constants). Each unit's own slope and
19 * offset are in flash. The offset is taken per unit at stream start instead of from the nominal
20 * 467.6 K: t7_bridge reads the device's own calibrated TEMPERATURE_DEVICE_K beside AIN14 (before
21 * the stream, which blocks command-response reads of the sensor) and solves for it, so the nominal
22 * slope only has to hold over the few kelvin the box drifts. (-92.379 / 465.129, used here before,
23 * are the U6's nominal constants, not the T7's.)
24 */
25constexpr double kAin14SlopeKPerV = -92.6;
26/** Nominal AIN14 offset (K), datasheet 18.0. Only the fake T7 uses it; a real one is solved. */
27constexpr double kAin14NominalOffsetK = 467.6;
28
29/** AIN14 offset (K) that makes slope*ain14_v land on the device's own temperature reading. */
30double cjc_device_offset_k(double device_temp_k, double ain14_v);
31
32/** Cold-junction temperature (C) from a streamed AIN14 reading. */
33double cjc_temp_c(double ain14_v, double device_offset_k, double cjc_offset_k);
34
35/** PT: linear between the signal's zero and full-scale outputs. */
36double pt_psi(double volts, const config::T7Channel& ch);
37
38/** LC: a bridge's output is sensitivity x excitation at rated load. */
39double lc_kg(double volts, const config::T7Channel& ch);
40
41/** Type K thermocouple: the measured EMF plus the EMF the cold junction subtracts. */
42double tc_c(double volts, double cold_junction_c);
43
44/** RTD on an LJTick-Resistance: the divider's output volts -> the RTD's ohms. NaN outside
45 * (0, vref_v), where the divider cannot be inverted (open or shorted RTD). */
46double rtd_ohms(double volts, const config::T7Channel& ch);
47
48/** RTD: ohms -> C on the IEC 60751 curve (full Callendar-Van Dusen, C term below 0 C). */
49double rtd_c(double volts, const config::T7Channel& ch);
50
51/** The Elodin field a calibrated channel of this kind publishes ("pressure_psi", ...), or ""
52 * for a kind with no calibrated table (VOLTAGE). Same names as the ESP32 boards' tables. */
53const char* calibrated_field(const std::string& kind);
54
55} // namespace t7
56} // namespace fsw
double cjc_device_offset_k(double device_temp_k, double ain14_v)
AIN14 offset (K) that makes slope*ain14_v land on the device's own temperature reading.
Definition T7Convert.cpp:17
constexpr double kAin14SlopeKPerV
The T7's internal temperature sensor (an LM94021 on AIN14) reads "Device temperature K =volts * -92....
Definition T7Convert.hpp:25
double lc_kg(double volts, const config::T7Channel &ch)
LC: a bridge's output is sensitivity x excitation at rated load.
Definition T7Convert.cpp:46
double rtd_ohms(double volts, const config::T7Channel &ch)
RTD on an LJTick-Resistance: the divider's output volts -> the RTD's ohms.
Definition T7Convert.cpp:58
const char * calibrated_field(const std::string &kind)
The Elodin field a calibrated channel of this kind publishes ("pressure_psi", ...),...
Definition T7Convert.cpp:70
double tc_c(double volts, double cold_junction_c)
Type K thermocouple: the measured EMF plus the EMF the cold junction subtracts.
Definition T7Convert.cpp:53
double cjc_temp_c(double ain14_v, double device_offset_k, double cjc_offset_k)
Cold-junction temperature (C) from a streamed AIN14 reading.
Definition T7Convert.cpp:21
double pt_psi(double volts, const config::T7Channel &ch)
PT: linear between the signal's zero and full-scale outputs.
Definition T7Convert.cpp:25
constexpr double kAin14NominalOffsetK
Nominal AIN14 offset (K), datasheet 18.0.
Definition T7Convert.hpp:27
double rtd_c(double volts, const config::T7Channel &ch)
RTD: ohms -> C on the IEC 60751 curve (full Callendar-Van Dusen, C term below 0 C).
Definition T7Convert.cpp:64
Motorized ball valve position: raw ADC counts -> % open.
One streamed analog input.
Definition T7Config.hpp:37
static double volts(uint32_t code)
Shunt volts for a code, as calibration_main's convert_hp_pt_to_pressure computes it.
static std::string ch(int ain, const std::string &kind, const std::string &extra="", const std::string &board="lj")
Definition test_t7.cpp:98