Products > Test Equipment
Download speed from Rigol DS1054Z or similar oscilloscope to a PC
<< < (3/8) > >>
DiTBho:
too confusing  :-//
DiTBho:
I don't have a Rigol DS1054Z, but sigrok seems to have support, see here
RoGeorge:

--- Quote from: alm on November 14, 2022, 01:53:32 pm ---
--- Quote from: RoGeorge on November 14, 2022, 01:22:07 pm ---Now I am seeing those 20+ minutes long transfers in Linux.

--- End quote ---
Is that over VXI-11 or over TCP sockets (TCPIP0::host address::port::SOCKET)? VXI-11 is probably not optimized for high throughput, but plain TCP sockets should be pretty straight-forward.

--- End quote ---

Wireshark was telling the LAN packets were of type VXI-11 protocol, most probably the slow transfer was for VXI.  In fact, it might be the only one supported, I don't know how to configure IVI to use SOCKET instead of VXI-11.

I've just tried "TCPIP0::host address::port::SOCKET" and it breaks with the err message "unrecognized resource string format".  By looking inside the code, the regular expressions used to validate the resource string doesn't know about the word "SOCKET", can only end in "INSTR".  Same in the man page, all examples are of type "TCPIP................INSTR"
https://www.systutorials.com/docs/linux/man/1-pythonivi


It is still possible to use python-ivi for all the other commands, and write a C function to fetch the ADC data points only using SOCKET and forcing the TCP packets size, the oscilloscope allows multiple connections.  Or I can dig in my own python2 repos from 8 years ago and check if the WAVE:DATA? scripts from back then are still fast (in Linux).

IVI is very appealing, but for some reason it didn't get enough traction, and now  it feels like abandonware, the last accepted pull in the main project was in 2016 or so.  For example, two years ago I had to merge from many forks and found no python-ivi driver for my signal generator.  Now, I had to search again through 108 forks and merge the most active (active in the sense that they appear to have extra python-ivi drivers), thought there is still no driver for my generator, but there is a generator driver from another instrument, and it happens that the main controls are the same, so at least I can change the frequency from python-ivi and do the rest from buttons.

I really like python-ivi, but it sunk me way too much time.  After all, I don't think any body else will reuse my automated test software, not even myself, so I can just use SCPI.  It's been 10 days since I've started to fool around with python-ivi and still tinkering around it instead of working at the data processing, which was the actual goal of the project.
alm:

--- Quote from: RoGeorge on November 14, 2022, 06:40:05 pm ---I've just tried "TCPIP0::host address::port::SOCKET" and it breaks with the err message "unrecognized resource string format".  By looking inside the code, the regular expressions used to validate the resource string doesn't know about the word "SOCKET", can only end in "INSTR".  Same in the man page, all examples are of type "TCPIP................INSTR"
https://www.systutorials.com/docs/linux/man/1-pythonivi

--- End quote ---
Reading the source code, this regular expression is for the resources python-ivi can handle directly without PyVisa, like VXI-11. Anything else should be passed to PyVisa, unless PyVisa is not imported, which sounds like is the case for you (the exception on line 1837).


--- Quote from: RoGeorge on November 14, 2022, 06:40:05 pm ---IVI is very appealing, but for some reason it didn't get enough traction, and now  it feels like abandonware, the last accepted pull in the main project was in 2016 or so.  For example, two years ago I had to merge from many forks and found no python-ivi driver for my signal generator.  Now, I had to search again through 108 forks and merge the most active (active in the sense that they appear to have extra python-ivi drivers), thought there is still no driver for my generator, but there is a generator driver from another instrument, and it happens that the main controls are the same, so at least I can change the frequency from python-ivi and do the rest from buttons.

I really like python-ivi, but it sunk me way too much time.  After all, I don't think any body else will reuse my automated test software, not even myself, so I can just use SCPI.  It's been 10 days since I've started to fool around with python-ivi and still tinkering around it instead of working at the data processing, which was the actual goal of the project.

