Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

I need to communicate with GPIB instruments using the NI GPIB-USB interface. How do I begin to write code in Visual Basic that will allow me to communicate with the interface and start talking to my machines?

Solved!
Go to solution
Start with the example programs that were installed with the driver (Start>National Instruments>NI-4882.2>Examples) and next time, don't cram everything into the subject line. You have a message body. Use it.
0 Kudos
Message 2 of 22
(7,607 Views)

Thank you Dennis.

I'm not exactly new to programming but I am just a beginner vith VB. It's been 30 years since my last instrument control program and things have changed a lot since then. I did as you suggested but the files require conversion to VB2008 which my computer won't do.

Notwithstanding, I need to discover how to send the command string that I write in VB to the NI488.2 interface and subesequently to the device (HP 437B power meter).

For instance:

DIM DEVice As String = "ibdev 0 13 0 13 1 0"

DIM RESet As String = "ibclr"

DIM IDEnt As String = "ibwrt"*IDN?""

Then what do I need to do to send these commands to the device and have it respond?

 

 

0 Kudos
Message 3 of 22
(7,534 Views)
VB 2008 is VB.NET, not VB. VB.NET is a different language. Thus, you would need to use .NET. Are you looking to program in the old VB (which would require you actually getting an old copy of the VB development environment, or an equivalent one), or are you looking to program in VB 2008? To program in VB 2008 you need to make sure you install the .NET support for the NI stuff. I'm not sure if this is selected by default.
0 Kudos
Message 4 of 22
(7,522 Views)
Then in that case make sure you've installed the .NET support as part of the NI device driver installation. This will install examples that show you how to access the NI .NET assemblies to communicate with GPIB instruments using a .NET development environment.
0 Kudos
Message 6 of 22
(7,458 Views)

I believe that I now have the .Net framework installed and am able to read the examples.

When I open create new project the windows forms application message reads "A project for creating an application with a windows user interface (.Net framework). So I double click Form 1, and using the example DMMSimple enter under Public Class Form 1 (Declairations) the first two lines of the example: Imports NationalInstruments.NI4882 (next line) Imports VB = Microsoft.VisualBasic. At this time I get an error "Imports statements must preceed any declarations" Can anyone tell me what I am doing wrong?

0 Kudos
Message 7 of 22
(7,378 Views)
Imports VB = Microsoft.VisualBasic  is not a valid statement. That's mixing up two different statements: an Imports statement and an assignment statement. 
0 Kudos
Message 8 of 22
(7,343 Views)

Thanks for your response. The Imports VB = Microsoft.VisualBasic statement was listed in the DMMSimple example which was why I entered it. Of course, as you say, it is invalid. I guess what I am asking for is an example of what to enter to initialize the NI interface. That is, to allow Visual Basic to open the interface so that I can send commands to my HP 437B power meter. I have been attempting this for weeks and haven’t gotten anywhere. Once I have accomplished this I can begin learning and developing my project and make some progress.

0 Kudos
Message 9 of 22
(7,323 Views)
Sorry, my mistake. That statement is actually creating an alias for that assembly. I'll try to take a look at this for you this afternoon. Kind of busy right now...
0 Kudos
Message 10 of 22
(7,317 Views)