03-08-2011 02:57 PM
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?
03-09-2011 01:40 PM
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.
03-09-2011 01:44 PM
MAX?
03-09-2011 02:16 PM
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.
03-09-2011 02:54 PM
Below code should get you started
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);
03-09-2011 03:27 PM
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!
03-09-2011 03:34 PM
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).
03-09-2011 03:54 PM
Okay, thanks. I'm assuming that because I have LabWindows 6.0 the viParsRsrcEx isn't available, so I'm going to use viParsRsrc.
03-09-2011 03:56 PM
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.