Skip to content

DAQ (Data Acquisition)¤

Errors raised by these methods are documented in Exceptions.

Interface¤

Bases: Instrument

Parameters:

  • name ¤

    (str) –

    Channel-name prefix for published data.

  • driver ¤

    (DAQDriverBase) –

    Concrete DAQ driver; owns its own transport::

    daq = InstroDAQ( "myDAQ", driver=Keysight34980A("USB0::0x0957::0x0507::MY44001757::INSTR"), )

  • publishers ¤

    (list[Publisher] | None, default: None ) –

    Publishers that receive emitted Measurement/Command data.

  • **kwargs ¤

    Default tags applied to every emitted Measurement/Command. Pass dataset_rid="<rid>" to auto-create a NominalCorePublisher (uses the on-disk 'default' Nominal credential).

name instance-attribute ¤

name = name

legacy_naming instance-attribute ¤

legacy_naming = legacy_naming

publishers instance-attribute ¤

publishers = publishers or []

default_tags instance-attribute ¤

default_tags: dict[str, str] = {}

channel_names property ¤

channel_names: tuple[str, ...]

Return an insertion-ordered snapshot of all published channel names.

Names are complete after one full daemon iteration: {name}.loop_time publishes every iteration, so call get_channel("loop_time", wait_for_new_samples=True) then read channel_names to ensure the complete set has arrived.

Raises:

  • RuntimeError

    No background buffer; start() was not called.

DEFAULT_SW_SAMPLE_RATE class-attribute ¤

DEFAULT_SW_SAMPLE_RATE: float = 1.0

driver property ¤

driver: DAQDriverBase

The underlying vendor driver. Source of truth for all channel/timing state.

channels property ¤

channels: tuple[DAQChannel, ...]

Frozen snapshot of all configured AI/AO/DI/DO channels (excludes relays).

ai_channels property ¤

Frozen snapshot of configured AI channels, keyed by alias.

ao_channels property ¤

Frozen snapshot of configured AO channels, keyed by alias.

di_channels property ¤

di_channels: Mapping[str, DigitalChannel]

Frozen snapshot of configured DI channels, keyed by alias.

do_channels property ¤

do_channels: Mapping[str, DigitalChannel]

Frozen snapshot of configured DO channels, keyed by alias.

relay_channels property ¤

relay_channels: Mapping[str, RelayChannel]

Frozen snapshot of configured relay channels, keyed by alias.

ai_hw_timing_config property ¤

ai_hw_timing_config: HWTimingConfig | None

ao_hw_timing_config property ¤

ao_hw_timing_config: HWTimingConfig | None

di_hw_timing_config property ¤

di_hw_timing_config: HWTimingConfig | None

do_hw_timing_config property ¤

do_hw_timing_config: HWTimingConfig | None

is_hw_timing_configured property ¤

is_hw_timing_configured: bool

True once configure_ai_hw_sample_rate() has programmed the AI sample clock.

is_sw_timing_configured property ¤

is_sw_timing_configured: bool

True once configure_ai_sw_sample_rate() has set a software-timed polling rate.

background_interval property writable ¤

background_interval: float

Daemon loop period (s); 0 unless configure_ai_sw_sample_rate() set a software-timed rate.

add_publisher ¤

add_publisher(publisher: Publisher)

Register a publisher to receive this instrument's Measurement/Command data.

publish ¤

publish(data: Measurement | Command, **kwargs)

Fan data out to every configured publisher; kwargs pass through.

add_background_daemon_function ¤

add_background_daemon_function(method: Callable, *args, **kwargs)

Append method to the daemon's call list. Use define_background_daemon to replace instead.

get_channel ¤

get_channel(
    channel_name: str,
    length: int = 1,
    wait_for_new_samples: bool = False,
    timeout: float = 10.0,
) -> Measurement

Return the most recent length samples for channel_name from the in-memory buffer.

If the channel does not exist yet, or no sample is available, the code will always block until timeout expires.

Parameters:

  • channel_name ¤

    (str) –

    Name of the channel to retrieve.

  • length ¤

    (int, default: 1 ) –

    Number of trailing samples to return.

  • wait_for_new_samples ¤

    (bool, default: False ) –

    Block until at least length new values arrive.

  • timeout ¤

    (float, default: 10.0 ) –

    Seconds to wait when insufficient data exists or wait_for_new_samples=True.

Raises:

  • RuntimeError

    No background buffer; start() was not called.

  • ChannelNotFoundError

    channel had no values and no data appeared before timeout. wait_for_new_samples=True and channel did not appear within timeout.

  • ChannelValueTimeoutError

    wait_for_new_samples=True and values did not arrive within timeout.

get_single_channel_value ¤

get_single_channel_value(channel_name: str) -> float | None

Return the most recent sample for channel_name from the in-memory buffer.

This will not wait, if data is not available then None is returned.

Parameters:

  • channel_name ¤

    (str) –

    Name of the channel to retrieve.

Raises:

  • RuntimeError

    No background buffer; start() was not called.

define_background_daemon ¤

define_background_daemon(method: Callable, *args, **kwargs)

Replace all daemon functions with a single method (called with the given args).

open ¤

open()

Open the underlying driver.

close ¤

close()

Run full teardown unconditionally: daemon, then publishers, then the driver, which owns its idempotency.

configure_voltage_input ¤

configure_voltage_input(
    physical_channel: str,
    *,
    alias: str | None = None,
    range_min: float = -10.0,
    range_max: float = 10.0,
    scaler: Scaler | None = None,
    terminal_config: str | TerminalConfig | None = None,
)

Configure an analog voltage input channel.

Parameters:

  • physical_channel ¤

    (str) –

    Vendor-specific channel id (e.g. "ai0" or "Dev1/ai0").

  • alias ¤

    (str | None, default: None ) –

    Friendly name; defaults to physical_channel.

  • range_min ¤

    (float, default: -10.0 ) –

    Lower voltage range (volts).

  • range_max ¤

    (float, default: 10.0 ) –

    Upper voltage range (volts).

  • scaler ¤

    (Scaler | None, default: None ) –

    Optional Scaler applied to AI samples after read.

  • terminal_config ¤

    (str | TerminalConfig | None, default: None ) –

    Terminal wiring (RSE / NRSE / DIFF) for the channel.

configure_voltage_output ¤

configure_voltage_output(
    physical_channel: str,
    *,
    alias: str | None = None,
    range_min: float = -10.0,
    range_max: float = 10.0,
    scaler: Scaler | None = None,
)

Configure an analog voltage output channel.

Parameters:

  • physical_channel ¤

    (str) –

    Vendor-specific channel id (e.g. "ao0" or "Dev1/ao0").

  • alias ¤

    (str | None, default: None ) –

    Friendly name; defaults to physical_channel.

  • range_min ¤

    (float, default: -10.0 ) –

    Lower voltage range (volts).

  • range_max ¤

    (float, default: 10.0 ) –

    Upper voltage range (volts).

  • scaler ¤

    (Scaler | None, default: None ) –

    Optional Scaler for the channel.

configure_current_input ¤

configure_current_input(
    physical_channel: str,
    *,
    alias: str | None = None,
    range_min: float = 0.0,
    range_max: float = 0.02,
    scaler: Scaler | None = None,
)

Configure an analog current input channel.

Parameters:

  • physical_channel ¤

    (str) –

    Vendor-specific channel id (e.g. "ai0" or "Dev1/ai0").

  • alias ¤

    (str | None, default: None ) –

    Friendly name; defaults to physical_channel.

  • range_min ¤

    (float, default: 0.0 ) –

    Lower current range (amps).

  • range_max ¤

    (float, default: 0.02 ) –

    Upper current range (amps).

  • scaler ¤

    (Scaler | None, default: None ) –

    Optional Scaler applied to AI samples after read.

configure_current_output ¤

configure_current_output(
    physical_channel: str,
    *,
    alias: str | None = None,
    range_min: float = 0.0,
    range_max: float = 0.02,
    scaler: Scaler | None = None,
)

Configure an analog current output channel.

