LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to extract values from a loop in real time ?

Hello,
I would like to use values generated by a loop (while), but outside this loop, and in real time. I can't use a wire, because I obtain either the last value the loop has generated, or an array with all the values the loop has generated. But that's not what I want. Do you have a solution or an example ? I hope you will understand my question. Sorry for my English.
Thanks for your futur answer.
0 Kudos
Message 1 of 10
(4,324 Views)
Hello foxone,

there is more than one solution, for instance using local variables or queues.
But it would be better to tell what kind of data you are processing, how fast has the data transfer to be and so on. Or give an example vi...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 10
(4,314 Views)
I tried with local variable but, it doesn't seem to work. Actually, I just want to transfer numeric values and I have two purpose:
The first one is to increment a subVI's input value, but the subVI is not inside the loop.
The second one is to have the ability to change dynamically a value in a subVI which contains a while loop.
 
I attached my VI (which uses the first purpose). It  will not work because subVis are missing, but you should be able to understand my problem with it. You will see, I tried to use a local variable, but without success.
Thanks.
0 Kudos
Message 3 of 10
(4,312 Views)
Hello foxone,

ok, you want to changes values in a subVi. Why don't you use global variables for this? They can be accessed in your main vi (in the for loop) and in the subvi (in the while loop) too.
But be aware of race conditions (writing to the same global at different places)...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 10
(4,307 Views)
Ok thanks, I just tried with global variable (cf attached file). but it doesn't work neither. Maybe I don't use global variable properly.
0 Kudos
Message 5 of 10
(4,299 Views)
Please, do you have an example of VI which uses global variable, because it doesn't work with mine, and I don't know why.
0 Kudos
Message 6 of 10
(4,289 Views)
I cannot understand what you are really trying to do, but may be attached will give you an idea.
You need to learn how LabVIEW works and executes it's nodes.

Sergey
0 Kudos
Message 7 of 10
(4,274 Views)
I cannot understand what you are really trying to do, but may be attached will give you an idea.
You need to learn how LabVIEW works and executes it's nodes. Forget about globals/locals at this time.

Sergey
0 Kudos
Message 8 of 10
(4,275 Views)
If you turn on the execution highlighter (light bulb) you will see that your subvi will not start executing until the loop inside the False case is finished.  So your subvi isn't even running while the loop is executing.  It will always get the last value of the local or global.  The trick here is to have the subvi run at the same time as the loop.  I suppose that is what you want to do from your description.  You cannot have a wire from the case structure output to the input of the subvi or the subvi will not start until the case is finished.  This is what is meant by data flow.  Functions or subvi's won't execute until all of its inputs are present.  In your vi, the subvi depends on an input that comes from the case structure output, so it won't execute until the case is finished.  I don't know what your vi and subvi do, but you have to remove that data dependency if you want both to run in parallel.  Then the global variable will work as it should.
- tbob

Inventor of the WORM Global
0 Kudos
Message 9 of 10
(4,263 Views)

Ok guys, thanks a lot for your answers. I will try tomorrow and I'll tell you if it works.

0 Kudos
Message 10 of 10
(4,254 Views)