10-17-2017 03:50 PM
10-17-2017 03:57 PM - edited 10-17-2017 04:04 PM
@Canucks.canucks wrote:
This is my VI. I want my while loop stops after a certain amount of time. I created a shift register to see how many times the loop was running. the problem is if i enter for example 1 second, it shows a value . Then if i stop my program and run it again with 1 second this shift register value is different. even when i close my program, reopen ,run and enter 1 second the shift register is different. what am i doing wrong?
Your Shift register is not initialized. Therefore the value will be retained on the shift register as long as the vi is in memory (or until it recompiles) Moreover, the count will increment multiple times for each press of Run
Lets look at it,
When Run is latched the value is read once as True and the inner while loop starts and will iterate until the "Time Has Elapsed" Boolean is true. Maybe a 1.21jiggatimes! it depends on how fast the CPU is. If you want a count of how many delays increment the value only when the Loop exit condition exists (hint: use select)
As for the value of How Long, The Terminal is read as soon as you run the vi and that value is placed on the wire. The the value on the front panel can't change the value on the wire until the outer loop iterates! Do look through some of the basic tutorials Altenbach mentioned.
10-17-2017 04:06 PM
equal zero like this?
i did initialize my shift register
10-17-2017 04:58 PM - edited 10-17-2017 05:01 PM
There is no "equal zero". Did you attach the correct VI?
If you would give your VIs reasonable names (not "Untitled....vi") it might be much easier to keep track of them. Note that every single VI you have attached in this thread has the same name, but they are not all the same!
10-17-2017 05:04 PM
See if this gives you some ideas ....