Differences between revisions 8 and 9
Revision 8 as of 2015-12-30 19:03:41
Size: 19149
Editor: RudolfReuter
Comment:
Revision 9 as of 2016-08-22 04:57:38
Size: 19662
Editor: RudolfReuter
Comment: updated
Deletions are marked like this. Additions are marked like this.
Line 10: Line 10:
I like to have an '''GPIB interface''' with '''open source code''' and '''low cost'''. Because this can not archived with a commercial version, I build my own. I started with an interface from Elektor, lease see at [[GPIBtoUSB2]]. There is a half [[http://lpvo.fe.uni-lj.si/en/raziskave/elektronika/podatkovni-in-merilni-vmesniki/|exception]] from '''lpvo'''. The commercial version of the '''lpvo USB-GPIB''' interface is not open source. The older development for '''hobbyists''' is open source. The lpvo driver in '''linux-gpib''' (since 2011) is named '''lpvo_usb_gpib'''. <<BR>>
So, there is a chance to modify this driver for my own interface [[GPIBtoUSB_Nano3]].
I like to have a '''GPIB interface''' with '''open source code''' and '''low cost'''. Because this can not archived with a commercial version, I build my own.

I started in '''2010'''
with an open source [[http://lpvo.fe.uni-lj.si/en/raziskave/elektronika/podatkovni-in-merilni-vmesniki/|version]] from '''lpvo'''. The commercial version of the '''lpvo USB-GPIB''' interface is no longer open source. Unfortunately I did not got it to work. The lpvo driver in '''linux-gpib''' (since 2011) is named '''lpvo_usb_gpib'''. <<BR>>
It looks like, that it is no longer in use (2016).

In '''2011''' an inter
face from Elektor was build up and works, please see at [[GPIBtoUSB2]].   In '''2016''' several '''open source''' projects are using the Prologix (R) command set.
Line 15: Line 21:
My target is to port the driver '''lpvo_usb_gpio''' to my own interface, but it looks like to be not so easy. My target was to port the driver '''lpvo_usb_gpio''' to my own interface, but it looks like to be not so easy.
Line 172: Line 178:
/!\ 2016-08-21 '''Software update''' - you can find an actual software version [[GPIBtoUSB_Nano3#Application_Program_hp1630_p23.py_for_Logic_Analyzer|here]]. The renewed program '''hp1630_p23.py''' was made compatible for '''Python 2 and 3''', and tested on Linux Ubuntu 16.04-32, Mac OS X 10.11.6 El Capitan, and Windows 7-64. Now it can be used as an '''example program''' also for other GPIB instruments.

Linux-GPIB Info

The Linux GPIB Package is a support package for GPIB (IEEE 488) hardware, please see at Linux-GPIBInfo#Links. The package contains kernel driver modules, and a C user-space library with Guile, Perl, PHP, Python and TCL bindings. The API of the C library is intended to be compatible with National Instrument's GPIB library.

I like to have a GPIB interface with open source code and low cost. Because this can not archived with a commercial version, I build my own.

I started in 2010 with an open source version from lpvo. The commercial version of the lpvo USB-GPIB interface is no longer open source. Unfortunately I did not got it to work. The lpvo driver in linux-gpib (since 2011) is named lpvo_usb_gpib.
It looks like, that it is no longer in use (2016).

In 2011 an interface from Elektor was build up and works, please see at GPIBtoUSB2.

In 2016 several open source projects are using the Prologix (R) command set.

Because the CPU R8C is a little bit exotic and the output drive current capacity is quite low, I ported the program to an Arduino Nano 3 module, please see at GPIBtoUSB_Nano3.

My target was to port the driver lpvo_usb_gpio to my own interface, but it looks like to be not so easy.

The used Linux version is Ubuntu 12.04 with actual patches.

If you like to debug linux-gpib, it works with Netbeans ver. 7.4. The version 7.0.1 from the Ubuntu 12.04 repository does not work.

Compile and Install

Do the following steps:

Extract the .tgz file and change directory.

$ ./configure 

$ make

$ sudo make install

$ sudo depmod -a

$ sudo ldconfig

Configuration gpib.conf

The file /etc/gpib.conf is the main configuration file for the GPIB library. For my interface it looks like:

interface {
        minor = 0       /* board index, minor = 0 uses /dev/gpib0, minor = 1 uses /dev/gpib1, etc. */
        board_type = "rwan_usb_gpib"    /* type of interface board being used */
        name = "rwan"   /* name for ibfind */
        pad = 0         /* primary address of interface             */
        sad = 0         /* secondary address of interface           */
        timeout = T3s   /* timeout for commands */

        eos = 0x0a      /* EOS Byte, 0xa is newline and 0xd is carriage return */
        set-reos = yes  /* Terminate read if EOS */
        set-bin = no    /* Compare EOS 8-bit */
        set-xeos = no   /* Assert EOI whenever EOS byte is sent */
        set-eot = yes   /* Assert EOI with last byte on writes */

        master = yes    /* interface board is system controller */

The abstact interface board, mostly a GPIB Controller, will usually have the minor number of 0. Then the Linux device name is /dev/gpib0.

The name is a comfort issue, which allows to search for the board with a handy name, e.g in the test program ibtest.

Test with new interface driver

The already installed driver can now be loaded, until a udev rule is setup for USB hotplug.

$ sudo modprobe rwab_usb_gpib

$ lsmod | grep rwan
rwan_usb_gpib          18498  0 
gpib_common            33177  1 rwan_usb_gpib

# Now test it (with modified ibutil.c, see at Troubleshooting):
$ sudo ibtest
Do you wish to open a (d)evice or an interface (b)oard?
        (you probably want to open a device): b
enter name of interface board (or device) you wish to open: rwan
trying to open board named 'rwan'
handle: pad 0 sad -96 board 1
handle: retval -1
libgpib: IBOPENDEV ioctl failed
libgpib: ibfind failed to get descriptor
failed to open board

$ 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]: 7
trying to open pad = 7 on /dev/gpib0 ...
handle: pad 7 sad -96 board 0
handle: retval -1
libgpib: IBOPENDEV ioctl failed
libgpib: error in is_cic()!
ibdev error

ibsta = 0x8000  < ERR >
iberr= 0
EDVR 0: OS error

ibcnt = 19

From /var/log/kernel.log you can see the start:

13:52:41 usb 2-3: FTDI USB Serial Device converter now attached to ttyUSB0
17:01:00 Linux-GPIB 3.2.19 Driver
17:32:42 show_signal_msg: 39 callbacks suppressed

19:11:05 gpib: registered rwan_usb_gpib interface
19:11:05 rwan_usb_gpib:usb_gpib_init_module - done

18:10:18 rsyslogd-2039: Could not open output pipe '/dev/xconsole' [try http://www.rsyslog.com/e/2039 ]

Use of xconsole

In order to use the debug messages from the driver with fprintf (KERN_ALERT you have to do:

$ sudo apt-get install xconsole

$ xconsole

But program xconsole is no longer supported from Unbuntu. Instead use for test:

$ sudo logger -p kern.alert -t Test "alert"
Nov  9 19:11:26 rudi-VB Test: alert

# read continuing the log:
$ tail -f /var/log/syslog

Test of the circuit

In order to test the basic function of the program and the interface, you need a terminal program. May I suggest PUTTY for Win32 and CoolTerm for Mac OS X.

PUTTY Parameters, Session:
  Connection Type: serial
  Serial line: COMx (x = USB Serial Emulation Nummer, z.B. 6)
  Speed: 38400

Keyboard input (blind, no Echo): "I", strg"J" (upper case I, Control+J = LineFeed)

Answer:
GPIB/USB converter rwan V1.2

or
Set local echo ON
Text from the clipboard is inserted into the terminal window via the middle mouse key.

Firmware Comands

The commands can be sent manually in a terminal to the GPIB-USB converter. All commands must be terminated with Linefeed (Ctrl + J).

  • C - Reset and Init GPIB Bus

  • Gx - Send Command byte, x = Zahl 0..255

  • I - Show the GPIB-USB info : GPIB/USB converter V1.1

  • Ra,s - Send a string and read answer, a = GPIB Adresse, s = String, end of read at LineFeed

  • S - Check GPIB SRQ signal

  • Tn - Set GPIB Timeout in n = ms

  • Wa,s = a = GPIB Address, s = String, Write a string

Extensions to GPIB_USB.c

To be able to operate my HP Logic Analyzer HP1631D in a useful manner with this interface a few commands were added:

  • B addr, byte LF - send a command Byte to the selected device, for example "B4,1\n" for the command Go To Local, in order to switch from Remote Mode back to Local Mode, in order to operate from the front panel again.

  • D LF byte - send a Data byte, if the device was addressed before with the L-command. Which is used to upload a file to the GPIB device.

  • E addr, command LF - This works like the R-command, but the end of the answer is not sinalled by a LineFeed, instead with EOI. Otherwise reading in of multi-line data, for example a screen hardcopy, will be more complicated.

  • L addr,LF - switching of the selected device to Listener, and uploading a file to the device.

  • U LF - switching off the Listener mode, with the sequence: LF+EOI, UNL, UNT. That could also be done with a sequence of other commands, but his is easier in the GPIB programming.

The extended files are here for download: GPIB_USB_nano.ino , GPIB_functions.ino and header file GPIB_nano.h.

Application Program hp1630.py for Logic Analyzer

/!\ 2016-08-21 Software update - you can find an actual software version here. The renewed program hp1630_p23.py was made compatible for Python 2 and 3, and tested on Linux Ubuntu 16.04-32, Mac OS X 10.11.6 El Capitan, and Windows 7-64. Now it can be used as an example program also for other GPIB instruments.

For comfortable using the HP Logic Analyzer HP1631D, I have written a Python command line program hp1630.py. It actually runs under MAC OS X, but should be easily ported to Win32 or Linux. If you run the programm without parameter you get get a help message. The GPIB Address of the device is coded to 4. The following commands are build in, as Command Line Parameter:

  • -a --printall - print the Text Screen, also the non visible part. Filename default: printall.txt

  • -b --beep - the Logic Analyzer will generate a Beep.

  • -d --date - sets the actual date and time in the Logic Analyzer. The time is incremented (RTC) until switching off the LA. There is no battery back up (27 years old).

  • -f --file - specify a Filename for download or upload.

  • -i --id - read out the identity info of the device (hp1631D).

  • -l --local - switch back the device from Remote mode to Local mode, for using again the front panel buttons. This is also possible by a switch on the front panel, but it could be more convenient.

  • -p --print - read out a Waveform screen shot and store in format PBM (Portable Bit Map). OpenOffice can import that file.

  • -r --restore - upload the Inverse Assembler for the HP 10269B Preprozessor (GPIB, RS232, RS449). This will show GPIB mnemonics on the screen, up to 1000 cycles.

  • -t --timeout - set GPIB timeout in seconds.

  • -u --usb read out the Info string "GPIB/USB converter V1.1" from the GPIB-USB converter.

  • -v --verbose enable temporarily status messages for debugging.

If you want to run a different GPIB device so you have to adjust the program accordingly. Since Python is a multi-platform interpreter programming language, an adoption should not be so difficult.

Test with Python

I will use a HP Logic Analyser 1652B for test:

import Gpib
a = Gpib.Gpib('rwan')
a.clear()
a.write('*IDN?')
print a.read(60)

Screen Shots

For screen shots please have a look at GPIBtoUSB2#Screen_Shots.

Troubleshooting

  • Device descriptor xconsole missing. Create it with:

# edit file util/create_xconsole.sh

#!/bin/sh
# 2013-11-08 Rudolf Reuter
# http://askubuntu.com/questions/108924/missing-dev-xconsole-causes-rsyslog-to-stop-as-well-as-all-other-services
# restore xconsole device descriptors
# call with: sudo ./create_xconsole.sh
# test with: ls /dev/xconsole

service rsyslog stop

# make device descriptor
mknod -m 640 /dev/xconsole c 1 3

# change owner
chown syslog:adm /dev/xconsole

service rsyslog start

# give execute rights
$ chmod ug+x create_xconsole.sh

# create device descriptor
$ sudo ./create_xconsole.sh
  • Another debugging hint: sometimes the gpib[0-15] entries in /dev/ get deleted (not really sure why, but I've noticed this from time to time, generally after some updates). This will cause the ni_gpib driver to fail. There are 2 solutions:
    • Reinstall the linux_gpib tool which will re-create the entries (but then you must make sure to re-setup the files as mentioned previously).
    • Create the nodes yourself using the same commands using during installation:

# edit file in util/create_gpib0.sh

#!/bin/sh
# restore gpib device descriptors
# call with: sudo ./create_gpib0.sh
# test with: ls /dev/gp*

for i in `seq 0 15`;
    do
        mknod -m u=rw,g=rw,o= /dev/gpib${i} c 160 ${i} || exit 1;
        chown root:gpib /dev/gpib${i};
    done

# give execute rights
$ chmod ug+x create_gpib0.sh

# create device descriptors gpib0 ... gpib15
$ sudo ./create_gpib0.sh
$ sudo ls -ls /dev/gpib0
0 crw-rw---- 1 root gpib 160,  0 Nov  8 17:45 /dev/gpib0
  • Debug ibutil.c

# edit lib/ibutil.c, function open_gpib_handle()
# add print statements:

# after: open_cmd.is_board = conf->is_interface;
    fprintf( stderr, "handle: pad %d sad %d board %d\n", open_cmd.pad, open_cmd.sad, open_cmd.is_board);

# after: retval = ioctl( board->fileno, IBOPENDEV, &open_cmd );
    fprintf( stderr, "handle: retval %d\n", retval);
  • Arduino window menu bar not visible: select Theme Radiance in System parameters

  • Prolific PL-2303 USB-to-Serial Bridge Controller
    • Driver: PL2303_MacOSX_v1.5.1.pkg
    • Snow Leopard 10.6.8: Device Descriptor: /dev/tty.SLAB_USBtoUART
    • Mavericks 10.9.0: the controller is recognized by the OS, but no device descriptor is made.
  • USB check, use the following command and plug in your USB-GPIB interface:

$ udevadm monitor --environment
UDEV  [21066.566555] add      /devices/pci0000:00/0000:00:1f.4/usb2/2-3/2-3:1.0 (usb)
ACTION=add
DEVPATH=/devices/pci0000:00/0000:00:1f.4/usb2/2-3/2-3:1.0
DEVTYPE=usb_interface
INTERFACE=255/255/255
MODALIAS=usb:v0403p6001d0600dc00dsc00dp00icFFiscFFipFF
PRODUCT=403/6001/600
SEQNUM=1542
SUBSYSTEM=usb
TYPE=0/0/0
UDEV_LOG=3
USEC_INITIALIZED=21066514524

UDEV  [21066.567972] add      /devices/pci0000:00/0000:00:1f.4/usb2/2-3/2-3:1.0/ttyUSB0 (usb-serial)
ACTION=add
DEVPATH=/devices/pci0000:00/0000:00:1f.4/usb2/2-3/2-3:1.0/ttyUSB0
SEQNUM=1543
SUBSYSTEM=usb-serial
UDEV_LOG=3
USEC_INITIALIZED=21066567907

UDEV  [21066.645399] add      /devices/pci0000:00/0000:00:1f.4/usb2/2-3/2-3:1.0/ttyUSB0/tty/ttyUSB0 (tty)
ACTION=add
DEVLINKS=/dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A900FYDY-if00-port0 /dev/serial/by-path/pci-0000:00:1f.4-usb-0:3:1.0-port0
DEVNAME=/dev/ttyUSB0
DEVPATH=/devices/pci0000:00/0000:00:1f.4/usb2/2-3/2-3:1.0/ttyUSB0/tty/ttyUSB0
ID_BUS=usb
ID_MM_CANDIDATE=1
ID_MODEL=FT232R_USB_UART
ID_MODEL_ENC=FT232R\x20USB\x20UART
ID_MODEL_FROM_DATABASE=FT232 USB-Serial (UART) IC
ID_MODEL_ID=6001
ID_PATH=pci-0000:00:1f.4-usb-0:3:1.0
ID_PATH_TAG=pci-0000_00_1f_4-usb-0_3_1_0
ID_REVISION=0600
ID_SERIAL=FTDI_FT232R_USB_UART_A900FYDY
ID_SERIAL_SHORT=A900FYDY
ID_TYPE=generic
ID_USB_DRIVER=ftdi_sio
ID_USB_INTERFACES=:ffffff:
ID_USB_INTERFACE_NUM=00
ID_VENDOR=FTDI
ID_VENDOR_ENC=FTDI
ID_VENDOR_FROM_DATABASE=Future Technology Devices International, Ltd
ID_VENDOR_ID=0403
MAJOR=188
MINOR=0
SEQNUM=1544
SUBSYSTEM=tty
UDEV_LOG=3
USEC_INITIALIZED=21066644818
  • Test with lpvo interface

Nov 10 19:38:08 rudi-VB-SL kernel: [ 1289.675596] Linux-GPIB 3.2.19 Driver
Nov 10 19:38:08 rudi-VB-SL kernel: [ 1289.694440] gpib: registered lpvo_usb_gpib interface
Nov 10 19:38:08 rudi-VB-SL kernel: [ 1289.694504] lpvo_usb_gpib:usb_gpib_init_module - done
Nov 10 19:54:00 rudi-VB-SL kernel: [ 2241.723856] lpvo_usb_gpib:usb_gpib_attach configuring lpvo_usb_gpib#0 as ttyUSB0
Nov 10 19:54:00 rudi-VB-SL kernel: [ 2241.757821] lpvo_usb_gpib:usb_gpib_attach - found f5fbe780 0
Nov 10 19:54:00 rudi-VB-SL kernel: [ 2241.757906] kernel tried to execute NX-protected page - exploit attempt? (uid: 0)
Nov 10 19:54:00 rudi-VB-SL kernel: [ 2241.757908] BUG: unable to handle kernel paging request at f6691964
Nov 10 19:54:00 rudi-VB-SL kernel: [ 2241.757911] IP: [<f6691964>] 0xf6691963
Nov 10 19:54:00 rudi-VB-SL kernel: [ 2241.757921] *pdpt = 00000000019fc001 *pde = 80000000366001e3 
Nov 10 19:54:00 rudi-VB-SL kernel: [ 2241.757924] Oops: 0011 [#1] SMP 

USBTMC

Debugging

List of pages in this category:

-- RudolfReuter 2013-11-07 18:02:17


Go back to CategoryLogicAnalyzer or StartSeite ; KontaktEmail (ContactEmail)

Linux-GPIBInfo (last edited 2016-08-22 04:57:38 by RudolfReuter)