09-04-2008 07:13 AM
Hello, everyone
I want to write a program to control my Agilent signal generator, my laptop connect to it with USB/GPIB adapter, i want my program to check whether the adapter is connecter and siganl generater is on before sending operation code in. is there any way to do that?
appreciouate for your help
09-04-2008 07:43 AM
Most GPIB devices (and just about every Agilent device) will respond to a *IDN? querry.
Before you start sending commands to the device, perform the *IDN?. You should get back a positive response almost immediately that will normally contain the device manufacturer, model number, serial number, firmware revision, date?
If this matches what you expect, start sending commands. If the response times out or is not the correct model, you can generate an error and flag the problem to the operator.
09-04-2008 07:56 AM
thanks for you reply, i already did this before, but this solution seems do not surport hot plug in/out, it means when the device is on, and the program works well with it, i plug the cable out, then connect it again, the program can not detect the instrument, and visa write block always send out error signal. so once the connection is built, the cable can not be disconnected.
09-04-2008 08:32 AM
I have not tried to hot plug any USB communication devices (DAQ or GPIB) while my application is running although I can think of at least two possible reasons why you are not able to communicate afterwards.
1) When the device is unplugged the driver sees the deviece as being gone and unloads itself thereby closing any open sessions you may have. This may require that you close your existing sessions (it is probably already invalid) and reopen a new session.
2) I am pretty sure that LabVIEW enumerates devices when it launches. If you unplug the USB device, as mentioned above, the driver unregisters itself and LabVIEW can not access it. You might be able to overcome this limitation by clicking on a VISA refnum front panel control and selecting "Refresh", performing a similar function in MAX. There might be a programatic interface to this bu I don't know what it is off the top of my head.
09-04-2008 09:20 AM
09-04-2008 09:29 AM
It's on the I/O palette.
Frankly, I don't think this will work anyway. The refresh with the VISA Resource Name control is not the same as the Refresh in MAX.
Are you anticipating that the USB controller will be unplugged on a regular basis or are you just speculating? I don't know why the controller would possilby get unplugged in the middle of a program. If it could happen by accident, I would just treat it with an error handler, restart the program, and tell the user to be more careful.
09-04-2008 09:31 AM
09-04-2008 09:34 AM