STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
fsw::t7 Namespace Reference

Namespaces

namespace  ljm_code
 LJM and device error codes the session acts on (labjack/ljm_constants, LJM errorcodes).
namespace  anonymous_namespace{T7Convert.cpp}
namespace  anonymous_namespace{LjmT7Device.cpp}

Classes

struct  T7CalChannel
 One T7 input as calibration sees it. More...
class  T7CalibrationMap
 Every PT / LC / TC input on every enabled T7, from config. More...
class  T7Error
 A device failure. More...
class  T7Device
 The device seam. More...
struct  StreamPlan
 What to write before streaming and what to stream, derived from a board's config. More...
struct  Sample
 One published value. More...
struct  ColdJunction
 One scan's thermocouple cold-junction temperature (the T7's terminals), in °C. More...
struct  Block
 A decoded LJM_eStreamRead block. More...
class  T7Session
 One T7's stream: open, configure, start, then read blocks until something throws. More...
class  FakeT7Unit
 The stand-in T7 itself, as distinct from a connection to it. More...
class  FakeT7Device
 A connection to a stand-in T7, for tests and for running the bridge with no hardware (t7_bridge --fake). More...
class  LjmT7Device
 A T7 reached over Ethernet through LabJack's LJM library. More...

Functions

uint8_t t7_logical_channel (uint8_t slot, uint8_t ain)
 Logical calibration channel for a T7 input.
uint16_t t7_uid (int board_id, int ain)
 uid of a T7 input: board_id * 100 + ain, the ESP32 scheme with the AIN as connector.
int32_t t7_counts (double volts)
 The calibration "ADC code" for a T7 reading: microvolts, rounded and clamped to int32.
double t7_volts (double counts)
 Volts from a calibration code.
std::array< uint8_t, 2 > cjc_table_id (uint8_t slot)
 Cold-junction table id for a slot.
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.
double cjc_temp_c (double ain14_v, double device_offset_k, double cjc_offset_k)
 Cold-junction temperature (C) from a streamed AIN14 reading.
double pt_psi (double volts, const config::T7Channel &ch)
 PT: linear between the signal's zero and full-scale outputs.
double lc_kg (double volts, const config::T7Channel &ch)
 LC: a bridge's output is sensitivity x excitation at rated load.
double tc_c (double volts, double cold_junction_c)
 Type K thermocouple: the measured EMF plus the EMF the cold junction subtracts.
double rtd_ohms (double volts, const config::T7Channel &ch)
 RTD on an LJTick-Resistance: the divider's output volts -> the RTD's ohms.
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).
const char * calibrated_field (const std::string &kind)
 The Elodin field a calibrated channel of this kind publishes ("pressure_psi", ...), or "" for a kind with no calibrated table (VOLTAGE).
std::array< uint8_t, 2 > table_id (uint8_t slot, uint8_t ain)
 Table id for one AIN: {0x26, (slot-1)*0x20 + ain}, the same layout as the ESP32 boards.
std::string entity_name (uint8_t slot, uint8_t ain)
 Elodin entity name for one AIN, e.g.
std::array< uint8_t, 2 > calibrated_table_id (uint8_t slot, uint8_t ain)
 Calibrated table for one AIN: table_id + 0x10, e.g.
std::string calibrated_entity_name (uint8_t slot, uint8_t ain)
 Calibrated entity name, e.g.
bool is_stream_not_running (int code)
 True for every way a stop can answer "there was no stream to stop".
StreamPlan plan_stream (const config::T7Board &board)

Variables

