Building Single-Execution Uninitialized Shift Registers

Publish Date: Oct 11, 2011 | 2 Ratings | 4.00 out of 5 | Print | 1 Customer Review | Submit your review

An uninitialized shift register stores values from one call to a subVI the next. If a program contains multiple levels of VIs, higher-level VIs "call" subVIs to perform certain operations when the program executes or runs. A subVI may be called multiple times during a program execution.

Use uninitialized shift registers to store a run count or other similar information about the execution of a program. Shift registers store values between executions. Whether a VI runs normally or is aborted, shift register values remain.

Suppose you need to count how many times a given event occurs during an execution. You can use an uninitialized shift register in a subVI and increment the shift register value each time the loop is called, but when you run the VI a second time, the count will pick up where it left off in the first execution.

To solve this problem, you must include a special call to the for or while loop that resets the loop to zero in your higher level VIs.

This example demonstrates how to build a shift register that stores its value between calls to the subVI, but not between full executions of the VI hierarchy.



Related Links:
Application Design Pattern: State Machines

 

Back to Top

Customer Reviews
1 Review | Submit your review

 - Mar 1, 2007

This was a handy tip as I'd forgotten that unitialised shift registers keep their value between executions. Cheers NI.

Bookmark & Share


Downloads

Attachments:

OneExeSR.llb

Requirements


Ratings

Rate this document

Answered Your Question?
Yes No

Submit