LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Best way to transfer strings, arrays, and clusters

Solved!
Go to solution

Hi, I just want to know the best way to transfer strings, arrays and clusters between a PC and a RT-computer (compactRIO) if I want to use them in deterministic loops:

For a string should I used a network-published shared variable or network stream?

For an array of doubles should I flatten the array into a string and transfer the string? or should I send it like an array?

The same for clusters, should I flatten the cluster or transfer it like a cluster?

 

Thanks!

0 Kudos
Message 1 of 8
(3,557 Views)
Solution
Accepted by topic author rugebiker

Transfers over the network are not deterministic.  Are you asking how to use the data in a deterministic way once it arrives on the RT system?  Usually you would create a separate, non-time-critical loop for handling network communications.  As data arrives it is copied into real-time-safe structures such as RT-FIFOs to make it available to the time-critical loop.

 

I can't give you specific advice on network variables and network streams; I last did this sort of transfer over TCP, before those other options were available.

Message 2 of 8
(3,553 Views)

Thanks for answering,

 

but lets say I want to transfer an array of doubles from the RT to the PC. Should I send it with a network-published shared variable? or get all the numbers of the array and send them to another loop via single process with FIFO selected? or should I use network streams?

 

thanks!

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

As I understand it, the choice is based on whether you need to be sure you're transferred all of the data or not.

 

  • Network-Published Shared Variables are used for data that doesn't matter if it's "lost" (i.e. overwritten before it is read), such as monitoring values or similar.
  • Network Streams are used where it's important to read all of the data that is written.

So if you need the whole array, I'd use Network Streams, but if you're only ever interested in the latest value, the Shared Variables are the way to go.  I think that with both options, you can transfer clusters/arrays as-is, without flattening to strings (that's probably done internally).

Message 4 of 8
(3,520 Views)

@rugebiker wrote:

or get all the numbers of the array and send them to another loop via single process with FIFO selected?


Can't understand why you're asking about this option.  Single-process variables cannot be used to transfer data between computers (that's what makes them "single-process").

 

Otherwise, GregS seems to have provided a good summary.  Shared variables are more resource intensive because they support more features and are hosted by a dedicated process that handles communication in the background.  Network streams use less processing time and memory but require slightly more programming and don't support as many options.

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

@nathand wrote:

or get all the numbers of the array and send them to another loop via single process with FIFO selected?


 

I read in the Real Time manual that sometimes it is recommended to use single process with FIFO selected to transfer data quickly out of the loop and then send it via a shared variable.

But ok I understand what greg said.

 

Thank you!

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

@rugebiker wrote:

I read in the Real Time manual that sometimes it is recommended to use single process with FIFO selected to transfer data quickly out of the loop and then send it via a shared variable.


Right - that's what I mentioned in my first message, that you may want one loop for handling network communication and a second loop for time-critical tasks.  But this is a separate issue from the network communication, not an alternative method for transferring data from a host to an RT system.

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

okok thank you very much! 😄

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