Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Problems with VISA and USB to RS232 Peripherals

I am currently involved in a project which interfaces the Uart of a PIC microcontroller with a USB-RS232 converter (ie; USB cable between PC and the USB-RS232 adapter which converts the USB signals to compatible Uart signals)

The application I wrote (LV8.2) uses VISA to communicate with the connected device via a 'virtual COM port' configured by the 3rd party driver supplied with the converter. I can open a visa session and communicate without issue; however, when I unplug the usb connector from the PC the resource seems to dissapear until I completely exit and restart labview. Actually, when I plug the USB connector back into the PC it does not show up in the windows (2000) device manager until I completely shutdown Labview. Is there some way to programatically release the hold the labview environment seems to have on such devices and rescan for presence?

BTW, I'm looking for all available COM resources using the VISA find resource VI, then talking to each resource to find the device (to remove the need to configure com port in the GUI so it has a true USB feel). When I run it for the first time all available ports show up including the virtual COM port assigned to the device. After I unplug and reconnect the device as mentioned above, the VI returns only the standard COM ports and not the virtual COM port assigned to this device.

Here's an example of how I am 'discovering' valid devices..
- VISA find all resources
- For each entry in found array:
- Init Port (19200, 8,n,1)
- Open Port (think this is already handled by Init -- not allowing duplicate sessions)
- Clear read/write buffers
- Send query packet to port
- Wait for response
- If found, add resource to 'valid resource array', otherwise Close Port
- Repeat until array is spent
(this process is really troublesome if you accidently allow an LPT port to be discovered)

Once all available resources have been tested, the 'valid resource array' is passed on to the rest of the application. If at any time the user 'disconnects' all resources are CLOSED.

Any help would be greatly appreciated. I can reply with specifics regarding the US232-B converter if required..

Regards,

Doug.
0 Kudos
Message 1 of 5
(3,746 Views)

Doug,

What adapter are you using?  Have you tried an alternate?  I've done similar things with both NI USB-232 and BlackBox PCMCIA-232 adapters and never had a problem.  I gave up on using several other adapters because of problems with the 3rd party drivers.

 

 

 

0 Kudos
Message 2 of 5
(3,725 Views)

As long as the 3rd party USB-serial driver is installed as the system's virtual COM port, NI-VISA recognises the port and you can use it from VISA, LabVIEW, etc. However there is a fact that some products are causing problems are when using with NI-VISA.  A small issue is that some baudrate or stopbits are unavailable, but the worst case is causing blue creen deth.   (In fact I have a couple of 3rd party adapters and one of them causes blue screen when calling viRead() function.) 

If you want to completely avoid the problem, you should buy NI's USB-serial adapter which is guaranteed to use with NI-VISA, though it is more expensive than others. 

0 Kudos
Message 3 of 5
(3,712 Views)
The device I'm presenly using is a CP2102 from Silicon Labs.  I will also be evaluating a package from FTDI.

My biggest concern which I feel will most likely apply to any device I use is how the Labview environment 're-enumerates' communication resources..

In this application, the problem I experience occurs when the USB adaptor is removed from the system then reinstalled.  Where VISA had previously been able to find the resource, it can't at this point until I've exited and restarted my application (or during development, the labview environment).

One thing I'm going to try is uninstalling a standard com port through device manager after the labview application has identified it as a resource and see if it can re-identify it after I've re-enabled the port through device manager..

I have the feeling that all available resources are scanned at startup and in the event of a problem occuring with one of the resources, cannot be realized by the environment until the next start-up.

Regards,

Doug.
0 Kudos
Message 4 of 5
(3,696 Views)

Doug,

What version of NI VISA are you running?  I found this post and a fix that was made to NI-VISA

 http://forums.ni.com/ni/board/message?board.id=170&message.id=142452&requireLogin=False

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