GPIB 2 USB

Anything not related to a specific project.

Re: GPIB 2 USB

Postby Sjaak » Tue Apr 03, 2012 4:25 am

You need a .inf which describes the hardware and tells windows which driver to load. I think you can use the microchip default.

You may need to add the VID/PID to the file in order to recognize the hardware. You can find the VID/PID by looking at the properties of the unknown device.

You can use the inf file we used for the buspirate (remember to check if you VID/PID is in the file!!) : http://code.google.com/p/dangerous-prot ... rate%2Finf
User avatar
Sjaak
Fellow
Fellow
 
Posts: 3013
Joined: Sun Jan 03, 2010 2:45 pm
Location: Hiero

Re: GPIB 2 USB

Postby Drod » Tue Apr 03, 2012 7:50 am

Eddietronic, as soon as you test some instructions, please, let us know if you had success!

Here's an Excel Macro example in order to comunicate with the hardware, sent by the creator:

I stumbled across a HO 3852A measurement mainframe a few months ago for
the sum of 60€ so I spent the weekend writing code for that. I have a
Excel sample I will post later that pulls 10 readings from the
High-Speed voltmeter and puts them in an excel sheet.
OK. Here is the Excelmacro:


Sub Logger()
'
' Loger Macro
' Sample to read 10 values from a HP 3852A
'
Dim Port As Integer
Dim rc As Long
Dim str As String
Dim i, j As Integer
Dim n As Long
Dim Result(20) As Double
Port = 1
j = 1
rc = CommClose(Port)
rc = CommOpen(Port, "COM5", "baud=9600 parity=N data=8 stop=1") ' Speed does not really matter as COM-port is virtual anyway
If rc > 0 Then
rc = CommGetError(str)
MsgBox str
End If

str = "Q " + Chr$(3) ' Turn off interface verbose mode
rc = CommWrite(Port, str)
CommFlush (Port)
str = "6" + Chr$(10) ' Set remote
rc = CommWrite(Port, str)
For n = 1 To 1000
Next n

str = "2 ?U8" + Chr$(10) ' Set HP 3852A to listen
rc = CommWrite(Port, str)
For n = 1 To 1000
Next n


CommFlush (Port)
rc = GPIB(Port, "DISPLAY START") ' Show info on display
rc = GPIB(Port, "OUTBUF ON") ' Set output buffering on
rc = GPIB(Port, "USE 600") ' Use Voltmeter in slot 6-7
rc = GPIB(Port, "RST 600") ' Reset it
rc = GPIB(Port, "TERM EXT") ' Use voltmeter external terminals
rc = GPIB(Port, "NRDGS 10") ' Ten readings
rc = GPIB(Port, "DELAY 0,1") ' 1s between readings
rc = GPIB(Port, "AZERO ONCE") ' Send command
rc = GPIB(Port, "TRIG INT") ' Internal trigger (pacer)
rc = GPIB(Port, "XRDGS 600") ' Do read

MsgBox "Press OK when you think 3852A has finished"

CommFlush (Port)
str = "2 ?UX" + Chr$(10) ' Set HP 3852A to talk
rc = CommWrite(Port, str)
For n = 1 To 1000
Next n
rc = GPIB(Port, "DISPLAY end") ' Show we're done
rc = CommWrite(Port, str)
For n = 1 To 1000
Next n
rc = GPIBReadValues(Port, 10, Result)

str = CommGetstr(Port) ' Read data to skip garbage
Cells(1, 1).Value = "Reading"
Cells(1, 2).Value = "Value"
For i = 2 To 11
Cells(i, 2).Value = Result(i)
Cells(i, 1).Value = i - 1
Next i

Cells(20, 1).Value = rc

str = "2 ?U " + Chr$(10) ' Unlisten
rc = CommWrite(Port, str)
str = "4 " + Chr$(10) ' IFC, Interface Clear
rc = CommWrite(Port, str)
rc = CommClose(Port)

