Skip to content

Shadetheartist/korad_psu_cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

KORAD PSU CLI

A simple and robust command-line interface for controlling Korad variable power supplies.

This program should be compatible with any KORAD KAxxxxP or KAxxxxD device. In addition, there are some rebrands of the device.

  • RND Lab 320-KA3005P
  • Tenma 72-25xx series
  • Velleman PS3005D

However I've only personally tested this tool with the KORAD KA3005P.


CLI to control a Korad variable power supply

Usage: korad_ka3005p_cli [OPTIONS] --device <DEVICE> <COMMAND>

Commands:
  identify        Identify the device
  status          Show status flags
  get-voltage     Get voltage from a channel
  set-voltage     Set voltage for a channel
  get-current     Get current from a channel
  set-current     Set current for a channel
  enable-output   Enable output
  disable-output  Disable output
  enable-beep     Enable beep
  disable-beep    Disable beep
  enable-ocp      Enable over-current protection
  disable-ocp     Disable over-current protection
  enable-ovp      Enable over-voltage protection
  disable-ovp     Disable over-voltage protection
  save            Save settings to a memory bank
  recall          Recall settings from a memory bank
  enable-lock     Enable front panel lock
  disable-lock    Disable front panel lock
  help            Print this message or the help of the given subcommand(s)

Options:
  -d, --device <DEVICE>  Serial device path (e.g., /dev/ttyACM0 or COM3)
  -b, --baud <BAUD>      Baud rate [default: 19200]
  -h, --help             Print help
  -V, --version          Print version

⚠ Warning — Use at Your Own Risk

This software allows remote control of a power supply, which can output hazardous voltages and currents capable of causing injury, fire, or equipment damage. Improper use — whether intentional or accidental — can result in serious harm to people, property, or connected devices.

You are solely responsible for understanding your hardware’s capabilities and limits, ensuring safe operating conditions, and preventing unauthorized access. The author of this software accepts no liability for any damages, losses, or injuries arising from its use. If you are not confident in your ability to operate a programmable power supply safely, do not use this tool.


Notes

The KA3005P can only accept 15-20 commands per second. It's quite slow to process each command, which sets a limit on some applications, for instance a gradual ramping of voltage.

The library imposes rate limits for the instance of KoradControl which is currently communicating. However through the CLI, each command has its own instance, and so the CLI is effectively not rate limited. For effective use, add 50ms delays between commands.

Installation

# In the root directory
cargo build --release

# move to local binaries directory, so it's in PATH
sudo mv ./target/release/korad_cli /usr/local/bin

### BONUS: Bash Tab Completion

# create the folder if it doesn't exist
mkdir -p ~/.local/share/bash-completion
# copy over the bash completion script
cp ./bash-completion ~/.local/share/bash-completion/korad_cli
# and source it, so its available in the current session
source ~/.local/share/bash-completion/korad_cli

Permissions

This software accesses serial ports on your system, and the user running the application must have permission to use the device. If you're on linux, add yourself to the group which has access to the device.

For example, if i plug in my KORAD power supply, i can check dmesg to see that it's on ttyACM0.

$ sudo dmesg | grep tty > cdc_acm 1-1.3:1.0: ttyACM0: USB ACM device

Then check the group of the device.

ls -l /dev | grep ttyACM0 > crw-rw---- 1 root uucp 166, 0 Aug 14 20:00 ttyACM0

uucp is the group.

Now you can add your existing user to the group with a command like

sudo usermod -aG uucp <username>

Then you must log out to see the effects of the command.

I'll just note that this uucp group may have strange behavior requiring some use of sudo for the effects to be apparent. More on that on this reddit thread.


Usage

Basic form:

korad_cli --device <DEVICE> [--baud <BAUD>] <COMMAND> [OPTIONS]
  • --device: Path to the serial device (e.g., /dev/ttyACM0, COM3)
  • --baud: Baud rate (default: 19200)

Commands

Identify

Show device identification string.

korad_cli --device /dev/ttyACM0 identify
# Example Output
# KORAD KA3005P V4.2 SN:34940001

Status

Show device status flags.

korad_cli --device /dev/ttyACM0 status
# Example output:
# CH1: CV, CH2: CC, OUT: true, BEEP: false, OCP: false, OVP: true [11010000]

Get Voltage

Read voltage from a specific channel. This is the actual voltage the device detects internally, not the intended/set value. Therefore, if the output is not enabled, this will always return 0.00V.

korad_cli --device /dev/ttyACM0 get-voltage --channel 1
# Example output: 5.00 V

Set Voltage

Set voltage for a specific channel.

korad_cli --device /dev/ttyACM0 set-voltage --channel 1 --volts 5.00
# Voltage set to 5.00 V on CH1

Get Current

Read current from a specific channel. This is the actual current the device detects internally, not the intended/set value. Therefore, if the output is not enabled, this will always return 0.00A.

korad_cli --device /dev/ttyACM0 get-current --channel 1
# Example output: 0.050 A

Set Current

Set current for a specific channel.

korad_cli --device /dev/ttyACM0 set-current --channel 1 --amps 0.10
# Current set to 0.020 A on CH1

Enable Output

Enable the power supply output.

korad_cli --device /dev/ttyACM0 enable-output

Disable Output

Disable the power supply output.

korad_cli --device /dev/ttyACM0 disable-output

Enable Beep

Enable beeper.

korad_cli --device /dev/ttyACM0 enable-beep

Disable Beep

Disable beeper.

korad_cli --device /dev/ttyACM0 disable-beep

Enable Over-Current Protection

korad_cli --device /dev/ttyACM0 enable-ocp

Disable Over-Current Protection

korad_cli --device /dev/ttyACM0 disable-ocp

Enable Over-Voltage Protection

korad_cli --device /dev/ttyACM0 enable-ovp

Disable Over-Voltage Protection

korad_cli --device /dev/ttyACM0 disable-ovp

Save Settings to Memory Bank

Save the current channel configuration to a bank (1, 2, 3, 4 for KA3005P).

korad_cli --device /dev/ttyACM0 save --bank 1

Recall Settings from Memory Bank

Recall channel configuration from a bank.

korad_cli --device /dev/ttyACM0 recall --bank 1

Enable Lock

Lock the front panel.

korad_cli --device /dev/ttyACM0 enable-lock

Disable Lock

Unlock the front panel.

korad_cli --device /dev/ttyACM0 disable-lock

Safety Notes

  • Always be careful when controlling the power supply remotely.
  • This crate's tests assume a 100 Ohm resistor between V+ and V-. Output is enabled during tests. So be careful.
  • Commands take effect immediately; changes are sent directly to the hardware.

About

A simple and robust command-line interface for controlling Korad variable power supplies.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages