LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

output single element from array

Solved!
Go to solution

I am successfully filling an array and now trying to iterate through each element and output it from my VI.

Output array element.png

 

The problem I am having is the for loop iterates through without sending the value to my indicator. I have flipped through all tunnel options and placed the indicator inside the for loop. From my programming background, my logic seems sound. Enter loop>Process element>Output element>Repeat loop until condition is met. What is the missing piece that I can't seem to translate into Labview code?? Thanks.

0 Kudos
Message 1 of 7
(4,834 Views)

First off, you were right with your instincts to put the indicator inside the loop.  Do that.

 

For example, you could do something like this to wait 1/10 second between each number of an array:

 

loop.png

 

Something to keep in mind, the little [] symbol on the left entry tunnel is for Auto Indexing.  This will iterate through every element in the array.  However you also are hard wiring in to loop 20 iterations.  This will automatically default to the SMALLER of the choices.  (either 20 or array.size).

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If someone helped you out, please select their post as the solution and/or give them Kudos!
0 Kudos
Message 2 of 7
(4,827 Views)

amacapa wrote:

From my programming background, my logic seems sound. Enter loop>Process element>Output element>Repeat loop until condition is met. What is the missing piece that I can't seem to translate into Labview code?? Thanks.


Except the output of the FOR loop is not available until all of the iterations of the loop have completed.  By putting the indicator inside of the loop, it will then be updated with each iteration.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 3 of 7
(4,800 Views)

Thank you for your reply Mr. Happy! I fixed my code with your suggestions.

Output array element.png

The probe 1 shows that it is going through all the elements now, but the output of the VI is stationary until the loop is completed. The only output is the final element. Am I still missing something?

0 Kudos
Message 4 of 7
(4,774 Views)
Solution
Accepted by topic author amacapa

HI amacapa,

 

you still miss the concept of DATAFLOW...

 

When FilteredOutput is an output of your VI you will always output just a scalar value - after the whole VI has been executed!

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 7
(4,766 Views)

Hmm, I see. Well back to the drawing board. Thank you for all of your help!

0 Kudos
Message 6 of 7
(4,760 Views)

One way to monitor each element being worked on is to simply make this FOR loop a wrapper for everything you are doing with the array elements (adding subVIs inside it). Then, compile all your results into your solution and take that out of the loop (unless just seeing all the individual data are what you want and you just stop, or you could write the whole kit and kaboodle to a file as text, graphs,pictures, whatever, to be deciphered later).

 

Cameron

 

To err is human, but to really foul it up requires a computer.
The optimist believes we are in the best of all possible worlds - the pessimist fears this is true.
Profanity is the one language all programmers know best.
An expert is someone who has made all the possible mistakes.

To learn something about LabVIEW at no extra cost, work the online LabVIEW tutorial(s):

LabVIEW Unit 1 - Getting Started</ a>
Learn to Use LabVIEW with MyDAQ</ a>
0 Kudos
Message 7 of 7
(4,750 Views)