LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Event structure in while loop issue

Solved!
Go to solution

Hello

I'm trying to use the same control in 3 different tabs, after surfing in the internet i find out that best thing is to use a Event Structure, so i did it and it worked.

 

FCance_0-1693457777236.png

 

 

But now i have 2 other issues, the .VI only run once every time a press a buttom. I need that event, from the buttom actioned, to run continously, this is my main problem. I know that the loop freezes and it waits for event structure for an action, i dont know how to fix this.

 

Also, another small issues that i find out is that when a press the buttoms too fast, i mean +/-, the vi starts to run slowly, i think it is something with the queue in the event case but i'm not sure.

 

Thank you

0 Kudos
Message 1 of 12
(1,256 Views)

You can use the timeout case of the event structure (instead of the 500ms wait outside the event structure).

But then the code still wouldn't make any sense.  What is it that you want to happen with each iteration?

0 Kudos
Message 2 of 12
(1,239 Views)

@FCance wrote:

I know that the loop freezes and it waits for event structure for an action, i dont know how to fix this.


Don't have them in the same loop ...

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 3 of 12
(1,220 Views)

Hi FCance,

 

your VI should look more like this:

(There also is an event for the stop button, in the timeout event your iteration counter is updated…)

 


@FCance wrote:

I'm trying to use the same control in 3 different tabs, after surfing in the internet i find out that best thing is to use a Event Structure, so i did it and it worked.


Which "control" do you want to use "in 3 different tabs"?

There is no tab container and there is no control used three times…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 12
(1,203 Views)

@FCance wrote:

Also, another small issues that i find out is that when a press the buttoms too fast, i mean +/-, the vi starts to run slowly, i think it is something with the queue in the event case but i'm not sure.

 


Faster than the 500 ms loop time? Why is there a loop timer at all? Like the others suggest, use the timeout of the structure with, let's say, 5 ms or 10 ms so it can react quickly to button presses. In the timeout case you could put some code and if that code shall only run, like, every 500 ms, then use a counter that counts the 5 ms timeouts to 100, then run the code and reset the counter.

 

Regarding your "once I press a button I want the code to start and run permanently", you could also do this with a boolean flag. Button ORed with flag -> first button press goes into case -> inside the case set flag to 1 -> next time case is executed automatically.  

0 Kudos
Message 5 of 12
(1,192 Views)

I tried that but for some reason the 2nd loop doesnt work, the data doesnt come out from the first loop.

 

FCance_1-1693484525978.png

 

0 Kudos
Message 6 of 12
(1,158 Views)

Hi Gerd, this what i mean with "same control in 3 differents tabs"

FCance_0-1693484978983.png

 

I tried your code it worked but it only cut data there is a point where i run out of data and the vi send error.

 

0 Kudos
Message 7 of 12
(1,154 Views)

The way LAbVIEW works, the second loop will run only when the input is available, and for that to happen the first loop has to stop. 

 

0 Kudos
Message 8 of 12
(1,148 Views)

Using tab control you need o add it to the event structure

the event will be triggered when tab control changes in addition to all the others.

LVNinja_0-1693487629768.png

 

LVNinja_1-1693487664119.png

 

 

0 Kudos
Message 9 of 12
(1,143 Views)

why do you need it to run continuously ? is this coming from data bein acquired ? In your file it will change only if one of the inputs (duration/start time) change. 

0 Kudos
Message 10 of 12
(1,137 Views)