Skip to content

Latest commit

 

History

History
498 lines (389 loc) · 14.7 KB

sigrok-tst-dsp5020.org

File metadata and controls

498 lines (389 loc) · 14.7 KB

Accessing DPS5020 Digital Power Supply using sigrok

Use sigrok-cli to control DPS5020 Digital Power Supply

This document demonstrates using sigrok-cli to control DPS5020 Digital Power Supply. The steps used in this demonstations are:

  1. connect DPS5020 using USB cable to PC
  2. use sigrok-cli command line tool to control DPS5020
  3. use a bash script (dps5020.sh) to wrap sigrok-cli to make it easier to implement voltage stepwise ramp using DPS5020

It is assumed that sigrok package has already been installed on the PC. For installing sigrok on

Table of Content

Connect DPS5020 with an USB to PC

When DPS5020 power supply is connected with an USB cable to a Linux PC, the command

lsusb | grep CH340

shows CH340 serial converter attahced to USB bus:

Bus 003 Device 021: ID 1a86:7523 QinHeng Electronics CH340 serial converter

A serial device /dev/ttyUSB0 should be created automagically once the USB connection is established. Command

ls -ltr /dev/ttyUSB*

shows the device with the owner root and group dialout

crw-rw---- 1 root dialout 188, 0 helmi  21 08:30 /dev/ttyUSB0

In order to be able access USB -device, the user should be attached to dialout group. This can be verified using the command.

groups

which returns list of group names the user is attached to. Expect to see dialout in the list, as in the example below

jj adm dialout cdrom sudo dip plugdev lpadmin lxd sambashare vboxusers docker

Missing dialout group can be added with the command.

sudo usermod -a -G dialout hacklab

In the example above, dialout group was added to hacklab user (replace it with your own user id). Logout and login is needed for the new group associations to become active.

sigrok-cli command line usage

sigrok-cli -version used

This document uses sigrok version

sigrok-cli 0.7.2

Libraries and features:
- libsigrok 0.5.2/5:1:1 (rt: 0.5.2/5:1:1).
 - Libs:
  - glib 2.67.5 (rt: 2.72.4/7204:4)
  - libzip 1.7.3
  - libserialport 0.1.1/1:0:1 (rt: 0.1.1/1:0:1)
  - libusb-1.0 1.0.25.11696 API 0x01000108
  - hidapi 0.10.1
  - bluez 5.56
  - libftdi 1.5
  - Host: x86_64-pc-linux-gnu, little-endian.
  - SCPI backends: TCP, serial, USBTMC.
- libsigrokdecode 0.5.3/6:1:2 (rt: 0.5.3/6:1:2).
 - Libs:
  - glib 2.71.1 (rt: 2.72.4/7204:4)
  - Python 3.10.2 / 0x30a02f0 (API 1013, ABI 3)
  - Host: x86_64-pc-linux-gnu, little-endian.

rdtech-dps: DPS5020 driver in sigrok-cli

Documentation on page https://sigrok.org/wiki/RDTech_DPS_series gives the name of the driver, rdtech-dps, for acccessing DPS5020 power supply. The driver is bundled with sigrok-cli, as demonstraded with the command:

sigrok-cli -L | grep rdtech-dps
  rdtech-dps           RDTech DPS/DPH series power supply

list-serial: identify USB serial devices

Command

sigrok-cli --list-serial

lists serial ports available on the system. If USB connection to DPS5020 is present the output should include /dev/ttyUSB device file for accessing DPS5020 power supply:

