LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Save state from one while loop to another

How can I latch a boolean state within a while loop, an error contition, retain this state for another while loop, and clear it within yet another loop?  The state has to be latched as it is a detected condition only available for a short period of time.
0 Kudos
Message 1 of 4
(2,720 Views)
My suggestion would be to right click on the border of the loop and add a shift register. Anything that goes out the right hand terminal of the shift register comes back in the left terminal in the next iteration. You can pass things along quite nicely this way.

     Rob
0 Kudos
Message 2 of 4
(2,714 Views)

Rob

This is all nice, I assume this is a push and pop with a stack.  Do I need a shift-register on the left side to match the right one?  The condition is created within a loop thus there is no comparable state entering the loop.  As important, how do I latch the error detection?

 

Thanks for you help

Ken aka: Kem

 

0 Kudos
Message 3 of 4
(2,693 Views)
Shift registers are great, but I saw that you mentioned you needed access to this in multiple loops.  A shift register will work wekk for one loop, but not the others.  Use a queue or a functional global (search the forums for functional global or lv2 syle global) to transfer the value around.

A shift register automatically puts a left hand terminal on your loop.  If you want more than one previous iteration, you can right click on your left hand terminal and select "Add element".

As far as the latching goes, here's something I normally do (below).  Just set on a true case, do nothing on a false.  As long as you never write to this in more than one spot (unless you're really careful - race conditions), and just read from it elsewhere, it should serve your needs.

Hope this helps.



Message Edited by Day on 09-22-2006 09:59 AM

0 Kudos
Message 4 of 4
(2,690 Views)