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.
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.
" " 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.
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)
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:
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:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With