GPIB to WLAN Interface, Arduino Mega

For control of a Logic Analyzer HP1631D via GPIB interface I saw now the posibility to do that via WLAN and for low cost. Up to now, most low cost GPIB-USB interfaces did not have the GPIB buffers. That limits the use to up to 2 devices on the GPIB bus. With the help of already existing open source examples, I tried to combine all that in a low cost interface, with the features and modules:

attachment:GPIBtoWLAN_housing_DSC06483.jpg

The Arduino Mega was choosen, because it has enough I/O pins for the GPIB bus and also an optional MicoSD Card Adapter. Also a second free Serial Port was neded to interface to the ESP8266 WLAN module. It was also important for me, that the Arduino Mega is still a current board with support.

The ESP-01 module was choosen, because of the low cost, and the possibility to act as a Serial Tranparent Bridge.

The 5V to 3.3V regulator module was choosen, because it is cheaper, than the individuel components in low quantity. But on the PCB (printed circuit board) there is also a provision to use individual components (AMS1117 3V3), if you want to build several boards.

The MicroSD Card Adapter (SPI interface) is supported by an Arduino FAT32 library, in case of a program extension. The software basics are already included.

attachment:GPIBtoWLAN_top_DSC06482.jpg

The power supply can be done via the USB plug (5 V, 1.0 A), or the power jack (7-9 V, 1.0 A).

To expand the pictures, click Left on the picture or diagram.

Simplified Hardware

Because the Arduino Mega is a complete micro computer board, which has its power supply from the USB port or a power jack, just some resistors, bypass capacitors, 2 integrated circuits and a GPIB connector (Centronics, 24 pin socket) are needed, please see the picture on the right.

I have drawn a diagram with Eagle 7.5 and attached:GPIB_Mega_7.sch

In order to see an overview of the diagram here on the right, as a PNG file (click to enlarge).

Plus a PDF file for a better printout GPIB_Mega_7_sch.pdf.

attachment:GPIB_Mega_7_sch.png

The Eagle board layout is also attached:GPIB_Mega_7.brd.

For the prototype board I etched both sides and soldered the plated through connections.

The rectangular cut out on the board was made in order to better see the Arduino Mega LED's.

For easier trouble shooting the hardware, I wrote a sotware to toggle each individuell GPIB signal in sequence.

Software

The development software is the standard IDE (version 1.6.7) from Arduino.

For a better overview the C software is modularized:

After download you have to rename all .c file to .ino for the Arduino IDE. The extension .c was used to allow for source code colored pretty printing (click Left on the file).

Test of the circuit

The normal access is via WLAN. The IP Address is given via the ESP8266 module. For basic tests the software utility telnet is the right tool. See an example telnet session:

$ telnet 192.168.17.142
Trying 192.168.17.142...
Connected to 192.168.17.142.
Escape character is '^]'.
++ver
GPIB/WLAN converter V6.0 , ++ZC/++ZD for IO-Test

# to finish the telnet session type CTRL ]
^]
telnet> q
Connection closed.

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. For test purpose you can connect via USB port also.

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

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

Answer:
GPIB/WLAN converter V6.0 , ++ZC/++ZD for IO-Test

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

Firmware Commands

The full command set is described in a manual, please see at Link #5.

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

Additional there are some own commands:

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

attachment:GPIB_DB24_plug.png

Debug

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

Application Program hp1630_plx.py for Logic Analyzer

For comfortable using the HP Logic Analyzer HP1631D, I have written a Python2/3 command line program hp1630_plx.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:

# show first the actual working path
/Volumes/DAT/HDA8/INSTALL/Develop/GPIB_USB/wanglib/wanglib-master
Usage: hp1630_plx.py [options] version 1.1

hp1630 - A remote control program with GPIB interface.

