LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Seeing only last step of for loops, instead of every step (matrix indicator)

Solved!
Go to solution

Hello guys!

 

I have a matrix indicator OUTSIDE of an event structure, like so:

 

outside.jpg

My problem is, that it shows the result of the for loops only, so the result of the last step. 

If I bring the indicator inside, I can see every step, like so:

 

inside.jpg

But the matrix indicator must be outside, because other events are using it.

 

My question is:

 

- how can I transfer each step outside so every step will be visible instead of only the last one?

(or alternatively)

- is it possible to have two copies of the same indicator that are pointing to the same frontpanel element?

0 Kudos
Message 1 of 9
(2,613 Views)

You can use an action engine and have it in many different places. You would write to it in the loop and read it where ever you needed the data.

 

You can also use a local variable but you need to be careful with the use of local variables.

Tim
GHSP
Message 2 of 9
(2,611 Views)
Solution
Accepted by topic author THunter

You don't need any of the inner loops or local variables. Keep the matrix data in a shift registers. Then just keep track of the indices in one shift register (one counting through the total number of elements, using Q&R to get the row/column at each iteration) of the outer loop and increment the values and modify the array in the timeout case set for a 100ms timeout. Also keep the current timeout value in a shift register and Once all values have been shown, reset the timeout back to -1 (infinite). Decide what to do if an event is triggered while it is still processing a current event (e.g. ignore and finish the new scenario, do the new thing instead, etc.).

This also has many advantages because it does not trap the code inside lengthy events during which nothing else can be processed by the event structure.

0 Kudos
Message 3 of 9
(2,602 Views)

Here's what I had in mind.

 

 

Message 4 of 9
(2,596 Views)

Just some pointers nobody asked for...

 

I'd hope the update of the matrix in the loop is only required for debugging? It would be a bit weird, and not recommended to put a wait in the inner loop of a for loop, except for debugging. If that's the case, you might as well try to use a probe instead of the indicator. You can combine it with a breakpoint, and remove the wait.

 

If it's a mockup\simulation of a process that takes a long time, you might outsource the calculation to an async process (producer\consumer, dynamic VI, etc.). It's considered good practice to do time consuming things outside the event structure, so it stays responsive. It's perfectly ok if the GUI can be locked during processing though...

 

Modifying your code to facilitate debugging has as downside that it's easy to forget to remove\put back the code when done debugging.

 

All's acceptable during experimental phase.

0 Kudos
Message 5 of 9
(2,570 Views)

Thank you, that is what I needed!

0 Kudos
Message 6 of 9
(2,540 Views)

But my original idea was, that this "scan" function stays in that "scan" event. Now everything is in the timeout event, I don't really like this. I would like that timeout event to stay clean as possible, and scan event handle this. How should I modify it?

0 Kudos
Message 7 of 9
(2,534 Views)

@THunter wrote:

But my original idea was, that this "scan" function stays in that "scan" event. Now everything is in the timeout event, I don't really like this. I would like that timeout event to stay clean as possible, and scan event handle this. How should I modify it?


No, event structures are for immediately dealing with something rapidly and going back to listening to new events. They are primarily for dealing with user interactions and should not be used for massive, lengthy processing. Trapping the code inside event frames for extended times is very bad architecture. If you don't want to use the timeout event, you need to create a parallel consumer loop, for example. While the long event frame is executing, the front panel is either locked (by default) or continues to accept user input. Since the code cannot process any event during that time because of dataflow, any user interaction will queue up events without user feedback and these will execute once the event structure is ready again.

0 Kudos
Message 8 of 9
(2,522 Views)

Allright, thanks for the explanation!

0 Kudos
Message 9 of 9
(2,508 Views)