LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using TCP or shared variable for data transfer

I am trying to send a large amount of numbers from a real-time module to a host computer.  These numbers have been arranged into a large array, such as an array with 10s of thousands of points.  The time critical portion of getting the information has already been done, so the data transfer back to the host VI is not time critical.  I know I will need to break the large array down into smaller arrays and then reform the large array after all the information has been sent.  I know how to use both TCP and shared variables with FIFO.  What I am unsure of is which one is better to use for this application.  I do not know what the maximum size arrays I can send through either.
 
Also, from what I have gathered from using LabView is that the sender has to be listening for a connection before the client opens a connection, or else it will throw an error.  When I tried breaking it down into 50 points, if i did not wait long enough in the host VI or if I did not put a long enough wait function in the RT loop, and error would throw, so it would take a long time to transfer the data when it worked properly.
 
Any help or suggestions is appreciated, thanks.
0 Kudos
Message 1 of 3
(2,780 Views)
Hello PT,
 
From what I understand, you have some questions about how to transfer data from your RT target to your host computer.  For this application, I would definitely use a shared variable with RT FIFOs enabled.  Shared variables will do most of the communication configurations under the hood so you won't have to mess with it.
 
If you do want to use the TCP VIs, there is an excellent example that ships with LabVIEW titled TCP Communication.lvproj.  You could easily integrate these VIs into your existing project.  Do make sure that you have your server running first - otherwise the client will timeout while trying to find the connection.
 
Have a great weekend,
 
Janell R | Applications Engineer
0 Kudos
Message 2 of 3
(2,748 Views)

Regarding the array size question, there is no real limit (other then the amount of memory in your system) to the size of data that you can transfer in a single block using either TCP or the Shared Variable. In your case you can easily transfer an array with 10's of thousands of data points in a single write operation. Both TCP and the Shared Variable will automatically handle breaking up the data for the maximum packet size on Ethernet and then reconstitute the array on the receiving end. In LabVIEW you will simply get back the array as a whole without needing to worrying about how the data is broken into smaller packets on the Ethernet.

I tested the attached example which transfers 400kB per block (50000 Doubles) without any problems. You do need to have the Server (in this case RT) running first before the client (Windows) can connect.

Message Edited by Christian L on 02-09-2007 11:34 AM

authored by
Christian L, CLA
Systems Engineering Manager - Automotive and Transportation
NI - Austin, TX


  
0 Kudos
Message 3 of 3
(2,738 Views)