DMM (Digital Multimeter)¤
Interface¤
Digital multimeter (DMM) instrument interface.
Defines InstroDMM.
Public API
InstroDMM
InstroDMM
¤
InstroDMM(
name: str,
driver: DMMDriverBase,
publishers: list[Publisher] | None = None,
**kwargs,
)
Bases: Instrument
Digital multimeter hardware abstraction to communicate with various models and vendor DMMs.
Methods return Measurement and Command data types to be compatible with Nominal Instrumentation tools. Configure measurement with set_measurement_function(), then call read() to trigger a measurement.
Parameters:
-
(name¤str) –A name to identify this DMM instance. Used in channel naming and published data.
-
(driver¤DMMDriverBase) –Driver instance for the specific DMM vendor/model. Concrete drivers own their transport setup::
dmm = InstroDMM( "main", driver=Agilent34401A("ASRL3::INSTR"), ) -
(publishers¤list[Publisher] | None, default:None) –List of publishers to send data to when executing methods. Defaults to None.
-
–**kwargs¤Optional keyword arguments used as tags throughout the life of the instrument. These tags are applied to the Measurement and Command objects.
Special keyword arguments: dataset_rid: If provided, automatically creates and adds a NominalCorePublisher with the specified dataset RID. Assumes a Nominal 'default' credential is stored on disk.
data_handler
instance-attribute
¤
data_handler = (
None
if connection_config is None
else DataHandler(select(connection_config))
)
background_interval
property
writable
¤
background_interval
Get the background worker interval setting.
Returns:
-
float–The current interval in seconds between background worker iterations. The worker waits this duration between executing background daemon functions.
background_enable
property
writable
¤
background_enable
Get the background worker enable state.
Returns:
-
bool–True if the background worker is enabled, False otherwise.
start
¤
start() -> None
Start the background worker thread.
Raises:
-
ValueError–If set_measurement_function() has not been called.
set_measurement_function
¤
set_measurement_function(
function: MeasurementFunction, **kwargs
) -> Command
Set the DMM to the measurement function (dc voltage, resistance, etc.) you intend to perform.
Parameters:
-
(function¤MeasurementFunction) –The measurement function to configure the DMM to.
-
–**kwargs¤Optional keyword arguments used as tags on the published Command.
Returns:
-
Command(Command) –A Command object containing the configuration, timestamp, and tags. The command is automatically published to all configured publishers.
set_digits
¤
Set resolution in digits. Requires set_measurement_function() to have been called.
set_aperture_seconds
¤
Set integration time (aperture) in seconds. Requires set_measurement_function() first.
set_aperture_nplc
¤
Set integration time (aperture) in number of power line cycles.
NPLC is number of power line cycles. DC Voltage, DC Current, and Resistance measurement resolution and accuracy are reduced by power line induced AC noise. Using NPLC of 1 or greater increases AC noise integration time and improves measurement resolution and accuracy at the cost of slower measurement rates. NPLC of 100 is recommended for highest accuracy.
Requires set_measurement_function() to have been called.
set_range
¤
Set manual range; None = auto range. Requires set_measurement_function() first.
Publishes range_mode.cmd ("AUTO" / "MANUAL") on every call and
range.cmd (float) only when a manual range is supplied. Splitting the two keeps
each channel single-typed, which the Nominal streaming backend requires.
read
¤
read(**kwargs) -> Measurement
Trigger a measurement and return the value. Requires set_measurement_function() first.
The driver's measurement is dispatched based on the configured measurement function. The result is wrapped in a Measurement and published.
add_publisher
¤
publish
¤
publish(data: Measurement | Command, **kwargs)
Publish a Measurement or Command to all configured publishers.
This method sends the data to all publishers that have been added to this instrument. Additional keyword arguments are passed through to each publisher's publish method.
Parameters:
-
(data¤Measurement | Command) –The measurement or command data to publish.
-
–**kwargs¤Optional keyword arguments passed to each publisher's publish method.
get_identity
¤
get_identity() -> str
Query the instrument's identity string.
This method sends the SCPI "*IDN?" command to retrieve the instrument's identification information, which typically includes manufacturer, model number, serial number, and firmware version.
Returns:
-
str(str) –The instrument's identity string.
Raises:
-
RuntimeError–If no connection is configured for this instrument (data_handler is None).
open_and_get_identity
staticmethod
¤
open_and_get_identity(connection_config: ConnectConfig) -> str
Convenience method to open a connection, query identity, and close.
This static method creates a temporary instrument instance, opens a connection, queries the identity, closes the connection, and returns the identity string. Useful for instrument discovery without maintaining a long-lived connection.
Parameters:
-
(connection_config¤ConnectConfig) –The connection configuration for the instrument.
Returns:
-
str(str) –The instrument's identity string.
Raises:
-
RuntimeError–If the connection cannot be established or the identity cannot be queried.
send_arbitrary_command
¤
Send an arbitrary command string to the instrument.
This method allows sending custom commands directly to the instrument without going through the instrument's high-level API. Useful for accessing instrument-specific features not exposed by the standard interface.
Parameters:
Raises:
-
RuntimeError–If no connection is configured for this instrument (data_handler is None).
query_arbitrary_command
¤
Send an arbitrary command string and return the instrument's response.
This method sends a command and waits for a response, useful for querying instrument state or configuration. The response is returned as a string.
Parameters:
Returns:
-
str(str) –The instrument's response to the query command.
Raises:
-
RuntimeError–If no connection is configured for this instrument (data_handler is None).
add_background_daemon_function
¤
Adds a function (and its arguments) to be periodically called by the background worker daemon.
There may already be functions defined and this will add to the end of that list.
Call define_background_daemon to clear and define a new function if you do not want the default
functions to run.
Parameters:
stop
¤
stop()
Stop the background worker thread.
This method signals the background worker thread to stop and waits for it to complete. If the thread is not running, this method does nothing.
get_channel
¤
get_channel(
channel_name: str,
length: int = 1,
wait_for_latest: bool = False,
timeout: float = 10.0,
) -> Measurement
Get most recent Measurement data for a specific channel from the buffer.
Parameters:
-
(channel_name¤str) –The name of the channel from which to retrieve data.
-
(length¤int, default:1) –The number of most recent samples to return.
-
(wait_for_latest¤bool, default:False) –Block and wait for the next channel value(s).
-
(timeout¤float, default:10.0) –Timeout in seconds when waiting for channel or values. Defaults to 10.0 seconds. Only applies when wait_for_latest=True.
Returns:
-
Measurement(Measurement) –A Measurement object containing the requested channel data and timestamps.
Raises:
-
RuntimeError–No background buffer exists because start() was not called.
-
ChannelNotFoundTimeoutError–If wait_for_latest=True and the channel does not appear within timeout.
-
ChannelValueTimeoutError–If wait_for_latest=True and sufficient values are not available within timeout.
define_background_daemon
¤
Clear all background daemon functions and register a single custom method.
This method clears any previously registered background daemon functions and registers a new method to be called in the background daemon loop. This is useful when you want to replace the default background functions with a custom implementation.
Parameters:
Types & Configuration¤
Digital multimeter (DMM) instrument interface and helpers.
Defines MeasurementFunction, DMMMeasurementConfig and related helpers.
Public API:
MeasurementFunction, DMMMeasurementConfig
MeasurementFunction
¤
RangeMode
¤
DMMMeasurementConfig
dataclass
¤
DMMMeasurementConfig(
function: MeasurementFunction,
digits: int | None = None,
aperture_seconds: float | None = None,
aperture_nplc: float | None = None,
range: float | None = None,
)
Full acquisition configuration for a DMM measurement.
Holds the measurement function and optional acquisition options so users can adjust DMM acquisition in one place. Drivers apply only the options they support; unsupported options are ignored or can raise in the driver.
Attributes:
-
function(MeasurementFunction) –Measurement function (required).
-
digits(int | None) –Resolution in digits (optional). None = instrument default.
-
aperture_seconds(float | None) –Integration time in seconds (optional). Some instruments use this; others use aperture_nplc.
-
aperture_nplc(float | None) –Integration time in number of power-line cycles (optional). Some instruments use this; others use aperture_seconds.
-
range(float | None) –Manual range in current function's units (optional). None = auto range.
Driver Interface¤
DMM driver base interface.
Defines DMMDriverBase.
Public API
DMMDriverBase
DMMDriverBase
¤
Bases: ABC
Abstract base class for vendor DMM drivers.
Concrete drivers own their transport setup and translate category-level calls into vendor-specific commands. The base declares only the category contract; transport choice and lifecycle live in the concrete driver.
Range and NPLC are split into per-function methods (set_voltage_range,
set_current_nplc, ...) so the driver never has to track which
measurement function is active. InstroDMM dispatches to the right
method based on its own _measurement_config.function. This keeps the
measurement function as a single source of truth on InstroDMM and
makes it impossible to pass the wrong function to the driver.
set_measurement_function
abstractmethod
¤
set_measurement_function(function: MeasurementFunction) -> None
Set the measurement function (mode) for the DMM.
set_aperture_seconds
¤
set_aperture_seconds(seconds: float) -> None
Set integration time (aperture) in seconds. Override if supported.
Vendor Drivers¤
Keithley 2400¤
Keithley 2400 SourceMeter driver (DMM measurement portion only).
Implements DMM-style measurement (DC voltage, DC current, 2-wire resistance) for the Keithley 2400 SMU. Only the sense functionality is exposed; source configuration is kept minimal (zero level for V/I). AC voltage and AC current are not supported by the 2400 in this context.
The driver owns the SCPI/VISA transport.
Public API
Keithley2400
Keithley2400
¤
Keithley2400(
connection: str | VisaConnectionConfig,
*,
visa_backend: str = "@ivi",
serial_config: SerialConfig | None = None,
terminator: TerminatorConfig | None = None,
timeout: TimeoutConfig | None = None,
)
Bases: DMMDriverBase
Driver for the Keithley 2400 SourceMeter (measurement only).
Supports DC voltage, DC current, and 2-wire resistance. Integration time is set via NPLC only (0.01 to 10); the 2400 does not expose aperture in seconds. Range and NPLC are scoped by the active measurement function, so those methods receive the function explicitly. Digits (resolution) is not directly settable; use NPLC. AC voltage/current are not supported.
Parameters:
-
(connection¤str | VisaConnectionConfig) –VISA resource string, or a full
VisaConnectionConfigwhen the caller needs to pass a prebuilt config object. -
(visa_backend¤str, default:'@ivi') –pyvisa backend specifier. Ignored when
connectionis already aVisaConnectionConfig. -
(serial_config¤SerialConfig | None, default:None) –Optional serial-line settings for ASRL resources.
-
(terminator¤TerminatorConfig | None, default:None) –Optional read/write terminator settings.
-
(timeout¤TimeoutConfig | None, default:None) –Optional operation timeout settings.
set_measurement_function
¤
set_measurement_function(function: MeasurementFunction) -> None
Configure the 2400 for the selected measurement function.
set_digits
¤
set_digits(n: int) -> None
The 2400 does not expose a direct digits SCPI; use NPLC for resolution.
Agilent 34401A¤
Agilent/HP/Keysight 34401A digital multimeter driver.
Implements DMM-style measurements (DC/AC voltage, DC/AC current, 2- and 4-wire resistance) for the Agilent 34401A. The driver owns the SCPI/VISA transport.
Transport/protocols: SCPI over GPIB or RS-232.
Public API
Agilent34401A
Agilent34401A
¤
Agilent34401A(
connection: str | VisaConnectionConfig,
*,
visa_backend: str = "@ivi",
serial_config: SerialConfig | None = None,
terminator: TerminatorConfig | None = None,
timeout: TimeoutConfig | None = None,
)
Bases: DMMDriverBase
Driver for the Agilent/HP/Keysight 34401A digital multimeter.
The driver owns the SCPI/VISA transport. Users provide connection
parameters for the instrument, and the driver handles VisaDriver
construction internally.
Parameters:
-
(connection¤str | VisaConnectionConfig) –VISA resource string, or a full
VisaConnectionConfigwhen the caller needs to pass a prebuilt config object. -
(visa_backend¤str, default:'@ivi') –pyvisa backend specifier. Ignored when
connectionis already aVisaConnectionConfig. -
(serial_config¤SerialConfig | None, default:None) –Optional serial-line settings for ASRL resources.
-
(terminator¤TerminatorConfig | None, default:None) –Optional read/write terminator settings.
-
(timeout¤TimeoutConfig | None, default:None) –Optional operation timeout settings.
set_two_wire_resistance_range
class-attribute
instance-attribute
¤
set_two_wire_resistance_range = _store_range
set_four_wire_resistance_range
class-attribute
instance-attribute
¤
set_four_wire_resistance_range = _store_range
open
¤
open() -> None
Open transport and place the instrument in remote mode.
Clears the error queue, then sends SYST:REM to disable the front
panel and the RS-232 echo that can interfere with communication.
set_measurement_function
¤
set_measurement_function(function: MeasurementFunction) -> None
Set the measurement function for subsequent reads.
Performs a dummy measurement to configure the instrument for this function.