LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to build array for every 2 iterations in while loop

Hi,

In one cycle of operation, there are two steps. 

I have 2 case structures inside while loop. one case structure will be true for each step. 

I need to build array , so that two case structure values to be in one row. currently I built two arrays to get values. Any idea ?

0 Kudos
Message 1 of 10
(3,670 Views)

you need "build array" 🙂

array.png

0 Kudos
Message 2 of 10
(3,639 Views)

The problem statement had the different cases providing data on different iterations.

 

Here is the solution.  Store the previous iteration value in a shift register on the 0, 2, 4, .... iterations.  Combine the previous and the new value into the 2-D array on the 1, 3, 5, ... iterations

 

 Example_VI_BD

Message 3 of 10
(3,626 Views)

@prabhu91 wrote:

In one cycle of operation, there are two steps. 

I have 2 case structures inside while loop. one case structure will be true for each step. 

I need to build array , so that two case structure values to be in one row. 


You are leaving out a lot of information and most statements are ambiguous:

What is a cycle? An iteration of the loop?  In the subject you want to only build every two iterations. What should happen at the other iterations? So you have two case structures? Which one is true? What is a step?  Is it always the same case structure that is true? Should they alternate to  be true?   Is always one true and one false? (in that case you probably only need one case structure with the two alternatives in the two cases). What's in the other case of each?

 


@prabhu91 wrote:

currently I built two arrays to get values. Any idea ?


Why don't you shows us the VI you currently have, then tell us what output you want.

0 Kudos
Message 4 of 10
(3,614 Views)

Do I understand correctly that you are alternating between different cases each iteration? Just wire the outputs in each case to the same indexing output tunnel on your while loop. If you have two unique case structures, then wire them each to their own output tunnel, with the conditional terminal enabled.  Wire a boolean through a shift register and flip its state each iteration with the Not operator, and use that line on the conditional terminals - one before the Not function and one after.  Then, you interleave the two arrays after the while loop completes.

0 Kudos
Message 5 of 10
(3,607 Views)

Sorry - that snippet wasn't supposed to be included.  It illustrates the point though - just replace the single case structure shown with your two individual structures.

0 Kudos
Message 6 of 10
(3,606 Views)

Hi,

Please find the vi.

 

 

0 Kudos
Message 7 of 10
(3,586 Views)

Thanks for the reply.

Mr.revansfan.

 

But I could get the solution. if possible replace it in my vi. also replace random number with numeric constant. 

 

I changed the two step process to single step. so i managed to program that. 

And

Thanks everyone.

0 Kudos
Message 8 of 10
(3,583 Views)

Are you saying you could get the solution?  Or could not?

 

The VI you posted right before this looks nothing like what I posted based on the image.  And that image is a snippet, so you can actually save the .png file to your hard drive, then drag that file into your block diagram and you'll have the actual code.

 

0 Kudos
Message 9 of 10
(3,575 Views)

@prabhu91 wrote:

Hi,

Please find the vi. 


This VI make certain beginner mistakes, complicated the code. I guess you found a better final solution. Can you post it? Thanks!

 

0 Kudos
Message 10 of 10
(3,564 Views)