# Power Supply (PSU)

Using InstroPSU for SCPI-based programmable power supplies

`InstroPSU` provides a unified interface for programmable power supplies. This class is initialized with a vendor-specific driver (`BK9115`, `KeysightE36100`, `RigolDP800`, …), and provides the vendor-agnostic API (`set_voltage`, `get_voltage`, `output_enable`, …).

## Creating an InstroPSU

```python
from instro.psu.drivers import SiglentSPD3303
from instro.psu import InstroPSU

psu = InstroPSU(
    name="myPSU",
    driver=SiglentSPD3303(visa_resource="USB0::0xF4EC::0x1430::SPD3XJGQ806726::INSTR"),
    num_channels=2,
)
```

## Supported Vendors

B&K Precision 9115

![](https://dev.nominal.io/instro/_images/BK9115.png)
[BK9115](https://dev.nominal.io/instro/psu/BK9115.md)

B&K Precision 914x

![](https://dev.nominal.io/instro/_images/BK914X.png)
[BK914X](https://dev.nominal.io/instro/psu/BK914X.md)

GW Instek GPD-3303D

![](https://dev.nominal.io/instro/_images/GWInstekGPD3303.png)
[GWInstekGPD3303](https://dev.nominal.io/instro/psu/GWInstekGPD3303.md)

Keysight E36100

![](https://dev.nominal.io/instro/_images/KeysightE36100.png)
[KeysightE36100](https://dev.nominal.io/instro/psu/KeysightE36100.md)

Keysight N5700

![](https://dev.nominal.io/instro/_images/KeysightN5700.png)
[KeysightN5700](https://dev.nominal.io/instro/psu/KeysightN5700.md)

Rigol DP800

![](https://dev.nominal.io/instro/_images/RigolDP800.png)
[RigolDP800](https://dev.nominal.io/instro/psu/RigolDP800.md)

Siglent SPD3303

![](https://dev.nominal.io/instro/_images/SiglentSPD3303.png)
[SiglentSPD3303](https://dev.nominal.io/instro/psu/SiglentSPD3303.md)

TDK Lambda Genesys

![](https://dev.nominal.io/instro/_images/TDKLambdaGenesys.png)
[TDKLambdaGenesys](https://dev.nominal.io/instro/psu/TDKLambdaGenesys.md)

- **Virtual**: no hardware or server; outputs simulated in-process (`VirtualPSU`, see [Virtual instruments](https://dev.nominal.io/instro/library/simulated-instruments.md#virtual-instruments))
- **Simulated**: no hardware required; pairs with the bundled [PSU simulator](https://dev.nominal.io/instro/library/simulated-instruments.md#psu-simulator) (`SimulatedPSU`)

The following vendor is available as a community-contributed driver in `instro-contrib` (install with `instro[contrib]`; see [Contrib drivers](https://dev.nominal.io/instro/library/contrib.md)):

- **Matrix**: WPS300S-series single-channel via SCPI/RS-232 (`MatrixWPS300S`)

If your vendor or model is not listed, see [Custom Driver Development](https://dev.nominal.io/instro/library/custom-instruments.md#power-supply-psu), or open a [Driver Request](https://github.com/nominal-io/instro/issues) issue on GitHub.

## Example

More examples found in [Examples](https://dev.nominal.io/instro/examples/psu.md)

## Details

The following presents details about the `InstroPSU`. Specific driver details can be found on [their pages](https://dev.nominal.io/instro/psu.md#supported-vendors).

### Driver Composition

An `InstroPSU` is built from a concrete driver:

```
InstroPSU("name", driver=BK9115(visa_resource="USB0::..."), num_channels=1)
```

- The **vendor driver** (e.g. `BK9115`) owns the connection setup and vendor-specific command mapping.
- **`InstroPSU`** owns the category-level workflow: measurements, commands, publishers, the background daemon.

### Lifecycle

The typical InstroPSU workflow:

1. **Construct**: instantiate the vendor driver and pass it to `InstroPSU`.
2. **`open()`**: establishes the VISA connection.
3. **Configure and measure**: set voltage/current limits, enable outputs, read measurements. `apply()` sets the current limit, then the voltage, then the output state in one call.
4. **`start()`**: begins a periodic background daemon. (Optional)
5. **`stop()`**: ends the background daemon (if started).
6. **`close()`**: disconnects from hardware.

### Protection Trips

When overvoltage or overcurrent protection trips, a supply typically latches the output off until the trip is cleared. `get_overvoltage_protection_tripped()` and `get_overcurrent_protection_tripped()` report the latch as a bool `Measurement` (`ch<n>.ovp.tripped`, `ch<n>.ocp.tripped`). `clear_protection()` clears every latched trip on the channel and publishes a `Command` (`ch<n>.protection.clear.cmd`). The output stays off after a clear; fix the cause, then re-enable it with `output_enable()`.

```python
psu.get_overcurrent_protection_tripped(channel=1)  # myPSU.ch1.ocp.tripped: [1.0]
psu.clear_protection(channel=1)
psu.output_enable(True, channel=1)
```

`RigolDP800` implements these methods. Drivers for supplies without the matching protection raise `FeatureNotSupportedError`; other drivers don’t implement them yet and raise `NotImplementedError`.

### Init from a Config File

`InstroPSU` can also be constructed directly from a JSON config file, which removes the need to write any Python setup code:

```python
from instro.psu import InstroPSU

psu = InstroPSU(config="bench_psu.json")
```

Where `bench_psu.json` contains:

```json
{
  "version": 1,
  "instrument": "InstroPSU",
  "device": {
    "name": "bench_psu",
    "description": "Bench channel 1 supply",
    "manufacturer": "B&K Precision",
    "model": "9115"
  },
  "driver": {
    "name": "BK9115",
    "num_channels": 1,
    "connection_type": "visa",
    "visa": {
      "visa_resource": "USB0::0x2A8D::0x0101::MY12345::INSTR"
    }
  },
  "timing": {
    "poll_interval": 1.0
  },
  "publishers": [
    {
      "type": "NominalCorePublisher",
      "dataset_rid": "<dataset_rid>"
    }
  ]
}
```

To try a config with no hardware, use the virtual driver: `"driver": {"connection_type": "virtual", "name": "VirtualPSU", "num_channels": 1}`. An optional `load_resistance` (ohms, default 1000) sets the load: one value for every channel, or a map such as `{"1": 10.0, "2": 1.0}`.

See [Config Files](https://dev.nominal.io/instro/library/config-files.md) for the full field reference.

### Simulated Power Supply

For development and testing without physical hardware, Nominal Instrumentation includes a local SCPI power-supply simulator. See [PSU simulator](https://dev.nominal.io/instro/library/simulated-instruments.md#psu-simulator) for the quickstart, usage notes, and supported command set. To skip the server entirely, use `VirtualPSU`, which simulates the outputs in-process.

## Custom Driver Development

For more information on writing a custom driver, see [Custom Driver Development](https://dev.nominal.io/instro/library/custom-instruments.md#power-supply-psu).
