LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Update an indicator from within while loop with event driven programs

Solved!
Go to solution

I am trying to update a graph shared by multiple events from within an Event Structure. I would like a value change on a button (NOPE, or OK buttons in the attached example images) to cause the event structure to cause a switch between different outputs to the graph. In the attached example, clicking the OK button will send random arrays to the graph, while clicking the NOPE button will send constant arrays to the graph. 

 

Because the process within the event structure is ongoing, I use a while loop within each of the different events in the Event Structure. So there is an Event structure and each of the events have while loops in them that should update the graph outside of the Event structure (see the attached images). 

 

This doesn't work to update the graph, the graph remains static instead why is this? How can I set it up to work as I described above?

 

I think a related question is: how can I use the same stop button within both of the inner while loops. In the example images I had to make two different ones, one for each of the different events. 

 

Thanks!

Download All
0 Kudos
Message 1 of 19
(6,016 Views)

Please attach your code.

 

Are the event set to lock the front panel?

What are the mechanical action settings of your buttons?

You should use the outer loop to update the graph, it won't update as long as only the inner loops are spinning.

0 Kudos
Message 2 of 19
(6,000 Views)

@altenbach wrote:

Please attach your code. 


I attached it now.
I don't think the events are set to lock the front panel, and the action settings of the buttons does not change the behavior. I think that makes sense as the event should be triggered as long as anything changes, right?

@altenbach wrote:

 

 

You should use the outer loop to update the graph, it won't update as long as only the inner loops are spinning.


I don't see how I could use the outer loop to update when I want the behavior to change with different events. How do you mean?

 

0 Kudos
Message 3 of 19
(5,987 Views)
Sorry, posting by phone...

Your inner loops are completely pointless because they are just spinning as fast as the computer allows, while only remembering the last data. Why are they even there?
0 Kudos
Message 4 of 19
(5,981 Views)

@altenbach wrote:
Sorry, posting by phone...

Your inner loops are completely pointless because they are just spinning as fast as the computer allows, while only remembering the last data. Why are they even there?

I didn't realize that the code inside case structure would continuously evaluate without a while loop of its own. 

0 Kudos
Message 5 of 19
(5,979 Views)
I don't understand what you are saying.
0 Kudos
Message 6 of 19
(5,977 Views)

I have the event structure with code inside of it, how is it that the code inside of the event structure is being evaluated over and over again without a while loop?

0 Kudos
Message 7 of 19
(5,972 Views)

Because you have a timeout event for 10ms. So every 10ms that code executes.

0 Kudos
Message 8 of 19
(5,967 Views)

I see.

 

Now I can hopefully better phrase the question: What if I need to continuously generate data or evaluate some code inside of that case structure and still have it graph something outside of the case structure, as I tried to do with having the inner while loop in the vi that I attached previously. For example, generate a random number and plot it in one case, but plot a constant in another case. How do I point both of the data outputs from the inner while loops to the same graph outside of them? Is that just not possible?

 

I am using a vendor-supplied set of functions that makes it difficult to exactly recast the situation I'm trying to solve with the basic functions (at least at my level of knowledge), but what I described is essentially the problem: I need to reuse a graph with different data inputs that are generated from inner while loops.

0 Kudos
Message 9 of 19
(5,960 Views)

If you are generating data continuously, you don't even need an event structure.

0 Kudos
Message 10 of 19
(5,956 Views)