03-16-2011 09:25 AM
I wrote a simple program with a while loop that contains a shift register that save the previous iteration value. When I stop the program and restart the program again, I thougth the shift register's value will get reset to 0 (for a I32 data type)? Apparenetly, the shift register retains the value from the previous run before I stop the program. Why is that? Why won't the shift register reset?
Solved! Go to Solution.
03-16-2011 09:36 AM - edited 03-16-2011 09:36 AM
Because that's by design. It's also documented in the LabVIEW Help. Did you look in there?
An Uninitialized shift register is actually quite useful in creating a LabVIEW 2-style global variable, AKA functional global, AKA Action Engines.
03-16-2011 09:57 AM
If you would like to reset the SR without moving a wire or other trivial change, just force a recompile by pressing ctrl while hitting the run button.
03-16-2011 10:36 AM
Just wire a constant with a value 0 to the SR before entering the while loop. Problem solved 😉
03-16-2011 11:35 AM - edited 03-16-2011 11:39 AM
03-16-2011 11:48 AM
Darin,
That's exactly what I am looking for. Can you point me the reference that talks about ctrl+run and recompiling?
03-16-2011 12:18 PM
This and many other fine keyboard shortcuts is available here:
http://www.ni.com/pdf/manuals/373353d.pdf
03-16-2011 12:20 PM
@jyang72211 wrote:
Darin,
That's exactly what I am looking for. Can you point me the reference that talks about ctrl+run and recompiling?
Of course, that won't solve the issue when you're running the VI normally. Unless you explicitly want the shift register to be uninitialized?
03-16-2011 12:36 PM - edited 03-16-2011 12:39 PM
That mask will not prevent us from finding the person who offered that extra length of rope.
Ben
Jyang,
Please see the link in my signature about "Race Conditions" to learn more about SR and how to exploit them.
03-16-2011 01:11 PM
Ben wrote:That mask will not prevent us from finding the person who offered that extra length of rope.
Telling someone there IS a bucket of Truth is not the same a pushing (or nudging) them in.