06-15-2011 03:50 AM
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
06-15-2011 04:30 AM
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.
06-15-2011 06:07 AM
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".
06-15-2011 07:09 AM
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.
06-15-2011 08:11 AM
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
06-15-2011 08:15 AM
Why use a global? It's always better to use a wire.
06-15-2011 08:26 AM
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.
06-15-2011 09:42 AM
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.