Options:
  -h, --help            show this help message and exit
  -A, --save-analog     save Analog Learn Strings to File (HP1631 only), enter
                        Filename with -f
  -b, --beep            actuate GPIB device beep
  -C, --save-config     save Config Learn String to File, enter Filename with
                        -f, default HP1630-TC.bin
  -d, --date            set PC date to hp1630
  -f FILENAME, --file=FILENAME
                        Enter filename, overwrite default
  -g GPORT, --gport=GPORT
                        other serial port, e.g. /dev/cu.xxx
  -i, --id              check for GPIB device ID
  -l, --local           switch GPIB device to local mode
  -m, --measurement     wait for analog measurement complete
  -o, --out-wform       convert .hpg file to .pgm file, show with Tkinter
  -p, --print           capture waveform screen to .hpg file and convert to
                        .pbm file
  -P, --printall        print all digital to .txt file
  -r, --restore         restore Learn String File, enter Filename with -f
  -s, --save-all        save All Learn Strings to File, enter Filename with -f
  -S, --save-state      save State Learn Strings to File, enter Filename with
                        -f
  -t, --timeout         Enter timeout in sec.
  -T, --save-timing     save Timing Learn Strings to File, enter Filename with
                        -f
  -u, --usb             check for USB/WLAN-GPIB interface version
  -v, --verbose         tell more internal values for debugging
  -V, --Verify Learn String
                        Verify Learn String File, enter Filename with -f
  -w, --wlan            control via WLAN, input other server IP
Default USB serial Port: /dev/cu.usbserial-A4009RFD
Default IP address: 192.168.17.142

Notes:

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

attachment:GPIB_handshake.png

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.

A speciality is the EOI (End or Identify) GPIB line. It signals the End of transmission, especially in case of a binary transmission.

GPIB command bytes

byte value, HEX

name

decription

0x01

GTL

Go To Local

0x04

SDC

Select Device Clear

0x05

PPC

Parallel Poll Configure

0x08

GET

Group Execute Trigger

0x09

TCT

Take Control

0x11

LLO

Local Lockout

0x14

DCL

Device Clear

0x15

PPU

Parallel Poll Unconfigure

0x18

SPE

Serial Poll Enable

0x19

SPD

Serial Poll Disable

0x20 - 0x3E

MTA0-30

My Listen Addr. 0 - 30

0x3F

UNL

Unlisten

0x40 - 0x5E

MTA0-30

My Talk Address 0 - 30

0x5F

UNT

Untalk

GPIB command bytes

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

This can be useful if debugging with a Logic Analyzer.

For a cheap (about 23 EUR) Logic Analyzer with command decoding for GPIB see at SigrokDecoderGPIB. It is part of the http://sigrok.org/ project.

It allows State and Timing Analysis.

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.

WiFi Protected Setup

WPS (WiFi Protected Setup, see Links #8) allows to connect to a new WiFi Access Point via push button switch, instead of entering the credentials manually.

Because this WPS feature was added later, I soldered all components on the existing PCB (Printed Circuit Board). Please see the picture on the right for the details.

For the wiring of the Push Button switch and a LED for indication see the schematic:

 *  Connection of ESP8266 GPIO0 and GPIO2 for WPS push button and LED indicator:
 *         Vcc  Vcc       Vcc = 3.3 V
 *          |    |         |
 *         4K7  4K7       1k0  pull up resistors (3K3 to 10K Ohm)
 *          |    |   +-|<|-+   LED red
 *          |    |   |
 * GPIO0  - +--------+---o |
 *               |         | -> | push button switch for WPS function
 * GPIO2  -------+-------o |
 *
 * from http://www.forward.com.au/pfod/ESP8266/GPIOpins/index.html

attachment:GPIBtoWLAN_WPS_DSC06640.jpg

If you power up the ESP8266 module, and the red LED (WPS indicator) lits (ON), it signals, that the WiFi module has lost the connection to the known Access Point, or the credentials of the Access Point had changed.

In case of changed credentials, it is possible to connect to the Access Point via WPS. The procedure is:

  1. Push the WLAN/WPS button at your Access Point, until it is signallsing the WPS mode. You have a 2 minute timeout.

  2. Push the WPS button switch at the ESP8266 module. The ESP8266 module is now trying to connect to the Access Point.

  3. If the connect was successful, the LED goes OFF.
  4. Check the WiFi connection via ping command in a terminal, or the application program, or the WiFi Access Point status web page.

  1. Arduino Mega 2560 details

  2. Arduino Development IDE

  3. Arduino SD Card Library (FAT32)

  4. GPIB Tutorial

  5. Prologix (R) manuals for download (see Ethernet version)

  6. Linux GPIB package

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

  8. how-does-wi-fi-protected-setup-work

List of pages in this category:

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


Go back to CategoryLogicAnalyzer or StartSeite ; KontaktEmail

GPIBtoWLAN_Mega (last edited 2016-10-24 16:02:14 by RudolfReuter)