GPIB to USB Interface, Arduino Nano 3

Rainer Schuster was so friendly, and has programmed in a good style a GPIB to USB converter with Win32 demo program to read a Tektronix TDS210 oscilloscope presented in the magazine Elektor 04-2011. The whole thing is much cheaper than commercial circuits, for hobby purpose. Please see for details at GPIBtoUSB2.

Unfortunately, by not using a GPIB bus driver, it is only possible to connect not more than one GPIB device. The R8C CPU can deliver up to 60 mA at the I/O ports in total. Per output pin it should not be more than 2 mA in order not to exceed the voltage of 0.8V for the LOW level. With IEEE-488 GPIB standard, each device on the bus has a termination 3 KOhm resistor to +5V and 10 KOhm to 0V.

Now I have ported the software to the Arduino Nano 3, please see at GPIBtoUSB_Nano3#Links.

The ATMega CPU can deliver up to 200 mA at the I/O ports in total. Per output pin it should not be more than 20 mA in order not to exceed the voltage of 0.8V for the LOW level. So, I think that a minimum of 3 instruments should be possible to connect on the GPIB bus.

/!\ 2016-01-16 Software Update to version 1.3. In header file GPIB_nano.h I had forgotten to set the ATN_D1 out direction in macro SET_TALK. The effect was, that the program works only after the first error.

/!\ 2016-08-21 Software update to version 1.4. The GPIB T1 data settle time was reduced from 10 us to 2 us. The USB serial baudrate was increased from 38400 to 115200 baud. The Python program was extended to work under Python 2 and 3, and function was tested under Linux Ubuntu 16.04-32, Mac OS X 10.11.6 and Windows 7-64.


Development Software

The development software is the standard IDE from Arduino, please see at GPIBtoUSB_Nano3#Links.

Simplified Hardware

Because the Nano 3 is a complete micro computer board, which has its power supply from the USB port, just some resistors and a GPIB connector (Centronics, 24 pin socket) are needed, please see the picture on the right.||

I have drawn a diagram with Eagle5 and attached:GPIB_USB_Nano.sch
In order to see an overview of the diagram here as a PNG file (click to enlarge).
Plus a PDF file for a better printout GPIB_USB_Nano_sch.pdf.


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, e.g. 6)
  Speed: 115200

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

GPIB/USB converter V1.4

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

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:

The extended files are here for download: GPIB_USB_nano.c , GPIB_functions.c and header file GPIB_nano.h. After download please rename the extension from .c to .ino for the Arduino IDE. I had to rename it to .c, in order to get the lexer of this wiki to work (color printing).



For easier trouble shooting, please see the pin out of the GPIB DB24 plug, on the right.

Application Program for Logic Analyzer

You need the modul pyserial in order to use this program. That can be installed with the following command line:

# Linux and Mac OS X
$ sudo pip3 install pyserial

# Windows 7
> py -3 -m pip install pyserial

For comfortable using the HP Logic Analyzer HP1631D, I have written a Python command line program The function was tested under Linux Ubuntu 16.04-32, Mac OS X 10.11.6 and Windows 7-64. If you run the programm without parameter you get get a help message. The GPIB Address of the device is coded to 4.

It is an example program, which can be easily adopted to other instruments. Most of the needed functions are already coded.


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.

On the right is a Screenshot of the Arduino IDE (Integrated Development Environment), click to enlarge.

GPIB handshake


The GPIB handshaking process follows these steps:

  1. Initially, the Talker holds the DAV line high indicating no data is available, while the Listeners holds the NRFD line high and the NDAC line low indicating it is ready for data and no data is accepted, respectively.

  2. When the Talker puts data on the bus, it sets the DAV line low, which indicates that the data is valid.

  3. The Listeners set the NRFD line low, which indicates that they are not ready to accept new data.

  4. The Listeners set the NDAC line high, which indicates that the data is accepted

  5. When all Listeners indicate that they have accepted the data, the Talker asserts the DAV line indicating that the data is no longer valid. The next byte of data can now be transmitted.

  6. The Listeners hold the NRFD line high indicating they are ready to receive data again, and the NDAC line is held low indicating no data is accepted.

  7. Please see the timing chart on the right.

/!\ If the ATN line is high during the handshaking process, the information is a command to an instrument.

If the ATN line is low, the information is a GPIB message from an instrument.

GPIB command bytes

byte value, HEX