Parameters:

  • physical_channel ¤

    (str) –

    Vendor-specific channel id (e.g. "ao0" or "Dev1/ao0").

  • alias ¤

    (str | None, default: None ) –

    Friendly name; defaults to physical_channel.

  • range_min ¤

    (float, default: 0.0 ) –

    Lower current range (amps).

  • range_max ¤

    (float, default: 0.02 ) –

    Upper current range (amps).

  • scaler ¤

    (Scaler | None, default: None ) –

    Optional Scaler for the channel.

configure_thermocouple_input ¤

configure_thermocouple_input(
    physical_channel: str,
    tc_type: str | TC_TYPE,
    *,
    unit: str | TC_UNIT,
    alias: str | None = None,
    range_min: float = 0.0,
    range_max: float = 100.0,
    scaler: Scaler | None = None,
    cjc_source: str | CJCSource = INTERNAL,
    cjc_temp: float | None = None,
    cjc_channel: str | None = None,
    tc_input_scaler: Scaler | None = None,
)

Configure a thermocouple input channel.

Parameters:

  • physical_channel ¤

    (str) –

    Vendor-specific channel id (e.g. "ai0" or "Dev1/ai0").

  • tc_type ¤

    (str | TC_TYPE) –

    Thermocouple type — one of B, E, J, K, N, R, S, T.

  • unit ¤

    (str | TC_UNIT) –

    Temperature unit for range_min/range_max, cjc_temp, and returned readings.

  • alias ¤

    (str | None, default: None ) –

    Friendly name; defaults to physical_channel.

  • range_min ¤

    (float, default: 0.0 ) –

    Lower temperature range (in unit).

  • range_max ¤

    (float, default: 100.0 ) –

    Upper temperature range (in unit).

  • scaler ¤

    (Scaler | None, default: None ) –

    Optional Scaler applied to AI samples after read.

  • cjc_source ¤

    (str | CJCSource, default: INTERNAL ) –

    Cold-junction compensation source (internal / constant / channel).

  • cjc_temp ¤

    (float | None, default: None ) –

    Cold-junction temperature when cjc_source is CONSTANT, expressed in unit.

  • cjc_channel ¤

    (str | None, default: None ) –

    Channel supplying cold-junction temperature when cjc_source is CHANNEL.

  • tc_input_scaler ¤

    (Scaler | None, default: None ) –

    Volts-domain scaler applied before temperature conversion if amplifier was used (LabJack only).

configure_digital_input ¤

configure_digital_input(
    physical_channel: str,
    *,
    logic: str | Logic = HIGH,
    logic_level: float | None = None,
    alias: str | None = None,
)

Configure a digital input line channel.

Parameters:

  • physical_channel ¤

    (str) –

    Vendor-specific line id (e.g. "port0/line3" on NI, "FIO0" on LabJack).

  • logic ¤

    (str | Logic, default: HIGH ) –

    Active-HIGH or active-LOW.

  • logic_level ¤

    (float | None, default: None ) –

    Voltage threshold (volts); the driver default is used when None.

  • alias ¤

    (str | None, default: None ) –

    Friendly name; defaults to physical_channel.

configure_digital_output ¤

configure_digital_output(
    physical_channel: str,
    *,
    logic: str | Logic = HIGH,
    logic_level: float | None = None,
    alias: str | None = None,
)

Configure a digital output line channel.

Parameters:

  • physical_channel ¤

    (str) –

    Vendor-specific line id (e.g. "port0/line3" on NI, "FIO0" on LabJack).

  • logic ¤

    (str | Logic, default: HIGH ) –

    Active-HIGH or active-LOW.

  • logic_level ¤

    (float | None, default: None ) –

    Voltage threshold (volts); the driver default is used when None.

  • alias ¤

    (str | None, default: None ) –

    Friendly name; defaults to physical_channel.

configure_analog_channel ¤

configure_analog_channel(
    direction: Direction,
    physical_channel: str,
    alias: str | None = None,
    range_min: float = -10.0,
    range_max: float = 10.0,
    scaler: Scaler | None = None,
    terminal_config: TerminalConfig | None = None,
)

Configure an analog channel.

Parameters:

  • direction ¤

    (Direction) –

    INPUT or OUTPUT.

  • physical_channel ¤

    (str) –

    Vendor-specific channel id (e.g. "ai0" or "Dev1/ai0").

  • alias ¤

    (str | None, default: None ) –

    Friendly name; defaults to physical_channel.

  • range_min ¤

    (float, default: -10.0 ) –

    Lower voltage range (volts).

  • range_max ¤

    (float, default: 10.0 ) –

    Upper voltage range (volts).

  • scaler ¤

    (Scaler | None, default: None ) –

    Optional Scaler applied to AI samples after read.

  • terminal_config ¤

    (TerminalConfig | None, default: None ) –

    Terminal wiring (RSE / NRSE / DIFF) for the channel.

configure_ai_sample_rate ¤

configure_ai_sample_rate(
    sample_rate: float, samples_per_channel: int | None = None, **kwargs
)

Configure the hardware sample clock for AI channels.

Parameters:

  • sample_rate ¤

    (float) –

    Sample rate (Hz). Applies to all AI channels.

  • samples_per_channel ¤

    (int | None, default: None ) –

    Samples per channel per read_analog() call; defaults to 10 % of sample_rate (e.g. 100 at 1 kHz).

configure_ai_hw_sample_rate ¤

configure_ai_hw_sample_rate(
    sample_rate: float, samples_per_channel: int | None = None
)

Configure the hardware sample clock for AI channels.

Parameters:

  • sample_rate ¤

    (float) –

    Sample rate (Hz). Applies to all AI channels.

  • samples_per_channel ¤

    (int | None, default: None ) –

    Samples per channel per read_analog() call; defaults to 10 % of sample_rate (e.g. 100 at 1 kHz).

configure_ai_sw_sample_rate ¤

configure_ai_sw_sample_rate(sample_rate: float)

Configure the software-timed polling rate for AI channels.

Parameters:

  • sample_rate ¤

    (float) –

    Rate (Hz) at which the background daemon polls AI channels.

start ¤

start(background: bool = True, **kwargs)

Start acquisition: hardware-timed, or the software-timed daemon when SW timing is configured.

With no AI timing configured, background=True falls back to software timing at 1 Hz.

Parameters:

  • background ¤

    (bool, default: True ) –

    When True (default), spin the daemon thread to continuously fetch the buffer. When False, begin hardware acquisition only and fetch the buffer yourself by calling read_analog(). Software-timed acquisition requires True — the daemon is what does the timing — so False logs an error and starts nothing.

  • **kwargs ¤

    channel_type (NI only) selects which DAQmx task to start.

stop ¤

stop(**kwargs)

Stop hardware acquisition and the background daemon; tolerant teardown when not open.

read_analog ¤

read_analog(**kwargs) -> Measurement | list[Measurement]

Dispatch a hardware-timed buffer fetch or a software-timed conversion based on configuration.

Each branch publishes its own Measurements; this dispatcher does not. Either timing mode with the background daemon running raises — the daemon owns the reads. Returns a single Measurement when channels share a timebase, otherwise one Measurement per timebase cluster.

read ¤

read(channel: str, **kwargs) -> Measurement

Read one AI/DI channel by alias; returns its Measurement.

read_batch ¤

read_batch(
    channels: list[str] | None = None, **kwargs
) -> dict[str, Measurement]

Read AI/DI channels by alias (None = all inputs); returns {alias: Measurement}, analog via read_analog (or the daemon buffer while it runs), digital per line/port.

write ¤

write(channel: str, value: float | int | bool, **kwargs) -> Command

Write value to one AO/DO channel by alias; returns its Command.

write_batch ¤

write_batch(
    channels: list[str],
    values: list[float | int | bool],
    continue_on_failed_write: bool = False,
    **kwargs,
) -> list[Command]

Write values[i] to output channels[i] (alias); continue_on_failed_write logs and skips failed writes instead of raising.

write_analog_value ¤

write_analog_value(channel: str, value: float, **kwargs) -> Command

Write value (volts) to AO channel (alias). Raises KeyError if channel isn't configured.

configure_digital_line ¤

configure_digital_line(
    direction: Direction,
    physical_channel: str,
    logic: Logic,
    logic_level: float | None = None,
    alias: str | None = None,
)