--- End quote ---
For me python-ivi is still worth it because it provides a fairly sensible way to abstract instruments, so I can use the same code for a Tektronix scope and a Lecroy scope, for example, which as a hobbyist with a heterogeneous lab with instruments from different manufacturers is very helpful. Even though I've had to develop most of the drivers that I use myself, this was a one-time effort. I don't just have three identical instruments to throw at the same problem, so if I need multiple scopes, power supplies or multimeters at the same time, they'll probably of different brands and vintages. I have not found an abstraction I liked better than python-ivi yet, and I certainly don't feel like inventing my own.
RoGeorge:
It looks like either python-ivi or pyvisa will use the same python-vxi11 module (import vxi11) to connect to an instrument over LAN.  I've tested and they are both very slow, it takes 23 minutes to fetch 24MSa.

--- Code: ---# pip install python-vxi11
# Successfully installed python-vxi11-0.9
import vxi11

dso = vxi11.Instrument('192.168.1.3')
# alternatives (transfer speed is the same):
# dso = vxi11.Instrument("TCPIP::192.168.1.3::INSTR")

print(dso.ask('*IDN?'))



dso.write(':RUN')
while dso.ask('*OPC?') != '1': print('Waiting for command to finish')
dso.write(':ACQ:MDEP 24000000')     # !!! can only be set when in :RUN mode
while dso.ask('*OPC?') != '1': print('Waiting for command to finish')

dso.write(':WAV:MODE MAX')          # !!! 1200 points in :RUN mode, all MDEP points in STOP mode
while dso.ask('*OPC?') != '1': print('Waiting for command to finish')

dso.write(':WAV:FORM BYTE')
while dso.ask('*OPC?') != '1': print('Waiting for command to finish')



dso.write(':WAV:SOUR CHAN1')
while dso.ask('*OPC?') != '1': print('Waiting for command to finish')

dso.write(':WAV:STAR 1')
while dso.ask('*OPC?') != '1': print('Waiting for command to finish')

dso.write(':STOP')
while dso.ask('*OPC?') != '1': print('Waiting for command to finish')
dso.write(':WAV:STOP 250000')       # !!! will be ignored and always 1200 in :RUN mode
while dso.ask('*OPC?') != '1': print('Waiting for command to finish')

wvfm_pre = dso.ask('WAV:PRE?')
while dso.ask('*OPC?') != '1': print('Waiting for command to finish')
print(wvfm_pre)

print(dso.ask('WAV:MODE?'), dso.ask('WAV:STAR?'), dso.ask('WAV:STOP?'))



dso.write(':STOP')
while dso.ask('*OPC?') != '1': print('Waiting for command to finish')

import time
t0 = time.time()
wvfm = dso.ask_raw(b':WAV:DATA?')      # get 1200 points in :RUN mode or :WAV:STOP? points in :STOP mode
t1 = time.time() - t0
print('Time to fetch the first waveform chunk: ' , t1)
print(type(wvfm), len(wvfm))
while dso.ask('*OPC?') != '1': print('Waiting for command to finish')

to_fetch = 1_000_000    # fetch only 1Msa of ADC samples
MAX_CHUNK = 250_000
M_DEPTH = int(dso.ask(':ACQ:MDEP?'))

all_wvfm = bytes()
t0 = time.time()
for i in range(0, min(to_fetch, M_DEPTH), MAX_CHUNK):

    dso.write(':WAV:STAR ' + str(i+1))
    while dso.ask('*OPC?') != '1': print('Waiting for command to finish')

    dso.write(':WAV:STOP ' + str(i + min(MAX_CHUNK, M_DEPTH, to_fetch-i)))
    while dso.ask('*OPC?') != '1': print('Waiting for command to finish')

    wvfm = dso.ask_raw(b':WAV:DATA?')      # get 1200 points in :RUN mode or :WAV:STOP? points in :STOP mode
    all_wvfm += wvfm[12:]

    print(len(wvfm))

t1 = time.time() - t0
print('Time to fetch ' + str(to_fetch) + ' ADC samples using "python-vxi11": ' + str(t1))



dso.close()

--- End code ---



If I open a connection with SOCKET, or if I use something like the 'socketscpi' module, it fetches 24MSa in 23 seconds. 

