Skip to main content
Control programmable power supplies to set voltage, current, and protection thresholds for your DUT.

Import

from lager import Net, NetType

Methods

MethodDescription
set_voltage()Set output voltage
set_current()Set output current limit
voltage()Read measured voltage
current()Read measured current
power()Read measured power
enable()Enable power output
disable()Disable power output
set_ovp()Set over-voltage protection threshold
set_ocp()Set over-current protection threshold
get_ovp_limit()Get over-voltage protection limit
get_ocp_limit()Get over-current protection limit
is_ovp()Check if OVP fault is active
is_ocp()Check if OCP fault is active
clear_ovp()Clear over-voltage protection fault
clear_ocp()Clear over-current protection fault

Method Reference

Net.get(name, type=NetType.PowerSupply)

Get a power supply net by name.
from lager import Net, NetType

psu = Net.get('VDD', type=NetType.PowerSupply)
Parameters:
ParameterTypeDescription
namestrName of the power supply net
typeNetTypeMust be NetType.PowerSupply
Returns: Power supply Net instance

set_voltage(value)

Set the output voltage.
psu.set_voltage(3.3)  # Set to 3.3V
ParameterTypeDescription
valuefloatTarget voltage in volts

set_current(value)

Set the output current limit.
psu.set_current(0.5)  # Set limit to 0.5A
ParameterTypeDescription
valuefloatCurrent limit in amps

voltage()

Read the measured output voltage.
v = psu.voltage()
print(f"Voltage: {v}V")
Returns: float - Measured voltage in volts

current()

Read the measured output current.
i = psu.current()
print(f"Current: {i}A")
Returns: float - Measured current in amps

power()

Read the measured output power.
p = psu.power()
print(f"Power: {p}W")
Returns: float - Measured power in watts

enable()

Enable the power output.
psu.enable()

disable()

Disable the power output.
psu.disable()

set_ovp(limit)

Set over-voltage protection threshold.
psu.set_ovp(3.6)  # Trip at 3.6V
ParameterTypeDescription
limitfloatOVP threshold in volts

set_ocp(limit)

Set over-current protection threshold.
psu.set_ocp(1.0)  # Trip at 1.0A
ParameterTypeDescription
limitfloatOCP threshold in amps

get_ovp_limit()

Get the configured OVP limit.
ovp = psu.get_ovp_limit()
print(f"OVP limit: {ovp}V")
Returns: float - OVP threshold in volts

get_ocp_limit()

Get the configured OCP limit.
ocp = psu.get_ocp_limit()
print(f"OCP limit: {ocp}A")
Returns: float - OCP threshold in amps

is_ovp()

Check if an over-voltage fault is active.
if psu.is_ovp():
    print("OVP fault detected!")
Returns: bool - True if OVP fault is active

is_ocp()

Check if an over-current fault is active.
if psu.is_ocp():
    print("OCP fault detected!")
Returns: bool - True if OCP fault is active

clear_ovp()

Clear over-voltage protection fault.
psu.clear_ovp()

clear_ocp()

Clear over-current protection fault.
psu.clear_ocp()

Examples

Basic Power Control

from lager import Net, NetType

# Get power supply net
psu = Net.get('VDD', type=NetType.PowerSupply)

# Configure output
psu.set_voltage(3.3)
psu.set_current(0.5)

# Enable output
psu.enable()

# Read measurements
print(f"Voltage: {psu.voltage():.2f}V")
print(f"Current: {psu.current():.3f}A")
print(f"Power: {psu.power():.3f}W")

# Disable when done
psu.disable()

With Protection Thresholds

from lager import Net, NetType
import time

psu = Net.get('VDD', type=NetType.PowerSupply)

# Configure voltage/current
psu.set_voltage(5.0)
psu.set_current(0.5)

# Set protection thresholds
psu.set_ovp(5.5)  # Trip at 5.5V
psu.set_ocp(0.6)  # Trip at 0.6A

# Enable output
psu.enable()
print("Power enabled")

# Monitor for faults
time.sleep(1)
if psu.is_ocp():
    print("OCP fault! Clearing...")
    psu.clear_ocp()

if psu.is_ovp():
    print("OVP fault! Clearing...")
    psu.clear_ovp()

# Clean up
psu.disable()

Monitor Power Consumption

from lager import Net, NetType
import time

psu = Net.get('VDD', type=NetType.PowerSupply)
psu.set_voltage(3.3)
psu.set_current(1.0)
psu.enable()

# Log power consumption
for i in range(10):
    v = psu.voltage()
    i = psu.current()
    p = psu.power()
    print(f"V={v:.2f}V, I={i:.3f}A, P={p:.3f}W")
    time.sleep(1)

psu.disable()

Supported Hardware

ManufacturerModel SeriesFeatures
RigolDP800 seriesMulti-channel, OVP/OCP
Keithley2200/2280 seriesHigh precision
KeysightE36200 seriesMulti-channel
KeysightE36300 seriesMulti-channel, high power
EAPSI seriesTwo-quadrant operation

Notes

  • Net must be configured as NetType.PowerSupply
  • Call enable() to turn on the output after setting voltage/current
  • Always call disable() when finished
  • Protection faults may automatically disable output
  • Use clear_ovp() or clear_ocp() after addressing fault conditions
  • Voltage and current limits depend on hardware capabilities