Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Implementing USB to RS-232 converter.

I am trying to use a USB to RS-232 adapter. The program already uses the PC COM port to control an RS-232 device. An additional COM port is required to control a second RS-232 device. 
 
Windows XP Version 2002 Service Pack 2
LabWindows/CVI Version 5.5.1
IOGEAR GUC232A USB/Serial Adapter
 
I installed the USB/Serail Adapter. It shows up in Device Manager as:
"ATEN USB to Serial Cable (COM11)"
 
I can communicate with the RS-232 device using COM11 in Hyper Terminal.
 
When I try the follwing I get a large number of these errors:
 
    NON-FATAL RUN-TIME ERROR
    The program has caused a first chance 'General Protection' fault at 001B:7C96CC82.
 
in:
 
     status = viFindRsrc (defaultRM, "ASRL?*::INSTR", &flist, &retCount,rsrcName);
 
    ViStatus status; /* For checking errors */
    ViSession defaultRM; /* Communication channels */
    ViSession instr; /* Communication channel */
    ViChar rsrcName[VI_FIND_BUFLEN]; /* Serial resource name */
    ViChar intfDesc[VI_FIND_BUFLEN]; /* Port binding description */
    ViUInt32 retCount; /* To hold number of resources */
    ViFindList flist; /* To hold list of resources */
 
    status = viOpenDefaultRM(&defaultRM);
    status = viFindRsrc (defaultRM, "ASRL?*::INSTR", &flist, &retCount,rsrcName);
 
If I keep pressing continue, eventually flist is created and here is what shows up:
 
Resource ASRL1::INSTR, Description ASRL1 (COM1)
Resource ASRL3::INSTR, Description ASRL3 (COM3)
Resource ASRL10::INSTR, Description ASRL10 (LPT1)
 
COM11 does not show up.
 
Anyone know how to get the USB to RS-232 Adapter to show up?
 
0 Kudos
Message 1 of 5
(4,984 Views)
NI-VISA might not correctly detect serial COM ports exceeding COM9.  Normally an additional COM port such as USB-Serial converter can be assigned to any arbitrary COM port#, therefore you better to assign COM9 or smaller port number to your conveter device. 
 
Go for Control Panel -> System -> Hardware tab -> Device Manager.   You can find your USB-Serial converter hardware under the Ports (COM & LPT) tree.  Then see the Property (from the righ-click context menu), select Port Settings tab-> Advanced.  You can there change the COM port# and you should select COM9 or smaller port number.
0 Kudos
Message 2 of 5
(4,960 Views)
 

There are a lot of USB to serial adapters out there that don't conform to the full built-in serial port spec.  It looks like this might be one of them.  NI-VISA is extremely careful (it checks for errors on every call) and robust in its serial calls.  It is probably making a serial function call that is not supported by your device.  If this is the case, then VISA is simply not going to work with your adapter since the problem is appearing on the find resource call. 

My recommendation would be to purchase a more robust adapter, such as our NI USB-232.  Digi and Keithley also make quality, industrial adapters rather than toys.  My fear would be that this problem with the driver is an indication of other problems you may run into in the future.

If you want to stick with your current adapter then your best bet would be to use the generic RS-232 Library in CVI instead of VISA.  You can then choose what calls you want to make and opt to not do any error checking.  You should be able to emulate HyperTerminal in this manner.

Hope this helps,

 
Robert Mortensen
Software Engineer
National Instruments
0 Kudos
Message 3 of 5
(4,938 Views)
Hello Makoto, Thanks for the help. I used COM4, and all is working now.
0 Kudos
Message 4 of 5
(4,928 Views)
I just wanted to note that if COM4 works, then the problem was still probably with the driver that came with the USB adapter. NI-VISA supports up to 256 COM ports, which is the maximum that Windows supports and I have personally tested it with up to 64 COM ports. From VISA perspective the COM number doesn't matter, because we are just requesting a handle from the OS.

-Josh
0 Kudos
Message 5 of 5
(4,922 Views)