Differences between revisions 1 and 2
Revision 1 as of 2013-11-07 18:02:17
Size: 10665
Editor: RudolfReuter
Comment: new
Revision 2 as of 2013-11-08 19:28:40
Size: 0
Editor: RudolfReuter
Comment: new #2
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
##master-page:Template DE
#format wiki
#language en
||<tablestyle="float:right;margin:0px;"style="padding:0.5em;border:0px;font-size:100%;"><<TableOfContents>> ||


== 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 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]].

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]].

Now,

=== 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:
$ 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'
libgpib: IBOPENDEV ioctl failed
libgpib: ibfind failed to get descriptor
failed to open board

}}}

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 ]
}}}


=== 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 V1.1

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
 * '''G'''x - Send Command byte, x = Zahl 0..255
 * '''I''' - Show the GPIB-USB info : GPIB/USB converter V1.1
 * '''R'''a,s - Send a string and read answer, a = GPIB Adresse, s = String, end of read at !LineFeed
 * '''S''' - Check GPIB SRQ signal
 * '''T'''n - Set GPIB Timeout in n = ms
 * '''W'''a,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: [[attachment:GPIB_USB_nano.ino]] , [[attachment:GPIB_functions.ino]] and header file [[attachment:GPIB_nano.h]].

=== Application Program hp1630.py for Logic Analyzer ===
For comfortable using the HP '''Logic Analyzer''' HP1631D, I have written a '''Python''' command line program [[attachment: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.

=== Screen Shots ===
For screen shots please have a look at [[GPIBtoUSB2#Screen_Shots]].

=== Troubleshooting ===
 * Device descriptor '''xconsole''' missing. Create it with:
{{{
$ sudo service rsyslog stop

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

# change owner
$ sudo chown syslog:adm /dev/xconsole

$ sudo service rsyslog start

# Verify it is working with reload as well
$ sudo service rsyslog reload
}}}

 * 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
}}}


=== Links ===
 * [[http://linux-gpib.sourceforge.net/|Home of linux-gpib project]]

 * [[http://www.ni.com/linux/d/|National Instruments und Linux, overview]]
 * [[http://www.ni.com/white-paper/12002/en/|Evaluating Linux for Your Test, Measurement, or Control Applications]]
 * [[http://www.ni.com/white-paper/11787/en|National Instruments I/O Driver Support for Linux, PCI]]
 * [[http://sine.ni.com/nips/cds/view/p/lang/de/nid/11737|NI Measurement Hardware DDK (Driver Development Kit)]]

 * [[http://www.cl.cam.ac.uk/~osc22/tutorials/gpib_usb_linux.html|GPIB-Linux USB Tutorial]]

 * [[http://comedi.org/|The Comedi project develops open-source drivers, tools, and libraries for data acquisition.]]
 * [[http://xoscope.sourceforge.net/|xoscope for Linux, GTK+ 2.0]]
 * [[http://digital.ni.com/public.nsf/allkb/FE65DE3647BC7F1B86256DA4007E55B1|What Data Acquisition Features Does Comedi Offer?]]
 * [[http://www.linux-usb-daq.co.uk/The World's First USB based DAQ for Linux]]
 * [[http://www.linux-usb-daq.co.uk/software2/qtscope/|QTScope is a program to display the signals acquired from daq devices via the comedi library.]]
 * [[http://www.linux-usb-daq.co.uk/software2/comedi2py/|Realtime data plotting and processing with python for your USB-DUX device.]]
 * [[https://pypi.python.org/pypi/pycomedi/|An object-oriented interface for the Comedi drivers.]]
 * [[https://wiki-ext.aps.anl.gov/epics/index.php/How_to_use_GPIB_ports_with_linux-gpib_and_StreamDevice|How to use GPIB ports with linux-gpib and StreamDevice]]
 * [[http://www.cl.cam.ac.uk/~osc22/tutorials/gpib_usb_linux.html|Tutorial GPIB USB Linux, /dev/gpib0]]



=== List of pages in this category: ===
<<FullSearch(category:CategoryLogicAnalyzer)>>

-- RudolfReuter <<DateTime(2013-11-07T18:02:17Z)>>

----
Go back to CategoryLogicAnalyzer or StartSeite ; KontaktEmail (ContactEmail)

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