Power Supply¶
PSU control (Siglent SPD and generic SCPI-99)
Main PowerSupply class for controlling SCPI power supplies.
Supports generic SCPI-99 compliant power supplies and Siglent SPD series models.
Installation
pip install "SCPI-Instrument-Control"
Or with power supply examples:¶
pip install "SCPI-Instrument-Control[power-supply-beta]"
Features
- Multiple connection types: Ethernet/LAN, USB, GPIB, Serial
- Full control of voltage, current, and output state
- Model-specific capability detection
- Data logging and automation support
- Context manager support for automatic connection management
Feedback
Please report issues and suggestions at: https://github.com/little-did-I-know/SCPI-Instrument-Control/issues
PowerSupply
¶
PowerSupply(host: str, port: int = 5025, timeout: float = 5.0, connection: Optional[BaseConnection] = None)
Main class for controlling SCPI power supplies.
This class provides a high-level interface for controlling power supply functions including voltage/current settings, output control, and measurements.
Supports both generic SCPI-99 power supplies and Siglent SPD series models with automatic model detection and capability-based feature availability.
Example
psu = PowerSupply('192.168.1.200') psu.connect() print(psu.identify()) print(f"Model: {psu.model_capability.model_name}") print(f"Outputs: {psu.model_capability.num_outputs}") psu.output1.voltage = 5.0 psu.output1.current = 1.0 psu.output1.enabled = True print(f"Actual voltage: {psu.output1.measure_voltage()}V") psu.disconnect()
Or using context manager:
with PowerSupply('192.168.1.200') as psu: ... psu.output1.voltage = 12.0 ... psu.output1.enable()
Initialize power supply connection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
host
|
str
|
IP address or hostname of the power supply |
required |
port
|
int
|
TCP port for SCPI communication (default: 5025, the Siglent raw SCPI socket; 5024 is the telnet-style port with prompts and is not recommended) |
5025
|
timeout
|
float
|
Command timeout in seconds (default: 5.0) |
5.0
|
connection
|
Optional[BaseConnection]
|
Optional custom connection object (uses SocketConnection if None) |
None
|
Note
Outputs are created dynamically after connection based on model capabilities. Call connect() to establish connection and initialize outputs.
Source code in scpi_control/power_supply.py
is_connected
property
¶
Check if connected to power supply.
Returns:
| Type | Description |
|---|---|
bool
|
True if connected, False otherwise |
tracking_mode
property
writable
¶
Get tracking mode for multi-output PSUs.
Returns:
| Type | Description |
|---|---|
str
|
Tracking mode: 'INDEPENDENT', 'SERIES', or 'PARALLEL' |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If tracking is not supported by this model |
device_info
property
¶
Get parsed device information.
Returns:
| Type | Description |
|---|---|
Optional[Dict[str, str]]
|
Dictionary with keys: manufacturer, model, serial, firmware |
Optional[Dict[str, str]]
|
None if not connected |
supported_outputs
property
¶
Get list of supported output numbers for this model.
Returns:
| Type | Description |
|---|---|
List[int]
|
List of output numbers (e.g., [1, 2, 3] for 3-output model) |
List[int]
|
Empty list if not connected |
Example
psu.connect() print(psu.supported_outputs) [1, 2, 3]
connect
¶
Establish connection to the power supply.
This method connects to the power supply, detects the model, and initializes model-specific capabilities and outputs.
Raises:
| Type | Description |
|---|---|
SiglentConnectionError
|
If connection fails |
SiglentTimeoutError
|
If connection times out |
Source code in scpi_control/power_supply.py
disconnect
¶
Close connection to the power supply.
Source code in scpi_control/power_supply.py
write
¶
Send a SCPI command to the power supply.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
command
|
str
|
SCPI command string |
required |
Raises:
| Type | Description |
|---|---|
SiglentConnectionError
|
If not connected |
CommandError
|
If command contains invalid characters |
Source code in scpi_control/power_supply.py
query
¶
Send a SCPI query and get the response.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
command
|
str
|
SCPI query command |
required |
Returns:
| Type | Description |
|---|---|
str
|
Response string from power supply |
Raises:
| Type | Description |
|---|---|
SiglentConnectionError
|
If not connected |
SiglentTimeoutError
|
If query times out |
CommandError
|
If command contains invalid characters |
Source code in scpi_control/power_supply.py
identify
¶
Get device identification string.
Returns:
| Type | Description |
|---|---|
str
|
Device identification string (manufacturer, model, serial, firmware) |
Example
'Siglent Technologies,SPD3303X,SPD3XXXXXXXXXXX,V1.01'
Source code in scpi_control/power_supply.py
reset
¶
Reset power supply to default settings.
Note: This may take several seconds to complete and will turn off all outputs.
clear_status
¶
get_error
¶
Get the last error from the error queue.
Returns:
| Type | Description |
|---|---|
str
|
Error string (format: "code,description") |
all_outputs_off
¶
Disable all outputs (safety feature).
This is a safety method to quickly turn off all power supply outputs.
Source code in scpi_control/power_supply.py
set_independent_mode
¶
set_series_mode
¶
Set outputs to series tracking mode.
In series mode, output voltages add up while current remains the same.
set_parallel_mode
¶
Set outputs to parallel tracking mode.
In parallel mode, output currents add up while voltage remains the same.
get_output
¶
Get output object by number.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output_num
|
int
|
Output number (1-based) |
required |
Returns:
| Type | Description |
|---|---|
Optional[PowerSupplyOutput]
|
PowerSupplyOutput object or None if output doesn't exist |
Example
psu.connect() out1 = psu.get_output(1)