LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

global variabel

Hey there

I am currently making a LabVIEW program, where I need to be able to use a STOP-button inside two while-loops (one loop around the other) in a subVI. I have tried to attach this stop button to a global variable, as I was suggested by a co-student, but it is not working.

Also within the first while-loop of the subVI, I need to send out an integer value, every time it runs, which then can be read from the main-vi (this is while the subvi is stil running).

Anyone know how I should do this?

Greetings
Christian Maden
0 Kudos
Message 1 of 23
(4,775 Views)
Hi Christian,

when you have the same stop condition in two nested while loops you either only need one stop button or only one while loop...

To send values from sub-vi to main-vi you should use a queue. This way you don't lose any data.
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 23
(4,765 Views)
Well, the thing is that the first outermost while-loop, runs for every scan I need to make (for each time I make a new xy-graph), and the second inner while-loop runs for every meaurement done (every xy-point in the graph).
My problem is I want to be able to stop this inner while-loop, if I see that I have put the wrong parameters into the program. I don't want to wait until it is done with its measurements (some times the inner loop has to run 200 times or more per scan).

The SubVI which contains these two while-loops already contains a stop, button which does this, but I want to acces this stop button from the mainVI, as I stated earlier.
0 Kudos
Message 3 of 23
(4,692 Views)
Hi Chr.,

you can wire the stop button to a global and read this global in your main vi. But you need to read it in the main vi in a separate loop!
Can you attach main and subvi?
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 23
(4,690 Views)
If you just call  a sub-vi, your main vi is inactive until the sub vi completes.
That's why the stop button does not work.
Try to call your sub vi with an invoke node - run vi
0 Kudos
Message 5 of 23
(4,682 Views)

forgot:  wire wait until done to false

0 Kudos
Message 6 of 23
(4,680 Views)
Ok. I have look at that invoke nod, and read about in the internet, and I can kind of see the idea behind it, but I can not figure out how to use it. It is something that I have never used before.
0 Kudos
Message 7 of 23
(4,662 Views)
Hi Chr.,

when there is something you "never used before" then there is (most probably) also an example installed with LabView demonstrating this function/technique!
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 23
(4,658 Views)
simple as that....
0 Kudos
Message 9 of 23
(4,645 Views)
Thanks. I got that far my self. Smiley Happy
It is just how to wire the values that I need to send the subVI to make it run correct and the values I need to get out of the subVI (and the previous mentioned way of stopping the subVI). That I haven't figured out yet.
0 Kudos
Message 10 of 23
(4,620 Views)