PSU (Power Supply Unit)¤
Interface¤
power supply (PSU) instrument interface and helpers.
Defines InstroPSU and related helpers.
Transport/protocols: SCPI, VISA.
Public API
InstroPSU, InstroPSUFacade
InstroPSU
¤
InstroPSU(
name: str,
connection_config: ConnectConfig,
driver: PSUDriverBase,
num_channels: int,
publishers: list[Publisher] | None = None,
**kwargs,
)
Bases: Instrument
Power Supply hardware abstraction to communicate with various models and vendor power supplies.
Methods return Measurement and Command data types to be compatible with Nominal Instrumentation tools.
Parameters:
-
(name¤str) –A name to identify this power supply instance. Used in channel naming and published data.
-
(connection_config¤ConnectConfig) –Connection configuration for the power supply (SCPI/VISA).
-
(driver¤PSUDriverBase) –The driver instance for the specific power supply vendor/model.
-
(num_channels¤int) –The number of output channels on this power supply.
-
(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 and can be utilized by publishers like NominalCorePublisher as added metadata.
Special keyword arguments: dataset_rid (str): 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,
num_channels: int,
publishers: list[Publisher] | None = None,
**kwargs,
) -> InstroPSU
Discover and create a InstroPSU instance by querying the instrument's IDN.
This factory method automatically discovers the power supply model and creates an appropriate driver instance from Nominal's list of registered psu 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 InstroPSU instance with the appropriate driver.
Parameters:
-
(name¤str) –A name to identify this power supply instance. Used in channel naming and published data.
-
(resource¤ConnectConfig) –A ConnectConfig for SCPI/VISA devices.
-
(num_channels¤int) –Number of channels on the power supply.
-
(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 and can be utilized by publishers like NominalCorePublisher as added metadata.
Special keyword arguments: dataset_rid (str): If provided, automatically creates and adds a NominalCorePublisher with the specified dataset RID. Assumes a Nominal 'default' credential is stored on disk.
Returns:
-
InstroPSU(InstroPSU) –Configured power supply instance with the appropriate driver.
Raises:
-
ValueError–If no matching driver is found for the IDN string.
-
TypeError–If resource is a string (vendor library devices require manual construction).
set_voltage
¤
Set the voltage on the power supply.
Parameters:
-
(voltage¤float) –The voltage to set (in volts).
-
(channel¤int, default:1) –For multi-channel power supplies. Defaults to 1.
-
–**kwargs¤Optional keyword arguments used as tags. These tags are applied to the Command object and can be utilized by publishers like NominalCorePublisher as added metadata.
Returns:
-
Command(Command) –A Command object containing the channel name, value, timestamp, and tags. The command is automatically published to all configured publishers.
get_voltage
¤
get_voltage(channel: int = 1, **kwargs) -> Measurement | None
Query the voltage that the power supply senses is active on its terminals.
Parameters:
-
(channel¤int, default:1) –For multi-channel power supplies. Defaults to 1.
-
–**kwargs¤Optional keyword arguments used as tags. These tags are applied to the Measurement object and can be utilized by publishers like NominalCorePublisher as added metadata.
Returns:
-
Measurement | None–Measurement | None: A Measurement object containing the channel name, voltage value, timestamp, and tags. The measurement is automatically published to all configured publishers. Returns None if the measurement could not be obtained.
set_current_limit
¤
Set the current limit on the power supply.
Parameters:
-
(current_limit¤float) –The current limit to set (in amperes).
-
(channel¤int, default:1) –For multi-channel power supplies. Defaults to 1.
-
–**kwargs¤Optional keyword arguments used as tags. These tags are applied to the Command object and can be utilized by publishers like NominalCorePublisher as added metadata.
Returns:
-
Command(Command) –A Command object containing the channel name, value, timestamp, and tags. The command is automatically published to all configured publishers.
get_current
¤
get_current(channel: int = 1, **kwargs) -> Measurement | None
Query the current that the power supply senses through its terminals.
Parameters:
-
(channel¤int, default:1) –For multi-channel power supplies. Defaults to 1.
-
–**kwargs¤Optional keyword arguments used as tags. These tags are applied to the Measurement object and can be utilized by publishers like NominalCorePublisher as added metadata.
Returns:
-
Measurement | None–Measurement | None: A Measurement object containing the channel name, current value, timestamp, and tags. The measurement is automatically published to all configured publishers. Returns None if the measurement could not be obtained.
output_enable
¤
Enable or disable the power supply output.
Parameters:
-
(enable¤bool) –True to enable the output, False to disable.
-
(channel¤int, default:1) –For multi-channel power supplies. Defaults to 1.
-
–**kwargs¤Optional keyword arguments used as tags. These tags are applied to the Command object and can be utilized by publishers like NominalCorePublisher as added metadata.
Returns:
-
Command(Command) –A Command object containing the channel name, value, timestamp, and tags. The command is automatically published to all configured publishers.
get_output_status
¤
get_output_status(channel: int = 1, **kwargs) -> Measurement | None
Query if the power supply output is on or off.
Parameters:
-
(channel¤int, default:1) –For multi-channel power supplies. Defaults to 1.
-
–**kwargs¤Optional keyword arguments used as tags. These tags are applied to the Measurement object and can be utilized by publishers like NominalCorePublisher as added metadata.
Returns:
-
Measurement | None–Measurement | None: A Measurement object containing the channel name, output status , timestamp, and tags. The measurement is automatically published to all configured publishers. Returns None if the measurement could not be obtained.
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:
start
¤
start()
Start the background worker thread.
This method creates and starts a daemon thread that periodically executes all
registered background daemon functions. If the thread is already running, this
method does nothing. The thread will continue running until stop() is called.
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:
InstroPSUFacade
¤
InstroPSUFacade(nominal_psu: InstroPSU)
Facade class that provides drivers with access to InstroPSU configuration.
This class implements the APIInstroPSU interface and allows drivers to access power supply configuration without direct access to the InstroPSU instance's internal state.
Parameters:
Driver Interface¤
power supply (PSU) instrument interface and helpers.
Defines PSUDriverBase and related helpers.
Transport/protocols: SCPI.
Public API
APIInstroPSU, PSUDriverBase, PSUDriverDataHandler
PSUDriverBase
¤
Bases: ABC
Abstract base class for vendor power supply.
Each concrete provider implements sending and receiving data for its vendor/model.
PSUDriverDataHandler
¤
PSUDriverDataHandler()
Bases: PSUDriverBase
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[PSUDriverDataHandler]
Find the appropriate driver class for a given IDN string.
Parameters:
Returns:
-
type[PSUDriverDataHandler]–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 / status register and raise exception if error pending.
If no errors, return silently.
set_voltage
abstractmethod
¤
get_voltage
abstractmethod
¤
set_current_limit
abstractmethod
¤
set_current_limit(current_limit: float, channel: int = 1) -> None
get_current
abstractmethod
¤
output_enable
abstractmethod
¤
Vendor Drivers¤
BK Precision (Single Channel)¤
Bk Single Channel driver for power supply (PSU) instruments.
Implements BKSingleChannelDriver and supporting helpers.
Transport/protocols: SCPI.
Public API
BKSingleChannelDriver
BKSingleChannelDriver
¤
BKSingleChannelDriver()
Bases: PSUDriverDataHandler
Driver for BK Precision 9115 PSU.
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[PSUDriverDataHandler]
Find the appropriate driver class for a given IDN string.
Parameters:
Returns:
-
type[PSUDriverDataHandler]–The driver class that matches the IDN string
Raises:
-
ValueError–If IDN is empty, no matching driver is found, or multiple drivers match
BK Precision (Multi Channel)¤
Bk Multi Channel driver for power supply (PSU) instruments.
Implements BKMultiChannelDriver and supporting helpers.
Transport/protocols: SCPI.
Public API
BKMultiChannelDriver
BKMultiChannelDriver
¤
BKMultiChannelDriver()
Bases: PSUDriverDataHandler
Driver for BK Precision 9140 Series of PSUs.
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[PSUDriverDataHandler]
Find the appropriate driver class for a given IDN string.
Parameters:
Returns:
-
type[PSUDriverDataHandler]–The driver class that matches the IDN string
Raises:
-
ValueError–If IDN is empty, no matching driver is found, or multiple drivers match
Rigol¤
Rigol driver for power supply (PSU) instruments.
Implements RigolPSUDriver and supporting helpers.
Transport/protocols: SCPI.
Public API
RigolPSUDriver
RigolPSUDriver
¤
RigolPSUDriver()
Bases: PSUDriverDataHandler
SCPI mapping for Rigol multi-channel PSUs.
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[PSUDriverDataHandler]
Find the appropriate driver class for a given IDN string.
Parameters:
Returns:
-
type[PSUDriverDataHandler]–The driver class that matches the IDN string
Raises:
-
ValueError–If IDN is empty, no matching driver is found, or multiple drivers match
Siglent¤
Siglent driver for power supply (PSU) instruments.
Implements SiglentPSUDriver and supporting helpers.
Transport/protocols: SCPI.
Public API
SiglentPSUDriver
SiglentPSUDriver
¤
SiglentPSUDriver()
Bases: PSUDriverDataHandler
SCPI mapping for Siglent PSUs.
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[PSUDriverDataHandler]
Find the appropriate driver class for a given IDN string.
Parameters:
Returns:
-
type[PSUDriverDataHandler]–The driver class that matches the IDN string
Raises:
-
ValueError–If IDN is empty, no matching driver is found, or multiple drivers match
TDK Lambda¤
Tdk Lambda driver for power supply (PSU) instruments.
Implements TDKLambdaPSUProvider and supporting helpers.
Transport/protocols: SCPI.
Public API
TDKLambdaPSUProvider
TDKLambdaPSUProvider
¤
TDKLambdaPSUProvider()
Bases: PSUDriverDataHandler
SCPI mapping for TDK Lambda PSUs (e.g. Genesys).
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[PSUDriverDataHandler]
Find the appropriate driver class for a given IDN string.
Parameters:
Returns:
-
type[PSUDriverDataHandler]–The driver class that matches the IDN string
Raises:
-
ValueError–If IDN is empty, no matching driver is found, or multiple drivers match
Simulated¤
Simulated driver for power supply (PSU) instruments.
Implements SimulatedPSUDriver and supporting helpers.
Public API:
SimulatedPSUDriver
SimulatedPSUDriver
¤
SimulatedPSUDriver()
Bases: PSUDriverDataHandler
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[PSUDriverDataHandler]
Find the appropriate driver class for a given IDN string.
Parameters:
Returns:
-
type[PSUDriverDataHandler]–The driver class that matches the IDN string
Raises:
-
ValueError–If IDN is empty, no matching driver is found, or multiple drivers match