pythongpibvisa

Using visa to interface with GPIB always gives me VisaIOError


I'm trying to import visa in Python and interface with GPIB to control a device. The name of device I'm using is "GPIB0::9::INSTR", and I think there should be no problem with this.

I ran the following code in 2.7.3 Python Shell

>>> from visa import *
>>> a = instrument("GPIB0::9", timeout = 20)
>>> a.write("*IDN?")
>>> print a.read()

Traceback (most recent call last):
  File "<pyshell#53>", line 1, in <module>
    print a.read()
  File "C:\Python27\lib\site-packages\pyvisa\visa.py", line 433, in read
    return self._strip_term_chars(self.read_raw())
  File "C:\Python27\lib\site-packages\pyvisa\visa.py", line 407, in read_raw
    chunk = vpp43.read(self.vi, self.chunk_size)
  File "C:\Python27\lib\site-packages\pyvisa\vpp43.py", line 840, in read
    visa_library().viRead(vi, buffer, count, byref(return_count))
  File "C:\Python27\lib\site-packages\pyvisa\vpp43.py", line 398, in check_status
    raise visa_exceptions.VisaIOError, status
VisaIOError: VI_ERROR_TMO: Timeout expired before operation completed.

Above is the error the system gave me. Actually at the beginning, I set the Timeout to be 3, it shows this errot. But after I changed the value to be 20 as shown above, it still didn't work.

Can somebody help me?


Solution

  • For each one specific instruments, it will have its own command to control them. Please refer to the device's user manual.