Configure a digital line channel.

Parameters:

  • direction ¤

    (Direction) –

    INPUT or OUTPUT.

  • physical_channel ¤

    (str) –

    Vendor-specific line id (e.g. "port0/line3" on NI, "5101/3" on Keysight, "FIO0" on LabJack).

  • logic ¤

    (Logic) –

    Active-HIGH or active-LOW.

  • logic_level ¤

    (float | None, default: None ) –

    Voltage threshold (volts); the driver default is used when None.

  • alias ¤

    (str | None, default: None ) –

    Friendly name; defaults to physical_channel.

configure_digital_port ¤

configure_digital_port(
    direction: Direction,
    physical_channel: str,
    logic: Logic,
    port_width: DigitalPortWidth,
    logic_level: float | None = None,
    alias: str | None = None,
)

Configure a digital port channel.

Parameters:

  • direction ¤

    (Direction) –

    INPUT or OUTPUT.

  • physical_channel ¤

    (str) –

    Vendor-specific port id (e.g. "port0" on NI, "5101" on Keysight, "AUXPORT0" on MCC).

  • logic ¤

    (Logic) –

    Active-HIGH or active-LOW.

  • port_width ¤

    (DigitalPortWidth) –

    Port width in bits (8/16/32/64).

  • logic_level ¤

    (float | None, default: None ) –

    Voltage threshold (volts); the driver default is used when None.

  • alias ¤

    (str | None, default: None ) –

    Friendly name; defaults to physical_channel.

write_digital_line ¤

write_digital_line(channel: str, data: int, **kwargs) -> Command

Write 0/1 to DO line channel (alias). Raises KeyError if channel isn't configured.

read_digital_line ¤

read_digital_line(channel: str, **kwargs) -> Measurement

Read DI line channel (alias). Raises KeyError if channel isn't configured.

write_digital_port ¤

write_digital_port(channel: str, data: int, **kwargs) -> Command

Write data to DO port channel (alias). Raises KeyError if channel isn't configured.

read_digital_port ¤

read_digital_port(channel: str, **kwargs) -> Measurement

Read DI port channel (alias). Raises KeyError if channel isn't configured.

configure_relay_channel ¤

configure_relay_channel(
    physical_channel: str, alias: str | None = None
)

Configure a relay channel (physical_channel e.g. "3101" = slot 3 / channel 101).

close_relay ¤

close_relay(channel: str, **kwargs) -> Command

Close relay channel (alias) — connects the circuit.

open_relay ¤

open_relay(channel: str, **kwargs) -> Command

Open relay channel (alias) — disconnects the circuit.

get_actual_sample_rate ¤

get_actual_sample_rate() -> float | None

Hardware's actual sample rate after start(); None if unsupported or not started.

get_points_in_buffer ¤

get_points_in_buffer(**kwargs) -> Measurement

Publish the current DAQ buffer depth on channel {name}.buffer.

Types & Configuration¤

DAQ shared types: vendors, channel types, terminal configs, hardware-timing config.

AnalogChannelUnion module-attribute ¤

DAQVendor ¤

Bases: Enum

NI class-attribute instance-attribute ¤

NI = 'NI DAQmx'

LABJACK_T_SERIES class-attribute instance-attribute ¤

LABJACK_T_SERIES = 'LabJack T-Series'

KEYSIGHT_34980 class-attribute instance-attribute ¤

KEYSIGHT_34980 = 'KEYSIGHT_34980'

MCC class-attribute instance-attribute ¤

MCC = 'MCC DAQ'

ChannelType ¤

Bases: Enum

ANALOG_INPUT class-attribute instance-attribute ¤

ANALOG_INPUT = 'ai'

ANALOG_OUTPUT class-attribute instance-attribute ¤

ANALOG_OUTPUT = 'ao'

DIGITAL_INPUT class-attribute instance-attribute ¤

DIGITAL_INPUT = 'di'

DIGITAL_OUTPUT class-attribute instance-attribute ¤

DIGITAL_OUTPUT = 'do'

Logic ¤

Bases: Enum

HIGH class-attribute instance-attribute ¤

HIGH = 'HIGH'

LOW class-attribute instance-attribute ¤

LOW = 'LOW'

Direction ¤

Bases: Enum

INPUT class-attribute instance-attribute ¤

INPUT = 'INPUT'

OUTPUT class-attribute instance-attribute ¤

OUTPUT = 'OUTPUT'

TerminalConfig ¤

Bases: Enum

DIFF class-attribute instance-attribute ¤

DIFF = 'DIFFERENTIAL'

NRSE class-attribute instance-attribute ¤

NRSE = 'NRSE'

RSE class-attribute instance-attribute ¤

RSE = 'RSE'

CJCSource ¤

Bases: Enum

INTERNAL class-attribute instance-attribute ¤

INTERNAL = 'INTERNAL'

CONSTANT class-attribute instance-attribute ¤

CONSTANT = 'CONSTANT'

CHANNEL class-attribute instance-attribute ¤

CHANNEL = 'CHANNEL'

HWTimingConfig dataclass ¤

HWTimingConfig(
    sample_rate: float, sample_period: int, samples_per_channel: int
)

sample_rate instance-attribute ¤

sample_rate: float

sample_period instance-attribute ¤

sample_period: int

samples_per_channel instance-attribute ¤

samples_per_channel: int

DAQChannel dataclass ¤

DAQChannel(*, physical_channel: str, alias: str, direction: Direction)

physical_channel instance-attribute ¤

physical_channel: str

alias instance-attribute ¤

alias: str

direction instance-attribute ¤

direction: Direction

AnalogChannel dataclass ¤

AnalogChannel(
    range_max: float,
    range_min: float,
    scaler: Scaler | None,
    terminal_config: TerminalConfig | None = None,
    *,
    physical_channel: str,
    alias: str,
    direction: Direction,
)

Bases: DAQChannel

range_max instance-attribute ¤

range_max: float

range_min instance-attribute ¤

range_min: float

scaler instance-attribute ¤

scaler: Scaler | None

terminal_config class-attribute instance-attribute ¤

terminal_config: TerminalConfig | None = None

physical_channel instance-attribute ¤

physical_channel: str

alias instance-attribute ¤

alias: str

direction instance-attribute ¤

direction: Direction

AnalogVoltageChannel dataclass ¤

AnalogVoltageChannel(
    range_max: float,
    range_min: float,
    scaler: Scaler | None,
    terminal_config: TerminalConfig | None = None,
    *,
    physical_channel: str,
    alias: str,
    direction: Direction,
)

Bases: DAQChannel

range_max instance-attribute ¤

range_max: float

range_min instance-attribute ¤

range_min: float

scaler instance-attribute ¤

scaler: Scaler | None

terminal_config class-attribute instance-attribute ¤

terminal_config: TerminalConfig | None = None

physical_channel instance-attribute ¤

physical_channel: str

alias instance-attribute ¤

alias: str

direction instance-attribute ¤

direction: Direction

AnalogCurrentChannel dataclass ¤

AnalogCurrentChannel(
    range_max: float,
    range_min: float,
    scaler: Scaler | None,
    *,
    physical_channel: str,
    alias: str,
    direction: Direction,
)

Bases: DAQChannel

range_max instance-attribute ¤

range_max: float

range_min instance-attribute ¤

range_min: float

scaler instance-attribute ¤

scaler: Scaler | None

physical_channel instance-attribute ¤

physical_channel: str

alias instance-attribute ¤

alias: str

direction instance-attribute ¤

direction: Direction

AnalogThermocoupleChannel dataclass ¤

AnalogThermocoupleChannel(
    range_max: float,
    range_min: float,
    scaler: Scaler | None,
    tc_type: TC_TYPE,
    cjc_source: CJCSource | None,
    cjc_temp: float | None,
    cjc_channel: str | None,
    unit: TC_UNIT,
    tc_input_scaler: Scaler | None = None,
    *,
    physical_channel: str,
    alias: str,
    direction: Direction,
)

Bases: DAQChannel

range_max instance-attribute ¤

range_max: float

range_min instance-attribute ¤

range_min: float

scaler instance-attribute ¤

scaler: Scaler | None

tc_type instance-attribute ¤

