LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to take the output from a while loop out to do comparison

Solved!
Go to solution

Sorry what a stupid mistake.....

 

 

0 Kudos
Message 11 of 16
(628 Views)
Solution
Accepted by topic author jcraffael

Ok, you can use a local variable (to create one, just right click any control/indicator and select 'Create >> Local Variable')

Find the attached modified VI and let us know if it works for you.


I am not allergic to Kudos, in fact I love Kudos.

 Make your LabVIEW experience more CONVENIENT.


0 Kudos
Message 12 of 16
(619 Views)

Just one question and one mistake I noticed:

 

Why do two loops at all? If you want to take two pieces of data every 100 ms, just put them in the same loop.

 

Mistake: You have lengthened your while loop structure so it extends over the error path outside and the Close UDP and error handler VIs are "floating on top" (you can see the "shadow"). This makes it really hard to read. Never cover up one thing with something else if at all possible.

 

Cameron

 

To err is human, but to really foul it up requires a computer.
The optimist believes we are in the best of all possible worlds - the pessimist fears this is true.
Profanity is the one language all programmers know best.
An expert is someone who has made all the possible mistakes.

To learn something about LabVIEW at no extra cost, work the online LabVIEW tutorial(s):

LabVIEW Unit 1 - Getting Started</ a>
Learn to Use LabVIEW with MyDAQ</ a>
0 Kudos
Message 13 of 16
(609 Views)

Well yes that works! Thank you.

Actually I was inspired by a tutor book before and tried to use 2 globel variables and form another

while loop to make comparison, the idea of which is similar to yours but yours is obviously simpler

to handle. I really appreciate your kind help, thanks again moderator!

 

Chao

0 Kudos
Message 14 of 16
(601 Views)

@jcraffael wrote:

Actually I was inspired by a tutor book before and tried to use 2 globel variables and form another

while loop to make comparison, the idea of which is similar to yours but yours is obviously simpler

to handle.


Local/Global variables should be avoided as they can cause RACE condition... however in your case, the requirement was just to read the value of an indicator from different loop, so I preferred simpler way to use the local variable.


I am not allergic to Kudos, in fact I love Kudos.

 Make your LabVIEW experience more CONVENIENT.


0 Kudos
Message 15 of 16
(596 Views)

Good question Cameron! it's a good idea to use only one loop. Because the UDP reader vi is actually a labview example

and i just copied it to have 2 blocks to receive data from 2 UDP ports without thinking of modifying the source code.

Besides, the covering error handler is also what the source code is like. But thanks for your suggestion!

Chao

0 Kudos
Message 16 of 16
(594 Views)