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

Classes

struct  AdcSelfTestResult
 ADC self-test via internal TDAC. More...
struct  BiasReadResult

Enumerations

enum class  BiasResult : uint8_t { CONNECTED = 0 , AMBIGUOUS = 1 , DISCONNECTED = 2 }

Functions

AdcSelfTestResult run_adc_self_test (ADS126X &adc, uint8_t drdy_pin, uint8_t original_ref_neg, uint8_t original_ref_pos)
void sensor_bias_enable (ADS126X &adc)
 Call once before the connector loop.
BiasReadResult read_sensor_bias (ADS126X &adc, uint8_t drdy_pin, uint8_t adc_channel, uint8_t aincom, uint8_t settle_cycles=5)
 Read one connector with sensor bias already active.
void sensor_bias_disable (ADS126X &adc)
 Call once after the connector loop.

Variables

constexpr int32_t ADC_TDAC_EXPECTED_CODE = 214748364
constexpr int32_t ADC_TDAC_TOLERANCE = 2147484
constexpr int32_t SENSOR_BIAS_CLOSED_THRESHOLD = 858993459
constexpr int32_t SENSOR_BIAS_OPEN_THRESHOLD = 1288490188
constexpr unsigned long BIAS_SETTLE_MS = 50
constexpr uint8_t BIAS_AVG_SAMPLES = 4

Enumeration Type Documentation

◆ BiasResult

enum class SensorSelfTest::BiasResult : uint8_t
strong
Enumerator
CONNECTED 
AMBIGUOUS 
DISCONNECTED 

Definition at line 35 of file SensorSelfTest.h.

Function Documentation

◆ read_sensor_bias()

BiasReadResult SensorSelfTest::read_sensor_bias ( ADS126X & adc,
uint8_t drdy_pin,
uint8_t adc_channel,
uint8_t aincom,
uint8_t settle_cycles = 5 )
inline

Read one connector with sensor bias already active.

After switching the mux, flushes settle_cycles conversions so the digital filter (e.g. SINC5 needs 5) fully settles on the new channel before taking the real measurement.

Returns CONNECTED if |code| < SENSOR_BIAS_CLOSED_THRESHOLD, DISCONNECTED if |code| >= SENSOR_BIAS_OPEN_THRESHOLD, AMBIGUOUS otherwise (or on checksum failure).

Definition at line 128 of file SensorSelfTest.h.

References adc(), AMBIGUOUS, BIAS_AVG_SAMPLES, BIAS_SETTLE_MS, CONNECTED, delay(), delayMicroseconds(), digitalRead(), DISCONNECTED, LOW, r, SENSOR_BIAS_CLOSED_THRESHOLD, and SENSOR_BIAS_OPEN_THRESHOLD.

Referenced by run_self_test_cb(), test_sensor_bias_ambiguous(), test_sensor_bias_checksum_fails(), test_sensor_bias_connected(), and test_sensor_bias_disconnected().

◆ run_adc_self_test()

AdcSelfTestResult SensorSelfTest::run_adc_self_test ( ADS126X & adc,
uint8_t drdy_pin,
uint8_t original_ref_neg,
uint8_t original_ref_pos )
inline

◆ sensor_bias_disable()

void SensorSelfTest::sensor_bias_disable ( ADS126X & adc)
inline

Call once after the connector loop.

Restores SBMAG = 0.

Definition at line 181 of file SensorSelfTest.h.

References adc(), and ADS126X_BIAS_MAG_0.

Referenced by run_self_test_cb().

◆ sensor_bias_enable()

void SensorSelfTest::sensor_bias_enable ( ADS126X & adc)
inline

Call once before the connector loop.

Configures sensor bias on ADC1 with 10MΩ pull-up, bypasses PGA (bias voltages can exceed PGA input range), and turns off IDACs.

Definition at line 102 of file SensorSelfTest.h.

References adc(), ADS126X_BIAS_ADC1, ADS126X_BIAS_MAG_10M, ADS126X_BIAS_PULLUP, ADS126X_IDAC_MAG_0, BIAS_SETTLE_MS, and delay().

Referenced by run_self_test_cb().

Variable Documentation

◆ ADC_TDAC_EXPECTED_CODE

int32_t SensorSelfTest::ADC_TDAC_EXPECTED_CODE = 214748364
constexpr

◆ ADC_TDAC_TOLERANCE

int32_t SensorSelfTest::ADC_TDAC_TOLERANCE = 2147484
constexpr

◆ BIAS_AVG_SAMPLES

uint8_t SensorSelfTest::BIAS_AVG_SAMPLES = 4
constexpr

Definition at line 33 of file SensorSelfTest.h.

Referenced by read_sensor_bias().

◆ BIAS_SETTLE_MS

unsigned long SensorSelfTest::BIAS_SETTLE_MS = 50
constexpr

Definition at line 30 of file SensorSelfTest.h.

Referenced by read_sensor_bias(), and sensor_bias_enable().

◆ SENSOR_BIAS_CLOSED_THRESHOLD

int32_t SensorSelfTest::SENSOR_BIAS_CLOSED_THRESHOLD = 858993459
constexpr

Definition at line 23 of file SensorSelfTest.h.

Referenced by read_sensor_bias().

◆ SENSOR_BIAS_OPEN_THRESHOLD

int32_t SensorSelfTest::SENSOR_BIAS_OPEN_THRESHOLD = 1288490188
constexpr

Definition at line 24 of file SensorSelfTest.h.

Referenced by read_sensor_bias().