LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to get the elapsed time when a certain condition is true?

Hi everyone,
 
I want to add in my VI "to calculate the Elapsed Time when a certain condition is True". Whenever i rotate the "Theta Knob" either to the left or right then counting should start. If Theta stops then counting should reset to zero.
 
If i run the VI Highlight execution I can see the counting of elapsed time but if i run in normal mode, the elapsed time remains zero.
Is it okay to use a For Loop inside the case structure than a While Loop?
Can anybody help me or give me hint to improve my VI. Thank you very much.
 
0 Kudos
Message 1 of 7
(3,760 Views)
There's nothing wrong in general in having a for loop inside a while loop, but here the for loop serves no purpose whatsoever that I can tell. Look at what you're doing. You're checking to see if theta is greater or less than the previous time you checked it (actually the time before the previous time to be precise - check your shift registers).

If that's true, then you convert the true to a 1 and run the for loop 1 times. Why have a for loop if you know it'll always run once here? And then you take a timestamp then immediately take another timestamp and subtract them. You're not getting the elapsed time from when the changing values started.

Take a step back and try to plan out what you want to accomplish. You want to take a timestamp when the values start changing, and then take another timestamp as soon as they stop changing. I'll give you a hint: you might make use of another shift register which tracks whether you are still changing values in theta.
Jarrod S.
National Instruments
0 Kudos
Message 2 of 7
(3,755 Views)
Thank you for the reply and hint. But unfortunately i can't follow yet using Tick Count.
I modified the VI and instead used an Elapsed Time Function. This works too.
 
 
Message 3 of 7
(3,747 Views)
Well done. Looks good! The Elapsed Time function is actually just using Tick Count under the hood to do what you would have had to do manually to complete the app with Tick Count. If you want to see what Elapsed Time or any other Express VI does, just right click on it and select Open Front Panel. This converts it into a regular subVI, meaning you can't configure it like an Express VI anymore. You can't undo this, but you don't have to save your changes if you just want to take a look.
Jarrod S.
National Instruments
0 Kudos
Message 4 of 7
(3,735 Views)
Just one little pointer:
 

Message Edited by Marc A on 01-26-2007 11:09 AM

0 Kudos
Message 5 of 7
(3,727 Views)
Thank you for making it more simple...arigatouSmiley Happy
0 Kudos
Message 6 of 7
(3,705 Views)
Hi Jarrod,
 
Thank you for the lots of info. The forum has always been very helpful.Smiley Happy
0 Kudos
Message 7 of 7
(3,704 Views)