VirtualELoad#

class VirtualELoad(
source_voltage: float = 12.0,
source_resistance: float = 0.5,
)[source]#

Bases: ELoadDriverBase

Single-channel E-Load simulated in-process: no transport, server, or hardware.

The load sinks from a simulated source: a fixed voltage behind an internal resistance. With the input off the terminals read the open-circuit voltage at 0 A; with it on, the readings are the operating point the active mode and level set on that source, plus noise (0.5%). As on the BK85XXB, short_output also switches the input: a short pulls the terminals to 0 V at the source’s short-circuit current, and ending it turns the input off. Range and slew-rate settings are accepted and have no effect on readings, so any InstroELoad call works.

Levels the source cannot reach are not errors: CC and CR stop at the short-circuit current, and CP stops at the source’s maximum power (half its open-circuit voltage), where a real load would lose regulation. There are no ratings, protections, or time dynamics.

Create a virtual E-Load.

Parameters:
  • source_voltage (float)

    Open-circuit voltage of the simulated source, in volts. Must not be negative.

  • source_resistance (float)

    Internal resistance of the simulated source, in ohms. Must be positive; it sets how far the voltage sags as the load draws current.

Both stay settable as attributes, e.g. to sag the source mid-run, and are validated on every set.

Raises:

ValueError – If source_voltage is negative or source_resistance is not positive.

Example:

from instro.eload import InstroELoad, LoadMode
from instro.eload.drivers import VirtualELoad

eload = InstroELoad(name="eload", driver=VirtualELoad(source_voltage=12.0, source_resistance=0.5))
with eload:
    eload.set_mode(LoadMode.CC)
    eload.set_level(2.0)
    eload.output_enable(True)
    print(eload.get_current().latest)  # about 2.0
    print(eload.get_voltage().latest)  # about 11.0

Attributes

source_resistance

Internal resistance of the simulated source, in ohms.

source_voltage

Open-circuit voltage of the simulated source, in volts.

Methods

close

Nothing to disconnect.

get_current

Measure the current the load is sinking on channel (amperes).

get_voltage

Measure the voltage at channel's terminals (volts).

open

Nothing to connect to.

output_enable

Turn the input on or off; a short set by short_output stays set.

set_level

Set mode's level; each mode keeps its own.

set_mode

Set the operating mode on channel: CC, CV, CP, or CR.

set_range

Accepted; no effect on readings.

set_slewrate

Accepted; no effect on readings, which settle instantly.

short_output

Start or end a short; like the BK85XXB, this also turns the input on or off.

property source_voltage: float#

Open-circuit voltage of the simulated source, in volts.

property source_resistance: float#

Internal resistance of the simulated source, in ohms.

open() → None[source]#

Nothing to connect to.

close() → None[source]#

Nothing to disconnect.

short_output(enable: bool, channel: int) → None[source]#

Start or end a short; like the BK85XXB, this also turns the input on or off.

The short stays set until short_output(False): turning the input off and on again with output_enable leaves it shorted, as INPut alone leaves INPut:SHORt on the BK85XXB.

set_mode(
mode: LoadMode,
channel: int,
) → None[source]#

Set the operating mode on channel: CC, CV, CP, or CR.

Not every model supports every mode; drivers should raise NotImplementedError for unsupported combinations.

set_level(
mode: LoadMode,
value: float,
channel: int,
curr_limit: float | None,
) → None[source]#

Set mode’s level; each mode keeps its own. curr_limit caps the current in CV mode.

set_range(
mode: LoadMode,
value: float,
channel: int,
) → None[source]#

Accepted; no effect on readings.

set_slewrate(
direction: SlewRateDirection,
rate: float,
channel: int,
) → None[source]#

Accepted; no effect on readings, which settle instantly.

output_enable(enable: bool, channel: int) → None[source]#

Turn the input on or off; a short set by short_output stays set.

get_current(channel: int) → float[source]#

Measure the current the load is sinking on channel (amperes).

get_voltage(channel: int) → float[source]#

Measure the voltage at channel’s terminals (volts).