Contents
|
GPIB to USB Interface, Elektor 04-2011
English version of the German page GPIBtoUSB.
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.
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, but 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.
Development Software
After 5,5 years the Toolchain from Renesas is a little bit scrambled.
Good explanation for beginners: Erste Schritte mit Renesas M16C und GCC (German)
Problems:
Because in the Release folder no GPIB_USB.MOT file was found, I liked to compile new, following the description from Elektor magazine 12-2005.
- The Monitor/Debugger KD30 could not be installed under Win7-32.
After the installation of NC30 from Renesas AutoUpdate a new version from HEW was updated, which had a different WorkSpace management.
At the software GPIB_USB the Workspace File GPIB_USB.hws was missing.
The old Workspace Project File GPIB_USB.hwp is no longer valid. In creating a new project file a few questions arised:
- Heap size = 100
Stack size = 80
The IDE HEW (High-performance Enbedded Workshop) did not show the menu Build.
This could be fixed by setting up Target = Simulator.
The Linker ln30 showed an error: ROMDATA' section 'vector' is overlapped on the 'interrupt' from FEDCH to FF68H.
proposed change: In file sect30.inc in line 609 change:
.org 0c800H ; was 0e000H
Unfortunately this change also changed the Interrupt Vektor Tabelle address. Hence, the data reception no longer works:
Solution: By setting up a new project a new file sect30.inc was created, with rom_NE_top = 0e000H. The version in the downloaded ZIP File had the value 0d000H at this location. By the proposed change to 0c800H the Interrupt Vektor for UART1 no longer fitted. After the file sect30.inc was copied from the ZIP archive into the Workspace, the program worked.
You can find some hints to R8C software problems in Softwareproblemen (German).
Simplified Hardware
Since the R8C Starter Kit (supplement in the 12-2005 Elektor magazine!) was present in the junk box I looked for a suitable USB-Serial cable. At Ebay for only EUR 5 (including shipping) there is a Nokia CA-42 clone (Polific PL2302 chip) available. I ordered it, but it gave the following difficulties:
The Nokia cable plug was sealed, the pin assignment was difficult to determine, see picture on the right. Click the picture to enlarge it. If the color to pin determination is done, you can start soldering. My assignment: |
Now I have learned, that only the cable with the blue USB plug housing (rubber like) does have a pl2303 chip inside. The cable with a black USB plug hard plastic housing does have a seldom used OTI 6858 chip (Ours Technology Inc.), which has drivers for Windows and Linux only. But this one has a DTR line and the USB +5 V readily available.
On the Serial side the signal voltage is +3.3 V only. Regarding the R8C/13 data sheet minimum +4 V are needed. That was archived with an IC LM339 (Quad Comperator, Reichelt 0,20 EUR).
The +5 V from the USB port on the cable end were not available. The sealed USB connector was carefully opened (cut) and a wire fed out from the +5 V terminal to the cable end. |
|
The construction was made on a breadboard of Vero company. There the GND and +5 V lines were already routed. |
|
The whole circuit has been built in an old housing (4-port USB hub). The GPIB connector could be fastened well there. For wiring Wire wrap wire was used, which does not stand out so much at 18 lines. The maxim was fast and inexpensive. I have a diagram with Eagle5 drawn and attached:GPIB_USB.sch |
|
In order to sees something of the diagram here as a PNG file. Plus a PDF file for better printout GPIB_USB.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, it also works on Win 7-32.
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.0 or Set local echo ON Text from the clipboard is inserted into the terminal window via the middle mouse key. or with the MAC OS X Terminal (sudo because of /var/spool/uucp access): $ sudo cu -l /dev/cu.PL2303-0000103D -s 38400 Help for "cu" (Call Up another system): ESCAPE: strg + alt gr + N = ~ Terminate: ~. Variable: ~v Commands: ~? \ = SHIFT + alt + 7
All that was tested under Virtual Box V.4.0.6 in MAC OS X 10.6.
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
Changes in the Firmware
Unfortunately there is a bug in the file GPIB_functions.c.
Cause: Since the port 0 bit 0 is used for the serial interface (TXD), the data must be shifted by 1 to the left. The bit 7 is output via Port 3, Bit 1. Because unfortunately it is pushed first and then tested for bit 7, all ASCII characters > 0x3F get bit 7 set. Some GPIB participants will correct that without complaint. My logic analyzer HP1631D does not.
Solution: In program GPIB_functions.c in function send_gpib_byte() the command sequence must be:
if (data & 0x80) p3_1=0; else p3_1=1; data = data <<1; //shift to p0_1..p0_7 p0= ~data;
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.c , GPIB_functions.c and binary Release.zip.
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.
Screen Shots
Finally a hardcopy picture from the HP1631D in Waveform mode:
and GPIB analyze text screen (command Beep) with Bus Preprocessor HP10342B and Inverse Assembler (IHPIBc & IHPIBi):
1 State Listing____________________Data Acquired Apr 13 2007 09:58
2 REMOTE <|
3 Label> ADDR ATN Mnemonic HEX EOI SRQ REN IFC STAT
4 Base > [HEX] [ ASM ] [HEX
5
6 [Mark] X [ Instructions ] X$
7
8 -0003* 0 ATN TAG_00 40 REN DA
9 -0002* 0 ATN *UNL* 3F REN DA
10 -0001* 0 ATN LAG_04 24 REN DA
11 +0000 0 B 42 REN DB
12 +0001 0 P 50 REN DB
13 +0002 0 ; 3B REN DB
14 +0003 0 <LF > 0A EOI REN D9
15 +0004* 0 ATN TAG_00 40 REN DA
16 +0005* 0 ATN *UNL* 3F REN DA
17 +0006* 0 ATN LAG_04 24 REN DA
18 +0007* 0 ATN GTL 01 REN DA
19
20
21
22
23
24
List of pages in this category:
-- RudolfReuter 2011-06-17 08:43:38
Go back to CategoryLogicAnalyzer or StartSeite ; KontaktEmail (ContactEmail)