tc_type: TC_TYPE

cjc_source instance-attribute ¤

cjc_source: CJCSource | None

cjc_temp instance-attribute ¤

cjc_temp: float | None

cjc_channel instance-attribute ¤

cjc_channel: str | None

unit instance-attribute ¤

unit: TC_UNIT

tc_input_scaler class-attribute instance-attribute ¤

tc_input_scaler: Scaler | None = None

physical_channel instance-attribute ¤

physical_channel: str

alias instance-attribute ¤

alias: str

direction instance-attribute ¤

direction: Direction

DigitalPortWidth ¤

Bases: IntEnum

WIDTH_8 class-attribute instance-attribute ¤

WIDTH_8 = 8

WIDTH_16 class-attribute instance-attribute ¤

WIDTH_16 = 16

WIDTH_32 class-attribute instance-attribute ¤

WIDTH_32 = 32

WIDTH_64 class-attribute instance-attribute ¤

WIDTH_64 = 64

DigitalChannel dataclass ¤

DigitalChannel(
    logic_level: float | None,
    logic: Logic,
    *,
    physical_channel: str,
    alias: str,
    direction: Direction,
)

Bases: DAQChannel

logic_level instance-attribute ¤

logic_level: float | None

logic instance-attribute ¤

logic: Logic

physical_channel instance-attribute ¤

physical_channel: str

alias instance-attribute ¤

alias: str

direction instance-attribute ¤

direction: Direction

DigitalPortChannel dataclass ¤

DigitalPortChannel(
    logic_level: float | None,
    logic: Logic,
    width: DigitalPortWidth,
    *,
    physical_channel: str,
    alias: str,
    direction: Direction,
)

Bases: DigitalChannel

width instance-attribute ¤

physical_channel instance-attribute ¤

physical_channel: str

alias instance-attribute ¤

alias: str

direction instance-attribute ¤

direction: Direction

logic_level instance-attribute ¤

logic_level: float | None

logic instance-attribute ¤

logic: Logic

DigitalLineChannel dataclass ¤

DigitalLineChannel(
    logic_level: float | None,
    logic: Logic,
    bit_position: int | None = None,
    *,
    physical_channel: str,
    alias: str,
    direction: Direction,
)

Bases: DigitalChannel

bit_position class-attribute instance-attribute ¤

bit_position: int | None = None

physical_channel instance-attribute ¤

physical_channel: str

alias instance-attribute ¤

alias: str

direction instance-attribute ¤

direction: Direction

logic_level instance-attribute ¤

logic_level: float | None

logic instance-attribute ¤

logic: Logic

RelayChannel dataclass ¤

RelayChannel(
    *, physical_channel: str, alias: str, direction: Direction
)

Bases: DAQChannel

A relay channel routed via open/close. direction is always OUTPUT (relay control is a command).

physical_channel instance-attribute ¤

physical_channel: str

alias instance-attribute ¤

alias: str

direction instance-attribute ¤

direction: Direction

Scaling¤

DAQ scaling package.

LinearScaler ¤

LinearScaler(gain: float, offset: float, units: str)

Bases: Scaler

output = raw * gain + offset.

units property ¤

units: str

scale ¤

scale(raw: float) -> float

ReverseLinearScaler ¤

ReverseLinearScaler(gain: float, offset: float, units: str)

Bases: Scaler

output = (raw - offset) / gain — inverse of LinearScaler, e.g. to back out a measurement amplifier.

units property ¤

units: str

scale ¤

scale(raw: float) -> float

Scaler ¤

Bases: ABC

Convert a raw DAQ reading to a physical value and report the resulting units.

Scalers compose via ScalerPipeline (e.g. voltage-divider → thermocouple). The pipeline's reported units come from the last stage.

units abstractmethod property ¤

units: str

Physical units of the scaled output (e.g. "V", "degC", "psi").

scale abstractmethod ¤

scale(raw: float) -> float

Convert a raw DAQ reading to a physical value in :attr:units.

ScalerPipeline ¤

ScalerPipeline(stage: Scaler, *stages: Scaler)

Bases: Scaler

Apply scaler stages sequentially (e.g. voltage divider → thermocouple). Units come from the last stage.

units property ¤

units: str

scale ¤

scale(raw: float) -> float

Thermocouple Scaling¤

Thermocouple scaling for DAQ: voltage → °C with cold-junction compensation.

TC_TYPE ¤

Bases: Enum

B class-attribute instance-attribute ¤
B = 'B'
E class-attribute instance-attribute ¤
E = 'E'
J class-attribute instance-attribute ¤
J = 'J'
K class-attribute instance-attribute ¤
K = 'K'
N class-attribute instance-attribute ¤
N = 'N'
R class-attribute instance-attribute ¤
R = 'R'
S class-attribute instance-attribute ¤
S = 'S'
T class-attribute instance-attribute ¤
T = 'T'

TC_UNIT ¤

Bases: Enum

CELSIUS class-attribute instance-attribute ¤
CELSIUS = 'degC'
KELVIN class-attribute instance-attribute ¤
KELVIN = 'K'
FAHRENHEIT class-attribute instance-attribute ¤
FAHRENHEIT = 'degF'
RANKINE class-attribute instance-attribute ¤
RANKINE = 'degR'

ThermocoupleSensor ¤

ThermocoupleSensor(type: TC_TYPE, cjc_temp: float)

Bases: Scaler

Thermocouple voltage → °C with cold-junction compensation.

ThermocoupleSensor(TC_TYPE.K, cjc_temp=25.0) # Type K, 25 °C reference junction

Parameters:

  • type ¤
    (TC_TYPE) –

    Thermocouple type (B/E/J/K/N/R/S/T).

  • cjc_temp ¤
    (float) –

    Cold-junction reference temperature in °C.

units property ¤
units: str
scale ¤
scale(raw: float | int) -> float

Voltage (volts or millivolts per the thermocouples library) → temperature (°C).

InverseThermocoupleSensor ¤

InverseThermocoupleSensor(type: TC_TYPE, cjc_temp: float)

Bases: Scaler

Temperature (°C) → voltage with cold-junction compensation — inverse of ThermocoupleSensor.

InverseThermocoupleSensor(TC_TYPE.K, cjc_temp=25.0) # Type K, 25 °C reference junction

Parameters:

  • type ¤
    (TC_TYPE) –

    Thermocouple type (B/E/J/K/N/R/S/T).

  • cjc_temp ¤
    (float) –

    Cold-junction reference temperature in °C.

units property ¤
units: str
scale ¤
scale(raw: float | int) -> float

Temperature (°C) → voltage with cold-junction compensation.

kelvin_to_unit ¤

kelvin_to_unit(temp_k: float, unit: TC_UNIT) -> float

Convert a Kelvin temperature to unit.

unit_to_kelvin ¤

unit_to_kelvin(temp: float, unit: TC_UNIT) -> float

Convert a temperature in unit to Kelvin.

Driver Interface¤

Bases: ABC

Vendor DAQ driver contract.

The driver is the single source of truth for configured channels and timing config, held in private dicts/slots that __init__ initializes so every concrete driver has the same shape; subclasses call super().__init__() and then populate those privates inside their own configure_* methods (self._ai_channels[channel.alias] = channel, self._ai_hw_timing_config = hw_timing_config, etc.). Read-only @property accessors hand back frozen snapshots so the state can't be mutated from outside the configure_* path; InstroDAQ exposes the same snapshots for user introspection — it does not keep its own copies.

points_in_buffer instance-attribute ¤

points_in_buffer: int = 0

channels property ¤

channels: tuple[DAQChannel, ...]

Frozen snapshot of all configured AI/AO/DI/DO channels (excludes relays).

ai_channels property ¤

Frozen snapshot of configured AI channels, keyed by alias.

ao_channels property ¤

Frozen snapshot of configured AO channels, keyed by alias.

di_channels property ¤

di_channels: Mapping[str, DigitalChannel]

Frozen snapshot of configured DI channels, keyed by alias.

do_channels property ¤

do_channels: Mapping[str, DigitalChannel]

Frozen snapshot of configured DO channels, keyed by alias.

relay_channels property ¤

relay_channels: Mapping[str, RelayChannel]