'
End Sub
Function CommGetstr(Port As Integer) As String
Dim str As String
Dim timeout As Integer
done = 0
timeout = 1000
While done <> 1 And timeout > 0
If CommRead(Port, str, 10) > 0 Then
If InStr(str, Chr$(10)) Then done = 1
CommGetstr = CommGetstr + str
End If
timeout = timeout - 1
Wend
CommGetstr = Replace(CommGetstr, Chr$(0), "")
CommGetstr = Replace(CommGetstr, Chr$(10), "*")
CommGetstr = Replace(CommGetstr, Chr$(13), "|")

End Function

Function GPIB(Port As Integer, Cmd As String) As Integer
rc = CommWrite(Port, " " + Cmd + Chr$(10))
For n = 1 To 1000
Next n
End Function

Function GPIBReadValues(Port As Integer, Num As Integer, A As Variant) As Integer
Dim str As String ' Read Num decimal values from GPIB at Port, put into Array
Dim str2 As String ' Returns number of values read or valued resd+1000 on timeout
Dim nvalues As Integer
Dim sVal As String
done = 0
nvalues = 0
timeout = 100000 ' Loop counter for timeout
While nvalues <= Num And timeout > 0
If CommRead(Port, str, 10) > 0 Then
str2 = str2 + str
End If
'
If InStr(str2, Chr$(10)) Then
sVal = Left(str2, InStr(str2, Chr$(10)) - 1)
sVal = Replace(sVal, Chr$(13), "")
str2 = Mid(str2, InStr(str2, Chr$(10)) + 2)
A(nvalues) = Val(sVal)
'MsgBox sVal
nvalues = nvalues + 1
End If
timeout = timeout - 1
Wend
For n = 1 To 1
Next n
If timeout <= o Then nvalues = nvalues + 1000
GPIBReadValues = nvalues
End Function
Drod
Newbie
Newbie
 
Posts: 8
Joined: Fri Mar 16, 2012 2:49 pm

Re: GPIB 2 USB

Postby Eddietronic » Thu Apr 05, 2012 3:47 pm

Hello, the computer now recognizes the pic with the generic driver microchip as a communication port (COM6).

I tried to run the two macros of the page

http://www.dalton.ax/gpib/code/macros.shtml

But do not work.

In OpenOffice the program crashes.

In Excel I get compilation error.

Some advice about some software to receive data from port COM?
Thanks.
Attachments
ErrorCompilacion.jpg
Compilation error.
Eddietronic
Newbie
Newbie
 
Posts: 3
Joined: Thu Mar 29, 2012 7:31 pm

Re: GPIB 2 USB

Postby brian » Tue May 01, 2012 4:11 pm

Looks like an open hardware project is now available:

http://scasagrande.blogspot.ca/2012/04/ ... -sale.html
brian
Sr. Member
Sr. Member
 
Posts: 465
Joined: Sun Nov 14, 2010 12:27 am

Re: GPIB 2 USB

Postby scasagrande » Sat May 05, 2012 2:35 pm

Hey everyone,

I just noticed that my blog was receiving a few hits from here. If you have any questions or comments regarding my OSHW GPIBUSB project feel free to ask me.
scasagrande
Newbie
Newbie
 
Posts: 23
Joined: Sat May 05, 2012 2:26 pm

Re: GPIB 2 USB

Postby ian » Mon May 07, 2012 7:58 am

Hi scasagrande,

Great project.Thanks for joining us and and offering to answer questions.
User avatar
ian
Crew
Crew
 
Posts: 10529
Joined: Mon Jul 06, 2009 6:14 am

Re: GPIB 2 USB

Postby scasagrande » Mon May 07, 2012 8:48 pm

Not a problem ian! I'm always happy to talk about my work.
scasagrande
Newbie
Newbie
 
Posts: 23
Joined: Sat May 05, 2012 2:26 pm

Re: GPIB 2 USB

Postby Drod » Tue May 08, 2012 10:01 am

Hi scasagrande, a salute from Brazil!

Just one question, where can I find all the basic RS232 commands?
I saw a few of them on the photo you have posted, like:

