LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to check whether device is connected and turned on?

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

0 Kudos
Message 1 of 8
(3,611 Views)

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.

Greg Sussman
Sr Business Manager A/D/G BU
0 Kudos
Message 2 of 8
(3,601 Views)

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.

0 Kudos
Message 3 of 8
(3,597 Views)

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.

Greg Sussman
Sr Business Manager A/D/G BU
0 Kudos
Message 4 of 8
(3,579 Views)
thanks a lot for your comment, where i can find this VISA refnum front panel control? 
0 Kudos
Message 5 of 8
(3,570 Views)

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.

0 Kudos
Message 6 of 8
(3,563 Views)
can i add this refresh button in my program?
0 Kudos
Message 7 of 8
(3,558 Views)
What refresh button? As I said there is no refresh option associated with the VISA control that will do anything in case some idiot unplugs the controller.
Message 8 of 8
(3,556 Views)