constexpr uint8_t kCjcTableOffset = 0x0F
 Raw-table offset (within a slot's 32-entry block) of the cold-junction table: AIN15 does not exist on a T7, so the slot is free.
constexpr uint8_t kT7LogicalBase = 128
 First logical calibration channel for T7 inputs.
constexpr double kAin14SlopeKPerV = -92.6
 The T7's internal temperature sensor (an LM94021 on AIN14) reads "Device temperature K = volts * -92.6 + 467.6" (T-series datasheet 18.0 Internal Temp Sensor; the same values are the nominal Temp_Slope / Temp_Offset in 20.0.1 T7 Calibration Constants).
constexpr double kAin14NominalOffsetK = 467.6
 Nominal AIN14 offset (K), datasheet 18.0.
constexpr uint8_t kTypeHi = 0x26
 Elodin table-id high byte for T7 analog inputs (0x20-0x25 are the ESP32 sensor types).
constexpr double kDummyValue = -9999.0
 What LJM writes into a scan lost to stream auto-recovery (LJM_DUMMY_VALUE).
constexpr uint8_t kCjcAin = 14
 The T7's internal temperature sensor, streamed for thermocouple cold-junction compensation whenever a board has a TC channel.

Function Documentation

◆ calibrated_entity_name()

std::string fsw::t7::calibrated_entity_name ( uint8_t slot,
uint8_t ain )

Calibrated entity name, e.g.

"T71_Cal.AIN3" (ESP32: "PT1_Cal.CH3").

Definition at line 34 of file T7Stream.cpp.

Referenced by main(), and main().

◆ calibrated_field()

const char * fsw::t7::calibrated_field ( const std::string & kind)

The Elodin field a calibrated channel of this kind publishes ("pressure_psi", ...), or "" for a kind with no calibrated table (VOLTAGE).

Same names as the ESP32 boards' tables.

Definition at line 70 of file T7Convert.cpp.

Referenced by main(), and main().

◆ calibrated_table_id()

std::array< uint8_t, 2 > fsw::t7::calibrated_table_id ( uint8_t slot,
uint8_t ain )

Calibrated table for one AIN: table_id + 0x10, e.g.

{0x26, 0x13} for slot 1 AIN3.

Definition at line 30 of file T7Stream.cpp.

References kTypeHi.

Referenced by main(), main(), and fsw::config::anonymous_namespace{SensorTables.cpp}::makeT7Ref().

◆ cjc_device_offset_k()

double fsw::t7::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 at line 17 of file T7Convert.cpp.

References kAin14SlopeKPerV.

Referenced by main(), and fsw::t7::T7Session::start().

◆ cjc_table_id()

std::array< uint8_t, 2 > fsw::t7::cjc_table_id ( uint8_t slot)

Cold-junction table id for a slot.

Definition at line 33 of file T7Calibration.cpp.

References kCjcTableOffset, and kTypeHi.

Referenced by fsw::t7::T7CalibrationMap::raw_tables(), and anonymous_namespace{t7_bridge_main.cpp}::run_board().

◆ cjc_temp_c()

double fsw::t7::cjc_temp_c ( double ain14_v,
double device_offset_k,
double cjc_offset_k )

Cold-junction temperature (C) from a streamed AIN14 reading.

Definition at line 21 of file T7Convert.cpp.

References kAin14SlopeKPerV.

Referenced by main(), and fsw::t7::T7Session::read().

◆ entity_name()

std::string fsw::t7::entity_name ( uint8_t slot,
uint8_t ain )

Elodin entity name for one AIN, e.g.

"T71.AIN3".

Definition at line 26 of file T7Stream.cpp.

Referenced by main().

◆ is_stream_not_running()

bool fsw::t7::is_stream_not_running ( int code)

True for every way a stop can answer "there was no stream to stop".

Definition at line 17 of file T7Stream.cpp.

References fsw::t7::ljm_code::kDeviceStreamNotRunning, fsw::t7::ljm_code::kStreamNotInitialized, and fsw::t7::ljm_code::kStreamNotRunning.

Referenced by fsw::t7::T7Session::start().

◆ lc_kg()

double fsw::t7::lc_kg ( double volts,
const config::T7Channel & ch )

LC: a bridge's output is sensitivity x excitation at rated load.

Definition at line 46 of file T7Convert.cpp.

References ch(), and volts().

Referenced by main(), and main().

◆ plan_stream()

StreamPlan fsw::t7::plan_stream ( const config::T7Board & board)

Definition at line 38 of file T7Stream.cpp.

References board(), kCjcAin, and p.

Referenced by main(), and fsw::t7::T7Session::T7Session().

◆ pt_psi()

double fsw::t7::pt_psi ( double volts,
const config::T7Channel & ch )

PT: linear between the signal's zero and full-scale outputs.

Definition at line 25 of file T7Convert.cpp.

References ch(), and volts().

Referenced by anonymous_namespace{t7_bridge_main.cpp}::fake_signal(), main(), and main().

◆ rtd_c()

double fsw::t7::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 at line 64 of file T7Convert.cpp.

References ch(), fsw::calibration::rtd::CVDCoeffs::R0, fsw::calibration::rtd::resistance_to_temp_cvd_full(), rtd_ohms(), and volts().

Referenced by main(), and main().

◆ rtd_ohms()

double fsw::t7::rtd_ohms ( double volts,
const config::T7Channel & ch )

RTD on an LJTick-Resistance: the divider's output volts -> the RTD's ohms.

NaN outside (0, vref_v), where the divider cannot be inverted (open or shorted RTD).

Definition at line 58 of file T7Convert.cpp.

References ch(), and volts().

Referenced by main(), and rtd_c().

◆ t7_counts()

int32_t fsw::t7::t7_counts ( double volts)

The calibration "ADC code" for a T7 reading: microvolts, rounded and clamped to int32.

Definition at line 21 of file T7Calibration.cpp.

References volts().

Referenced by main(), and main().

◆ t7_logical_channel()

uint8_t fsw::t7::t7_logical_channel ( uint8_t slot,
uint8_t ain )

Logical calibration channel for a T7 input.

Definition at line 13 of file T7Calibration.cpp.

References kT7LogicalBase.

Referenced by main(), and fsw::t7::T7CalibrationMap::T7CalibrationMap().

◆ t7_uid()

uint16_t fsw::t7::t7_uid ( int board_id,
int ain )

uid of a T7 input: board_id * 100 + ain, the ESP32 scheme with the AIN as connector.

Definition at line 17 of file T7Calibration.cpp.

References board_id.

Referenced by fsw::t7::T7CalibrationMap::T7CalibrationMap().

◆ t7_volts()

double fsw::t7::t7_volts ( double counts)

Volts from a calibration code.

Definition at line 29 of file T7Calibration.cpp.

Referenced by main().

◆ table_id()

std::array< uint8_t, 2 > fsw::t7::table_id ( uint8_t slot,
uint8_t ain )

Table id for one AIN: {0x26, (slot-1)*0x20 + ain}, the same layout as the ESP32 boards.

The calibrated counterpart, when there is one, takes +0x10 as theirs does.

Definition at line 22 of file T7Stream.cpp.

References kTypeHi.

Referenced by main(), fsw::t7::T7CalibrationMap::raw_tables(), and anonymous_namespace{t7_bridge_main.cpp}::run_board().

◆ tc_c()

double fsw::t7::tc_c ( double volts,
double cold_junction_c )

Type K thermocouple: the measured EMF plus the EMF the cold junction subtracts.

Definition at line 53 of file T7Convert.cpp.

References fsw::calibration::type_k_c_from_mv(), fsw::calibration::type_k_mv_from_c(), and volts().

Referenced by main(), and main().

Variable Documentation

◆ kAin14NominalOffsetK

double fsw::t7::kAin14NominalOffsetK = 467.6
constexpr

Nominal AIN14 offset (K), datasheet 18.0.

Only the fake T7 uses it; a real one is solved.

Definition at line 27 of file T7Convert.hpp.

Referenced by fsw::t7::FakeT7Device::volts().

◆ kAin14SlopeKPerV

double fsw::t7::kAin14SlopeKPerV = -92.6
constexpr

The T7's internal temperature sensor (an LM94021 on AIN14) reads "Device temperature K = volts * -92.6 + 467.6" (T-series datasheet 18.0 Internal Temp Sensor; the same values are the nominal Temp_Slope / Temp_Offset in 20.0.1 T7 Calibration Constants).

Each unit's own slope and offset are in flash. The offset is taken per unit at stream start instead of from the nominal 467.6 K: t7_bridge reads the device's own calibrated TEMPERATURE_DEVICE_K beside AIN14 (before the stream, which blocks command-response reads of the sensor) and solves for it, so the nominal slope only has to hold over the few kelvin the box drifts. (-92.379 / 465.129, used here before, are the U6's nominal constants, not the T7's.)

Definition at line 25 of file T7Convert.hpp.

Referenced by cjc_device_offset_k(), cjc_temp_c(), and fsw::t7::FakeT7Device::volts().

◆ kCjcAin

uint8_t fsw::t7::kCjcAin = 14
constexpr

The T7's internal temperature sensor, streamed for thermocouple cold-junction compensation whenever a board has a TC channel.

Published raw like any AIN (no calibrated table).

Definition at line 47 of file T7Stream.hpp.

Referenced by plan_stream(), and fsw::t7::FakeT7Device::volts().

◆ kCjcTableOffset

uint8_t fsw::t7::kCjcTableOffset = 0x0F
constexpr

Raw-table offset (within a slot's 32-entry block) of the cold-junction table: AIN15 does not exist on a T7, so the slot is free.

Entity T7<slot>.CJC, field temperature_c.

Definition at line 31 of file T7Calibration.hpp.

Referenced by cjc_table_id(), main(), and anonymous_namespace{t7_bridge_main.cpp}::run_board().

◆ kDummyValue

double fsw::t7::kDummyValue = -9999.0
constexpr

What LJM writes into a scan lost to stream auto-recovery (LJM_DUMMY_VALUE).

Definition at line 30 of file T7Stream.hpp.

Referenced by fsw::t7::T7Session::read(), and fsw::t7::FakeT7Device::stream_read().

◆ kT7LogicalBase

uint8_t fsw::t7::kT7LogicalBase = 128
constexpr

First logical calibration channel for T7 inputs.

ESP32 boards use (slot-1)*10 + connector, at most 80; T7 inputs use 128 + (slot-1)*16 + ain (128..255), so the two cannot collide in PTCalibrationManager / SensorCalibrationManager.

Definition at line 36 of file T7Calibration.hpp.

Referenced by t7_logical_channel().

◆ kTypeHi

uint8_t fsw::t7::kTypeHi = 0x26
constexpr

Elodin table-id high byte for T7 analog inputs (0x20-0x25 are the ESP32 sensor types).

Definition at line 27 of file T7Stream.hpp.

Referenced by calibrated_table_id(), cjc_table_id(), main(), and table_id().