Frozen snapshot of configured relay channels, keyed by alias.

ai_hw_timing_config property ¤

ai_hw_timing_config: HWTimingConfig | None

ao_hw_timing_config property ¤

ao_hw_timing_config: HWTimingConfig | None

di_hw_timing_config property ¤

di_hw_timing_config: HWTimingConfig | None

do_hw_timing_config property ¤

do_hw_timing_config: HWTimingConfig | None

open abstractmethod ¤

open()

Open the underlying transport (or verify the device is present, for handle-less SDKs).

close abstractmethod ¤

close()

Close every task/handle owned by the driver. Idempotent.

configure_ai_channel abstractmethod ¤

configure_ai_channel(channel: AnalogChannel)

Register an AI channel with the underlying driver (range, terminal mode, scaler — vendor-specific).

configure_ao_channel ¤

configure_ao_channel(channel: AnalogChannel)

Register an AO channel. Override if the driver supports analog output.

configure_ai_voltage_channel ¤

configure_ai_voltage_channel(channel: AnalogVoltageChannel)

Register an AI voltage channel. Override if the driver supports analog voltage input.

configure_ao_voltage_channel ¤

configure_ao_voltage_channel(channel: AnalogVoltageChannel)

Register an AO voltage channel. Override if the driver supports analog voltage output.

configure_ai_current_channel ¤

configure_ai_current_channel(channel: AnalogCurrentChannel)

Register an AI current channel. Override if the driver supports analog current input.

configure_ao_current_channel ¤

configure_ao_current_channel(channel: AnalogCurrentChannel)

Register an AO current channel. Override if the driver supports analog current output.

configure_ai_thermocouple_channel ¤

configure_ai_thermocouple_channel(channel: AnalogThermocoupleChannel)

Register an AI thermocouple channel. Override if the driver supports thermocouple input.

configure_ai_hw_timing abstractmethod ¤

configure_ai_hw_timing(hw_timing_config: HWTimingConfig)

Configure hardware-timed AI sampling at hw_timing_config.sample_rate.

Called before start() whenever InstroDAQ.configure_ai_sample_rate() is invoked. The driver should program the sample clock and any samples_per_channel buffer sizing the underlying SDK requires.

configure_di_line_channel abstractmethod ¤

configure_di_line_channel(
    physical_channel: str,
    logic: Logic,
    logic_level: float | None = None,
    alias: str | None = None,
)

Parse, program, and register a DI line channel.

configure_do_line_channel abstractmethod ¤

configure_do_line_channel(
    physical_channel: str,
    logic: Logic,
    logic_level: float | None = None,
    alias: str | None = None,
)

Parse, program, and register a DO line channel.

configure_di_port_channel ¤

configure_di_port_channel(
    physical_channel: str,
    logic: Logic,
    port_width: DigitalPortWidth,
    logic_level: float | None = None,
    alias: str | None = None,
)

Parse, program, and register a DI port channel. Override if the driver supports port-mode digital input.

configure_do_port_channel ¤

configure_do_port_channel(
    physical_channel: str,
    logic: Logic,
    port_width: DigitalPortWidth,
    logic_level: float | None = None,
    alias: str | None = None,
)

Parse, program, and register a DO port channel. Override if the driver supports port-mode digital output.

configure_di_channel ¤

configure_di_channel(channel: DigitalLineChannel)

Register a DI line channel. Override if the driver supports digital input.

configure_do_channel ¤

configure_do_channel(channel: DigitalLineChannel)

Register a DO line channel. Override if the driver supports digital output.

start abstractmethod ¤

start(**kwargs)

Start hardware-timed acquisition.

InstroDAQ passes channel_type=<ChannelType> when the user targets a specific task (e.g. on NI, where AI/AO/DI/DO each have their own DAQmx task). Drivers without that distinction can ignore it.

stop abstractmethod ¤

stop(**kwargs)

Stop a running acquisition and release any scan buffers. channel_type mirrors :meth:start.

read_analog abstractmethod ¤

read_analog() -> Any

Software-timed read of every configured AI channel.

Returns a vendor-specific payload that _read_to_measurements then unpacks into Measurements. response.dt should be None so the wrapper timestamps with wall-clock time.

fetch_analog abstractmethod ¤

fetch_analog() -> Any

Block until samples_per_channel new AI samples are available, then return them.

Drivers should set self.points_in_buffer for buffer-depth telemetry and return dt (ns per sample) so the wrapper can build contiguous timestamps via HWTimestamper.

get_actual_sample_rate ¤

get_actual_sample_rate() -> float | None

Actual hardware sample rate achieved after start().

Default returns None (driver doesn't know or hasn't started). Override on drivers whose SDK reports the effective rate (NI, MCC, LabJack T-series all do).

write_analog_value ¤

write_analog_value(channel: AnalogChannelUnion, value: float)

Write value to AO channel. Override if the driver supports analog output.

write_digital_line abstractmethod ¤

write_digital_line(channel: DigitalChannel, data: int)

Drive a single DO line. data is 0 or 1 (active-low channel.logic is handled in the driver).

read_digital_line abstractmethod ¤

read_digital_line(channel: DigitalChannel) -> int

Sample a single DI line. Returns 0 or 1 after applying channel.logic.

write_digital_port abstractmethod ¤

write_digital_port(channel: DigitalChannel, data: int)

Drive a multi-line DO port. data is an N-bit integer; bit i controls line i.

read_digital_port abstractmethod ¤

read_digital_port(channel: DigitalChannel) -> int

Sample a multi-line DI port. Returns an N-bit integer; bit i reflects line i.

define_relay_channel ¤

define_relay_channel(
    physical_channel: str, alias: str | None = None
) -> RelayChannel

Build a RelayChannel for physical_channel (e.g. "3101" = slot 3 / channel 101).

Default implementation suits the Keysight 34980A's slot/channel addressing; override if the driver needs different parsing. Overrides must also record the resulting channel on self._relay_channels.

close_relay ¤

close_relay(channel: RelayChannel)

Close the relay (connect the circuit). Override if the driver supports relays.

open_relay ¤

open_relay(channel: RelayChannel)

Open the relay (disconnect the circuit). Override if the driver supports relays.

Contiguous nanosecond timestamps for hardware-timed DAQ batches.

Anchors to the wall clock exactly once via seed(), then advances by sample period on every next_batch() call — eliminates timestamp overlap when consecutive reads return in rapid succession.

seed classmethod ¤

seed(
    t_wall: int, dt: int, length: int
) -> tuple[HWTimestamper, list[int]]

Anchor the timeline at t_wall ns (read-return time of the first batch).

next_batch ¤

next_batch(dt: int, length: int) -> list[int]

Return length ns timestamps at dt spacing, continuing from the previous batch.

Vendor Drivers¤

Keysight 34980A¤

Keysight 34980A Multifunction Switch/Measure Unit DAQ driver.

KeysightData dataclass ¤

KeysightData(
    data: str, timestamp: int | None = None, dt: int | None = None
)
data instance-attribute ¤
data: str
timestamp class-attribute instance-attribute ¤
timestamp: int | None = None
dt class-attribute instance-attribute ¤
dt: int | None = None

Keysight34980A ¤

Keysight34980A(
    visa_resource: str | VisaConfig, *, sync_system_clock: bool = True
)

Bases: DAQDriverBase

Keysight 34980A Multifunction Switch/Measure Unit.

Parameters:

  • visa_resource ¤
    (str | VisaConfig) –

    VISA resource string or full VisaConfig.

  • sync_system_clock ¤
    (bool, default: True ) –

    Sync the instrument clock to host UTC on open() so returned timestamps align with the host. Enabled by default.

points_in_buffer instance-attribute ¤
points_in_buffer: int = 0
channels property ¤
channels: tuple[DAQChannel, ...]

Frozen snapshot of all configured AI/AO/DI/DO channels (excludes relays).

ai_channels property ¤

Frozen snapshot of configured AI channels, keyed by alias.

ao_channels property ¤

Frozen snapshot of configured AO channels, keyed by alias.

di_channels property ¤
di_channels: Mapping[str, DigitalChannel]

Frozen snapshot of configured DI channels, keyed by alias.

