Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

controlling GPIB from VBA 1

Status
Not open for further replies.

mustangcoupe

Electrical
Nov 13, 2002
10
0
0
US
Anyone able to give me some insight on how to controll a GPIB device via VBA. How do I Address, open, listen and talk through the port?

Todd
 
Replies continue below

Recommended for you

Depending on what brand GPIB card you have, you have to include the code modules to provide the VB language interface to the GPIB DLL calls. For a National Instruments card, these would be NIGLOBAL.BAS and VBIB-32.BAS - just add these as code modules in the VBA project manager. Then you'll be able to make your write and read calls to instruments on the bus in your program code.
 
1. I am writing this code to be used by more than myself. There are two other users. I have a NI PCMCIA GPIB card and one of the others have a NI PCI card and the other user uses a NON NI PCI GPIB card. If I use the NIGLOBAL.BAS and VBIB-32.BAS this shoule work for both NI cards but not the NON NI card right?

2. I found the NIGLOBAL.BAS and VBIB-32.BAS and imported them as modules. But the example files do not work with VBE. How can I find out more about calling the functions in the module? This is a first time for me trying to call and run modules.

Todd
 
I have used the NI PCI card, never have used the PCMCIA type, but those modules will most likely work with both. For the non-NI card, you will most definitely have to obtain the correct code modules from that manufacturer.

I'm not sure exactly what you have to do, but controlling instruments from VBA usually involves only a few command calls. Here's some code that I have used recently to extract
measurements from a Yokogawa WT1600 power analyzer:

YokoAddr = 5 ' GPIB address of WT1600
bdIndx = 0 ' GPIB board index#

Call ibdev(bdIndx, YokoAddr, 0, T10s, 1, 0, ud%) 'Open and initialize

EL1volt = "NUMERIC:NORMAL:VALUE? 1" 'Yokogawa command string

Data = Space$(20) 'define string length
Call ibwrt(ud%, EL1volt) 'send command string
Call ibrd(ud%, Data) 'read data from a device into a user buffer

In this case, I am just providing the initialization of the communication parameters, and sending the Yokogawa command string to tell it I need a voltage reading, and then reading the value back and placing it in a variable.

National Instruments generally has excellent documentation, and non-NI cards should have similar command calls, but you'll have to obtain the correct language interface code modules.

Hope this helps.

Mike
 
Status
Not open for further replies.
Back
Top