Available serial/HID/BT/BLE ports:
  /dev/ttyUSB0	USB Serial
  hid/<chip>/raw=/dev/hidraw2	HID Logitech USB Receiver 400a-e0-f3-34-8b [046d.400a]
  hid/<chip>/raw=/dev/hidraw2	HID Logitech USB Receiver 400a-e0-f3-34-8b [046d.400a]
  hid/<chip>/raw=/dev/hidraw2	HID Logitech USB Receiver 400a-e0-f3-34-8b [046d.400a]
  hid/<chip>/raw=/dev/hidraw2	HID Logitech USB Receiver 400a-e0-f3-34-8b [046d.400a]
  hid/<chip>/raw=/dev/hidraw2	HID Logitech USB Receiver 400a-e0-f3-34-8b [046d.400a]
  hid/<chip>/raw=/dev/hidraw1	HID Logitech USB Receiver [046d.c52b]
  hid/<chip>/raw=/dev/hidraw1	HID Logitech USB Receiver [046d.c52b]
  hid/<chip>/raw=/dev/hidraw1	HID Logitech USB Receiver [046d.c52b]
  hid/<chip>/raw=/dev/hidraw4	HID SteelSeries SteelSeries Apex Pro [1038.1610]
  hid/<chip>/raw=/dev/hidraw5	HID SteelSeries SteelSeries Apex Pro [1038.1610]
  hid/<chip>/raw=/dev/hidraw6	HID SteelSeries SteelSeries Apex Pro [1038.1610]
  hid/<chip>/raw=/dev/hidraw7	HID SteelSeries SteelSeries Apex Pro [1038.1610]
  hid/<chip>/raw=/dev/hidraw7	HID SteelSeries SteelSeries Apex Pro [1038.1610]
  hid/<chip>/raw=/dev/hidraw7	HID SteelSeries SteelSeries Apex Pro [1038.1610]
  hid/<chip>/raw=/dev/hidraw8	HID SteelSeries SteelSeries Apex Pro [1038.1610]

Later, the examples below use serial device /dev/ttyUSB0 to demonstrate DPS5020 usage.

scan: scan for connected devices

Without driver and connection specifiaction sigrok-cli --scan

finds only demo device.

The following devices were found:
demo - Demo device with 13 channels: D0 D1 D2 D3 D4 D5 D6 D7 A0 A1 A2 A3 A4

When the --scan command is given driver and connection options

sigrok-cli  --driver=rdtech-dps:conn=/dev/ttyUSB0  --scan

the output identifies RDTech DPS5020

The following devices were found:
rdtech-dps - RDTech DPS5020 v16 with 3 channels: V I P

show: show device/format/decoder details

Details of the device are retrieved with --show -command.

sigrok-cli  --driver=rdtech-dps:conn=/dev/ttyUSB0 --show

Particularly, the output presents configuration options supported, i.e. parameters that can be read or set on the device.

Driver functions:
    Power supply
Scan options:
    conn
    serialcomm
    modbusaddr
rdtech-dps - RDTech DPS5020 v16 with 3 channels: V I P
Supported configuration options:
    continuous: on, off
    limit_samples: 0 (current)
    limit_time: 0 (current)
    voltage: 0.000000 (current)
    voltage_target: 0.000000, 50.000000, 0.010000
    current: 0.000000 (current)
    current_limit: 0.000000, 20.000000, 0.010000
    enabled: on, off (current)
    regulation: CV (current)
    ovp_active: on, off (current)
    ovp_threshold: 51.000000 (current)
    ocp_active: on, off (current)
    ocp_threshold: 20.200000 (current)

get, set and config: access device options

This chapter demonstrates:

  • reading enabled status of DPS5020 (initially false)
  • setting voltage_target to 3.3V
  • reading voltage_target to validate that is was set correctly
  • reading output voltage (expect 0V, because device is not enabled)
  • turning the output on by setting the enabled status to true
  • reading output voltage (should match voltage_target once the device is on) enabled)
  • finally setting enabled status off

The enabled status of DPS5020 on USB device /dev/ttyUSB0 is read with the command

sigrok-cli  --driver=rdtech-dps:conn=/dev/ttyUSB0 --get enabled
false

To set voltage target to 3.3V, pass --config and --set options, as shown below

sigrok-cli  --driver=rdtech-dps:conn=/dev/ttyUSB0 --config voltage_target=3.3V --set

Current voltage target is read with the command

sigrok-cli  --driver=rdtech-dps:conn=/dev/ttyUSB0 --get voltage_target
3.29

If the device the output is not enabled, the voltage shows 0.0

sigrok-cli  --driver=rdtech-dps:conn=/dev/ttyUSB0 --get voltage
0.0

After turning the device on,