do_channels property ¤
do_channels: Mapping[str, DigitalChannel]

Frozen snapshot of configured DO channels, keyed by alias.

relay_channels property ¤
relay_channels: Mapping[str, RelayChannel]

Frozen snapshot of configured relay channels, keyed by alias.

ai_hw_timing_config property ¤
ai_hw_timing_config: HWTimingConfig | None
ao_hw_timing_config property ¤
ao_hw_timing_config: HWTimingConfig | None
di_hw_timing_config property ¤
di_hw_timing_config: HWTimingConfig | None
do_hw_timing_config property ¤
do_hw_timing_config: HWTimingConfig | None
open ¤
open()
close ¤
close()
configure_ai_channel ¤
configure_ai_channel(channel: AnalogChannel)

Configure an AI channel: CONF:VOLT:DC at computed range, then add to ROUT:SCAN and enable timestamps.

configure_ai_hw_timing ¤
configure_ai_hw_timing(hw_timing_config: HWTimingConfig)

Configure TRIG:SOUR TIMER at the configured sample period and infinite count.

start ¤
start(**kwargs)

Enable timestamps and INIT the scan.

stop ¤
stop(**kwargs)

ABORt any pending scan.

read_analog ¤
read_analog() -> KeysightData
fetch_analog ¤
fetch_analog() -> KeysightData

Block until the buffer holds at least one full per-channel batch, then drain a channel-aligned chunk.

configure_di_line_channel ¤
configure_di_line_channel(
    physical_channel: str,
    logic: Logic,
    logic_level: float | None = None,
    alias: str | None = None,
)

Parse MNNN/B (slot/channel/bit), program the port for DI, and register the line.

configure_do_line_channel ¤
configure_do_line_channel(
    physical_channel: str,
    logic: Logic,
    logic_level: float | None = None,
    alias: str | None = None,
)

Parse MNNN/B (slot/channel/bit), program the port for DO, and register the line.

configure_di_port_channel ¤
configure_di_port_channel(
    physical_channel: str,
    logic: Logic,
    port_width: DigitalPortWidth,
    logic_level: float | None = None,
    alias: str | None = None,
)

Parse MNNN (slot/channel), program the port for DI, and register the port.

configure_do_port_channel ¤
configure_do_port_channel(
    physical_channel: str,
    logic: Logic,
    port_width: DigitalPortWidth,
    logic_level: float | None = None,
    alias: str | None = None,
)

Parse MNNN (slot/channel), program the port for DO, and register the port.

write_digital_line ¤
write_digital_line(channel: DigitalChannel, data: int) -> None
read_digital_line ¤
read_digital_line(channel: DigitalChannel) -> int
write_digital_port ¤
write_digital_port(channel: DigitalChannel, data: int)

Drive a DO port as one N-bit integer. Active-low is applied in hardware via CONF:DIG:POL.

read_digital_port ¤
read_digital_port(channel: DigitalChannel) -> int

Sample a DI port as one N-bit integer. Active-low is applied in hardware via CONF:DIG:POL.

close_relay ¤
close_relay(channel: RelayChannel)

ROUTe:CLOSe the relay.

open_relay ¤
open_relay(channel: RelayChannel)

ROUTe:OPEN the relay.

configure_ao_channel ¤
configure_ao_channel(channel: AnalogChannel)

Register an AO channel. Override if the driver supports analog output.

configure_ai_voltage_channel ¤
configure_ai_voltage_channel(channel: AnalogVoltageChannel)

Register an AI voltage channel. Override if the driver supports analog voltage input.

configure_ao_voltage_channel ¤
configure_ao_voltage_channel(channel: AnalogVoltageChannel)

Register an AO voltage channel. Override if the driver supports analog voltage output.

configure_ai_current_channel ¤
configure_ai_current_channel(channel: AnalogCurrentChannel)

Register an AI current channel. Override if the driver supports analog current input.

configure_ao_current_channel ¤
configure_ao_current_channel(channel: AnalogCurrentChannel)

Register an AO current channel. Override if the driver supports analog current output.

configure_ai_thermocouple_channel ¤
configure_ai_thermocouple_channel(channel: AnalogThermocoupleChannel)

Register an AI thermocouple channel. Override if the driver supports thermocouple input.

configure_di_channel ¤
configure_di_channel(channel: DigitalLineChannel)

Register a DI line channel. Override if the driver supports digital input.

configure_do_channel ¤
configure_do_channel(channel: DigitalLineChannel)

Register a DO line channel. Override if the driver supports digital output.

get_actual_sample_rate ¤
get_actual_sample_rate() -> float | None

Actual hardware sample rate achieved after start().

Default returns None (driver doesn't know or hasn't started). Override on drivers whose SDK reports the effective rate (NI, MCC, LabJack T-series all do).

write_analog_value ¤
write_analog_value(channel: AnalogChannelUnion, value: float)

Write value to AO channel. Override if the driver supports analog output.

define_relay_channel ¤
define_relay_channel(
    physical_channel: str, alias: str | None = None
) -> RelayChannel

Build a RelayChannel for physical_channel (e.g. "3101" = slot 3 / channel 101).

Default implementation suits the Keysight 34980A's slot/channel addressing; override if the driver needs different parsing. Overrides must also record the resulting channel on self._relay_channels.

keysight_str_to_ns ¤

keysight_str_to_ns(ts_str: str) -> int

Convert a Keysight "YYYY,MM,DD,HH,MM,SS.sss" timestamp (UTC) to ns since the Unix epoch.

parse_datastring ¤

parse_datastring(data: str) -> tuple[list[float], list[int]]

Split a Keysight reading/timestamp data string into (measurements, timestamps_ns).

get_scanlist ¤

get_scanlist(channels: list[DAQChannel]) -> list[DAQChannel]

NI-DAQmx¤

DAQmxData dataclass ¤

DAQmxData(data: list[list[float]], timestamp: int, dt: int | None)
data instance-attribute ¤
data: list[list[float]]
timestamp instance-attribute ¤
timestamp: int
dt instance-attribute ¤
dt: int | None

NIDAQDriver ¤

NIDAQDriver(device_id: str)

Bases: DAQDriverBase

NI-DAQmx DAQ driver.

points_in_buffer instance-attribute ¤
points_in_buffer: int = 0
channels property ¤
channels: tuple[DAQChannel, ...]

Frozen snapshot of all configured AI/AO/DI/DO channels (excludes relays).

ai_channels property ¤

Frozen snapshot of configured AI channels, keyed by alias.

ao_channels property ¤

Frozen snapshot of configured AO channels, keyed by alias.

di_channels property ¤
di_channels: Mapping[str, DigitalChannel]

Frozen snapshot of configured DI channels, keyed by alias.

do_channels property ¤
do_channels: Mapping[str, DigitalChannel]

Frozen snapshot of configured DO channels, keyed by alias.

relay_channels property ¤
relay_channels: Mapping[str, RelayChannel]

Frozen snapshot of configured relay channels, keyed by alias.

ai_hw_timing_config property ¤
ai_hw_timing_config: HWTimingConfig | None
ao_hw_timing_config property ¤
ao_hw_timing_config: HWTimingConfig | None
di_hw_timing_config property ¤
di_hw_timing_config: HWTimingConfig | None
do_hw_timing_config property ¤
do_hw_timing_config: HWTimingConfig | None
open ¤
open()

NI-DAQmx has no explicit connect — verifies the device is present in niSystem.local().

close ¤
close()

Close every DAQmx task this driver owns.

configure_ai_channel ¤
configure_ai_channel(channel: AnalogChannel)

Configure a channel on the NI device.

configure_ao_channel ¤
configure_ao_channel(channel: AnalogChannel)
configure_ai_hw_timing ¤
configure_ai_hw_timing(hw_timing_config: HWTimingConfig)

Configure hardware timing for the specified channels.

configure_di_line_channel ¤
configure_di_line_channel(
    physical_channel: str,
    logic: Logic,
    logic_level: float | None = None,
    alias: str | None = None,
)

Parse DevN/portM/lineP, add as CHAN_PER_LINE to the shared DI line task, and register the line.

