zorro Posted August 1, 2008 Report Share Posted August 1, 2008 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. Quote Link to comment
LAVA 1.0 Content Posted August 1, 2008 Report Share Posted August 1, 2008 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 Quote Link to comment
mross Posted August 1, 2008 Report Share Posted August 1, 2008 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). Quote Link to comment
zorro Posted August 3, 2008 Author Report Share Posted August 3, 2008 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? Quote Link to comment
mross Posted August 4, 2008 Report Share Posted August 4, 2008 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. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.