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
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.
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.
# 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_cliThis 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.
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)
Show device identification string.
korad_cli --device /dev/ttyACM0 identify
# Example Output
# KORAD KA3005P V4.2 SN:34940001Show device status flags.
korad_cli --device /dev/ttyACM0 status
# Example output:
# CH1: CV, CH2: CC, OUT: true, BEEP: false, OCP: false, OVP: true [11010000]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 VSet voltage for a specific channel.
korad_cli --device /dev/ttyACM0 set-voltage --channel 1 --volts 5.00
# Voltage set to 5.00 V on CH1Read 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 ASet 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 the power supply output.
korad_cli --device /dev/ttyACM0 enable-outputDisable the power supply output.
korad_cli --device /dev/ttyACM0 disable-outputEnable beeper.
korad_cli --device /dev/ttyACM0 enable-beepDisable beeper.
korad_cli --device /dev/ttyACM0 disable-beepkorad_cli --device /dev/ttyACM0 enable-ocpkorad_cli --device /dev/ttyACM0 disable-ocpkorad_cli --device /dev/ttyACM0 enable-ovpkorad_cli --device /dev/ttyACM0 disable-ovpSave the current channel configuration to a bank (1, 2, 3, 4 for KA3005P).
korad_cli --device /dev/ttyACM0 save --bank 1Recall channel configuration from a bank.
korad_cli --device /dev/ttyACM0 recall --bank 1Lock the front panel.
korad_cli --device /dev/ttyACM0 enable-lockUnlock the front panel.
korad_cli --device /dev/ttyACM0 disable-lock- 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.