LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to detect a device on COM port is power-on? and how to detect a USB device connected?

Dear all,

 

I am wondering how can we detect an external device connected to COM port is power-on?   If not, we can notify the user.

 

Also anyone has examples on how to notify the user that the USB VISA device is not connected?

 

Thank you very much!

 

 

0 Kudos
Message 1 of 9
(5,020 Views)

This is very simple: if you know the device type, initiate communication with it, like request model number, execute function, etc. If the Visa Read/write function times out, it means the device is not connected or not powered on...

0 Kudos
Message 2 of 9
(5,007 Views)

Hi, Thank you!  The time out doesn't seem to work on COM port. The 'VISA Configure Serial Port VI' does not give time out errors.

VISASerialTimeOut.png

 

@Blokk wrote:

This is very simple: if you know the device type, initiate communication with it, like request model number, execute function, etc. If the Visa Read/write function times out, it means the device is not connected or not powered on...


 

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

It works for me. Maybe you could specify your actual hardware config to see what can be the problem here...

 

edit: and the timeout error should come from a write/read attempt, not at the initialization step obviously...

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

It is a motor connected to COM3. It doesn't give time out error when the motor is not power-on. I think it is because COM3 is listed on VISA source name.

 

@Blokk wrote:

It works for me. Maybe you could specify your actual hardware config to see what can be the problem here...


 

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

A motor can mean many things. Specify the model, interface, etc. I never heard about a "motor" directly connected to a serial port. Do you have any manual? What kind of serial commands are available?

 

edit: i mean, it is not the serial port which directly drives the motor. There is always some more electronics. Also, some protocol to issue commands from the PC.

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

Velmex Motor Controller,  PC issue comands to COM port to control the motor.

 

@Blokk wrote:

A motor can mean many things. Specify the model, interface, etc. I never heard about a "motor" directly connected to a serial port. Do you have any manual? What kind of serial commands are available?

 

edit: i mean, it is not the serial port which directly drives the motor. There is always some more electronics. Also, some protocol to issue commands from the PC.


 

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

I repeat: try to issue a command, and if timeout happens, it can be due to disconnected state or power off. If the motor has a separate power supply, it might happen that its interface module does not "respond" with a visa timeout. But check the manual: there might be a command to check the motor power state? Anyway, this is really model specific thing, read and understand the manual before anything...

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

Serial ports do not have any standard means of detecting whether anything is connected (at least when using the common (minimalist) connections. So what Bokk has been trying to say is that the only way you can tell if something is there is to send it a command which is certain to return a known response. If that response is received within the timeout period then the device is there and active. Otherwise something is not working, although you cannot tell what the problem might be.

 

I have not looked at Velmex drivers for a long time. In the past they were poorly written but I think at least some of them generated responses.

 

Lynn

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