configure_do_line_channel ¤
configure_do_line_channel(
    physical_channel: str,
    logic: Logic,
    logic_level: float | None = None,
    alias: str | None = None,
)

Parse DevN/portM/lineP, add as CHAN_PER_LINE to the shared DO line task, and register the line.

configure_di_port_channel ¤
configure_di_port_channel(
    physical_channel: str,
    logic: Logic,
    port_width: DigitalPortWidth,
    logic_level: float | None = None,
    alias: str | None = None,
)

Parse DevN/portM, add as CHAN_FOR_ALL_LINES to a dedicated DI task, and register the port.

configure_do_port_channel ¤
configure_do_port_channel(
    physical_channel: str,
    logic: Logic,
    port_width: DigitalPortWidth,
    logic_level: float | None = None,
    alias: str | None = None,
)

Parse DevN/portM, add as CHAN_FOR_ALL_LINES to a dedicated DO task, and register the port.

start ¤
start(**kwargs)

Start the DAQ device for data acquisition.

stop ¤
stop(**kwargs)

Stop the DAQ device.

read_analog ¤
read_analog() -> DAQmxData

Read from analog input channels.

fetch_analog ¤
fetch_analog() -> DAQmxData
get_actual_sample_rate ¤
get_actual_sample_rate() -> float | None
write_analog_value ¤
write_analog_value(channel: AnalogChannel, value: float)
write_digital_line ¤
write_digital_line(channel: DigitalChannel, data: int)

Write to digital output channels.

read_digital_line ¤
read_digital_line(channel: DigitalChannel) -> int
write_digital_port ¤
write_digital_port(channel: DigitalChannel, data: int)

Drive a DO port as one N-bit integer; bit i controls line i.

read_digital_port ¤
read_digital_port(channel: DigitalChannel) -> int

Sample a DI port as one N-bit integer; bit i reflects line i.

configure_ai_voltage_channel ¤
configure_ai_voltage_channel(channel: AnalogVoltageChannel)

Register an AI voltage channel. Override if the driver supports analog voltage input.

configure_ao_voltage_channel ¤
configure_ao_voltage_channel(channel: AnalogVoltageChannel)

Register an AO voltage channel. Override if the driver supports analog voltage output.

configure_ai_current_channel ¤
configure_ai_current_channel(channel: AnalogCurrentChannel)

Register an AI current channel. Override if the driver supports analog current input.

configure_ao_current_channel ¤
configure_ao_current_channel(channel: AnalogCurrentChannel)

Register an AO current channel. Override if the driver supports analog current output.

configure_ai_thermocouple_channel ¤
configure_ai_thermocouple_channel(channel: AnalogThermocoupleChannel)

Register an AI thermocouple channel. Override if the driver supports thermocouple input.

configure_di_channel ¤
configure_di_channel(channel: DigitalLineChannel)

Register a DI line channel. Override if the driver supports digital input.

configure_do_channel ¤
configure_do_channel(channel: DigitalLineChannel)

Register a DO line channel. Override if the driver supports digital output.

define_relay_channel ¤
define_relay_channel(
    physical_channel: str, alias: str | None = None
) -> RelayChannel

Build a RelayChannel for physical_channel (e.g. "3101" = slot 3 / channel 101).

Default implementation suits the Keysight 34980A's slot/channel addressing; override if the driver needs different parsing. Overrides must also record the resulting channel on self._relay_channels.

close_relay ¤
close_relay(channel: RelayChannel)

Close the relay (connect the circuit). Override if the driver supports relays.

open_relay ¤
open_relay(channel: RelayChannel)

Open the relay (disconnect the circuit). Override if the driver supports relays.

LabJack T-series¤

logger module-attribute ¤

logger = getLogger(__name__)

LabJackData dataclass ¤

LabJackData(data: list[float], timestamp: int, dt: int | None)
data instance-attribute ¤
data: list[float]
timestamp instance-attribute ¤
timestamp: int
dt instance-attribute ¤
dt: int | None

LabJackTSeriesDriver ¤

LabJackTSeriesDriver(device_id: str, stream_buffer_bytes: int = 0)

Bases: DAQDriverBase

LabJack T-series DAQ driver (T4/T7/T8 via the LJM library).

Parameters:

  • device_id ¤
    (str) –

    Device serial number, or "ANY" for the first device found.

  • stream_buffer_bytes ¤
    (int, default: 0 ) –

    Device-side stream buffer size, always written when AI hardware timing is configured so no value carries over from an earlier session. 0 selects the device's own default. Must be a power of 2 and the max is 262144. Setting this prevents the device from dropping scans at high sample rates, which LJM reports as -9999 sample values.

points_in_buffer instance-attribute ¤
points_in_buffer: int = 0
channels property ¤
channels: tuple[DAQChannel, ...]

Frozen snapshot of all configured AI/AO/DI/DO channels (excludes relays).

ai_channels property ¤

Frozen snapshot of configured AI channels, keyed by alias.

ao_channels property ¤

Frozen snapshot of configured AO channels, keyed by alias.

di_channels property ¤
di_channels: Mapping[str, DigitalChannel]

Frozen snapshot of configured DI channels, keyed by alias.

do_channels property ¤
do_channels: Mapping[str, DigitalChannel]

Frozen snapshot of configured DO channels, keyed by alias.

relay_channels property ¤
relay_channels: Mapping[str, RelayChannel]

Frozen snapshot of configured relay channels, keyed by alias.

ai_hw_timing_config property ¤
ai_hw_timing_config: HWTimingConfig | None
ao_hw_timing_config property ¤
ao_hw_timing_config: HWTimingConfig | None
di_hw_timing_config property ¤
di_hw_timing_config: HWTimingConfig | None
do_hw_timing_config property ¤
do_hw_timing_config: HWTimingConfig | None
open ¤
open()

Connect to LabJack device.

stop ¤
stop(**kwargs)

Stop the DAQ device.

close ¤
close()

Disconnect from LabJack device.

get_info ¤
get_info() -> tuple[int, int, int, int, int, int]

Get the LabJack device info.

configure_ai_channel ¤
configure_ai_channel(channel: AnalogChannel)

Deprecated: use configure_ai_voltage_channel. Configures an ai channel on the LabJack device.

configure_ao_channel ¤
configure_ao_channel(channel: AnalogChannel)

Deprecated: use configure_ao_voltage_channel. Configures an AO channel on the LabJack device.

configure_ai_voltage_channel ¤
configure_ai_voltage_channel(channel: AnalogVoltageChannel)

Configure a voltage ai channel on the LabJack device.

configure_ao_voltage_channel ¤
configure_ao_voltage_channel(channel: AnalogVoltageChannel)

Configure a voltage AO channel on the LabJack device.

configure_ai_current_channel ¤
configure_ai_current_channel(channel: AnalogCurrentChannel)
configure_ao_current_channel ¤
configure_ao_current_channel(channel: AnalogCurrentChannel)
configure_ai_thermocouple_channel ¤
configure_ai_thermocouple_channel(channel: AnalogThermocoupleChannel)

Configure a thermocouple ai channel; volts convert to temperature in the channel's unit on read.

range_min/range_max are ignored: the ADC range is fixed per model (T7 0.1 V, T8 0.075 V, T4 none).

configure_ai_hw_timing ¤
configure_ai_hw_timing(hw_timing_config: HWTimingConfig)

Configure hardware timing for the specified channels.

start ¤
start(**kwargs)

Start the DAQ device for hw timed data acquisition.

read_analog ¤
read_analog() -> LabJackData

Read from analog input channels.

fetch_analog ¤
fetch_analog() -> LabJackData
get_actual_sample_rate ¤
get_actual_sample_rate() -> float | None
write_analog_value ¤
write_analog_value(channel: AnalogChannelUnion, value: float)
configure_di_line_channel ¤
configure_di_line_channel(
    physical_channel: str,
    logic: Logic,
    logic_level: float | None = None,
    alias: str | None = None,
)
configure_do_line_channel ¤
configure_do_line_channel(
    physical_channel: str,
    logic: Logic,
    logic_level: float | None = None,
    alias: str | None = None,
)
configure_di_channel ¤
configure_di_channel(channel: DigitalLineChannel)

Register a DI line channel on the LabJack device.

