0

I need to query the test equipment on a GPIB bus.

I tried looking through NationalInstruments.VisaNS.

NationalInstruments.NI4882.AddressCollection.GetEnumerator();

i.e. GPIB::6::INSTR, GPIB::7::INSTR, ......GPIB::20::INSTR.

  • I usually do it manually since it only needs to be done once. Open NIMAX and find the GPIB device and click on it. There should be a button that appears saying "Discover Devices". – jdweng Jul 22 '19 at 16:13
  • Thanks for the reply, I want to simulate functionality of the Visa control in the LabView, which it would make it easier for the user to select. – mattdl68 Jul 22 '19 at 17:49
  • You would need to use DllImport to call Visa Methods. The manual for definitions are here : http://www.ni.com/pdf/manuals/370132c.pdf – jdweng Jul 22 '19 at 19:19

1 Answers1

0

If you are using Vb or C# use Visa32.bas or Visa32.cs from the sample programs disk

int DefaultSessionId= 0;
int SessionId= 0;
int LastStatus = 0;
string Address = "GPIB0::6" ; //any address

//Session Open
LastStatus = visa32.viOpenDefaultRM(out DefaultSessionId);

//Connection Open
LastStatus = visa32.viOpen(DefaultSessionId, Address + "::INSTR", 0, 0, out sessionId);
LastStatus = visa32.viSetAttribute(SessionId, visa32.VI_ATTR_TERMCHAR, 13);// Set the termination character to carriage return (i.e., 13);
LastStatus = visa32.viSetAttribute(SessionId, visa32.VI_ATTR_TERMCHAR_EN, 1);// Set the flag to terminate when receiving a termination character
LastStatus = visa32.viSetAttribute(SessionId, visa32.VI_ATTR_TMO_VALUE, 2000);// Set timeout in milliseconds; set the timeout for your requirements

//Communication
LastStatus = visa32.viPrintf(SessionId, command + "\n");//device specific commands to write
StringBuilder message = new StringBuilder(2048);
LastStatus = visa32.viScanf(SessionId, "%2048t", message);//Readback

//Session and Connection Close
visa32.viClose(SessionId);
visa32.viClose(DefaultSessionId);

Reference from

Joe
  • 349
  • 2
  • 3