| Products > Test Equipment |
| Download speed from Rigol DS1054Z or similar oscilloscope to a PC |
| << < (5/8) > >> |
| RoGeorge:
The connection, yes it works, the PythonIVI driver for DS1054Z, not really. For example I was expecting to see the <LF> (0x0a) at the end of the SCPI commands, but the PC doesn't send 0x0a in the LAN packets. The oscilloscope replies with the expected 0x0a terminator. Will look closer these days. |
| alm:
Did you try playing with read and write termination attributes that I set in my samples? I'd expect setting write termination to '\n' to fix the problem of missing line feeds when sending to the scope. |
| RoGeorge:
Only took a brief look, it was very late yesterday. The read or write_termination are from pyvisa, ivi doesn't seem to have them. I guess I should configure the pyvisa backend before making a connection from ivi, not sure how to do it. There is not much documentation, and I'm not a programmer. Digging through code is much more difficult then reading a manual. Overriding or extending classes bamboozles me a lot, since I don't have yet a clean map of the objects used in PythonIVI. |
| alm:
See my earlier posts on how to set termination through python-ivi. |
| RoGeorge:
I don't know how to apply read/write_termination before opening the instrument. If I open the instrument first, by default the driver sends '*CLS' without the 0x0a terminator, which hangs the oscilloscope communication, and can recover only by a power cycle. By looking through sources, found out that there are optional parameters possible to send when opening a new connection, one of the parameters being to not emit a "*CLS" command by default. --- Code: ---import ivi ivi.set_prefer_pyvisa() dso = ivi.rigol.rigolDS1104Z(resource='TCPIP0::192.168.1.3::5555::SOCKET', id_query=False, reset=False) dso._interface.instrument.read_termination = '\n' dso._interface.instrument.write_termination = '\n' dso.identity.instrument_model dso._ask('*IDN?\n') while dso._ask('*OPC?\n') != '1': print('Waiting for command to finish') dso._write(':ACQ:MDEP 24000000\n') # !!! can only be set when in :RUN mode while dso._ask('*OPC?\n') != '1': print('Waiting for command to finish') dso._write(':WAV:MODE MAX\n') # !!! 1200 points in :RUN mode, all MDEP points in STOP mode while dso._ask('*OPC?\n') != '1': print('Waiting for command to finish') dso._write(':WAV:FORM BYTE\n') while dso._ask('*OPC?\n') != '1': print('Waiting for command to finish') dso._write(':RUN\n') dso._write(':WAV:SOUR CHAN1\n') while dso._ask('*OPC?\n') != '1': print('Waiting for command to finish') dso._write(':WAV:STAR 1\n') while dso._ask('*OPC?\n') != '1': print('Waiting for command to finish') dso._write(':STOP\n') while dso._ask('*OPC?\n') != '1': print('Waiting for command to finish') dso._write(':WAV:STOP 250000\n') # !!! will be ignored and always 1200 in :RUN mode while dso._ask('*OPC?\n') != '1': print('Waiting for command to finish') wvfm_pre = dso._ask('WAV:PRE?\n') while dso._ask('*OPC?\n') != '1': print('Waiting for command to finish') print(wvfm_pre) print(dso._ask('WAV:MODE?\n'), dso._ask('WAV:STAR?\n'), dso._ask('WAV:STOP?\n')) dso._write(':STOP\n') while dso._ask('*OPC?\n') != '1': print('Waiting for command to finish') import time t0 = time.time() wvfm = dso._ask_raw(b':WAV:DATA?\n') # 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?\n') != '1': print('Waiting for command to finish') to_fetch = 24_000_000 # fetch only 1Msa of ADC samples MAX_CHUNK = 250_000 M_DEPTH = int(dso._ask(':ACQ:MDEP?\n')) 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) + '\n') while dso._ask('*OPC?\n') != '1': print('Waiting for command to finish') dso._write(':WAV:STOP ' + str(i + min(MAX_CHUNK, M_DEPTH, to_fetch-i)) + '\n') while dso._ask('*OPC?\n') != '1': print('Waiting for command to finish') wvfm = dso._ask_raw(b':WAV:DATA?\n') # get 1200 points in :RUN mode or :WAV:STOP? points in :STOP mode # b = bytes(wvfm[12:], 'latin_1') # all_wvfm += b all_wvfm += wvfm[12:] print(len(wvfm)) t1 = time.time() - t0 print('Time to fetch ' + str(to_fetch) + ' ADC samples using "socketscpi": ' + str(t1)) dso.close() --- End code --- This makes possible to connect to an instrument without sending any (wrong terminated) commands, then configure read/write_termination, which worked. However, the read/write_termination settings seems to apply only for ivi functions. For example, if I use osc._ask_raw(':WAV:DATA?\n'), then I must add the 0x0a manually, as '\n'. I had to look more into the ivi sources. Maybe there is a way to set the automatic addition of the 0x0a terminator in pyvisa-py, so I won't end with a mixture of functions where some requires 0x0a while others don't. The transfer speed is 65 seconds to fetch 24MSa. Not bad, but still 3 times slower than the 22 seconds I get when downloading with https://github.com/morgan-at-keysight/socketscpi I wonder if it would be possible to use 'socketscpi' instead of 'pyvisa', or maibe to configure 'pyvisa' to use 'socketscpi' instead of 'pyvisa-py'. I've uploaded my current PythonIVI changes on gitlab, https://gitlab.com/RoGeorge/python-ivi, because github got crazy and doesn't let me any more to remote update my own repositories, unless I got a security token from them, which I don't want. Adios GitHub, hello GitLab. |
| Navigation |
| Message Index |
| Next page |
| Previous page |