LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How is it possible to read from/write to a usb-to-serial adapter in LabVIEW?

Hi all,

I'm using LabVIEW 7.1 on SuSE Linux 9.3. My Notebook doesn't have a serial interface, so I have to use an usb-to-serial adapter. The Notebook detects the usb-to-serial adapter as follows:

Sep 27 15:28:23 icg246 kernel: usb 3-2: new full speed USB device using address6
Sep 27 15:28:23 icg246 kernel: pl2303 3-2:1.0: PL-2303 converter detected
Sep 27 15:28:23 icg246 kernel: usb 3-2: PL-2303 converter now attached to ttyUSB0
Sep 27 15:28:33 icg246 /etc/dev.d/tty/50-visor.dev[7309]: add tty device /class/tty/ttyUSB0

With "cat /dev/ttyUSB0" from command line I see the incoming data.

I tried to use "Basic Serial Write and Read.vi", but I don't know which "VISA resource name" I have to use. I found a description, that
ASRL0 is /dev/ttya
ASRL1 is /dev/ttyb and so on, but this does not work.

How is it possible to use /dev/ttyUSB0?
Does anyone of you have an example (a working VI) how to use such an adapter on a Linux system with labview?
Or is there a general problem of using an usb-to-serial adapter on a linux system?
Or does anyone know which usb-to-serial adapter works with labview on a linux system?


Thanks in andvance!

snork

0 Kudos
Message 1 of 10
(4,862 Views)

From your subject line I figured that it would be an easy answer, yes you can use a usb to serial adapter under LabVIEW, but when I saw that you are using Linux it became a little less certain. I haven't used LabVIEW under Linux (yet!) so I can't speak with quite as much assurance. Normally (WinOS) when the usb-serial device is installed it will show up in the VISA resource name control, usually just as a new "COM" port (COM6 for instance). I don't know how the VISA resource name control works under Linux, but it _should_ behave similarly, with the port name related to which usb port it is plugged into, for instance the same adapter mentioned above shows up as COM5 when plugged into a different usb port. Does the VISA resource name display the other ports when you l"eft click" the selection arrow? If yes it should listed there.

P.M.

Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



0 Kudos
Message 2 of 10
(4,851 Views)

Hello Snork!

If you use a USB to serial adapter under MacOs you have to install a driver for the adaptor that will allow the Macintosh to recognize the serial port as one of the system's native ports (http://digital.ni.com/public.nsf/allkb/B5DA820D78E9639086256776005468CB) . Maybe for Linux you also need a driver.

Best regards

Volker

0 Kudos
Message 3 of 10
(4,832 Views)
Hi P.M.,

first, thanks for your answer.

When I left click the selection arrow of the VISA resource name, the only port I get is ASRL2::INSTR. Funnily enough I get ASRL2::INSTR for choice regardless of connected the adapter or not.

snork

0 Kudos
Message 4 of 10
(4,833 Views)
Hi Volker,

perhaps I need a driver, but I don't know where to find one. I searched through the SuSE support and hardware database and I searched through the NI Knowledge database as well as the NI Support database without any result.  Normally the fist native serial port is detected as /dev/ttyS0 the second as /dev/ttyS1 and so on. My USB-to-serial adapter is detected as /dev/ttyUSB0 and I think, LabVIEW can't communicate with this.

I don't know how to use VISA or how to try out the serial port in general. It's the first time, I work with a serial port or usb-to-serial adapter. So it's possible, that I make a mistake in using VISA in general. I use the default settings in the "Basic Serial Write and Read.vi".


snork

0 Kudos
Message 5 of 10
(4,818 Views)

Hi Snork,

Here is a link to a tutorial about using Visa to control a USB device:

http://zone.ni.com/devzone/conceptd.nsf/webmain/6792BAB18242082786256DD7006B6416

But I`m not sure if you need one about using the serial interface.
 
Volker
0 Kudos
Message 6 of 10
(4,796 Views)

What USB to serial adapter do you use?

Volker

0 Kudos
Message 7 of 10
(4,796 Views)
Hello Volker,

the only information I have about the USB-to-serial adapter, is the information I get out of the linux log-file, which I have listed above.

Today, we've tried a lot. On an ASUS S1300N Notebook we've set a link from /dev/ttyUSB0 to /dev/ttyS0 and this WORKS!! On this way we could use the serial-VISA-VIs in Labview with the VISA resource name ASLR1::INSTR.
But on an IBM R40 Notebook with the same SuSE Linux and the same kernel, it does not work on this way. Very curious....


snork

0 Kudos
Message 8 of 10
(4,768 Views)
snork,

Sure you can use your USB to serial converter in Linux.  All you need to do is run visaconf to configure your serial port.  I am assuming it will not detect the usb to serial converter by default, so you will need to click on the Add Static button to create the VISA device.  From the Add Static window choose Local Serial Port from the Interface list.   From here you can pick an interface number (ASRL#::INSTR) and the device it Binds to (/dev/ttyUSB0).

Once you have configured the device with visaconf you can use your interface in LabVIEW.

Shawn B.
National Instruments
Use NI products on Linux? Come join the NI Linux Users Community
Message 9 of 10
(4,750 Views)
Hi Shawn,

today I've tried again to use the USB to serial adapter. I never heard about visaconf before. For any reason visaconf was not installed during the main installation of labview. Now, I've installed it manually and so I could configure the serial port.  Everything works fine now. Thanks!

snork

0 Kudos
Message 10 of 10
(4,694 Views)