LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I control the working time of while loop structure in the event structure?

Solved!
Go to solution

Hi all

My task is: Structure While Loop generates signal for 4 seconds when you press button "start generate", after that data was saved. You press button "start generate" again, and the loop does one again.

My problem is: the first pressing, the loop does exactly 4s (3,999s), but the secondly, thirdly pressing.... Elapsed time is not 4 seconds, always smaller (even ~ 0.003s). The Loop only works properly after pressing button "Exit" and launch program again.

How can I control exactly time work of Structure While Loop without pressing button "Exit".

Thank you any help!

P/S: I used Tick Count (ms) simply for viewing time of working of the While Loop. 

NMCuong

Message Edited by nguyenmanhcuong on 09-03-2009 03:12 PM
Message Edited by nguyenmanhcuong on 09-03-2009 03:13 PM
0 Kudos
Message 1 of 8
(4,221 Views)
My gut reaction is I think the loop is always performing correctly.  It's your method of elapsed time detection that is flawed.  Let me think on this...
Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 2 of 8
(4,199 Views)

Hi billko

Did you run my program I attached? I'm sure the loop incorrectly works. For easy, you can increase the Time Taget to 5s, 6s, you will see the difference. Note, plz, that press the button "start generation" for some times while program running.

Thanks

Message Edited by nguyenmanhcuong on 09-03-2009 03:57 PM
0 Kudos
Message 3 of 8
(4,172 Views)

I'm sorry, Nguyen:

 

I have only LabVIEW 7.1 so I cannot run the VI.  😞

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 4 of 8
(4,118 Views)
You are using the Elapsed Time express VI. You will need to reset the timer every time the while loop runs. Also, I would recommend not using the while loop inside event structures. You should have a look at the Producer/Consumer Design Pattern (Events) template which can be found at File -> New..
Message Edited by Adnan Z on 09-03-2009 05:23 PM
Adnan Zafar
Certified LabVIEW Architect
Coleman Technologies
Message 5 of 8
(4,114 Views)

You need to reset the Elapsed timer after the first time.

 

Use a shift register to pass a True into the while loop but then feed in a false in the right side shift register.

 

Each time you press Start generation it will reset the timer 

 

The times then were almost =

4.01

Omar
Message 6 of 8
(4,104 Views)
Solution
Accepted by topic author nguyenmanhcuong

This shows a quick fix

 

 

Reset Timer.png

Omar
Message 7 of 8
(4,100 Views)

OK, thank everyone. The Loop well works now.

 

NguyenMC

0 Kudos
Message 8 of 8
(4,073 Views)