Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Native .NET Instrument Driver Sample

Anybody know if there are any samples or a general style guide for writing an instrument driver using the native .NET VISA assembly? In other words, I want to create an instrument driver in C# using NI-VISA with the VisaNS assembly. Note: I do not want to create a wrapper class for an IVI driver and I do not want to use that VisaNS Instrumentation Task Class. I want to create a pure C# driver that just uses the VisaNS assembly. Sort of what you would do in LabVIEW by using the instrinsic VISA functions in LabVIEW. The only examples that ship with Measurement Studio is for a simple Read/Write which is pretty trivial.
0 Kudos
Message 1 of 11
(7,378 Views)
The NI-488.2 and NI-VISA driver software includes documentation and shipping examples to use VISA and GPIB in C# and VB.NET. You need to make sure you enable support for this by checking the option in the driver's installer feature tree.

The installer will also install documentation for the 488.2 and VISA .NET class libraries into the MSDN help collection. You access the NI-488.2 and NI-VISA .NET API function reference through the Help menu in Visual Studio .NET in the same manner that you access .NET framework class library help.
  • To use the GPIB API in a VB.NET or C# project, go to Add References in the Solution Explorer and choose National Instruments 488.2
  • To use the VISA API in a VB.NET or C# project, go to Add References in the Solution Explorer and choose National Instruments VisaNS
The directory for the examples are installed by default to:
  • C:\Program Files\National Instruments\MeasurementStudioVS2003\DotNET\Examples\GPIB
  • C:\Program Files\National Instruments\MeasurementStudioVS2003\DotNET\Examples\VISA
Also, I have found two example programs using C#.  I'm not sure if these were the examples you were referencing, but you might want to take a look at them.  I hope this helps you get started.


Mark W.
Download All
0 Kudos
Message 2 of 11
(7,357 Views)
Thanks for the response. Actually, I know all about how to set up the reference to the VisaNS assembly and have already done so. My issue isn't really how to set it up, but rather more of a style for writing an instrument driver using this assembly in C#. Kind of like the equivalent of what exists if you want to write an IVI instrument driver or, say, a LabVIEW instrument driver. As I indicated the examples that are provided with the .NET assembly for VISA are pretty simplistic and not indicative of trying to create an application like an instrument driver. For example, error handling is tantamount to simply displaying a popup dialog box. Not much use to that. Unfortunately, the examples you provided don't even use the .NET assemblies, and are simply read/write examples, just like the examples that come with the .NET assemblies for VISA.

Well, I guess I'll just wait around to see if this mechanism gains any traction in the industry. If nobody comes out with instrument drivers using this assembly directly rather than creating wrappers around IVI drivers it pretty much answers whether there's any advantage in using this technology in writing instrument drivers under .NET.


0 Kudos
Message 3 of 11
(7,358 Views)
What you are looking for is a kind of IVI.NET specifications or something like that.  I believe the IVI Foundation are discussing .NET based driver/assembly specifications, however they are not released yet.  The only IVI's specification concering to .NET is the Primary Interop Assembly specification.  However, it is just for .NET interface wrapper for IVI-COM drivers, which are native for Intel/Win32 platform.
 
 
 
0 Kudos
Message 4 of 11
(7,318 Views)
And if you really want to write a .NET instrument driver, which is fully IVI compliant, you have to wait for the official release of IVI.NET specifications.  Otherwise, you have to write a .NET driver with your own architecture. 
0 Kudos
Message 5 of 11
(7,315 Views)
Which is what I'm currently doing... I've written instrument drivers before, and was just looking for a decent starting place for .NET-based instrument drivers if any existed. It was a shot in the dark.

I am aware that IVI is currently working on specifications for .NET based driver specs, but I don't really want a full-blown IVI-compliant instrument driver since I find IVI's usefulness dubious, but I really don't want to get into that debate.

Thanks...

0 Kudos
Message 6 of 11
(7,309 Views)
smercurio_fc,

At this time, National Instruments is limited with the example programs for GPIB Instrument Drivers in .NET.  The best resource would be using the Measurement Studio
LabWindows/CVI Instrument Driver Developers Guide to create a
.NET-based instrument drivers.

Measurement StudioLabWindows/CVI Instrument Driver Developers Guide -
http://www.ni.com/pdf/manuals/320684f.pdf


Mark.

Message Edited by Mark W on 03-16-2006 06:33 PM

0 Kudos
Message 7 of 11
(7,276 Views)
Thanks for the link, but that document describes how to do an IVI-based instrument driver, and I couldn't find any mention of .NET anywhere in the document. Are you sure you provided the right link?
0 Kudos
Message 8 of 11
(7,264 Views)
smercurio
 
I have been writing my own drivers for about 3 years now using .NET and have had great success with the approach I have taken.  I wrote an example application and posted it at http://www.codeproject.com/dotnet/FreeCal.asp.  The mentioned example is several years old and my style has slightly changed since then, but it does demonstrate what you are requesting.  The new approach I have taken relies heavily on Interfaces and Inheritance (the old way also used Inheritance, but not Interfaces).
 
If you want more information, just let me know and I will send you some example instrument classes (both base and driver level) that I have developed and use.
 
Scott Page
Message 9 of 11
(6,469 Views)
Scott,

 I would love to see what you have done.  I am about to being a project that sounds very similar to work you have done.  I head start always helps.
Thanks in advance ekorpinen@puslewaverf.com
0 Kudos
Message 10 of 11
(6,294 Views)