Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# Visual Studio GPIB Commands

Tags:

c#

gpib

What commands do you use to talk to a GPIB instrument in C#, visual studio? I need to be able to write commands to the instrument and read the output.

like image 330
Ofri Harlev Avatar asked Jun 27 '12 18:06

Ofri Harlev


People also ask

What is the full name of C?

In the real sense it has no meaning or full form. It was developed by Dennis Ritchie and Ken Thompson at AT&T bell Lab. First, they used to call it as B language then later they made some improvement into it and renamed it as C and its superscript as C++ which was invented by Dr.

What do you mean by C?

" " C is a computer programming language. That means that you can use C to create lists of instructions for a computer to follow. C is one of thousands of programming languages currently in use.


2 Answers

I use Agilent IO Library Suite.

Here is a tutorial to use it on C#: I/O programming examples in C#

Nevertheless, in my company we had stability issues with the VISA-COM implementation, so we wrote our own wrapper around the visa32.dll (also part of the IO Library suite) using P/Invoke.

(Disclosure: I work in a company that make intense use of GPIB instruments)

like image 128
Benoit Blanchon Avatar answered Oct 01 '22 12:10

Benoit Blanchon


I'm using National Instruments VISA and NI 488.2.

First make sure that you checked the VisaNS.NET API in the NI-VISA Setup, see the following figure:

enter image description here

Add a reference to NationalInstruments.VisaNS and NationalInstruments.Common to your project.

Create a MessageBasedSession, see the following code:

string resourceName = "GPIB0::20::INSTR"; // GPIB adapter 0, Instrument address 20
var visa = new NationalInstruments.VisaNS.MessageBasedSession(resourceName);
visa.Write("*IDN?"); // write to instrument
string res = visa.ReadString(); // read from instrument

A MessageBasedSession can be used to communicate with your instrument over GPIB, Ethernet or USB.

Update

Ivi.Visa superseded NationalInstruments.VisaNS. So you should add a reference only to Ivi.Visa to your project.

The example would look like that:

string resourceName = "GPIB0::20::INSTR"; // GPIB adapter 0, Instrument address 20
var visa = GlobalResourceManager.Open(resourceName) as IMessageBasedSession;
visa.RawIO.Write("*IDN?\n"); // write to instrument
string res = visa.RawIO.ReadString(); // read from instrument

The benefit of using Ivi.Visa is that it works with one of the following libraries:

  • National Instruments VISA
  • Keysight IO Libraries Suite
  • Rohde & Schwarz VISA
like image 21
Wollmich Avatar answered Oct 01 '22 12:10

Wollmich