1

I am trying to communicate with a Tektronix oscilloscope TDS 210 using a GPIB-USB-HS adapter of National Instruments. My system is Ubuntu 14.04.3 where I installed linux-gpib as described in this link: Linux GPIB Driver package (source) and also python-gpib. I reconfigured the /etc/gpib.conf like this:

interface {
    minor = 0   /* board index, minor = 0 uses /dev/gpib0, minor = 1 uses /dev/gpib1, etc. */
    board_type = "ni_usb_b" /* type of interface board being used */
    name = "tds"    /* optional name, allows you to get a board descriptor using ibfind() */
    pad = 0 /* primary address of interface             */
    sad = 0 /* secondary address of interface           */
    master = yes    /* interface board is system controller */
    timeout = TNONE /* timeout for commands */
}
device {
       minor = 0
       name = "ATTN"
       pad = 0
       sad = 0
}

The lsmod give me this:

$ lsmod | grep gpib
ni_usb_gpib            36515  1 
gpib_common            38274  3 ni_usb_gpib

The dmesg:

$ dmesg | grep gpib
[ 2173.992039] ni_usb_gpib driver loadingni_usb_gpib: probe succeeded for path: usb-0000:00:1a.0-1.2
[ 2173.992098] usbcore: registered new interface driver ni_usb_gpib
[ 2173.992102] gpib: registered ni_usb_b interface
[ 2173.995077] ni_usb_gpib: attach

But when a try to communicate with the oscilloscope using ibtest I receive this error:

gpib status is: 
ibsta = 0x8100  < ERR CMPL >
iberr= 0
EDVR 0: OS error
ibcnt = 25

And with Python:

import Gpib
tds = Gpib.Gpib(0,0)
tds.write("*IDN?")
---------------------------------------------------------------------------
GpibError                                 Traceback (most recent call last)
<ipython-input-4-e61e6a76ac49> in <module>()
      1 import Gpib
      2 inst = Gpib.Gpib(0,0)
----> 3 inst.write("*IDN?")

/usr/local/lib/python2.7/dist-packages/Gpib.pyc in write(self, str)
     47 
     48         def write(self,str):
---> 49                 gpib.write(self.id, str)
     50 
     51         def write_async(self,str):

GpibError: write() error: Inappropriate ioctl for device (errno: 25)

Did someone already have a similar problem or knows how to fix this?

VML
  • 11
  • 2
  • Did you try communication with the vendor provided tools first? I found this very helpful before programming myself, since typically there are many parameters to consider, like whether there is a character at the end of each line or even when to toggle certain control signals. Also, you might even have a problem with the cabling or compatability. Finally, not all devices support *IDN? (I had some ancient devices, I think they had *ID? instead). – Andreas Reiff Nov 26 '15 at 20:05
  • I believe the problem is in GPIB configuration... I already made many python scripts for the Tektronix oscilloscope, Lock-in, monochromator, but always using ttyUSB or usbtmc, in other words RS232 protocol, with and without a adapter plug... this error never happened before.The vendor always try to sell me the Labview =/. Could be the cabling... I will check. *IDN? is a SCPI for Tektronix and National Instruments in general. Thanks! – VML Nov 26 '15 at 20:50

1 Answers1

0

I had the exact same errors as you from both ibtest, and python. I was trying to get gpib working on a pi. I followed the tutorial https://xdevs.com/guide/ni_gpib_rpi/

I fixed it by changing my /etc/gpib.conf (note eos):

interface {
minor = 0  
board_type = "ni_usb_b"
name = "violet"
pad = 0 
sad = 0 
timeout = T30s  
eos = 0xd       /* EOS Byte, was 0xa and I got same errors as you */
set-reos = yes   
set-bin = no    
set-xeos = no   
set-eot = yes   
master = yes    
}

Now everything works!

$ sudo gpib_config
$ sudo ibtest
Do you wish to open a (d)evice or an interface (b)oard?
    (you probably want to open a device): d
enter primary gpib address for device you wish to open [0-30]: 3
trying to open pad = 3 on /dev/gpib0 ...
You can:
    w(a)it for an event
    ...
    (w)rite data string
: w
enter a string to send to your device: *idn?
sending string: *idn?

gpib status is:
ibsta = 0x2100  < END CMPL >
iberr= 0

ibcnt = 6
You can:
    w(a)it for an event
    ...      
    (r)ead string

: r
enter maximum number of bytes to read [1024]:
trying to read 1024 bytes from device...
received string: 'AEROFLEX,3920,1000662592,3.7.0,2'
Number of bytes read: 32
gpib status is:
ibsta = 0x2100  < END CMPL >
iberr= 0

ibcnt = 32

In Python, I get errors unless I call clear after instantition, after that it's good to go:

? sudo python
Python 2.7.9 (default, Mar  8 2015, 00:52:26)
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import Gpib
>>> inst = Gpib.Gpib(0,3)
>>> inst.clear()
>>> inst.write("*idn?")
>>> inst.read(100)
'AEROFLEX,3920,1000662592,3.7.0,2'

If you still can't talk to an instrument try the string ID? instead of *IDN?. Some hp equipment has an alternate command syntax which uses different command strings, check the manual (it might be in the back mentioned in passing), you can usually switch the syntax back and forth with a command. Good luck.

wat
  • 53
  • 1
  • 4