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 Read and Write in Separate Loops

I want to read constantly and write TCP commands in separate loops as shown in the following attached VI.
I know it's messy code but it works. It's just that I know there has to be a better way of doing it, and this is one part of my bigger VI and I'm sure this is what is slowing it down and making it go crazy (over time).

Any input would be excellent!!!!!

Cheers.

0 Kudos
Message 1 of 3
(2,508 Views)

1. No need for the sequence structure.  You have enough data flow to initialize the important things.

2. Get rid of the wait in your top loop.  The Event Structure "sleeps" when it is waiting for an event.  So the rate at which you get events will limit your loop rate.  Right now, you are limiting the rate of events to 5 seconds!  That is an eternity!  And there is absolutely no need for it.

3. There is no need for that "Zero" button.  Just use the data from the User Event in your event case.  Actually, there isn't even a need for the case structure in that event case.  It will always be TRUE when you get that event.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 3
(2,476 Views)

Thanks mate, good feedback. That's how I did it originally and then for some reason it didn't work, so I added in extra unnecessary stuff then it worked. In the end it was a timing issue (that's why I put the massive wait in). All good now! Thanks again.

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