configure_do_channel ¤
configure_do_channel(channel: DigitalLineChannel)

Register a DO line channel on the LabJack device.

write_digital_line ¤
write_digital_line(channel: DigitalChannel, data: int)
read_digital_line ¤
read_digital_line(channel: DigitalChannel) -> int
write_digital_port ¤
write_digital_port(channel: DigitalChannel, data: int)
read_digital_port ¤
read_digital_port(channel: DigitalChannel) -> int
configure_di_port_channel ¤
configure_di_port_channel(
    physical_channel: str,
    logic: Logic,
    port_width: DigitalPortWidth,
    logic_level: float | None = None,
    alias: str | None = None,
)

Parse, program, and register a DI port channel. Override if the driver supports port-mode digital input.

configure_do_port_channel ¤
configure_do_port_channel(
    physical_channel: str,
    logic: Logic,
    port_width: DigitalPortWidth,
    logic_level: float | None = None,
    alias: str | None = None,
)

Parse, program, and register a DO port channel. Override if the driver supports port-mode digital output.

define_relay_channel ¤
define_relay_channel(
    physical_channel: str, alias: str | None = None
) -> RelayChannel

Build a RelayChannel for physical_channel (e.g. "3101" = slot 3 / channel 101).

Default implementation suits the Keysight 34980A's slot/channel addressing; override if the driver needs different parsing. Overrides must also record the resulting channel on self._relay_channels.

close_relay ¤
close_relay(channel: RelayChannel)

Close the relay (connect the circuit). Override if the driver supports relays.

open_relay ¤
open_relay(channel: RelayChannel)

Open the relay (disconnect the circuit). Override if the driver supports relays.

MCC USB-series¤

MCCDAQData dataclass ¤

MCCDAQData(data: list[float], timestamp: int, dt: int | None)
data instance-attribute ¤
data: list[float]
timestamp instance-attribute ¤
timestamp: int
dt instance-attribute ¤
dt: int | None

MCCDriver ¤

MCCDriver(device_id: str, buffer_multiplier: int = 2)

Bases: DAQDriverBase

MCC (Universal Library / mcculw) DAQ driver.

Parameters:

  • device_id ¤
    (str) –

    Device unique ID, optionally with a board number as "<serial>:<board_number>" (e.g. "344371:0"). Defaults to board 0.

  • buffer_multiplier ¤
    (int, default: 2 ) –

    Circular-buffer size relative to per-fetch size. Higher values tolerate more jitter at the cost of memory.

points_in_buffer instance-attribute ¤
points_in_buffer: int = 0
channels property ¤
channels: tuple[DAQChannel, ...]

Frozen snapshot of all configured AI/AO/DI/DO channels (excludes relays).

ai_channels property ¤

Frozen snapshot of configured AI channels, keyed by alias.

ao_channels property ¤

Frozen snapshot of configured AO channels, keyed by alias.

di_channels property ¤
di_channels: Mapping[str, DigitalChannel]

Frozen snapshot of configured DI channels, keyed by alias.

do_channels property ¤
do_channels: Mapping[str, DigitalChannel]

Frozen snapshot of configured DO channels, keyed by alias.

relay_channels property ¤
relay_channels: Mapping[str, RelayChannel]

Frozen snapshot of configured relay channels, keyed by alias.

ai_hw_timing_config property ¤
ai_hw_timing_config: HWTimingConfig | None
ao_hw_timing_config property ¤
ao_hw_timing_config: HWTimingConfig | None
di_hw_timing_config property ¤
di_hw_timing_config: HWTimingConfig | None
do_hw_timing_config property ¤
do_hw_timing_config: HWTimingConfig | None
open ¤
open()

Connect to MCC device.

close ¤
close()

Disconnect from MCC device.

get_info ¤
get_info() -> DaqDeviceInfo

Underlying mcculw DaqDeviceInfo.

configure_ai_channel ¤
configure_ai_channel(channel: AnalogChannel)

Configure an analog input channel on the MCC DAQ device.

configure_ao_channel ¤
configure_ao_channel(channel: AnalogChannel)

Configure an analog output channel on the MCC DAQ device.

configure_ai_hw_timing ¤
configure_ai_hw_timing(hw_timing_config: HWTimingConfig)

Configure hardware timing for the specified channels.

start ¤
start(**kwargs)

Start the MCC DAQ device for hw timed data acquisition.

get_actual_sample_rate ¤
get_actual_sample_rate() -> float | None
stop ¤
stop(**kwargs)

Stop the MCC DAQ device.

read_analog ¤
read_analog() -> MCCDAQData

Read from analog input channels.

fetch_analog ¤
fetch_analog() -> MCCDAQData

Block until samples_per_channel new samples are available, then drain the circular buffer.

write_analog_value ¤
write_analog_value(channel: AnalogChannel, value: float)

Write an analog value to an analog output channel.

configure_di_line_channel ¤
configure_di_line_channel(
    physical_channel: str,
    logic: Logic,
    logic_level: float | None = None,
    alias: str | None = None,
)

Parse DigitalPortType/#, configure the bit for DI, and register the line.

configure_do_line_channel ¤
configure_do_line_channel(
    physical_channel: str,
    logic: Logic,
    logic_level: float | None = None,
    alias: str | None = None,
)

Parse DigitalPortType/#, configure the bit for DO, and register the line.

configure_di_port_channel ¤
configure_di_port_channel(
    physical_channel: str,
    logic: Logic,
    port_width: DigitalPortWidth,
    logic_level: float | None = None,
    alias: str | None = None,
)

Parse DigitalPortType, configure the port for DI, and register the port.

configure_do_port_channel ¤
configure_do_port_channel(
    physical_channel: str,
    logic: Logic,
    port_width: DigitalPortWidth,
    logic_level: float | None = None,
    alias: str | None = None,
)

Parse DigitalPortType, configure the port for DO, and register the port.

write_digital_line ¤
write_digital_line(channel: DigitalChannel, data: int)

Write 0/1 to a single DO line (DigitalLineChannel).

read_digital_line ¤
read_digital_line(channel: DigitalChannel) -> int

Read 0/1 from a single DI line (DigitalLineChannel).

write_digital_port ¤
write_digital_port(channel: DigitalChannel, data: int)

Write an N-bit value to a DO port (bit i drives line i).

read_digital_port ¤
read_digital_port(channel: DigitalChannel) -> int

Read an N-bit value from a DI port (bit i reflects line i).

configure_ai_voltage_channel ¤
configure_ai_voltage_channel(channel: AnalogVoltageChannel)

Register an AI voltage channel. Override if the driver supports analog voltage input.

configure_ao_voltage_channel ¤
configure_ao_voltage_channel(channel: AnalogVoltageChannel)

Register an AO voltage channel. Override if the driver supports analog voltage output.

configure_ai_current_channel ¤
configure_ai_current_channel(channel: AnalogCurrentChannel)

Register an AI current channel. Override if the driver supports analog current input.

configure_ao_current_channel ¤
configure_ao_current_channel(channel: AnalogCurrentChannel)

Register an AO current channel. Override if the driver supports analog current output.

configure_ai_thermocouple_channel ¤
configure_ai_thermocouple_channel(channel: AnalogThermocoupleChannel)

Register an AI thermocouple channel. Override if the driver supports thermocouple input.

configure_di_channel ¤
configure_di_channel(channel: DigitalLineChannel)

Register a DI line channel. Override if the driver supports digital input.

configure_do_channel ¤
configure_do_channel(channel: DigitalLineChannel)

Register a DO line channel. Override if the driver supports digital output.

define_relay_channel ¤
define_relay_channel(
    physical_channel: str, alias: str | None = None
) -> RelayChannel

Build a RelayChannel for physical_channel (e.g. "3101" = slot 3 / channel 101).

Default implementation suits the Keysight 34980A's slot/channel addressing; override if the driver needs different parsing. Overrides must also record the resulting channel on self._relay_channels.

close_relay ¤
close_relay(channel: RelayChannel)

Close the relay (connect the circuit). Override if the driver supports relays.

open_relay ¤
open_relay(channel: RelayChannel)

Open the relay (disconnect the circuit). Override if the driver supports relays.