3.0 KiB
3.0 KiB
Power Supply (Owon) — control, configuration, tests, and quick demo
This guide covers using the Owon bench power supply via SCPI over serial with the framework.
- Library:
ecu_framework/power/owon_psu.py - Hardware test:
tests/hardware/test_owon_psu.py - quick demo script:
vendor/Owon/owon_psu_quick_demo.py - Configuration:
config/test_config.yaml(power_supply), optionally merged fromconfig/owon_psu.yamlor envOWON_PSU_CONFIG
Install dependencies
pip install -r .\requirements.txt
Configure
You can keep PSU settings centrally or in a machine-specific YAML.
- Central:
config/test_config.yaml→power_supplysection - Separate:
config/owon_psu.yaml(orOWON_PSU_CONFIGenv var)
Supported keys:
power_supply:
enabled: true
port: COM4 # e.g., COM4 (Windows) or /dev/ttyUSB0 (Linux)
baudrate: 115200
timeout: 1.0
eol: "\n" # or "\r\n" if required
parity: N # N|E|O
stopbits: 1 # 1|2
xonxoff: false
rtscts: false
dsrdtr: false
idn_substr: OWON
do_set: false
set_voltage: 5.0
set_current: 0.1
The central config loader automatically merges config/owon_psu.yaml (or the path in OWON_PSU_CONFIG) into power_supply.
Run the hardware test
Skips unless power_supply.enabled is true and port is set.
pytest -k test_owon_psu_idn_and_optional_set -m hardware -q
What it does:
- Opens serial with your configured line params
- Queries
*IDN?(checksidn_substrif provided) - If
do_setis true, sets voltage/current, enables output briefly, then disables
Use the library programmatically
from ecu_framework.power import OwonPSU, SerialParams
params = SerialParams(baudrate=115200, timeout=1.0)
with OwonPSU("COM4", params, eol="\n") as psu:
print(psu.idn())
psu.set_voltage(1, 5.0)
psu.set_current(1, 0.1)
psu.set_output(True)
# ... measure, etc.
psu.set_output(False)
Notes:
- Commands use newline-terminated writes; reads use
readline() - SCPI forms:
SOUR:VOLT,SOUR:CURR,MEAS:VOLT?,MEAS:CURR?,output 0/1,output?
quick demo script
The quick demo reads OWON_PSU_CONFIG or config/owon_psu.yaml and performs a small sequence.
python .\vendor\Owon\owon_psu_quick_demo.py
It also scans ports with *IDN? using scan_ports().
Troubleshooting
- Empty
*IDN?or timeouts:- Verify COM port and exclusivity (no other program holding it)
- Try
eol: "\r\n" - Adjust
parityandstopbitsper your device manual
- Windows COM > 9:
- Most Python code accepts
COM10directly; if needed in other tools, use\\.\\COM10
- Most Python code accepts
- Flow control:
- Keep
xonxoff,rtscts,dsrdtrfalse unless required
- Keep
Related files
ecu_framework/power/owon_psu.py— PSU controller (pyserial)tests/hardware/test_owon_psu.py— Hardware test using central configvendor/Owon/owon_psu_quick_demo.py— Quick demo runnerconfig/owon_psu.example.yaml— Example machine-specific YAML