Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Where do I find a tutorial/ code samples for GPIB control with Visual Basic?

gpibtester and George,

Thanks to gpibtester for being quick to point out my error.  There are a wide variety of language interfaces available.  George, feel free to use any of the language interfaces on the page linked by gpibtester, although in general it will be much easier to find help when using one of the language interfaces which currently ships with NI-488.2.

Let us know if we can help in any other way,

Jason S.
Applications Engineer
National Instruments
0 Kudos
Message 21 of 36
(3,750 Views)
Gentle reader,
The saga continues.

I have no problem using Visual Basic 2005 Express if I can only figure out how to do it.
So I followed Jasons suggestions indicated by the ** below:

** 1. Upgrade NI-VISA and NI-488.2 if you do not have the latest versions installed.  Currently the latest
** versions are NI-VISA 3.6and NI-488.2 2.4.  The latest version of NI-VISA includes .NET Framework 2.0
** Assemblies.

I already had NI-488.2 2.4, but not NI-VISA 3.6 so I went to the NI website and downloaded the visa360full.zip package 'O bits. Unzipped and ran the self extraction and installation. Everything appeared to be fine.

** 2. Open the VISA .NET examples which can be found in C:\Program Files\National
** Instruments\MeasurementStudioVS2003\DotNET\Examples\Visa.  I would recommend starting with the ** SimpleReadWrite example.  Allow Visual Basic to convert the project for you.

I looked, but in the ...\DotNET\Examples folder was only a folder labled GPIB. No Visa folder.
I searched the entire harddrive for other \Examples folders, but none had a \Visa subfolder.

I did track down the NI-VISA Help dated Feb 2006, and it had introductory programming examples and suggested that if I wanted to look at Visual Basic .NET examples (and I most certainly did) that I should go to... the same directory Jason suggested in item 2 above.

Suggestions?

George

p.s. I didn't list Pascal and FORTRAN because I wanted to try and run a GPIB system over them, I mentioned them simply to give some feel for my programming background.
0 Kudos
Message 22 of 36
(3,731 Views)
C:\Program Files\National Instruments\MeasurementStudioVS2003\DotNET\Examples\Visa
 
is there on my PC and it most definitely was installed by NI-VISA because it wasn't there before the install
 
 

Message Edited by nyc on 05-04-2006 09:05 AM

0 Kudos
Message 23 of 36
(3,720 Views)
George,

When you install NI-VISA you have the option to install the .NET Assemblies for version 1.1 and 2.0 frameworks.  Re-run the VISA installed and be sure to select all the .NET options when you are asked to select which components to install.

Let me know if you still have any issues with this,

Jason Smith
Applications Engineer
National Instruments
0 Kudos
Message 24 of 36
(3,715 Views)
Episode N+1...
I reinstalled the NI-VISA and when prompted for Features --> Development Support discovered that the .NET Framework 1.1 Language Support and .NET Framework 2.0 Langugage Support were not selected. I selected them and *TA DA* now I have a ...DotNET\Examples\Visa folder complete with a Visual Basic SimpleReadWrite program.

Early in said program their is a line
Imports NationalInstruments.VisaNS

The help accessible from within Visual Basic 2005 Express had no option for pulling down Measurement Express help, nor did it have any idea what VisaNS might be.

Could someone

A. Tell me what VisaNS might be.
B. Tell me where I might find a reference to the classes/functions that are used in the SimpleReadWrite example program so I might, someday, be able to write some code to control an instrument on the GPIB bus

Regards,
George
0 Kudos
Message 25 of 36
(3,702 Views)
Hi George,

Look in your Start Menu under Programs->National Instruments->VISA and you should be able to find the references for the .NET assemblies.

Jason S.
Applications Engineer
National Instruments
0 Kudos
Message 26 of 36
(3,699 Views)

Hi,

thinking about your problem, I remembered that in the manuals of a GPIB
board of NI was a manual as "WIN32 programmer's manual" which released
samples of syntax for calling the API from VB ... There is a long way
to a working program but it may help if VB is a requirement ...

Regards,

FG

0 Kudos
Message 27 of 36
(3,697 Views)
Morning all.
I managed to get two meters and two supplies up and running by leveraging off the NI-VISA based code that Makoto posted way back on 4/9/06 (Makoto, I owe you a frosty beverage).
However I am having trouble getting the two supplies to trigger at the same time.
Details:
The supplies are HP E3642A's.
The code snippet is as follows

'Set up Supply1
Supply1.WriteString("*CLS")
Supply1.WriteString("*RST")
Supply1.WriteString("OUTP ON")
Supply1.WriteString("VOLT:TRIG")
Supply1.WriteString("TRIG:SOUR BUS")
Supply1.WriteString("INIT")

'Set up Supply2
Supply2.WriteString("*CLS")
Supply2.WriteString("*RST")
Supply2.WriteString("OUTP ON")
Supply2.WriteString("VOLT:TRIG")
Supply2.WriteString("TRIG:SOUR BUS")
Supply2.WriteString("INIT")

What I'd like to do at this point is issue some flavor of the GPIB global trigger to trigger both supplies so they come up at the same time. I tried

Supply1.WriteString("GET")

but all I got was an error from the supply talking about "Query Interrupted"? and only one supply turned on.

I tried
Supply1.WriteString("*TRG")
Supply2.WriteString("*TRG")

and both supplies came one but there was a 250msec lag between Supply1 and Supply2. I am trying to power up a dual supply power op amp so I'd very much like both supplies to come up at the same time.

Suggestions?

Curiously yours,
George
0 Kudos
Message 28 of 36
(3,594 Views)

http://forums.ni.com/ni/board/message?board.id=140&message.id=17237

you'll need to port it over to Visual Basic 2005

0 Kudos
Message 29 of 36
(3,586 Views)

Using VISA, an IEEE488.1 "get" message can be sent to multiple devices at a time with the following method.  Mind that you must have an INTFC session (equivalent to NI-488.2M board-level session).

' Open INTFC session, then reference to INTFC interface
Dim gpintfc As IGpibIntfc
Set gpintfc = rm.Open("GPIB0::INTFC")   
   
' If needed, send IFC and REN (probably unneeded)
' gpintfc.SendIFC
' gpintfc.ControlREN GPIB_REN_ASSERT

' Send ATN-true command
Dim cmd(0 To 4) As Byte
cmd(0) = &H3F  'UNL
cmd(1) = &H40 + gpintfc.PrimaryAddress 'TA
cmd(2) = &H20 + 1 'LA1
cmd(3) = &H20 + 2 'LA2
cmd(4) = 8 'GET
gpintfc.Command cmd, 5

This will send a GET message to GPIB address 1 & 2 at the same time.  You can have multiple sessions (such as INSTR and INTFC) kept open at the same time.

 

 

このメッセージは 06-13-2006 11:20 AMに Makoto が編集しています。

このメッセージは 06-13-2006 11:21 AMに Makoto が編集しています。

このメッセージは 06-13-2006 11:26 AMに Makoto が編集しています。

0 Kudos
Message 30 of 36
(3,579 Views)