Jump to content

How to generate an array by a While loop?


Recommended Posts

I want to generate an array by a While loop with an indexing tunnel. But my VI doesn't work. The wire inside the loop can transfer data but the one outside the loop doesn't and I can't get an array.

Could anyone explain the reason of it? How does a loop(While and For) work with an array in LabVIEW? And how to change my VI to fix this problem?

Thanks as advanced.

Link to comment

QUOTE (zorro @ Jul 31 2008, 05:22 PM)

I want to generate an array by a While loop with an indexing tunnel. But my VI doesn't work. The wire inside the loop can transfer data but the one outside the loop doesn't and I can't get an array.

Could anyone explain the reason of it? How does a loop(While and For) work with an array in LabVIEW? And how to change my VI to fix this problem?

Thanks as advanced.

The problem is your loop never end, the data is not transfered outside the loop, you will need to stop the loop to get the data in your indicator

Dany

Link to comment

You did generate one, but the data is not passed to the indicator until you stop the loop. This is called data flow you need to learn how this part of LabVIEW works. If you turn on the light bulb on your block diagram you can watch the VI run and you see what i am talking about.

If you right-click on the tunnel and choose Replace with Shift Register. Then place the other "end" of the shift register (SR) on the left side of the while loop. When the loop runs the data goes into the right side node of the SR, then the loop starts again and the left side node of the SR sends data out, and so on. You place a two terminal Build Array functions on the diagram, wire the random number to the lower terminal and wire the left side SR to the upper node; the right side, output node is wired to the rigth side node of the SR. Create an indicator on the output of the left side SR node and you can watch the array grow in that array (Which is inside the loop, it runs every time the loop iterates).

Link to comment

QUOTE (mross @ Jul 31 2008, 04:54 PM)

You did generate one, but the data is not passed to the indicator until you stop the loop. This is called data flow you need to learn how this part of LabVIEW works. If you turn on the light bulb on your block diagram you can watch the VI run and you see what i am talking about.

If you right-click on the tunnel and choose Replace with Shift Register. Then place the other "end" of the shift register (SR) on the left side of the while loop. When the loop runs the data goes into the right side node of the SR, then the loop starts again and the left side node of the SR sends data out, and so on. You place a two terminal Build Array functions on the diagram, wire the random number to the lower terminal and wire the left side SR to the upper node; the right side, output node is wired to the rigth side node of the SR. Create an indicator on the output of the left side SR node and you can watch the array grow in that array (Which is inside the loop, it runs every time the loop iterates).

Thank you very much. It is really helpful.

Another question is what happens if Iwire the right side SR of the upper node of Build Array function?

Link to comment

QUOTE (zorro @ Aug 2 2008, 11:01 AM)

Thank you very much. It is really helpful.

Another question is what happens if Iwire the right side SR of the upper node of Build Array function?

The only difference is that you see the array at different times. I suggest you wire a create a second array so you can observe it as the VI runs. I temporarily create many arrays so I can see how the changes as the VI is progressing. The arrays are free of cost and you can delete them after everything is working the way you want. You can also right click on any wire and create a probe that shows you the contents as the VI runs.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.