LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

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?

0 Kudos
Message 1 of 9
(4,444 Views)

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.

 

0 Kudos
Message 2 of 9
(4,408 Views)

MAX?

0 Kudos
Message 3 of 9
(4,404 Views)

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.

0 Kudos
Message 4 of 9
(4,399 Views)

Below code should get you started Smiley Happy

 

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);

 

 

0 Kudos
Message 5 of 9
(4,387 Views)

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!

0 Kudos
Message 6 of 9
(4,380 Views)

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). 

0 Kudos
Message 7 of 9
(4,376 Views)

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

0 Kudos
Message 8 of 9
(4,371 Views)

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.

0 Kudos
Message 9 of 9
(4,368 Views)