Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

LabVIEW autodetect correct Com Port or USB resource

I would like to program LabVIEW to automatically find the correct resource or com port when using 3 USB-to-serial adapters with FTDI chips. Does anyone have any ideas about how to accomplish this? I have tried 2 different approaches with no success:

 

1) Create a driver using the NI Driver Wizard, and run the adapters in RAW mode (I could not retrieve any hardware identification unless in this mode). This allowed me to get a serial off of each adapter in my VI and make a distinction but I do not know how to program communication well enough in RAW mode to be able to read and write with VISA Serial as I would normally.  I also could not find any examples or tutorials on setting up RAW USB to be run as if it was using VISA and a com port.

 

2) I attempted to have the VI access the registry values that Windows keeps the com port numbers in, these are assigned by the FTDI chip serial. This method failed when using the Read Registry Value Simple function with the error "-604" "remote access registry denied". I can fix this by manually changing the registry permissions but that is too complicated for the client users.

 

If anyone has any suggestions that would be very helpful. The ultimate goal is when a client plugs in all three serial adapters, the VI can find and distinguish them correctly (by previously knowing the adapter serial or other identifier) without having to manually decide which com port Windows decided on and entering them.  This is a problem I have faced many times in the past and still have never come up with a solution.

Thanks!

 

0 Kudos
Message 1 of 3
(5,307 Views)
It seems backwards to me what you are doing. The converter is worthless without an instrument and you can get a list of all com resources and simply query each one to determine which instrument is connected to which port.
0 Kudos
Message 2 of 3
(5,287 Views)

The USB-Serial devices have a VID/PID.

When windows enumerates a device, it creates a registry entry with things like the VID, PID, serial, driver used, assigned COM port, power status, etc etc etc.

With this information you can build a list of VISA resources; and either using the serial in the registry or by querying the device at the other end of the serial connection, identify what's what in your system.

 

Using USB-RAW is the very wrong way to go about this problem.  Use the driver that comes with the device.

 

Alternatively, there's a tool called "devcon" that's a commandline interface to device manager... could very likely glean the same or similar information from that as you can through the registry.

 

0 Kudos
Message 3 of 3
(5,282 Views)