1
\$\begingroup\$

I have a script for capturing waveform data via USB, that at one point in time was working appropriately. However, recently it stopped working and multiple things/settings were changed making it hard to pinpoint the exact issue.

I am hoping that with luck, and some logs perhaps someone can help me figure out why I am having a timeout issue.

I am using NI-VISA for the driver, and I am using pyvisa/python to communicate with a Tektronix TBS2074B scope. For some reason, I am unable to use the :CURVE?" command and some others, without getting a timeout. I suspect my issue has to do with the configuration of the scope or how things are being transferred but I can't find anything on how to correct this.

Certain simple commands do work, like changing settings, or using '*IDN?' But I really want to be able to save the curve/raw wave data to a container in Python.

import pyvisa

rm = ResourceManager()
rm.list_resources()
scope = rm.open_resource('RESOURCE')

scope.query('*IDN?') # Works
scope.query('CURVE?') # Doesn't work - timeout occurs

As I have said, I have tried adjusting the timeout, but that doesn't seem to help. I think there is a configuration issue somewhere that I am unable to determine.

Here is the error message:

>>> scope.query('CURV?')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\ablem\AppData\Local\Programs\Python\Python311\Lib\site-packages\pyvisa\resources\messagebased.py", line 648, in query
    return self.read()
           ^^^^^^^^^^^
  File "C:\Users\ablem\AppData\Local\Programs\Python\Python311\Lib\site-packages\pyvisa\resources\messagebased.py", line 486, in read
    message = self._read_raw().decode(enco)
              ^^^^^^^^^^^^^^^^
  File "C:\Users\ablem\AppData\Local\Programs\Python\Python311\Lib\site-packages\pyvisa\resources\messagebased.py", line 442, in _read_raw
    chunk, status = self.visalib.read(self.session, size)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\ablem\AppData\Local\Programs\Python\Python311\Lib\site-packages\pyvisa\ctwrapper\functions.py", line 2337, in read
    ret = library.viRead(session, buffer, count, byref(return_count))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\ablem\AppData\Local\Programs\Python\Python311\Lib\site-packages\pyvisa\ctwrapper\highlevel.py", line 226, in _return_handler
    return self.handle_return_value(session, ret_value)  # type: ignore
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\ablem\AppData\Local\Programs\Python\Python311\Lib\site-packages\pyvisa\highlevel.py", line 251, in handle_return_value
    raise errors.VisaIOError(rv)
pyvisa.errors.VisaIOError: VI_ERROR_TMO (-1073807339): Timeout expired before operation completed.

And here is the waveform configuration info:

>>> scope.query('WFMI?')
':WFMINPRE:BYT_NR 1;BIT_NR 8;ENCDG ASCII;BN_FMT RI;BYT_OR MSB;NR_PT 2000;PT_FMT Y;XUNIT "s";XINCR 1.0000E-9;XZERO -50.0000E-6;PT_OFF 0;YUNIT "V";YMULT 4.0000E-3;YOFF 0.0E+0;YZERO 0.0E+0;FILTERFREQ 200000000\n'

If anyone has any tips for troubleshooting this issue, it would be greatly appreciated.

\$\endgroup\$
6
  • \$\begingroup\$ Hypothesis: The command is working, but you're asking for a larger amount of data that takes more time. Try to reduce the amount of data by changing capture buffer settings (lower the number of points, which may be controlled via sampling rate and duration). Perhaps you're now downloading multiple channels, where previously there weren't as many active. \$\endgroup\$
    – Ben Voigt
    Commented Dec 18, 2023 at 20:41
  • \$\begingroup\$ However, your configuration appears to be 2000 points at 8 bits, which shouldn't be a large amount at all. Perhaps the encoding changed from efficient binary to verbose ASCII text. \$\endgroup\$
    – Ben Voigt
    Commented Dec 18, 2023 at 20:42
  • \$\begingroup\$ @BenVoigt Hello, thanks for the reply! I think it is an issue with encoding perhaps. But I thought in the past, I had everything set to ASCII and it worked just fine. I am not familiar with how to configure it for binary transfers as far as like transfer size goes etc. \$\endgroup\$ Commented Dec 18, 2023 at 21:23
  • \$\begingroup\$ You want a much easier solution than the py_visa stuff? Ditch USB, use your Ethernet port with SCPI commands, and try: socketscpi at socketscpi.readthedocs.io/en/latest/index.html I just used it on a Keysight supply, and works like a charm (it uses the same GPIB-ish command format, no visa overhead and visa-manager crud to install on the pc). Soooooo much easier. \$\endgroup\$ Commented Dec 18, 2023 at 22:09
  • \$\begingroup\$ @ChrisKnudsen: Avoiding the NI software stack is definitely worthwhile. The darn thing is several gigabytes (at least last time I used it, which was a while ago), with close to a dozen software layers and it seems like most of them live in kernel mode. yuck! \$\endgroup\$
    – Ben Voigt
    Commented Dec 18, 2023 at 22:39

1 Answer 1

2
\$\begingroup\$

While I wasn't able to figure out why it wasn't working the way I was doing it, I did find a solution that works.

scope.query_ascii_values('CURVE?')

In my case I did want the ASCII values and that was what I had set in my waveform preamble. So perhaps the straight up query command is better suited to binary? Not sure.

Anyways, hope this helps someone else.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.