Author Topic: How to use sigrok and gnuplot  (Read 1669 times)

0 Members and 1 Guest are viewing this topic.

Offline HoracioDosTopic starter

  • Frequent Contributor
  • **
  • Posts: 344
  • Country: ar
  • Just an IT monkey with a DSO
How to use sigrok and gnuplot
« on: October 18, 2018, 09:56:42 pm »
I would like to share this example about how to use sigrok and gnuplot. I did this without any particular purpose. I know that there are more useful examples than reading values from a Korad but perhaps someone would fine it useful.
This simple bash script (getdata.sh) gets data from a Korad PSU with sigrok and it creates an output file.
Code: [Select]
#!/usr/bin/env bash
echo 'Starting ...'
sigrok-cli  --driver=korad-kaxxxxp:conn=/dev/ttyACM0  --set --config enabled=off
echo 'Setting Voltage'
sigrok-cli  --driver=korad-kaxxxxp:conn=/dev/ttyACM0  --set --config voltage_target=9
echo 'Enabling Output'
sigrok-cli  --driver=korad-kaxxxxp:conn=/dev/ttyACM0  --set --config enabled=on
echo 'Logging'
sigrok-cli --driver=korad-kaxxxxp:conn=/dev/ttyACM0  --continuous -o /tmp/data.dat -O csv
trap "{ echo 'Quit...' ; sigrok-cli  --driver=korad-kaxxxxp:conn=/dev/ttyACM0  --set --config enabled=off ; exit 255; }" EXIT
Then Gnuplot script (demo.plt) reads the last 50 lines of the output file while sigrok appends new lines at the end in an infinite loop until the escape key is pressed.
Code: [Select]
# set title "Test"
# set title  font ",20" norotate
set datafile separator ','
set yrange[0:0.03]
set autoscale x
set ylabel "A"
set xlabel "Samples"
set grid
bind "Escape" "unset output; exit gnuplot"
plot "< tail -n 50 /tmp/data.dat" using 3 smooth acsplines title "I"
pause 1
reread
Execute gnuplot ./demo.plt to plot data. Remember to Quit by pressing Escape key.
 

Offline HoracioDosTopic starter

  • Frequent Contributor
  • **
  • Posts: 344
  • Country: ar
  • Just an IT monkey with a DSO
Re: How to use sigrok and gnuplot
« Reply #1 on: October 19, 2018, 12:45:51 pm »
This is a brymen 257s logging voltage.
Code: [Select]
#!/usr/bin/env bash
echo 'Logging'
sigrok-cli --driver=brymen-bm25x:conn=/dev/ttyUSB0 --continuous -o /tmp/data.dat -O csv
trap "{ echo 'Quit...' ; exit 255; }" EXIT
Brymen plot script
Code: [Select]
set datafile separator ','
set yrange[8.980:9.010]
set autoscale x
set ylabel "Volts"
set xlabel "Samples"
set grid
bind "Escape" "unset output; exit gnuplot"
plot "< tail -n 50 /tmp/data.dat" using 2 smooth acsplines title "V"
pause 1
reread
Korad again with two y-axis
Code: [Select]
set datafile separator ','
set yrange[0.01:0.03]
set y2range[0:12]
set autoscale x
set ylabel "Ampere"
set y2label "Volts"
set ytics border nomirror
set y2tics border nomirror
set xlabel "Samples"
set grid
set key box lt -1 lw 1
bind "Escape" "unset output; exit gnuplot"
plot "< tail -n 50 /tmp/data.dat" using 3 smooth acsplines title "I" , '' using 2 with lines axes x1y2 title "V"
pause 1
reread
« Last Edit: October 19, 2018, 06:54:03 pm by HoracioDos »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf