×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

controlling GPIB from VBA

controlling GPIB from VBA

controlling GPIB from VBA

(OP)
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

RE: controlling GPIB from VBA

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.

RE: controlling GPIB from VBA

(OP)
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

RE: controlling GPIB from VBA

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources