A .NET library for controlling OWON DC Power Supply units via SCPI commands over serial connections.
$ dotnet add package Owon.DCPSUA .NET library for controlling OWON DC Power Supply units via SCPI commands over serial connections.
dotnet add package Owon.DCPSU
git clone https://github.com/your-repo/owon-dcpsu.git
cd owon-dcpsu
dotnet build
using Owon.DCPSU;
using Owon.DCPSU.Transports;
// Create serial transport
using var transport = new SerialScpiTransport(portName: "COM3", baudRate: 115200);
var psu = new OwonDcPowerSupply(transport);
// Connect and control
await psu.ConnectAsync();
var id = await psu.IdentifyAsync();
Console.WriteLine($"Device: {id}");
// Set voltage and current
await psu.SetRemoteAsync();
await psu.SetVoltageAsync(12.0); // 12V
await psu.SetCurrentAsync(2.0); // 2A
await psu.SetOutputAsync(true); // Enable output
// Measure output
var (voltage, current, power) = await psu.MeasureAllAsync();
Console.WriteLine($"Output: {voltage}V, {current}A, {power}W");
// Disable output and return to local mode
await psu.SetOutputAsync(false);
await psu.SetLocalAsync();
var transport = new SerialScpiTransport(
portName: "COM3", // Serial port name
baudRate: 115200, // Baud rate (default: 115200)
parity: Parity.None, // Parity (default: None)
dataBits: 8, // Data bits (default: 8)
stopBits: StopBits.One // Stop bits (default: One)
);
| Method | Description | Parameters |
|---|---|---|
ConnectAsync() | Establish connection to power supply | CancellationToken |
IdentifyAsync() | Get instrument identification | CancellationToken |
ResetAsync() | Reset to factory defaults | CancellationToken |
| Method | Description | Parameters |
|---|---|---|
SetOutputAsync(bool) | Enable/disable output | enabled, CancellationToken |
GetOutputAsync() | Query output status | CancellationToken |
| Method | Description | Parameters |
|---|---|---|
SetVoltageAsync(double) | Set output voltage | volts, CancellationToken |
GetVoltageAsync() | Query voltage setting | CancellationToken |
SetVoltageLimitAsync(double) | Set OVP limit | volts, CancellationToken |
GetVoltageLimitAsync() | Query OVP limit | CancellationToken |
MeasureVoltageAsync() | Measure actual voltage | CancellationToken |
| Method | Description | Parameters |
|---|---|---|
SetCurrentAsync(double) | Set output current | amps, CancellationToken |
GetCurrentAsync() | Query current setting | CancellationToken |
SetCurrentLimitAsync(double) | Set OCP limit | amps, CancellationToken |
GetCurrentLimitAsync() | Query OCP limit | CancellationToken |
MeasureCurrentAsync() | Measure actual current | CancellationToken |
| Method | Description | Returns |
|---|---|---|
MeasurePowerAsync() | Measure output power | double (watts) |
MeasureAllAsync() | Measure V, I, P simultaneously | (volts, amps, watts) |
MeasureAllInfoAsync() | Extended measurement with status | (volts, amps, watts, ovp, ocp, otp, mode) |
| Method | Description | Parameters |
|---|---|---|
SetLocalAsync() | Switch to local mode | CancellationToken |
SetRemoteAsync() | Switch to remote mode | CancellationToken |
The power supply operates in different modes:
Use MeasureAllInfoAsync() to query the current operating mode and fault status.
System.IO.Ports package (included)The repository includes a complete example project (Owon.DCPSU.Example) demonstrating:
Run the example:
cd Owon.DCPSU.Example
dotnet run
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
For issues and questions, please open an issue on the GitHub repository.