LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to initialize shift register for the inner for loop without always returns to the initial value when everytime running

Hello everyone!

 

If I make the programming with a main while loop outside, then inside it there is a case structure with a for loop in the innest. If I want to create the shift register for for loop and would like to let the shift register only remember the current value after the calculation in the for loop.

 

So would anyone please give me some instructions on how to initialize the shift register so that everytime when case structure functions, the for loop will not be initialized to the very beginning initial value?

 

PS: the while loop is for the controlling of the whole vi with a stop button to stop it.

 

Thank you very much!

0 Kudos
Message 1 of 8
(3,130 Views)

Can you put the shift register on the outer while loop?

 

Rhys

0 Kudos
Message 2 of 8
(3,126 Views)

I would put an initialized shift register in the while loop in addition to the shift register of the FOR loop and wire them all together.

0 Kudos
Message 4 of 8
(3,091 Views)

Thx, sorry but I am not quite clear, in that case should I also add a shift register on the outer while loop? Or just on the inner for loop?

 

If former, what do you mean by initializing it inside the while loop?

 

Best regards!

0 Kudos
Message 5 of 8
(3,079 Views)

Thx, is that to say adding the corresponding shift register on the outer while loop and also put the initial value outside the while loop?

0 Kudos
Message 6 of 8
(3,078 Views)

Yes, an initialized shift register at the while loop boundary has the initialization on the outside of the while loop.

0 Kudos
Message 7 of 8
(3,068 Views)

A nice solution I use for this type of situation is to replace the Shift Register with a Feedback Node, and move the Initializer out to the outermost loop (or wherever you want it).  So it would look something like this:

 

FeedbackNode_BD.png

 

This saves on running wires through parts of the code that don't need to know about this value.

Message 8 of 8
(3,054 Views)