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: 

TCP IP to recieve and split data in real time

Solved!
Go to solution

I am using labview 11 and I have a computer send data over tcp ip. The data string is like this P 22 33 44 P 22 44 66 P 22 33 11 P and so on The numbers in between P are x y and z co-ord I need labview to receive this and seperate each x y and z as seperate outputs

0 Kudos
Message 1 of 21
(4,344 Views)

You will need to write a parser for the data. There are several options available to you. If you data will always be well behaved you can use a regular expression or scan from string to grab the P x y z.

 

I would probably write your application using two loops. One loop simply reads data from the TCP connection. It reads it in chunks and simply passes those to a processing task. That task can use the above suggestion to pull the data from the buffer. You could also do some level of data validation in that task just to verify that you haven't received garbage.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 2 of 21
(4,339 Views)

First, define what you mean be "real time". If you are running under Windoz you can't have "real time" as it is usually technically defined, i.e. deterministic (where events occur at repeatable and predictable times). Also, tcp/ip is generally not deterministic (you never know, precisely, when the next packet of data will arrive) particularly if the communications is over a "shared" network with multiple computers on the the network.

 

There are several examples of tcp/ip communications under LabVIEW in the examples ("Help:Find Examples" tcp). If the messages are well defined, i.e. P 22 33 44 P 11 22 44, then you just parse based on the delimiters, in your example apparently a space. A number of ideas come to mind, first being the "spreadsheet to array" function, using a space as the delimiter. This would give you an array with each P, 22, 33, 44, in a seperate column. There are a nearly  inifinite way of parsing the string out to its x,y,z components

Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



Message 3 of 21
(4,334 Views)

Thank you for the fast reply 🙂 I am a novice in LabVIEW. So this is what I exactly want to do. I have a sytem recording the x y and z co ordinates of a marker. This computer sends the data over to another computer over the network with labView in it. The tcp/ip port is 2000. The data receieved will be in this format P x y z P x y z P and so on. The P is there to signify the end of one frame. so the first x y z are the xyz co ord of the marker at time 0 and the second xyz after the P is the marker position at time 1 and so on. I made labview connect to this computer using TCP listen and made TCP read function to display the received string. The issue is that TCP read needs to read and display the data continuosly. Another issue is to split this data into seperate x y and z outputs and this output should keep updating itself as time passes. Kindly help me.

0 Kudos
Message 4 of 21
(4,321 Views)

A sample vi would highly help 🙂 if it isnt asking too much

0 Kudos
Message 5 of 21
(4,318 Views)

@kishorgenius wrote:

A sample vi would highly help 🙂 if it isnt asking too much


If you're good enough at LabVIEW to make a TCP/IP connection, why don't you browse the "String" and "Array" palettes and see what you can come up with?  🙂

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 6 of 21
(4,311 Views)

Establishing the connection part was easy. I am trying as much as I can to solve this. This forum has been highly useful in helping me accomplish whatever I could so far. So kindly help. 

0 Kudos
Message 7 of 21
(4,306 Views)

Thank you for the fast reply :smileyhappy: I am a novice in LabVIEW. So this is what I exactly want to do. I have a sytem recording the x y and z co ordinates of a marker. This computer sends the data over to another computer over the network with labView in it. The tcp/ip port is 2000. The data receieved will be in this format P x y z P x y z P and so on. The P is there to signify the end of one frame. so the first x y z are the xyz co ord of the marker at time 0 and the second xyz after the P is the marker position at time 1 and so on. I made labview connect to this computer using TCP listen and made TCP read function to display the received string. The issue is that TCP read needs to read and display the data continuosly. Another issue is to split this data into seperate x y and z outputs and this output should keep updating itself as time passes. Kindly help me.

0 Kudos
Message 8 of 21
(4,300 Views)

What many LabVIEW newcomers don't realize is that you can click on the [?] on the VI toolbar to bring up the context help for whatever they mouse over - just about anywhere in LabVIEW.  Sometimes this still isn't enough information.  You'll find that, more often than not, there is more extensive help to be had by clicking on the "Click here for more help" link in the context help window.

 

If this STILL isn't enough help, it might be worth considering taking some of tutorials offered by NI.

 

If you have basic understanding of LabVIEW programming, we've given you a great headstart with the info already in the thread.  If not, it might be time to hit the tutorials...  Please, just give it a go and see what you can come up with...

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 9 of 21
(4,288 Views)
Solution
Accepted by topic author kishorgenius

Here are two examples of some basic parsing:

 

Simple Parser.png

 

The top portion is using a regular expression which is much more forgving than the bottom section which uses the Scan From String. The Scan From String will only work if there is a single space between the items. The regular expression will work will allow multiple spaces.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 10 of 21
(4,275 Views)