"+a:"
"+eoi:"
"+eos:"
"read"

Do you have a list for all the commands?

Congratulations and thanks a lot!

Diego
Drod
Newbie
Newbie
 
Posts: 8
Joined: Fri Mar 16, 2012 2:49 pm

Re: GPIB 2 USB

Postby scasagrande » Tue May 08, 2012 1:50 pm

Drod wrote:Hi scasagrande, a salute from Brazil!

Just one question, where can I find all the basic RS232 commands?
I saw a few of them on the photo you have posted, like:

"+a:"
"+eoi:"
"+eos:"
"read"

Do you have a list for all the commands?

Congratulations and thanks a lot!

Diego

Hello Diego! All those commands are internal commands to my GPIBUSB. They are used to set the target GPIB address, enable or disable EOI use, set an EOS character, etc. All of these can be found in the document on github here https://github.com/Galvant/gpibusb-documentation under basic_commands.od
scasagrande
Newbie
Newbie
 
Posts: 23
Joined: Sat May 05, 2012 2:26 pm

Re: GPIB 2 USB

Postby jbeale » Sun Dec 16, 2012 1:57 am

As anyone reading this thread probably already knows, there are a lot of good quality, older instruments on the used market with GPIB ports, these are from the pre-USB era. But a GPIB-USB adaptor may cost more than the instrument did!

So, I bought one of the GPIB-USB adaptors that scasagrande is selling, after seeing it mentioned on this thread. It is the cheapest fully assembled GPIB board I know of. Mine is now working and it reads data from my Tek TDS 210 scope on GPIB address #1.

Code: Select all
+a:1

*IDN?
TEKTRONIX,TDS 210,0,CF:91.1CT FV:v1.06 TDS2CM:CMV:v1.02

:DIS?
:DIS:FORM YT;STY VEC;PERS 0;CONTR 55

:WFMP?
:WFMP:BYT_N 1;BIT_N 8;ENC BIN;BN_F RI;BYT_O MSB;NR_P 2500;WFI "Ch2, DC coupling, 2.0E0 V/div, 1.0E-3 s/div, 2500 points, Sample mode";PT_F Y;XIN 4.0E-6;PT_O 0;XZE -5.0E-3;XUN "s";YMU 8.0E-2;YZE 0.0E0;YOF 2.0E0;YUN "Volts"

I just wanted to mention what I did, in case it helps someone else.

1) Touched up one solder joint lacking solder, and added a jumper from pin 20 to pin 4 of the FTDI chip. Steven's schematic shows those pins connected (both should be Vcc) but the PCB I got (Rev B) had no trace connecting to pin 4, and I measured 0 V on that pin. (FTDI FT232RL pin 4 is VCCIO). (Note, he says he will be laying out a new PCB).

