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?

Well rats.
If you look at the Microsoft Visual Basic 2005 Express FAQ it clearly states that you cannot use it to develop applications to target the .NET Framework 1.1

I talked to NI tech support and was told that the NI-488.2 version that would support the .Net Framework 2.0 is version 2.4.3... which is not yet released.

So the Visual Basic 2005 Express approach is Dead In The Water.

There are application notes talking about using NI-488.2 with QuickBasic applications, but I couldn't find the appropriate drivers/downloads on the NI site.

Does anyone have any suggestions on how to use NI-488.2 with some version of Basic?

Curiously yours,
George
0 Kudos
Message 11 of 36
(3,712 Views)
If you want to run old DOS/NI-488.2 app such as what written in QuickBASIC under the DOS prompt inside Windows, see the following tips:
 
 
If you are looking for a real DOS/NI-488.2 device driver, download the NI-488.2 For DOS VER 2.7.2 at the following site:
 
 
Makoto
0 Kudos
Message 12 of 36
(3,703 Views)
George,

I am curious to find out if you have installed the .NET Framework 1.1 and tried running the shipping examples which come with NI-488.2.  I was able to find a similar statement about Visual Studio 2005 Professional (which I use), stating that is is only able to target version 2.0 of the framework, but I am still able to load the example programs, convert them to 2005, and run them just fine.  If you have not tried it, please try executing the examples, and let us know if they work after you have installed version 1.1 of the framework.

While I do not know everything about the compatibility of Visual Studio 2005 with different versions of the framework, I expect that since the assembly is already created it does not really matter which framework the assembly calls.  Any new .NET calls you use within your program will apparently have to target version 2.0 of the framewor.  The advantage of updating the assemblies to use version 2.0 of the framework is that you do not have to have both versions of the .NET framework installed on your machine.

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


@George in Colorado wrote:
So the Visual Basic 2005 Express approach is Dead In The Water.

I disagree about this. I have Visual Basic 2005 Express loaded on one of our non-critical test station PCs which has latest NI-VISA. I modified the files that Makoto provided in one of his earlier posts on this thread, and I am able to communicate to the instruments using the VISA-COM approach.


Message Edited by nyc on 04-27-2006 09:32 AM

0 Kudos
Message 14 of 36
(3,696 Views)
Jason et al,
I took your suggestion and ran the Framework 1.1 updates (see message from JasonS 4/26/06), then reinstalled the NI-488.2 software package to include the Framework 1.1 and .NET support. Wonder of wonders, they installed without complaint.
I then headed for the the examples at c:\Program Files\NationalInstruments\MeasurementStudioVS2003\DotNET\Examples, opened the relevent project files, saw a notice about the files were going to be updated, did I really want to do this, said yes and *poof* there they were.
But. Except for the Imports NationaInstruments.NI4882 line in the code, nothing made sense. I couldn't recognize any function or subroutine calls. I looked at the NI488 Users Manual, it talked about VisualBasic (Version 4.0 or later) and said that you can "...use the traditional NI-488.2 calls as subroutines, using the BASIC keyword CALL followed by the traditional NI-488.2 call name, or you can access them using the il set of functions".
I skimmed the example programs, looking for anything that looked like what I saw in the documentation of the NI488.2 vis a vi routine or function names. No joy.

It looks like something significant happened in the way of different forms of Visual Basic that I haven't the documentation to describe.

At this point I am looking at three options:

1. Forget the whole Visual Basic thing, revert to coding up the project in QuickBasic 4.5 using the NI-488.2 For DOS VER 2.7.2 from the site Makoto recommended back on 4/26/06. I'd rather not, but I'm running out of time to screw around, and I am fairly certain I can write code in QuickBasic.

2. Forget this fancy Visual Basic 2005 Express and find and use a copy of Visual Basic 4, which seems to have much more available documentation vis a vi NI-488.2. I'd rather not since in choosing VB2005 Express I read about all manner of horrible things in the earlier versions of Visual Basic.

3. The web rides to my rescue. Someone out there looks at what I have done and what I am trying to do and says. "George, no worries. You just need the XYZ documentation that describes how you can get NI-488.2 for Windows/XP Version 2.4 to work with Visual Basic 2005 Express. Here's the hyperlink".

Needless to say that I am somewhat frustrated with the situation. If anyone from National Instruments is listening, I suggest you sit down and pound out a "ReadMeFirstWeMeanIt" on any page that talks about the NI-488.2 and describe, in grim detail, the options for writing applications with the NI-488.2 code. This would be a tough document to write, and it would require constant vigilance to keep current. However I would dearly dearly love to have had such a thing way back when I decided to go with NI's USB GPIB product and the NI-488.2 software.

