STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
T7Config.hpp
Go to the documentation of this file.
1#pragma once
2
3// LabJack T7 boards in config.toml.
4//
5// A T7 is declared like any other board, as a [boards.<name>] section with type = "T7", and
6// carries a table of the analog inputs it streams:
7//
8// [boards.labjack_1]
9// type = "T7"
10// ip = "192.168.2.81"
11// mac = "" # DHCP reservation, same as the ESP32 boards (deploy/dhcp)
12// board_id = 81
13// enabled = true
14// scan_rate_hz = 100 # scans per second; every channel is sampled once per scan
15//
16// [[boards.labjack_1.channels]]
17// ain = 1 # AIN number as printed on the T7 (0-13)
18// kind = "PT"
19// role = "LOX Tank"
20// range = 10.0 # +/- volts: 10, 1, 0.1 or 0.01
21//
22// Only t7_bridge reads these. daq_bridge, config_broadcast and active_boards() see type "T7" as
23// an unknown board type and skip it, so a T7 entry never receives ESP32 packets.
24//
25// Parsing is strict on purpose. A T7 config that is wrong (a duplicate AIN, a range the device
26// does not have, a thermocouple with no type) is reported in Config::t7_errors and t7_bridge
27// refuses to start, rather than streaming something other than what the config says.
28
29#include <cstdint>
30#include <string>
31#include <vector>
32
33namespace fsw {
34namespace config {
35
36/** One streamed analog input. */
37struct T7Channel {
38 int ain = -1; ///< AIN number on the device, 0-13.
39 std::string kind; ///< "PT" | "TC" | "LC" | "RTD" | "VOLTAGE" — what is wired to it.
40 std::string role; ///< Sensor name, e.g. "LOX Tank" — what the GUI calls it.
41 double range_v = 10; ///< +/- input range in volts: 10, 1, 0.1 or 0.01.
42 bool differential = false; ///< true: AIN(ain) - AIN(ain+1); ain must be even.
43 std::string tc_type; ///< Thermocouple type letter (kind == "TC" only): "K".
44
45 // Volts -> engineering units (t7_bridge publishes both). Every number describing the sensor
46 // is stated in the channel; there are no defaults for them, so a missing one is a config
47 // error rather than a plausible-looking wrong reading.
48 double full_scale = 0; ///< PT: psi at full output. LC: kg at rated output.
49 std::string signal; ///< PT output: "0-5V" "0.5-4.5V" "1-5V" "0-10V" "4-20mA".
50 double shunt_ohms = 0; ///< PT "4-20mA": the resistor the loop current crosses.
51 double sensitivity_mv_per_v = 0; ///< LC: rated output, mV per V of excitation.
52 double excitation_v = 0; ///< LC: bridge excitation voltage.
53 // RTD through a LabJack LJTick-Resistance: a divider from the tick's 2.5 V reference through
54 // the RTD and a fixed precision resistor, read across the fixed one,
55 // Vout = Vref * R_fixed / (R_fixed + R_rtd) (LabJack, LJTick-Resistance datasheet).
56 double r0_ohms = 0; ///< RTD: resistance at 0 C, 100 (Pt100) or 1000 (Pt1000).
57 double ljtr_ohms = 0; ///< RTD: the tick's fixed resistor, 1k/10k/100k/1M by model.
58 /** RTD: the tick's reference. 2.5 V +/-0.04 % per its datasheet; set a measured value here. */
59 double vref_v = 2.5;
60
61 /** AIN#_NEGATIVE_CH value: 199 = single-ended, else the paired odd input. */
62 int negative_ch() const {
63 return differential ? ain + 1 : 199;
64 }
65};
66
67/** One [boards.*] section with type = "T7". */
68struct T7Board {
69 std::string section; ///< "boards.labjack_1"
70 std::string ip;
71 std::string mac;
72 int64_t serial = 0; ///< Optional; when non-zero t7_bridge checks the unit that answered.
73 int board_id = -1;
74 bool enabled = true;
75 double scan_rate_hz = 100.0;
76 int resolution_index = 0; ///< STREAM_RESOLUTION_INDEX; 0 = device default.
77 double settling_us = 0.0; ///< STREAM_SETTLING_US; 0 = automatic.
78 int scans_per_read = 0; ///< Scans per LJM_eStreamRead; 0 = scan_rate/20 (a 50 ms block).
79 /** Thermocouple cold junction = T7 internal sensor + this (K). The default is LabJack's
80 * figure for the built-in screw terminals AIN0-AIN3: "expect the returned value
81 * [TEMPERATURE_DEVICE_K] minus 3 C to reflect the temperature of the built-in
82 * screw-terminals with an accuracy of +/-2.5 C" (datasheet 18.0). A TC on a CB37 (AIN4-13
83 * are DB37 only) is at air temperature instead: TEMPERATURE_AIR_K, device - 4.3 K on USB,
84 * - 4.9 K on USB + Ethernet. Measure it on the stand either way and set it. */
85 double cjc_offset_k = -3.0;
86 std::vector<T7Channel> channels;
87
88 /** Elodin slot, same rule as BoardConfig::slot(): board_id % 10, 0 -> 10. */
89 uint8_t slot() const {
90 int m = board_id % 10;
91 return static_cast<uint8_t>(m == 0 ? 10 : m);
92 }
93
94 /** scans_per_read with the default applied; always >= 1. */
95 int effective_scans_per_read() const;
96};
97
98/** Highest AIN number on a T7 without an expansion mux (AIN0-AIN13). */
99constexpr int kT7MaxAin = 13;
100
101// Parsed by config::load() into Config::t7_boards / Config::t7_errors (see Config.cpp).
102
103} // namespace config
104} // namespace fsw
constexpr int kT7MaxAin
Highest AIN number on a T7 without an expansion mux (AIN0-AIN13).
Definition T7Config.hpp:99
Motorized ball valve position: raw ADC counts -> % open.
std::vector< T7Channel > channels
Definition T7Config.hpp:86
double settling_us
STREAM_SETTLING_US; 0 = automatic.
Definition T7Config.hpp:77
int scans_per_read
Scans per LJM_eStreamRead; 0 = scan_rate/20 (a 50 ms block).
Definition T7Config.hpp:78
double cjc_offset_k
Thermocouple cold junction = T7 internal sensor + this (K).
Definition T7Config.hpp:85
int effective_scans_per_read() const
scans_per_read with the default applied; always >= 1.
Definition T7Config.cpp:14
int64_t serial
Optional; when non-zero t7_bridge checks the unit that answered.
Definition T7Config.hpp:72
int resolution_index
STREAM_RESOLUTION_INDEX; 0 = device default.
Definition T7Config.hpp:76
std::string section
"boards.labjack_1"
Definition T7Config.hpp:69
uint8_t slot() const
Elodin slot, same rule as BoardConfig::slot(): board_id % 10, 0 -> 10.
Definition T7Config.hpp:89
One streamed analog input.
Definition T7Config.hpp:37
double ljtr_ohms
RTD: the tick's fixed resistor, 1k/10k/100k/1M by model.
Definition T7Config.hpp:57
int negative_ch() const
AIN::_NEGATIVE_CH value: 199 = single-ended, else the paired odd input.
Definition T7Config.hpp:62
double r0_ohms
RTD: resistance at 0 C, 100 (Pt100) or 1000 (Pt1000).
Definition T7Config.hpp:56
int ain
AIN number on the device, 0-13.
Definition T7Config.hpp:38
double vref_v
RTD: the tick's reference.
Definition T7Config.hpp:59
std::string tc_type
Thermocouple type letter (kind == "TC" only): "K".
Definition T7Config.hpp:43
std::string kind
"PT" | "TC" | "LC" | "RTD" | "VOLTAGE" — what is wired to it.
Definition T7Config.hpp:39
double shunt_ohms
PT "4-20mA": the resistor the loop current crosses.
Definition T7Config.hpp:50
std::string signal
PT output: "0-5V" "0.5-4.5V" "1-5V" "0-10V" "4-20mA".
Definition T7Config.hpp:49
double full_scale
PT: psi at full output. LC: kg at rated output.
Definition T7Config.hpp:48
double range_v
+/- input range in volts: 10, 1, 0.1 or 0.01.
Definition T7Config.hpp:41
std::string role
Sensor name, e.g. "LOX Tank" — what the GUI calls it.
Definition T7Config.hpp:40
double excitation_v
LC: bridge excitation voltage.
Definition T7Config.hpp:52
double sensitivity_mv_per_v
LC: rated output, mV per V of excitation.
Definition T7Config.hpp:51
bool differential
true: AIN(ain) - AIN(ain+1); ain must be even.
Definition T7Config.hpp:42