From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Writing to a single serial port with multiple VI's in LabVIEW

Shall you please guide me... for the data transfer between computer VI to myRio VI using same serial port

 

Objective using same serial port : First Vi (Desktop/computer) write the data, Second VI (myRio) read the data

 

 

 

I found the below link, which may be the exact solution. But the program VI is not working with Labview 2016.

 

http://www.ni.com/example/29287/en/

 

Windows will only allow one program to access a serial port at a time. This is so that two programs do not try to talk to the same device at the same time and scramble each other's data; however, you can coordinate two or more VI's, so that they work together and share the serial port by using VISA. The first VI opens the VISA session and puts the VISA refnum into a queue and then begins to talk to the serial device. The second VI would read the VISA refnum from the same queue. The VISA driver coordinates the activities of the two VIs automatically, since they are both using the same VISA refnum. 

 

 

 

 

 

0 Kudos
Message 1 of 16
(3,186 Views)

I'm afraid your description doesn't clearly describe what you are trying to do?

 

You talk about how two programs can't access the same serial port at the same time.  That is true.

But you talk about "data transfer between computer VI to myRio VI using same serial port".  What exactly does that mean?  What serial port?  One on your computer?  One on your myRIO?  Wouldn't they be two different serial ports?

 

The link you attached is about getting two different VI's in the same session of LabVIEW to work together to share the same serial port.  So that is a 3rd thing you are describing, but really doesn't apply to either of the first two situations you described.

 

Perhaps you can attach a sketch of how things are connected together, and describe your application in a little more detail about what data is being passed back and forth via the serial port(s).

0 Kudos
Message 2 of 16
(3,166 Views)

Thanks for the reply.

 

Please refer my project objective,

 

I created "computer VI" for the leap motion sensor, which can work on computer. This will help to get data (x, y, z).

 

This data need to send to myRio, which is connected to computer through USB.

 

myRio will use this data to control three motors.

Download All
0 Kudos
Message 3 of 16
(3,161 Views)

Hi RAMASG,

 

- don't initialise the serial port in each iteration of the "computer VI" loop, just once before the loop is enough!

- append a TermChar to the string in the "computer VI", use NL aka 0x0A aka \n

- DON'T use BytesAtPort in the "myRIO VI"

- don't initialise the serial port in each iteration of the "myRIO VI" loop!

- just read 999 bytes in the "myRIO VI" and let the TermChar handle the message length automatically!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 16
(3,138 Views)

Dear GerdW,

 

Thanks for the feedback.

 

I amended the program. But I'm sure about point (2 & 5).

 

Please find enclosed the attachment and review the same.

0 Kudos
Message 5 of 16
(3,131 Views)

But I'm not sure about point (2 & 5).

 

Sorry for the typo error

0 Kudos
Message 6 of 16
(3,125 Views)

Hi RAMASG,

 

But I'm sure about point (2 & 5).

You need to add the TermChar to the message string you create in your "computer VI".

  1. Enable the display mode indicator for the format string.
  2. Set the display mode to "\-code".
  3. Append a "\n" (without quotation marks) to the format string.

Finished…

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 16
(3,123 Views)

Thanks for your support and details.

 

But I couldn't able to make it.

 

Shall you please help to guide me further.

 

 

Download All
0 Kudos
Message 8 of 16
(3,110 Views)

Hi RAMASG,

 

as I wrote before:

check.png

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 9 of 16
(3,098 Views)

Appreciated your earlier reply.

 

myRio VI is still not reading the data from Computer VI.

 

Shall you please enlighten the com port selection in both VI.

Download All
0 Kudos
Message 10 of 16
(3,068 Views)