Simulate solar panel characteristics for testing solar-powered devices.
Import
There are two ways to control solar simulation:
# Option 1: Net-based API (recommended)
from lager import Net, NetType
# Option 2: Dispatcher functions (for simple scripts)
from lager.solar.dispatcher import (
set_to_solar_mode, stop_solar_mode, irradiance,
mpp_current, mpp_voltage, resistance, temperature, voc
)
The lager.solar module’s __init__.py is empty. For dispatcher functions, import directly from lager.solar.dispatcher.
Net API Methods
| Method | Description |
|---|
connect_instrument() | Connect and start solar simulation mode |
disconnect_instrument() | Disconnect and stop solar simulation |
irradiance(value) | Set or read irradiance (W/m²) |
mpp_current() | Read maximum power point current |
mpp_voltage() | Read maximum power point voltage |
voc() | Read open-circuit voltage |
temperature() | Read simulated cell temperature |
resistance(value) | Set or read panel resistance |
Solar methods return string values from the instrument. Convert to float if needed for calculations.
Method Reference
Net.get(name, type=NetType.PowerSupply2Q)
Get a solar simulation net by name.
from lager import Net, NetType
solar = Net.get('SOLAR', type=NetType.PowerSupply2Q)
Parameters:
| Parameter | Type | Description |
|---|
name | str | Name of the solar net |
type | NetType | Must be NetType.PowerSupply2Q |
Returns: Solar simulation Net instance
connect_instrument()
Connect to the instrument and start solar simulation mode.
solar.connect_instrument()
disconnect_instrument()
Disconnect from the instrument and stop solar simulation.
solar.disconnect_instrument()
irradiance(value=None)
Set or read the irradiance level.
# Set irradiance
solar.irradiance(1000) # Standard test condition (1000 W/m²)
# Read current irradiance
irr = solar.irradiance()
print(f"Irradiance: {irr}") # Returns string
| Parameter | Type | Description |
|---|
value | float or None | Irradiance in W/m² (0-1500). If None, reads current value. |
Returns: str - Current irradiance value
voc()
Read the open-circuit voltage.
voc_str = solar.voc()
print(f"Voc: {voc_str}")
voc = float(voc_str) # Convert to float for calculations
Returns: str - Voltage value
mpp_voltage()
Read the maximum power point voltage.
v_mpp = solar.mpp_voltage()
print(f"MPP voltage: {v_mpp}")
Returns: str - Voltage value
mpp_current()
Read the maximum power point current.
i_mpp = solar.mpp_current()
print(f"MPP current: {i_mpp}")
Returns: str - Current value
resistance(value=None)
Set or read the dynamic panel resistance.
# Set resistance
solar.resistance(5.0)
# Read resistance
r = solar.resistance()
print(f"Resistance: {r}")
| Parameter | Type | Description |
|---|
value | float or None | Resistance in ohms. If None, reads current value. |
Returns: str - Resistance value
temperature()
Read the simulated cell temperature.
temp = solar.temperature()
print(f"Cell temp: {temp}")
Returns: str - Temperature value
Examples
Basic Solar Simulation
from lager import Net, NetType
import time
solar = Net.get('SOLAR_INPUT', type=NetType.PowerSupply2Q)
# Start simulation
solar.connect_instrument()
# Set standard test conditions (1000 W/m²)
solar.irradiance(1000)
time.sleep(1)
# Read panel characteristics (returns strings)
voc = solar.voc()
v_mpp = solar.mpp_voltage()
i_mpp = solar.mpp_current()
print(f"Voc: {voc}")
print(f"MPP: {v_mpp}V @ {i_mpp}A")
# Calculate max power (convert to float first)
v = float(v_mpp)
i = float(i_mpp)
print(f"Max Power: {v * i:.2f}W")
# Clean up
solar.disconnect_instrument()
Test Multiple Irradiance Levels
from lager import Net, NetType
import time
solar = Net.get('SOLAR', type=NetType.PowerSupply2Q)
solar.connect_instrument()
conditions = [200, 500, 800, 1000, 1200]
for irr in conditions:
solar.irradiance(irr)
time.sleep(1)
# Read and convert values
voc = float(solar.voc())
v_mpp = float(solar.mpp_voltage())
i_mpp = float(solar.mpp_current())
print(f"Irradiance: {irr} W/m²")
print(f" Voc: {voc:.2f}V")
print(f" MPP: {v_mpp:.2f}V @ {i_mpp:.3f}A")
print(f" Power: {v_mpp * i_mpp:.2f}W")
print()
solar.disconnect_instrument()
MPPT Tracking Test
from lager import Net, NetType
import time
solar = Net.get('SOLAR', type=NetType.PowerSupply2Q)
dut_current = Net.get('DUT_CURRENT', type=NetType.ADC)
solar.connect_instrument()
solar.irradiance(1000)
# Monitor MPPT tracking
for i in range(30):
i_mpp = float(solar.mpp_current())
actual = dut_current.input()
efficiency = (actual / i_mpp) * 100 if i_mpp > 0 else 0
print(f"Target: {i_mpp:.3f}A, Actual: {actual:.3f}A, Eff: {efficiency:.1f}%")
time.sleep(1)
solar.disconnect_instrument()
Supported Hardware
| Manufacturer | Model | Features |
|---|
| EA | PSI/EL series | Two-quadrant, PV simulation |
| EA | PSB 10060-60 | Bidirectional |
| EA | PSB 10080-60 | Bidirectional |
Dispatcher Functions
For simple scripts, you can use dispatcher functions that take net names directly:
Mode Control
from lager.solar.dispatcher import set_to_solar_mode, stop_solar_mode
# Start solar simulation mode
set_to_solar_mode('SOLAR')
# Stop solar simulation
stop_solar_mode('SOLAR')
Irradiance Control
from lager.solar.dispatcher import irradiance
# Set irradiance to 1000 W/m² (Standard Test Conditions)
irradiance('SOLAR', 1000)
# Read current irradiance setting (value=None)
irradiance('SOLAR')
Read Measurements
from lager.solar.dispatcher import mpp_current, mpp_voltage, voc, temperature
# Read maximum power point values (returns strings)
i_mpp = mpp_current('SOLAR')
v_mpp = mpp_voltage('SOLAR')
v_oc = voc('SOLAR')
temp = temperature('SOLAR')
Panel Resistance
from lager.solar.dispatcher import resistance
# Set panel resistance
resistance('SOLAR', 5.0)
# Read panel resistance (value=None)
resistance('SOLAR')
Dispatcher Functions Reference
| Function | Description |
|---|
set_to_solar_mode(netname) | Initialize solar simulation mode |
stop_solar_mode(netname) | Stop solar simulation |
irradiance(netname, value=None) | Set/read irradiance (W/m²) |
mpp_current(netname) | Read MPP current |
mpp_voltage(netname) | Read MPP voltage |
voc(netname) | Read open-circuit voltage |
temperature(netname) | Read cell temperature |
resistance(netname, value=None) | Set/read panel resistance |
Dispatcher vs Net API
# Dispatcher functions (simpler, uses net name directly)
from lager.solar.dispatcher import set_to_solar_mode, irradiance, mpp_voltage, mpp_current
set_to_solar_mode('SOLAR')
irradiance('SOLAR', 1000)
v = mpp_voltage('SOLAR')
i = mpp_current('SOLAR')
print(f"MPP: {v}V @ {i}A")
# Net API (object-oriented)
from lager import Net, NetType
solar = Net.get('SOLAR', type=NetType.PowerSupply2Q)
solar.connect_instrument()
solar.irradiance(1000)
v = solar.mpp_voltage()
i = solar.mpp_current()
print(f"MPP: {v}V @ {i}A")
solar.disconnect_instrument()
Notes
- Solar simulation requires bidirectional (two-quadrant) power supplies
- Standard Test Conditions (STC): 1000 W/m², 25°C, AM1.5
- The I-V curve is automatically generated based on irradiance
- Call
connect_instrument() before using solar-specific methods
- Always call
disconnect_instrument() when finished
- Return values are strings - convert to float for calculations
- Dispatcher functions use net names directly for simpler scripts