--- Code: ---# socketscpi is using direct TCP socket instead of VXI-11
# pip install socketscpi
# Successfully installed socketscpi-2022.8.0
#   might work as a backend for PyVISA ????? for LXI instruments
#   https://github.com/morgan-at-keysight/socketscpi/blob/master/examples.py

import socketscpi

dso = socketscpi.SocketInstrument(ipAddress='192.168.1.3', port=5555, timeout=1)
# dso = socketscpi.SocketInstrument(ipAddress='192.168.1.3', port=5555, globalErrCheck=True)

print(dso.instId)



dso.write(':RUN')
while dso.query('*OPC?') != '1': print('Waiting for command to finish')
dso.write(':ACQ:MDEP 24000000')     # !!! can only be set when in :RUN mode
while dso.query('*OPC?') != '1': print('Waiting for command to finish')

dso.write(':WAV:MODE MAX')          # !!! 1200 points in :RUN mode, all MDEP points in STOP mode
while dso.query('*OPC?') != '1': print('Waiting for command to finish')

dso.write(':WAV:FORM BYTE')
while dso.query('*OPC?') != '1': print('Waiting for command to finish')



dso.write(':WAV:SOUR CHAN1')
while dso.query('*OPC?') != '1': print('Waiting for command to finish')

dso.write(':WAV:STAR 1')
while dso.query('*OPC?') != '1': print('Waiting for command to finish')

dso.write(':STOP')
while dso.query('*OPC?') != '1': print('Waiting for command to finish')
dso.write(':WAV:STOP 250000')       # !!! will be ignored and always 1200 in :RUN mode
while dso.query('*OPC?') != '1': print('Waiting for command to finish')

wvfm_pre = dso.query('WAV:PRE?')
while dso.query('*OPC?') != '1': print('Waiting for command to finish')
print(wvfm_pre)

print(dso.query('WAV:MODE?'), dso.query('WAV:STAR?'), dso.query('WAV:STOP?'))



dso.write(':STOP')
while dso.query('*OPC?') != '1': print('Waiting for command to finish')

import time
t0 = time.time()
wvfm = dso.query(':WAV:DATA?')      # get 1200 points in :RUN mode or :WAV:STOP? points in :STOP mode
t1 = time.time() - t0
print('Time to fetch the first waveform chunk: ' , t1)
print(type(wvfm), len(wvfm))
while dso.query('*OPC?') != '1': print('Waiting for command to finish')

to_fetch = 1_000_000    # fetch only 1Msa of ADC samples
MAX_CHUNK = 250_000
M_DEPTH = int(dso.query(':ACQ:MDEP?'))

all_wvfm = b''
t0 = time.time()
for i in range(0, min(to_fetch, M_DEPTH), MAX_CHUNK):

    dso.write(':WAV:STAR ' + str(i+1))
    while dso.query('*OPC?') != '1': print('Waiting for command to finish')

    dso.write(':WAV:STOP ' + str(i + min(MAX_CHUNK, M_DEPTH, to_fetch-i)))
    while dso.query('*OPC?') != '1': print('Waiting for command to finish')

    wvfm = dso.query(':WAV:DATA?')      # get 1200 points in :RUN mode or :WAV:STOP? points in :STOP mode

    b = bytes(wvfm[12:], 'latin_1')
    all_wvfm += b

    print(len(wvfm))

t1 = time.time() - t0
print('Time to fetch ' + str(to_fetch) + ' ADC samples using "socketscpi": ' + str(t1))



dso.close()

--- End code ---
The downside is if I send a wrong command I have to power cycle the oscilloscope.



My oscilloscope is Rigol DS1104Z (in python-ivi its driver module is 'rigol.rigolDS1054'), it has the fixed IP 192.168.1.3, and the port for SOCKET access is 5555.

Do you have a working code example, please, for connecting to the oscilloscope from python-ivi, or even from PyVISA, but using SOCKET instead of VXI11, and then print the result of the '*IDN?'
Navigation
Message Index
Next page
Previous page
There was an error while thanking
Thanking...

Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod