Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

How to open VISA session, Set GPIB / I.P. address in C#, working with .NET Interop assembly DLL?

Hi.

I generated .NET Interop assembly DLL from LabView 2012 and have to use it in C#.

DLL - is from Agilent 34401A labview driver.

.NET Iterop assembly wizard generated Initialize function like this:

 public static void Initialize(LVReferenceNumber VISA_32resource_32name, bool ID_32Query_32_40True_41, bool Reset_32_40True_41, out LVReferenceNumber VISA_32resource_32name_32out);        

What should I write in my C# test to set GPIB / I.P. addres? from Labview or MAX my DMM is acessible using address: GPIB0::22::INSTR.

Also, I have to generate DLL to scope and have to use I.P. address to open VISA.

I understand that I have to set some value to variiable:

LVReferenceNumber VISA_32resource_32name 

BUT, don't know exactly how to do it.

Can you help me?

0 Kudos
Message 1 of 19
(8,901 Views)

I don't know why you went to all of the trouble to do this when you can easily use the IVI driver for this instrument.

0 Kudos
Message 2 of 19
(8,887 Views)

Because I downloaded instrument driver from NI.com as Labview project with descrete VIs. And every VI has VISA in and VISA out. My question is how to create variable in C# that will hold VISA address - GPIB0::22:INSTR   for example or I.P. address if needed.

0 Kudos
Message 3 of 19
(8,846 Views)

Again, why are you using LabVIEW driver when your programming language is C#.

It makes NO sense.

 

If you are using NI hardware, look at the programming examples that should have been installed on your PC.

0 Kudos
Message 4 of 19
(8,830 Views)

I'm using Agilent, Tectronics, BertScope and Holzworth hardware.

standard instrument drivers from NI - labview VI.

Also, for new custom made instruments all what I get from manufacture is set of GPIB commands and maximum what i canask is to have labview VIs.

This is the reason.

And usage of .NET Interop assemble DLL in C# is standard procedure.

All what i need is to understand how to set VISA ...

0 Kudos
Message 5 of 19
(8,816 Views)

@IgorKurtser wrote:

I'm using Agilent, Tectronics, BertScope and Holzworth hardware.

standard instrument drivers from NI - labview VI.

Also, for new custom made instruments all what I get from manufacture is set of GPIB commands and maximum what i canask is to have labview VIs.

This is the reason.

And usage of .NET Interop assemble DLL in C# is standard procedure.

All what i need is to understand how to set VISA ...


And as I wrote above, look at the programing examples that was installed on your PC by NI.

 

0 Kudos
Message 6 of 19
(8,798 Views)

NYC.

Will you be so kind to give me a link to this manual (I failed to find it ...), assuming that LV installation path is standard istead of saying RTFM? Thanks in advance.

0 Kudos
Message 7 of 19
(8,792 Views)

It is not in a manual. The links to the examples should be under the National Instruments NI-VISA in the Windows Start Menu

You may need to go back and install NI-VISA if you did not include the support for .NET Framework during the installation.

 

0 Kudos
Message 8 of 19
(8,787 Views)
I'm also having trouble understanding what you are doing. You just mentioned a LabVIEW manual when you should be looking at the VISA programming examples.

I don't understand why you would request a LabVIEW driver from a vendor when IVI-C or IVI-.NET would be more appropriate.

A VISA Resource Name can be simply text and the oft mentioned examples should make that clear.
0 Kudos
Message 9 of 19
(8,783 Views)

 

Guys … Thanks for suggestion, but please understand that someone who started programming in LabView 6.0 knows why his question came to this forum.

I have tons of instrument drivers, written in LabView or just valuable code, which should be used from C#.

For this purpose I have to use .NET Interop Assembly. Or you can suggest better way?

Standard VISA example written in this manner:

 

using NationalInstruments.NI4882;

 

private Device device;

 

device = new Device((int)boardIdNumericUpDown.Value,(byte)primaryAddressNumericUpDown.Value,(byte)currentSecondaryAddress);

device.Write(ReplaceCommonEscapeSequences(stringToWriteTextBox.Text));

 

 

BUT, in NI manuals, usage of Interop assembly followed by:

 

using NationalInstruments.LabVIEW.Interop;

and only after I can use created DLL (with instrument driver):

using DmmAg3440aVer2;

 

The point is that Initialize VI, which nicely opens VISA session in LabView to this DMM, converted to function like this:

 

public static void Initialize(LVReferenceNumber VISA_32resource_32name, bool ID_32Query_32_40True_41, bool Reset_32_40True_41, out LVReferenceNumber VISA_32resource_32name_32out);

 

where GPIB address in some way have to be set in function argument:

 

LVReferenceNumber VISA_32resource_32name

 

And I don’t know how to deal with variables from this type.

 

So,

Try please with all respect try to answer on MY question …

0 Kudos
Message 10 of 19
(8,778 Views)