From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Trouble with Elapsed Time function and shift register

Solved!
Go to solution

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?

 

0 Kudos
Message 1 of 15
(3,350 Views)
  • You might want to initialize the shift register.
  • You might want to reset your express VI whenever i=0 on the inner loop
  • You might want to slow down your loops. No need to spin millions of times per second.

Start with a few simple LabVIEW tutorials....

0 Kudos
Message 2 of 15
(3,343 Views)

thank you for your suggestion. I added a wait function for 50 m/s and initialized my shift register. however, the problem still exists. also, I have to every time stop the program and enter a new value for how long control. if i just enter a new value and hit run it only run the loop once

0 Kudos
Message 3 of 15
(3,321 Views)

You only mentioned two out of my three suggestions. What happened to the remaining? Also look at the express dialog.

 

50 m/s is a speed, not a wait. (Meters per second). What did you add and where?

 

Whenever you trap the code inside inner loops, a simple state machine architecture is probably a better choice.

0 Kudos
Message 4 of 15
(3,317 Views)

sorry my apologies. I created this VI and initialized. I don't know how to initialize the loop . is there a tutorial available for state machine with shift register?

0 Kudos
Message 5 of 15
(3,302 Views)

Sorry I meant 50 mili second. This is my vi

0 Kudos
Message 6 of 15
(3,298 Views)
  • You still have not connected the RESET input as instructed in my earlier reply.
  • Your VI still uses 100% of a CPU core when not doing anything (i.e. when not in the inner loop).
  • There is no need to maximize the front panel and diagram to the screen. Annoying!
  • You "elapsed time" indicator has the wrong representation. Also a "relative time" would be more appropriate.
  • If you initialize everything to default, you don't need to do the same to other controls/indicators. Seems redundant. (none of this would be needed if you would use a proper state machine. Also, a default time of zero does not seem reasonable.
  • Your VI cannot be stopped while it is in the inner loop.
0 Kudos
Message 7 of 15
(3,284 Views)

unfortunately I don't know how to reset the express VI whenever i=0 on the inner loop or stop my vi when inner loop is running.  can you please kindly tell me how to do it

0 Kudos
Message 8 of 15
(3,280 Views)

You have the iteration terminal of the inner loop, so wire an =0 to it and wire the output to the express VI. Right?

 

As I said, things would be much simpler without stacked loops. They key word is "state machine".

0 Kudos
Message 9 of 15
(3,271 Views)

you are talking about the i in while loop? you can't wire anything to it except an indicator [ not constant 0. 

0 Kudos
Message 10 of 15
(3,263 Views)