Go To Local



Select Device Clear



Parallel Poll Configure



Group Execute Trigger



Take Control



Local Lockout



Device Clear



Parallel Poll Unconfigure



Serial Poll Enable



Serial Poll Disable

0x20 - 0x3E


My Listen Addr. 0 - 30




0x40 - 0x5E


My Talk Address 0 - 30




GPIB command bytes

The table on the right shows most of the GPIB Commands.

This can be useful if debugging with a Logic Analyzer.

Only the Primary Addresses are show. The command codes 0x60 - 0x7E are used for Secondary Addresses and Parallel Poll use. This is not covered here, please see here for details.

Debugging the GPIB

I will try to give a help for trouble shooting the GPIB. The shown example is the Identification command, which does most instruments have.

In this case the instrument is an old Logic Analyser HP1631D with GPIB address 4.

The command for identification is the ASCII text ID followed by the byte newline (LineFeed). This can be entered manually from the Arduino Monitor, it does not need a comuter program for that.

The baudrate of the Arduino Monitor must match the baudrate of the USB-GPIB interface, in my case 115200 baud.

The answer text from the instrument must be HP1631D.

State Analysis

In order to better understand the sequence of the commands, I made a State Analysis with an HP1652B Logic Analyser, with Inverse Assembler for the GPIB mnemonics.

   1    MACHINE 1    -   STATE LISTING   2016-08-10                                  
   2   Label   >  ADDR           ATN  Mnemonic  HEX EOI SRQ REN IFC  STAT                      
   3   Base    >   Hex                    Instructions                Hex                      
   5    +0000                    ATN   *UNL*    3F          REN        1A            
   6    +0001                    ATN   *UNT*    5F          REN        1A            
   7    +0002                    ATN   LAG_04   24          REN        1A            
   8    +0003                            I      49          REN        1B            
   9    +0004                            D      44          REN        1B            
  10    +0005                          <LF >    0A  EOI     REN        19            
  11    +0006                    ATN   *UNL*    3F          REN        1A            
  12    +0007                    ATN   *UNT*    5F          REN        1A            
  13    +0008                    ATN   TAG_04   44          REN        1A            
  14    +0009                            H      48          REN        9B            
  15    +0010                            P      50          REN        9B            
  16    +0011                            1      31          REN        9B            
  17    +0012                            6      36          REN        9B            
  18    +0013                            3      33          REN        9B            
  19    +0014                            1      31          REN        9B            
  20    +0015                            D      44  EOI     REN        99            
  21    +0016                    ATN   *UNL*    3F          REN        1A            
  22    +0017                    ATN   *UNT*    5F          REN        1A   
  23    File: hp1652-state_hp1630-ID.txt 


Timing Analysis

While the data flow in the State Analysis looks consecutive, it is not in the Timing Analysis.

Please see the first Timing Diagram on the right. It shows the Talker Handshake Timing, and is about 100 us long.


The second Timing Diagram on the right shows the End of the command sequence.

At the letter D you will see the Listener Handshake Timing.

Each byte of the command sequence has a duration of about 25 us. So, a telegram of 18 bytes length could have a theroretical duration of 450 us, in reality it needs 33500 us, wich is a factor of 75. Let's write it in a formula for an easier understanding:

That was the difficulty with the Timing Analysis, on one hand you need a resolution of 10 us per division, in order to see the handshake timing, but if you want to show the total sequence length, you will get a screen resolution of 5000 us per division, which can not show any handshake detail.


The third Timing Diagram on the right will show that.

You see at the previous mentioned times, some data transfer will go on, but no details are marked in the timing diagram.

For a better understanding of the GPIB bus, please read the reference manuals referenced in Links #7 and #8.

  1. Arduino Nano 3 details

  2. Arduino Development IDE

  3. GPIB Tutorial

  4. GPIB handshake explained

  5. Linux GPIB package

  6. Linux GPIB instrument support utilities, 2014-08 version 1.5

  7. National Instruments NAT7210 GPIB Reference Manual 1995

  8. Tutorial Description of the Hwlett-Packard Interface Bus 1987

List of pages in this category:

-- RudolfReuter 2013-11-05 12:28:29

Go back to CategoryLogicAnalyzer or StartSeite ; KontaktEmail

rudiswiki9: GPIBtoUSB_Nano3 (last edited 2016-08-26 14:33:27 by RudolfReuter)