DMM (Digital Multimeter)¤
Interface¤
Digital multimeter (DMM) instrument interface and helpers.
Defines NominalDMM and related helpers.
Transport/protocols: SCPI, VISA.
Public API
NominalDMM, NominalDMMFacade
NominalDMM
¤
NominalDMM(
name: str,
driver: DMMDriverBase,
connection_config: ConnectConfig | None = None,
device_id: str | None = None,
publishers: list[Publisher] | None = None,
**kwargs,
)
Bases: NominalInstrument
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) –The driver instance for the specific DMM vendor/model.
-
(connection_config¤ConnectConfig | None, default:None) –Connection configuration for SCPI/VISA devices. Pass None for vendor-library drivers that use device_id.
-
(device_id¤str | None, default:None) –Device identifier for vendor-library drivers. Pass None for SCPI devices.
-
(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.
auto_create
classmethod
¤
auto_create(
name: str,
resource: ConnectConfig,
publishers: list[Publisher] | None = None,
**kwargs,
) -> NominalDMM
Discover and create a NominalDMM instance by querying the instrument's IDN.
This factory method automatically discovers the DMM model and creates an appropriate driver instance from Nominal's list of registered DMM vendors/models.
The discovery process: 1. Open a VISA session to the resource string. 2. Send '*IDN?' query. 3. Parse the returned vendor/model string. 4. Find a matching driver subclass. 5. Close the temporary session. 6. Create and return a NominalDMM instance with the appropriate driver.
Parameters:
-
(name¤str) –A name to identify this DMM instance. Used in channel naming and published data.
-
(resource¤ConnectConfig) –A ConnectConfig for SCPI/VISA devices.
-
(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.
Special keyword arguments: dataset_rid: If provided, automatically creates and adds a NominalCorePublisher with the specified dataset RID.
Returns:
-
NominalDMM(NominalDMM) –Configured DMM instance with the appropriate driver.
Raises:
-
ValueError–If no matching driver is found for the IDN string.
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.
Parameters:
-
(n¤int) –Resolution in digits.
-
–**kwargs¤Optional keyword arguments used as tags on the published Command.
Returns:
-
Command(Command) –A Command object. The command is automatically published.
Raises:
-
ValueError–If set_measurement_function() has not been called.
set_aperture_seconds
¤
Set integration time (aperture) in seconds. Requires set_measurement_function() to have been called.
Parameters:
-
(seconds¤float) –Integration time in seconds
-
–**kwargs¤Optional keyword arguments used as tags on the published Command.
Returns:
-
Command(Command) –A Command object. The command is automatically published.
Raises:
-
ValueError–If set_measurement_function() has not been called.
set_aperture_nplc
¤
Set integration time (aperture) in number of power line cycles. Requires set_measurement_function() to have been called.
NPLC is number of power line cycles. DC Voltage, DC Current, and Resistance measurement resolution, accuracy is reduced by power line induced AC noise. Using NPLC of 1 or greater increases AC noise integration time, and increases measurement resolution and accuracy, however the trade-off is slower measurement rates. For highest measurement accuracy NPLC of 100 is recommended.
Parameters:
-
(nplc¤float) –Integration time number of power line cycles.
-
–**kwargs¤Optional keyword arguments used as tags on the published Command.
Returns:
-
Command(Command) –A Command object. The command is automatically published.
Raises:
-
ValueError–If set_measurement_function() has not been called.
set_range
¤
Set manual range; None = auto range. Requires set_measurement_function() to have been called.
Parameters:
-
(value¤float | None) –Range in current function's units, or None for auto range.
-
–**kwargs¤Optional keyword arguments used as tags on the published Command.
Returns:
-
Command(Command) –A Command object. The command is automatically published.
Raises:
-
ValueError–If set_measurement_function() has not been called.
read
¤
read(**kwargs) -> Measurement
Trigger a measurement and return the value. Requires set_measurement_function() first.
The driver uses the current measurement function (from the facade) to dispatch to the appropriate measure method. The result is wrapped in a Measurement and published.
Parameters:
-
–**kwargs¤Optional keyword arguments used as tags on the published Measurement.
Returns:
-
Measurement(Measurement) –A Measurement object containing the channel name, value, timestamp, and tags. The measurement is automatically published.
Raises:
-
ValueError–If set_measurement_function() has not been called.
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:
NominalDMMFacade
¤
NominalDMMFacade(nominal_dmm: NominalDMM)
Facade class that provides drivers with access to NominalDMM configuration.
This class implements the APINominalDMM interface and allows drivers to access the current measurement configuration without direct access to the NominalDMM instance's internal state.
Parameters:
-
(nominal_dmm¤NominalDMM) –The NominalDMM instance to provide access to.
measurement_function
property
¤
measurement_function: MeasurementFunction
Get the current measurement function (mode) of the DMM.
Returns:
-
MeasurementFunction(MeasurementFunction) –The current measurement function.
Raises:
-
ValueError–If set_measurement_function() has not been called.
measurement_config
property
¤
measurement_config: DMMMeasurementConfig
Get the current acquisition configuration of the DMM.
Returns:
-
DMMMeasurementConfig(DMMMeasurementConfig) –The current measurement configuration.
Raises:
-
ValueError–If set_measurement_function() has not been called.
Types & Configuration¤
Digital multimeter (DMM) instrument interface and helpers.
Defines MeasurementFunction, DMMMeasurementConfig and related helpers.
Public API:
MeasurementFunction, DMMMeasurementConfig
MeasurementFunction
¤
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¤
Digital multimeter (DMM) instrument interface and helpers.
Defines DMMDriverBase and related helpers.
Transport/protocols: SCPI.
Public API
APINominalDMM, DMMDriverBase, DMMDriverDataHandler
APINominalDMM
¤
Bases: Protocol
API for the NominalDMM instrument type.
Exposes the currently configured measurement function and optionally the full measurement config so the driver can dispatch read() correctly.
measurement_function
property
¤
measurement_function: MeasurementFunction
Get the current measurement function (mode) of the DMM.
measurement_config
property
¤
measurement_config: DMMMeasurementConfig
Get the current acquisition configuration of the DMM.
DMMDriverBase
¤
Bases: ABC
Abstract base class for vendor DMM.
Each concrete provider implements sending and receiving data for its vendor/model.
set_measurement_function
abstractmethod
¤
set_measurement_function(function: MeasurementFunction) -> None
Set the measurement function (mode) for the DMM.
Parameters:
-
(function¤MeasurementFunction) –The measurement function (mode) to set for the DMM.
set_digits
¤
set_digits(n: int) -> None
Set resolution in digits. Override in subclasses if supported.
set_aperture_seconds
¤
set_aperture_nplc
¤
set_range
¤
measure_four_wire_resistance
¤
measure_four_wire_resistance() -> float
Measure 4-wire resistance. Override in subclasses if supported.
measure_dc_voltage
abstractmethod
¤
measure_dc_voltage() -> float
Measure DC voltage. Override to raise if unsupported.
measure_ac_voltage
abstractmethod
¤
measure_ac_voltage() -> float
Measure AC voltage. Override to raise if unsupported.
measure_resistance
abstractmethod
¤
measure_resistance() -> float
Measure resistance. Override to raise if unsupported.
DMMDriverDataHandler
¤
DMMDriverDataHandler()
Bases: DMMDriverBase
Base class for SCPI-based DMM drivers using DataHandler.
set_data_handler
¤
set_data_handler(data_handler: DataHandler) -> None
Set the data handler for SCPI-based drivers.
Parameters:
-
(data_handler¤DataHandler) –The DataHandler instance to use for communication.
get_driver
classmethod
¤
get_driver(idn: str) -> type[DMMDriverDataHandler]
Find the appropriate driver class for a given IDN string.
Parameters:
Returns:
-
type[DMMDriverDataHandler]–The driver class that matches the IDN string.
Raises:
-
ValueError–If IDN is empty, no matching driver is found, or multiple drivers match.
match_idn
abstractmethod
classmethod
¤
check_errors
abstractmethod
¤
check_errors() -> None
Query the error queue and raise if error pending. Return silently if no errors.
set_measurement_function
abstractmethod
¤
set_measurement_function(function: MeasurementFunction) -> None
Set the measurement function (mode) for the DMM.
Parameters:
-
(function¤MeasurementFunction) –The measurement function (mode) to set for the DMM.
set_digits
¤
set_digits(n: int) -> None
Set resolution in digits. Override in subclasses if supported.
set_aperture_seconds
¤
set_aperture_nplc
¤
set_range
¤
measure_four_wire_resistance
¤
measure_four_wire_resistance() -> float
Measure 4-wire resistance. Override in subclasses if supported.
measure_dc_voltage
abstractmethod
¤
measure_dc_voltage() -> float
Measure DC voltage. Override to raise if unsupported.
measure_ac_voltage
abstractmethod
¤
measure_ac_voltage() -> float
Measure AC voltage. Override to raise if unsupported.
measure_resistance
abstractmethod
¤
measure_resistance() -> float
Measure resistance. Override to raise if unsupported.
Vendor Drivers¤
Keithley 2400¤
Keithley 2400 SourceMeter driver (DMM measurement portion only).
Implements DMM-style measurement (DC voltage, DC current, resistance) for the Keithley 2400 Source Measure Unit. Only the measurement (sense) functionality is exposed; source configuration is kept minimal (e.g. zero level for V/I, small current for resistance). AC voltage and AC current are not supported by the 2400 in this context and raise NotImplementedError.
Transport/protocols: SCPI.
Public API
Keithley2400DMMDriver
Keithley2400DMMDriver
¤
Keithley2400DMMDriver()
Bases: DMMDriverDataHandler
DMM driver for Keithley 2400 SourceMeter (measurement only).
Supports DC voltage, DC current, and resistance. Integration time is set via NPLC only (0.01 to 10); the 2400 does not support aperture in seconds (no :SENS:VOLT:APER-style SCPI). Range and NPLC are supported. Digits (resolution) are not directly set; use NPLC. AC voltage/current are not supported.
match_idn
classmethod
¤
Match Keithley 2400 series (*IDN? contains KEITHLEY and 2400).
set_measurement_function
¤
set_measurement_function(function: MeasurementFunction) -> None
Configure the 2400 for the selected measurement function and options.
set_digits
¤
set_digits(n: int) -> None
Keithley 2400 does not expose a direct digits SCPI; use set_aperture (NPLC) for resolution.
set_aperture_nplc
¤
set_aperture_nplc(nplc: float) -> None
Set integration time via NPLC (0.01 to 10). This model has no aperture-in-seconds SCPI.
set_range
¤
set_range(value: float | None) -> None
Set manual range (V, A, or Ohm); None = auto range.
measure_dc_voltage
¤
measure_dc_voltage() -> float
Measure DC voltage. Output is turned on at 0 V to allow reading.
measure_dc_current
¤
measure_dc_current() -> float
Measure DC current. Output is turned on at 0 A to allow reading.
measure_resistance
¤
measure_resistance() -> float
Measure resistance. Output is turned on with default source current.
measure_ac_voltage
¤
measure_ac_voltage() -> float
AC voltage is not supported by the Keithley 2400 in this driver.
measure_ac_current
¤
measure_ac_current() -> float
AC current is not supported by the Keithley 2400 in this driver.
check_errors
¤
check_errors() -> None
Query the instrument error queue and raise if an error is reported.
set_aperture_seconds
¤
measure_four_wire_resistance
¤
measure_four_wire_resistance() -> float
Measure 4-wire resistance. Override in subclasses if supported.
set_data_handler
¤
set_data_handler(data_handler: DataHandler) -> None
Set the data handler for SCPI-based drivers.
Parameters:
-
(data_handler¤DataHandler) –The DataHandler instance to use for communication.
get_driver
classmethod
¤
get_driver(idn: str) -> type[DMMDriverDataHandler]
Find the appropriate driver class for a given IDN string.
Parameters:
Returns:
-
type[DMMDriverDataHandler]–The driver class that matches the IDN string.
Raises:
-
ValueError–If IDN is empty, no matching driver is found, or multiple drivers match.
Agilent 34401A¤
Agilent/HP 34401A Digital Multimeter driver.
Implements DMM-style measurements (DC/AC voltage, DC/AC current, resistance) for the Agilent 34401A DMM.
Supports both 2-wire and 4-wire resistance measurements.
Transport/protocols: SCPI over GPIB, RS-232.
Public API
Agilent34401ADMMDriver
Agilent34401ADMMDriver
¤
Agilent34401ADMMDriver()
Bases: DMMDriverDataHandler
DMM driver for Agilent/HP/Keysight 34401A digital multimeter.
match_idn
classmethod
¤
Match Agilent/HP/Keysight 34401A (*IDN? contains 34401).
open
¤
open() -> None
Initialize the instrument for remote operation.
Clears errors and sends SYST:REM to put instrument in remote mode, which disables the front panel and RS-232 echo that can interfere with communication, we send the SYST:REM command to put the instrument in remote mode.
set_measurement_function
¤
set_measurement_function(function: MeasurementFunction) -> None
Set the measurement function for subsequent reads.
Does a dummy read to configure the instrument for this function.
set_digits
¤
set_range
¤
measure_dc_voltage
¤
measure_dc_voltage() -> float
Trigger a DC voltage measurement and return the result.
Uses MEAS:VOLT:DC? with optional range and resolution parameters.
measure_dc_current
¤
measure_dc_current() -> float
Trigger a DC current measurement and return the result.
Uses MEAS:CURR:DC? with optional range and resolution parameters.
measure_resistance
¤
measure_resistance() -> float
Trigger a 2-wire resistance measurement and return the result.
Uses MEAS:RES? with optional range and resolution parameters.
measure_four_wire_resistance
¤
measure_four_wire_resistance() -> float
Trigger a 4-wire resistance measurement and return the result.
Uses MEAS:FRES? with optional range and resolution parameters.
measure_ac_voltage
¤
measure_ac_voltage() -> float
Trigger an AC voltage measurement and return the result.
Uses MEAS:VOLT:AC? with optional range and resolution parameters. Note: AC measurements are true RMS, AC-coupled.
measure_ac_current
¤
measure_ac_current() -> float
Trigger an AC current measurement and return the result.
Uses MEAS:CURR:AC? with optional range and resolution parameters. Note: AC measurements are true RMS, AC-coupled.
check_errors
¤
check_errors() -> None
Query the instrument error queue and raise if an error is reported.
Note: On RS-232, this may timeout if the instrument is busy or if communication settings aren't optimal. Timeouts are silently ignored to avoid blocking normal operation.
set_aperture_seconds
¤
set_aperture_nplc
¤
set_data_handler
¤
set_data_handler(data_handler: DataHandler) -> None
Set the data handler for SCPI-based drivers.
Parameters:
-
(data_handler¤DataHandler) –The DataHandler instance to use for communication.
get_driver
classmethod
¤
get_driver(idn: str) -> type[DMMDriverDataHandler]
Find the appropriate driver class for a given IDN string.
Parameters:
Returns:
-
type[DMMDriverDataHandler]–The driver class that matches the IDN string.
Raises:
-
ValueError–If IDN is empty, no matching driver is found, or multiple drivers match.