LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Optimizing multiple loops w/ TCP/IP Comm

Hello, I am currently working on developing data collection/analysis VI over TCP/IP. I need to read data at a 100Hz rate from my DUT which to me seems fairly quick for LV. So I am using 3 loops to handle all the interactions. One loop has an event structure to handle interface with the front panel controls. One loop to handle the main task of polling the TCP/IP buffer. The last loop handles the periodic (approx every 5 sec) "Keep alive" message LV must send to the DUT to keep it outputting ethernet messages. I was thinking of another loop to setup the DUT and support equipment (RF Source, Spec. Analyser, etc), but have not implemnted it yet. So my questions are:    

1) Is there a better way to implement the "Keep Alive" loop so that it doesnt delay the exiting of the VI for 5 seconds?    
2) How do I keep from getting a TCP/IP error from the "Keep Alive" loop when I exit the VI?   
3) Is there a way to register a "TCP/IP buffer not Empty" event so I do not have to keep polling the buffer with a while loop?    
4) Generally speaking, what is the performance impact of adding another loop, the "send messages" loop, to this VI? I am not looking for what is going to happen in this specific case. Rather, I am curious on the performance hit when using 3 or more loops.    
5) Is there a better way to use the message queue so that I do not need to check that it is not empty before dequeueing something? If I do not include the small case, the main while loop just hangs.

Keep in mind that I am pretty new to LV and this is my first VI using muliple loops and event structures. Any comments/input would be a BIG help.

Thanks for your time.


0 Kudos
Message 1 of 5
(3,479 Views)
I am using Labview 7.0 so I cant view your VI,  but I have used LV 8.2 (and the TCP/IP) before and I will try to give some suggestions to your questions.
 
1) Is there a better way to implement the "Keep Alive" loop so that it doesnt delay the exiting of the VI for 5 seconds?    
       - In LV 8 there is a timed loop structure that you can stop progmaticaly if you name the loop.  I think it will work perfect for this step.

2) How do I keep from getting a TCP/IP error from the "Keep Alive" loop when I exit the VI?   
      -  If the error is constant or always the same you could intercept the error and clean it out and convert it to a warning if you want

3) Is there a way to register a "TCP/IP buffer not Empty" event so I do not have to keep polling the buffer with a while loop?
     -  I would suggest using a "wait on TCP" or "wait for listener" (not sure of the name) without a timeout value (-1).  This will wait for data in the loop.  If you need to stop it from waiting you can close the reference (problably outside the loop) and the VI will continue.  This will generate an error however and you will need to handle this (usually just convert it to a warning).
    
Hope this helps some.  I did a project not to long ago with TCP/IP with multiple loops.  But I don't have access to LV 8.2 or the TCP/IP VI's so I cant check to see how I implemented them.
0 Kudos
Message 2 of 5
(3,468 Views)

I tried to open you VI again and noticed that it was in 7.1.1 which I still cant open but it was not 8 or 8.2 like I first thought.  So, I don't think the timed loop is available in your version of labview.  At least it is not in my of 7.0.

In your "keep alive" loop do you call a "wait" function?  If you do, change that to "wait until next mS".  Also, decrease the wait time and then use shift registers to keep track of the time.  Then use a case statement to execute the "keep alive" TCP/IP comand after 5 seconds has elapsed.  Stop the loop when you need to.  Basicaly this will run the loop more often but you will not send you "keep alive" until it has loop X number of you loop iteration.

Sorry about the confusin about the LV versions

Paul

0 Kudos
Message 3 of 5
(3,466 Views)
Thanks for your quick reply.

What I ended up doing with my "Keep Alive" loop is pushing in into my event structure. I just set the timeout value equal to my message time, ~5 seconds, and things work great. Nice and fast with no errors.

I thought the TCP Wait on listener was used for letting another device connect with LV. I didnt think it could also be used to check the status of the TCP buffer. But, im pretty new at this stuff so I will look into it more fully.

What I am still stumped on is how to implement the setup of the DUT and associated test equipment. What is going to give me the least amount of latency?

Thanks again.
0 Kudos
Message 4 of 5
(3,456 Views)

I was mistaken about the "wait on listener".  You are correct.  What I wanted to tell you was that the TCP Read has a timeout input.  If you set that to -1 it will never timeout untill it reads the number bytes you are looking for.  It will pause at this VI in the loop until data arrives.  When you want the VI to continue (probably to exit the program) you can close the connection ID from outside the loop.  Then the TCP Read vi will stop and put an error on the error out of the VI.  Change that specific error to a warning or clear it.

I am really missing LV 8/8.2 right now.  Smiley Sad

0 Kudos
Message 5 of 5
(3,445 Views)