VirtualPSU#
- class VirtualPSU(
- num_channels: int = DEFAULT_NUM_CHANNELS,
- load_resistance: float | Mapping[int, float] = DEFAULT_LOAD_RESISTANCE,
Bases:
PSUDriverBasePSU simulated in-process: no transport, server, or hardware.
Each channel drives its own resistive load. With the output on, a channel holds its voltage setpoint (constant voltage) until the load would draw more than the current limit, then holds the current limit (constant current). Readings carry 0.5% noise, the SCPI simulator’s level. The current limit starts at the channel maximum (10 A), so setting a voltage and enabling the output is enough to see it.
As on the SCPI simulator, voltages must lie within 0 to 60 V and currents within 0 to 10 A, or the setter raises
ValueError. Unlike it, a setpoint may sit above its protection level, which is how a virtual channel trips: there is no external source to push the output past its setpoint.Enabled overvoltage or overcurrent protection trips when the output exceeds its level, latching the output off until
clear_protectionand a newoutput_enable;output_enablealone also clears the latch, as on the SCPI simulator. As there, protection is checked after every change that can move the output (setpoints, protection settings, output enable, and the load), so a fault trips when it happens, and readings never change state. Remote sense and the overvoltage protection delay are stored and have no effect on readings. To exercise the VISA transport as well, useSimulatedPSUwith the bundled SCPI simulator.Create a virtual PSU.
- Parameters:
num_channels (int)
Number of output channels, numbered from 1. Pass the same count to
InstroPSU; a channel above it raisesValueError.load_resistance (float | Mapping[int, float])
Resistance of each channel’s load, in ohms: one value for every channel, or a mapping from channel to value, with channels left out at 1000 ohms.
0is a short andmath.infan open circuit. Change it at any time withset_load_resistanceto move a channel between constant voltage and constant current.
- Raises:
ValueError –
num_channelsis less than 1, orload_resistanceis negative or names a channel that does not exist.
Example:
from instro.psu import InstroPSU from instro.psu.drivers import VirtualPSU driver = VirtualPSU(num_channels=2, load_resistance={1: 10.0, 2: 1.0}) with InstroPSU(name="psu", driver=driver, num_channels=2) as psu: for channel in (1, 2): psu.apply(current_limit=1.0, voltage=5.0, enable=True, channel=channel) print(psu.get_operating_mode(channel=1).latest) # CV: 10 ohms draws 0.5 A print(psu.get_operating_mode(channel=2).latest) # CC: 1 ohm would draw 5 A driver.set_load_resistance(100.0, channel=2) print(psu.get_operating_mode(channel=2).latest) # CV
Methods
Clear every latched protection trip on
channel.Nothing to disconnect.
Query the measured output current (amperes) on
channel.Query the configured current-limit setpoint (amperes) on
channel.Return the load resistance on
channel, in ohms.Query whether
channelis regulating in constant voltage, constant current, unregulated, or off.Query whether the output on
channelis enabled.Query whether overcurrent protection is enabled on
channel.Query the overcurrent protection threshold (amperes) on
channel.Query whether overcurrent protection has tripped on
channeland not been cleared.Query the overvoltage protection trip delay (seconds) on
channel.Query whether overvoltage protection is enabled on
channel.Query the overvoltage protection threshold (volts) on
channel.Query whether overvoltage protection has tripped on
channeland not been cleared.Query whether remote sense is enabled on
channel.Query the measured output voltage (volts) on
channel.Query the configured voltage setpoint (volts) on
channel.Nothing to connect to.
Enable or disable the output on
channel.Set the current limit (amperes) on
channel.Set the load on
channel, or on every channel whenchannelisNone.Enable or disable overcurrent protection on
channel.Set the overcurrent protection threshold (amperes) on
channel.Stored; protection trips without delay.
Enable or disable overvoltage protection on
channel.Set the overvoltage protection threshold (volts) on
channel.Stored; the virtual load has no lead resistance, so readings are unchanged.
Set the output voltage (volts) on
channel.- set_load_resistance( ) None[source]#
Set the load on
channel, or on every channel whenchannelisNone.- Parameters:
- Raises:
ValueError –
resistanceis negative, orchanneldoes not exist.
- get_voltage(channel: int) float[source]#
Query the measured output voltage (volts) on
channel. Output may vary from voltage setpoint outside of constant voltage mode.
- set_current_limit(current_limit: float, channel: int) None[source]#
Set the current limit (amperes) on
channel.
- get_current(channel: int) float[source]#
Query the measured output current (amperes) on
channel. Output may vary from current-limit setpoint outside of constant current mode.
- get_voltage_setpoint(channel: int) float[source]#
Query the configured voltage setpoint (volts) on
channel. Output may vary from actual measured voltage outside of constant voltage mode.
- get_current_setpoint(channel: int) float[source]#
Query the configured current-limit setpoint (amperes) on
channel. Output may vary from actual measured current outside of constant current mode.
- get_operating_mode(
- channel: int,
Query whether
channelis regulating in constant voltage, constant current, unregulated, or off.
- set_overvoltage_protection_level( ) None[source]#
Set the overvoltage protection threshold (volts) on
channel.
- get_overvoltage_protection_level(channel: int) float[source]#
Query the overvoltage protection threshold (volts) on
channel.
- set_overvoltage_protection_enabled( ) None[source]#
Enable or disable overvoltage protection on
channel.
- get_overvoltage_protection_enabled(channel: int) bool[source]#
Query whether overvoltage protection is enabled on
channel.
- get_overvoltage_protection_delay(channel: int) float[source]#
Query the overvoltage protection trip delay (seconds) on
channel.
- set_overcurrent_protection_level( ) None[source]#
Set the overcurrent protection threshold (amperes) on
channel.
- get_overcurrent_protection_level(channel: int) float[source]#
Query the overcurrent protection threshold (amperes) on
channel.
- set_overcurrent_protection_enabled( ) None[source]#
Enable or disable overcurrent protection on
channel.
- get_overcurrent_protection_enabled(channel: int) bool[source]#
Query whether overcurrent protection is enabled on
channel.
- clear_protection(channel: int) None[source]#
Clear every latched protection trip on
channel. The output stays off until re-enabled.
- get_overvoltage_protection_tripped(channel: int) bool[source]#
Query whether overvoltage protection has tripped on
channeland not been cleared.
- get_overcurrent_protection_tripped(channel: int) bool[source]#
Query whether overcurrent protection has tripped on
channeland not been cleared.