LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Executing a while loop only if input data is changed

Solved!
Go to solution

Hello! 

 

I have a code in LabVIEW that uses a matlab script to output a few graphs that are dependent on certain input controls in labVIEW. I wanted to modify the code so that as the program runs, the graphs change as the controls are changed. I started by putting the code in a while loop, but found that the graphs pop up indefinitely, so i will get hundreds of graphs until i stop the code. 

 

Essentially I was wondering if there was a way to only proceed to the next iteration of the while loop if the controls on the front panel are changed. That way, a new set of graphs will pop up each time the controls are changed, and I won't need to keep stopping and starting the program. 

 

I hope this makes sense but if there are any questions let me know! Thanks in advance!

0 Kudos
Message 1 of 5
(2,465 Views)
Solution
Accepted by topic author Katie_Lab4

If I understand correctly an event structure could help here. This will pause the while loop until a certain event is fired and registered. Look at the attached VI and see whether you can make something of this.

 

Feel free to ask further.

Download All
Message 2 of 5
(2,456 Views)

It typically helps if you attach your code, because there are millions of possibilities to do what you describe. Very ambiguous!

 

What else does the while loop do? Is there any defined timing? Is there a reason you need to use matlab? Seems like a gigantic detour to show a few graphs. Why can't you use LabVIEW graphs without popping anything at all?

0 Kudos
Message 3 of 5
(2,446 Views)

Take a look at this answer Yddet gave me just today. 

https://forums.ni.com/t5/LabVIEW/Change-input-controls-during-execution-of-a-loop/td-p/4050180

 

Looks very promising except I haven't figured out how to use it with my instrument handles and errors between states but I'm sure there is a way.

Message 4 of 5
(2,422 Views)

Thank you so much! This does exactly what I want! 

0 Kudos
Message 5 of 5
(2,351 Views)