LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to use the serial-port-VIs (configure/read)

Hello,

i created a program that uses for example the VI "Bytes at serial port.vi". This has as input only an integer for the port-number. Inside of this Vi is then an "Open serial driver.vi" and in there is finally the real VISA-Open.

 

Now i have to questions about this:

1. Can i use this VIs or is there any problem that the port is always reopened? (I also use Serial port read / write where the port also is opened always)

 

2. To configure the port i use the "VISA configure serial port". BUT here the input is not an integer. It is a "Visa resource name". The question is now: When i run this vi and configure for example COM1 to a specific baudrate/parity/stopBit... are these values then stores automatically somewhere in labview? So that when i run after this a "Serial port read" (which gets the integer-comport) also knows about this setting?

 

Or are this two different ways if using the comport that cannot be combined?

 

Thanks for help

0 Kudos
Message 1 of 8
(3,418 Views)

Hi OnlyOne,

In order to use "Bytes at Serial Port.vi" (Which is a property node with "reference in" as an input), you would need to have the serial port open first. You can have the serial port open outside of the VI and pass in the serial reference (This is equal to VISA Resource Name Output from VISA Configure Serial Port).

 

You can refer to an example code "Basic Serial Write and Read.vi" under example finder in LabVIEW to find out how to use the vi/s mentioned. Attached is the code from the example finder.

 

 

- Meadow -
LabVIEW 7.0 - 2011, Vision, RT, FPGA
TestStand 3.0 - 4.5
0 Kudos
Message 2 of 8
(3,412 Views)

I am not using the property "Bytes at port". This is a vi saved in in:

 

C:\Program Files\National Instruments\LabVIEW 8.6\vi.lib\instr\Serial.llb\Bytes At Serial Port.vi

And the vi has an integer as input "portnumber".

 

0 Kudos
Message 3 of 8
(3,398 Views)

Quite simply, you are using the wrong function. You should be using the VISA Bytes at Serial Port that is on the palette. The function you found is for compatability with very old and obsolete serial functions.

0 Kudos
Message 4 of 8
(3,393 Views)

OK, changed to the new functions.

Another question: After configuring the port with baudrate, stopbits, ...then i save the returned reference of the  "VISA Configure Serial Port" in a Global-Variable. Then later when using the "VISA read" i open the Global an get the reference from there.

Is this working that i save the reference in a global instead of passing it with a direct wire from vi to vi?

Thx

0 Kudos
Message 5 of 8
(3,387 Views)

Why use a global? It's always better to use a wire.

0 Kudos
Message 6 of 8
(3,385 Views)

I´m using the vis in TestStand.

So at the beginning is a" Open-Vi" that configures the port and saves the reference in a global. And somewhere later is a write vi that uses the global to retrieve the same reference.

 

0 Kudos
Message 7 of 8
(3,382 Views)

So you are doing something similar to the shipping example called LVDMM.seq? I would probably write to a parameter or local instead of a file/station global but either way should work.

0 Kudos
Message 8 of 8
(3,377 Views)