sigrok-cli  --driver=rdtech-dps:conn=/dev/ttyUSB0 --config enabled=on --set

the enable status is true

sigrok-cli  --driver=rdtech-dps:conn=/dev/ttyUSB0 --get enabled
true

and the output voltage corresponds the target_voltage set above

sigrok-cli  --driver=rdtech-dps:conn=/dev/ttyUSB0 --get voltage

Finally, the device is turned off

sigrok-cli  --driver=rdtech-dps:conn=/dev/ttyUSB0 --config enabled=false --set

dps5020.sh a simple bash wrapping sigrok-cli

dps5020.sh: script created

A simple script for controlling DSP5020:

  • configuring serial device where DPS is attached to (default /dev/ttyUSB0)
  • turning DPS on/off
  • setting target voltage
  • waiting for given time (to create stepwise ramp)

Save the following code into a file dps5020.sh in a PATH-directory, and make it executable

# Tangled from sigrogk-tst-dps5020.org - changes will be overridden

# A simple script to allow:
# - configuring serial device where DPS is attached to (default /dev/ttyUSB0) 
# - turning DPS on/off
# - setting target voltage
# - wait for given time


# exit on error or undefined variable
set -e
set -u 

TTY=/dev/ttyUSB0
TS_FORMAT="+%Y%m%d-%T"

usage() {
   echo $0 usage:
   echo 
   echo $0 'option* cmd*'
   echo
   echo "where 'option' one one"
   echo "- tty  <dev>      : use device <dev> instead of default device /dev/ttyUSB0"
   echo
   echo "and 'cmd' one one"
   echo "- sleep <secs>    : delay of secs <secs> seconds"
   echo "- on              : turn DPS on"
   echo "- off             : turn DPS off"
   echo "- voltage <volt>  : set DPS voltage target to <volt>"
 
   exit 1
}

if [ "$#" -lt 1 ]; then usage; fi

# ------------------------------------------------------------------
# Parse options
while :; do

    case "$1" in
	  -sh_trace)
	      shift; set -x;
	      ;;

	  -\?|--help)
	      usage
	      ;;

	  -tty)
	      shift; TTY=$1; shift
	      ;;

	  *) # not an option - start processing cmds
	      break
	      ;;
    esac
done

# ------------------------------------------------------------------
# Parse cmd

while :; do
    # Done?
    if [ "$#" -lt 1 ]; then break; fi

    case "$1" in
	  on)
	      shift; 
	      echo $(date +$TS_FORMAT)  - on
	      sigrok-cli  --driver=rdtech-dps:conn=$TTY --config enabled=on --set
	      ;;

	  off)
	      shift; 
	      echo $(date +$TS_FORMAT)  - off
	      sigrok-cli  --driver=rdtech-dps:conn=$TTY --config enabled=off --set
	      ;;

	  sleep)
	      shift; 
	      TIME=$1; shift
	      echo $(date +$TS_FORMAT)  - enter sleep
	      sleep $TIME
	      echo $(date +$TS_FORMAT)  - exit sleep
	      ;;

	  voltage)
	      shift; 
	      V=$1; shift
	      echo $(date +$TS_FORMAT)  - set target voltage $V
	      sigrok-cli  --driver=rdtech-dps:conn=$TTY --config voltage_target=$V --set
	      ;;

	  *)  # error
	      echo "Unknown command '$1'"
	      echo
	      usage
	      ;;
    esac
done

exit 0

dps5020.sh: example use

Example of using the script dps5020.sh to stepwise ramp voltage from 0 to 1V (5 secs) to 2.5V (5 secs). After the ramp the device is turned off.

dps5020.sh off voltage 0 on voltage 1 sleep 5 voltage 2.5 sleep 5  off 
+20230221-12:21:13 - off
+20230221-12:21:14 - set target voltage 0
+20230221-12:21:16 - on
+20230221-12:21:18 - set target voltage 1
+20230221-12:21:20 - enter sleep
+20230221-12:21:25 - exit sleep
+20230221-12:21:25 - set target voltage 2.5
+20230221-12:21:27 - enter sleep
+20230221-12:21:32 - exit sleep
+20230221-12:21:32 - off

Fin