LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Passing Array through while loop

Hello! I want to pass an array from a while loop to another loop. I realized after the array passes through the while loop, it won't be reading anything after the loop. How do I pass the value through loop to loop?                                                    

0 Kudos
Message 1 of 11
(4,979 Views)

Why don't you try telling us what you are trying to do instead of how you are trying to accomplish it?  You seem to be very new to LabVIEW; odds are, there's probably a better way to do it.  🙂

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 2 of 11
(4,951 Views)

Why wouldn't it be reading anything after the loop?  The array doesn't just vanish.

 

But, I'd agree with the other post.  Tell us what you're trying to do.  It sounds a bit strange to pass a single array between two loops without making any changes to it.

0 Kudos
Message 3 of 11
(4,932 Views)

It is something like this! I want to use output 2 to pass the array through the while loop to another loop.

0 Kudos
Message 4 of 11
(4,923 Views)

You didn't really answer the question.  What is it you're actually trying to do?

 

In the code you show us, you're duplicating work.  You're using the build array with the shift register to build up an array as you go.  You probably should have initialized the shift register to an empty array.  As it is, you'll build up the array and with each time you run the VI, you'll build up on the array from the last iteration of the VI. That isn't likely your intended behavior.  It's more likely the "auto-indexed tunnel" you already have is what you want.  You can delete the shift register entirely and get the auto-indexed tunnel to build the array for you.  Just wire out of it and you'll have the array.

 

But again, that doesn't tell us what it is you're trying to do that makes you think this is a wise architecture choice.

0 Kudos
Message 5 of 11
(4,902 Views)

It is all in the dataflow.

 

No data can leave the first loop until the loop has stopped, only then data will be available on the output array and the second loop can start.

 

You should start with a few basic LabVIEW tutorials to eliminate some of your misconceptions.

 

Tell us what you want the VI to do. Most likely there is an easy solution.

Do you want both loops to run in sequence or in parallel?

What is the purpose of the first and second loop?

0 Kudos
Message 6 of 11
(4,887 Views)

Thanks for the replies!

I want the values in the first loop to go to the second loop. The second loop will have a delay because I want the reading to display according to the time. The first loop will have a calculation and I want the array of the calculated values to go to the second loop to display accordingly to the time delay.

What can I do? 

0 Kudos
Message 7 of 11
(4,873 Views)

You need to be more specific. What does "go to the second loop" mean? According to what "time"? Typically the time is determined by the producer loop, right. Have a look at the design patterns that ship with LabVIEW. One of them might do what you want. Maybe two parallel loops and a queue would be useful.

 

So far you still have not explained in understandable terms what you want. How often is data produced in loop one? What should the second loop doo if no new data is available but the time is up? What if you produce data twice as fast as you want to display it in the second loop? Why can't you acquire, process and display the data in a single loop?

 

As mentioned, currently you have a wired data dependecy that prevents the second loop from starting until the first loop has stopped. They cannot run in parallel.

0 Kudos
Message 8 of 11
(4,819 Views)

Ok, but I want the values being displayed with two different delay. If I put the second loop into the first loop to make it just one loop, the program will just run based on one delay.  Basically let's say I have an x array of readings streaming in, I want the readings to display with only delay 0.05. I will use the array to do some calculation and I want the result of the calculated values to display let's say 1minute to 1 value.

If I only put one loop, how can I have two delays?

0 Kudos
Message 9 of 11
(4,766 Views)

Hi lamela,

 

I want the readings to display with only delay 0.05. I will use the array to do some calculation and I want the result of the calculated values to display let's say 1minute to 1 value. If I only put one loop, how can I have two delays?

Decimate your readings! (Or get the mean of the last minute…)

Right now you sample with 20Hz ("delay 0.05") and you need 1/60Hz ("1minute to 1value"): You need to decimate by a factor of 20*60=1200. Or you need to average 1200 samples…

 

Have you taken the beginner courses for LabVIEW? In all your threads you ask very basic stuff, which is explained in those courses…

Best regards,
GerdW


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