NI Home
Cart Cart | Help
Hello Events Academic NI Developer Zone Support Solutions Products & Services Contact NI MyNI
You are here: 
NI Home > NI Developer Zone > NI Discussion Forums


Reply
Member
TurboMetrologist
Posts: 74
0 Kudos

Detect Which GPIB Addresses Are Connected?

Is it possible to detect which GPIB addresses are connected? Also, is it possible to query an instrument, such as "*IDN?" without the ibdev command?

Member
Paul_Knight_Lockheed_Martin
Posts: 91
0 Kudos

Re: Detect Which GPIB Addresses Are Connected?

MAX does that when you ask it to scan for instruments.

 

I have done it also by looping through all the GPIB address, but you have to use the ibdev command to get a handle.

Then use the ibwrt command to send the "IDN?" and ibread to read see if there is a response.

 

Depending on your timeout setting, if no instrument exists at the address you can wait awhile.

 

Member
TurboMetrologist
Posts: 74
0 Kudos

Re: Detect Which GPIB Addresses Are Connected?

MAX?

Member
Paul_Knight_Lockheed_Martin
Posts: 91
0 Kudos

Re: Detect Which GPIB Addresses Are Connected?

National Instruments has a program called Measurement and Automation Explorer,  MAX for short.

When you install LabWindows / LabView MAX gets installed.  I think it also gets install if you are using the NI GPIB-USB-HS.

 

I have found that if MAX can't find an instrument then neither can my programs. 

 

You can also use MAX to configure alias for USB and IVI instruments.

Member
ngay528
Posts: 184
0 Kudos

Re: Detect Which GPIB Addresses Are Connected?

Below code should get you started :smileyhappy:

 

viFindRsrc search string can be modified to detect only on certain bus, or certain type.

 

 

error = viOpenDefaultRM(&resourceManager);

   viFindRsrc (resourceManager, "?*INSTR", &findList, &numDevices, desc);
	if (numDevices) {
	error = ibconfig (0, IbcAUTOPOLL, 1);	//Sets up autopolling for the GPIB bus to status registers
	error = viParseRsrcEx (resourceManager, desc, &intf_type, &intf_num, desc, unalias_name, alias_name);
	if (intf_type != 4) {
		viOpen(resourceManager,unalias_name,VI_NULL,VI_NULL,&inst_handle);
		viQueryf(inst_handle,"*IDN?\n","%t",response);
		viClose(inst_handle);
	}

	
    }

for (i = 2; i <= numDevices; i++) {
	viFindNext (findList, desc);
	error = viParseRsrcEx (resourceManager, desc, &intf_type, &intf_num, desc, unalias_name, alias_name);
	if (intf_type != 4) { 
		viOpen(resourceManager,unalias_name,VI_NULL,VI_NULL,&inst_handle);
		viQueryf(inst_handle,"*IDN?\n","%t",response);
		viClose(inst_handle); //We could keep open, but if we can call the proper function, defaults and timeouts will be properly set.
	}

}
	
viClose(findList);
viClose(resourceManager);

 

 

Member
TurboMetrologist
Posts: 74
0 Kudos

Re: Detect Which GPIB Addresses Are Connected?

Okay, thanks. This is my first time using VISA then. By viParseRsrcEx did you mean viParseRsrc? If so, the latter uses 4 parameters instead of the 7 or is there another include besides visa.h I should add?

Thanks!

Member
ngay528
Posts: 184
0 Kudos

Re: Detect Which GPIB Addresses Are Connected?

Either would work.  viParsRsrcEx just gets more info back such as an alias name (which can be set in the MAX program).  And yes including visa.h will allow you to use these functions (assuming). 

Member
TurboMetrologist
Posts: 74
0 Kudos

Re: Detect Which GPIB Addresses Are Connected?

Okay, thanks. I'm assuming that because I have LabWindows 6.0 the viParsRsrcEx isn't available, so I'm going to use viParsRsrc.

Member
ngay528
Posts: 184
0 Kudos

Re: Detect Which GPIB Addresses Are Connected?

Probably the case.

 

Note from within function:

This function also returns three new parameters that are new to the VISA 3.0 specification.  These are the Resource Class, Expanded Unaliased Name, and Alias If Exists.

By using this web site, you accept the Terms of Use for this web site. Please read these Terms of Use carefully before using any part of this site. Please go here for information on ni.com's copyright infringement policy.
My Profile | Privacy | Legal | Contact NI © 2011 National Instruments Corporation. All rights reserved.    |    E-Mail this Page E-Mail this Page