Regards,
George
0 Kudos
Message 15 of 36
(3,664 Views)
George,
 
I really don't understand your reluctance to try VISA-COM. Why go back to NET1.1 when
NET2 is what is now being used by Visual Basic 2005?
 
Did you look at the example Makoto provided in an earlier post?
It uses the new VB.NET concept of Try/Catch error processing.
With it, communicating through GPIB - reading/writing - to instruments is simple.
And I am not even a VB person. Most of my experience has been with LabVIEW.
 
Going from VB6 to VB.NET is a big jump. But if you are writing a new test program from scratch,
it is not difficult. I have worked through the examples in Visual Basic 2005 Step-by-Step
book and also the free e-book from Microsoft about learning to program in VB2005.
 
 
0 Kudos
Message 16 of 36
(3,653 Views)
Hi George,

The help for the NI-488.2 .NET interface is separate from the help file you see on the Start Menu, and is installed to the Measurement Studio help.  This is not available from the Start Menu if you do not have Measurement Studio installed.  The following KnowledgeBase shows how you can access the help file without Measurement Studio installed:

Cannot Access .NET Class Library Help if Visual Studio Is Not Installed


For most situations, I would recommend using NI-VISA rather than NI-488.2 directly.  The .NET help file for NI-VISA is available directly from the VISA folder on the start menu, and example programs can be found in a location similar to where you found the 488.2 Examples.

The reason everything looks different in .NET is because it is now an object oriented interface.  In addition to the help files which are installed with NI-488.2, the Visual Basic Object Browser is useful when you are searching for a method or an attribute, because it allows you to visualize the class structure.  Please let us know if you have any specific questions after you have looked at the help files, example code, and object browser.

Jason S.
Applications Engineer
National Instruments
0 Kudos
Message 17 of 36
(3,653 Views)
Greetings.

1. I am not reluctant to try VISA-COM. I am unclear how to try it.
2. I tried to pop open the .zip file example that Makoto posted earlier and got some sort of error. I will re-download and re-attempt today.
3. I Followed the link to try and access the help for NI-488.2 .NET, but I couldn't get the suggested command to work. The suggestion was as follows:

"Use the following command to launch the help:"C:\Program Files\Common Files\Microsoft Shared\Help\dexplore.exe" /helpcol ms-help://NI.MeasurementStudio

I got a "file not found" type error and couldn't manually find the dexplore.exe

And that's when I finally realized I started, weeks ago, with the wrong question. What I should have written was something like

"Good day. I would like to use NI-488.2 and a USB-GPIB converter to control a small set of instruments and supplies. I do not have the budget to purchase Measurement Studio. I have some programming experience in the following languages: QuickBasic, PASCAL, FORTRAN. I do not have experience with any form of object oriented code. I seek two things:
1. Advice as how to most easily control the GPIB bus (ie how to write the control application)
2. Suggestions as to where to find examples of said control applications.

Thanks for your time,
George
0 Kudos
Message 18 of 36
(3,626 Views)
Hello George,

Unfortunately, National Instruments no longer provides language interfaces for Basic, Pascal, or Fortran.  As I know that you have Visual Basic Express 2005, I would recommend the following:

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.6 and NI-488.2 2.4.  The latest version of NI-VISA includes .NET Framework 2.0 Assemblies.

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.

3. If you experience errors when running the application, remove the references to the National Instruments assemblies, then add references to NationalInstruments.Common and NationalInstruments.VisaNS assemblies.

4. Use the file NI-VISA .NET Framework 2.0 Help, which can be found on the Start Menu in the National Instruments->VISA folder, as a reference to the .NET VISA commands.  You will find information on using NI-VISA under the NI Measurement Studio .NET Class Libraries section.

Let me know if I can answer any more specific questions.  If you do not wish to use Visual Basic, we also have examples available for C and LabVIEW, although those do not appear to be options for you.

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

George and Jason,

Contrary to what Jason said, you can download the GPIB language interface and examples for many different programming languages including Pascal, Basic, and so on. Here is a link to the main page where you can pick from:

Language Interfaces (for GPIB).

FYI- The ones listed as DOS can still be used in newer Windows operating systems such as Windows 2000 or XP by enabling DOS support.

I hope this information is helpful.

0 Kudos
Message 20 of 36
(3,619 Views)