2) Talked to the board using a simple serial terminal, Termite 2.6 (http://www.compuphase.com) on WinXP box. I used Settings: 460800 bps, 8N1, append CR to transmit text. At first it didn't work because I had the wrong baud rate- I never used that particular setting before. I had to press the reset button on the board before it worked, maybe a bad state due to wrong initial serial speed.

Photo of board:
GPIB-USB.JPG
photo of GPIB-USB board
larger photo: https://picasaweb.google.com/1099282360 ... 6720652594

The board is nice and compact, and connects directly to an instrument's GPIB port. However I worry about doing it that way, being out of sight it is easy to forget and tilt up the instrument or push it against a wall, maybe damaging the board. Might be better on a short GPIB cable (some cheap ones now on Ebay, assuming they work).

Also, would like to put it in a plastic case. I have access to a Makerbot so I wonder if anyone has made a case design for this size board that I could adapt.
jbeale
Full Member
Full Member
 
Posts: 146
Joined: Thu Jan 13, 2011 6:48 pm

Re: GPIB 2 USB

Postby Sleepwalker3 » Sun Dec 16, 2012 2:18 am

Thanks for posting that info, sounds good. I have some doubts whether the board would fit directly to the back of the instrument I was thinking of using it on, it usually sits tilted and there is already space constraints behind it. Many instruments are fairly long, so I think a cable would have to be used in many cases, but that's fine. I'm interested to see it used on old HP gear (HPIB), as apparently it's slightly different and I've read of cases for other adaptors (not necessarily this one) where the software (firmware) won't work on older gear. I think I read a while back that others had got it working on older stuff, but not certain.
User avatar
Sleepwalker3
Hero Member
Hero Member
 
Posts: 527
Joined: Mon Jan 16, 2012 4:12 am
Location: Down Under

Re: GPIB 2 USB

Postby jbeale » Mon Dec 17, 2012 10:27 am

I don't have an older HP instrument to try it. But another GPIB adaptor sold by Beiming Tech (which is more expensive), apparently will work with old HP units, with some software configuration changes. See for example http://bmjd.biz/index.php?m=content&c=i ... id=15&id=6

EDIT: although the workaround the link above talks about seems to be for an older instrument not supporting the *IDN? command, which is not relevant to the adaptor I got anyway. That would happen at a higher software level, not in the firmware.
jbeale
Full Member
Full Member
 
Posts: 146
Joined: Thu Jan 13, 2011 6:48 pm

Re: GPIB 2 USB

Postby jbeale » Mon Dec 17, 2012 4:26 pm

Just for reference, here's a quick Python program to read a multimeter every 10 seconds or so.

Output of program in 'K196-log.csv' :
Code: Select all
date_time,volts
# Keithley 196 log v0.1 Dec.17 2012 JPB
2012-12-17 13:25:18.006000,+10.00400E+0
2012-12-17 13:25:28.115000,+10.00401E+0
2012-12-17 13:25:38.147000,+10.00400E+0
2012-12-17 13:25:48.225000,+10.00400E+0
2012-12-17 13:25:58.256000,+10.00400E+0
2012-12-17 13:26:08.365000,+10.00401E+0
2012-12-17 13:26:18.396000,+10.00400E+0


Code: Select all
# Python 2.7 code to get readings from Keithley 196 multimeter via GPIB
# Assumes meter is already set up to correct mode, eg. from front panel
# Dec. 17 2012 J.Beale

from __future__ import print_function   # to use print without newline
from serial import *
import time,datetime

cmd = "?\r"            # GPIB command to Keithley 196 must end with carriage return
eol_str = "\n"  # end of line string in file output
buffer =''           # serial input buffer
outbuf = ''          # file output buffer

ser=Serial(17,460800,8,'N',1,timeout=1)  # GPIB-USB board on COM18, with 460800 bps, 8-N-1
f = open('K196-log.csv', 'w')
print ("Keithley 196 log v0.1 Dec.17 2012 JPB")
f.write ("date_time,volts\n")
f.write ("# Keithley 196 log v0.1 Dec.17 2012 JPB\n")

while True:
    ser.read(255)            # clear out existing buffer & throw it away
    ser.write(cmd)                 # send query to instrument
    buf = ser.readline()         # string terminated with '\n'
    buffer = buf.split()[0]   # get rid of the \r\n characters at the end
    outbuf = str(datetime.datetime.now()) + ',' + buffer
    print (outbuf)
    f.write (outbuf)
    f.write (eol_str)
    time.sleep(9)                        # from 'time' to wait this many seconds
   
f.close                  # close log file
ser.close()            # close serial port when done. If we ever are...

jbeale
Full Member
Full Member
 
Posts: 146
Joined: Thu Jan 13, 2011 6:48 pm

Re: GPIB 2 USB

Postby Sleepwalker3 » Tue Dec 18, 2012 5:53 am

Thank J, I've never done anything with Python code, looks a bit like a combo of C and Basic. Will be useful starting point if I ever get around to making getting one of these units. I believe it's a popular way to program the Pi too, so I might have to learn it at some point.
User avatar
Sleepwalker3
Hero Member
Hero Member
 
Posts: 527
Joined: Mon Jan 16, 2012 4:12 am
Location: Down Under

Previous

Return to General discussion