LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problems with the two Elapsed Time vi

Dear All,

I would like the realize the following purpoes, as shown in the attached figures:

In Loop 0:

Elapsed Time1 increase from 0 to 5s; Elapsed Time2 increase from 0 to 5s.

And then in Loop 1:

Elapsed Time1 increase from 0 to 5s; Elapsed Time2 increase from 0 to 5s.

In Loop 2:

Elapsed Time1 increase from 0 to 5s; Elapsed Time2 increase from 0 to 5s.

…..

InLoop 7:

Elapsed Time1 increase from 0 to 5s; Elapsed Time2 increase from 0 to 5s.

 

However, the real situation is:

In Loop 1:

Elapsed Time1 increase from 5 to 7s.

This means that the Auto Reset was not properly used in Elapsed Time1.

I have spent several hours to solve this problem, but failed.

Anyone can help me? Thank you very much.

Download All
0 Kudos
Message 1 of 17
(3,462 Views)

You misunderstood the way AutoReset works. Read the help carefully: Resets the start time to the value in Present (s) when the Express VI reaches the Time Target (s).

The value in Present (s) is the time when the delay is elapsed. But then - in Loop 0 - you wait 2+5 s, so in Loop1 the very first invocation of ElapsedTime1 gives a 7 s delay, so the inner loop stops immediately. And so on. Basically, ElapsedTimer1 is never given a chance to restart from 0.

The bottom line is: don't use AutoRestart unless you are calling ElapsedTimer continuously.

Use the Reset input terminal instead, but only reset at the first invocation in each sub-loop - that is, when the Iteration terminal outputs 0.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
Message 2 of 17
(3,440 Views)

What are you trying to accomplish? If you tell us what your real world goal is maybe we can direct your efforts in a more productive way.

Tim
GHSP
Message 3 of 17
(3,385 Views)

Hi Paolo,

Thank you  for your help. Your comments are very helpful.

I  need  ElapsedTimer restart from 0 in each invocation, and I also need  to call ElapsedTimer continuously. If Elapsed Time Vi can not realize these two goals simutanously, is there any other Vi can realize them? Thanks a lot!

 

0 Kudos
Message 4 of 17
(3,350 Views)

Hi Tim,

Thank you for your help.

My real world goal is as follow.

 

I have two devices, a stepping motor and a power meter, to continuously monitor the power of light at two different positions repeatedly.  First, I move the stepping motor to  position A; measure the power continuously for 5s  and update the power every 100ms;   move the stepping motor to  position B;  measure the power continuously for 5s  and update it every 100ms; Then,  I repeat these operations many times.

 

Is there any better Vi than Elapsed Time Vi to realize this purpose?

 

Thanks a lot.

 

 

0 Kudos
Message 5 of 17
(3,343 Views)

Believe me, Elapsed Time is not a problem. It's code is rather simple and could be rewritten completely in a few minutes.

More important is: how much accuracy do you expect from the measurement timing? Keep in mind that software timing is not very precise, you may have a jitter of many milliseconds depending on the computer hardware and operating system you are using.

What hardware do you plan t use to measure the power? If it's a board with timing capabilities, you may simply program it to acquire 50 samples at 10 Hz et voilà! The 100 ms time step would be very precise in this case.

On the other hand, if you are not exceedingly worried about the timing, you may simply put up a loop where you read the power and wait 100 ms (with a simple Wait (ms)) 50 times.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
Message 6 of 17
(3,302 Views)

Hi Paolo, Thank you for your good suggestion.

Jitter is not a problem for me, becuase I donot require a high accuracy.  The hardare I am using is a powermeter from Thorlabs (PM100D). Thorlabs has already  provided Vi to aquire data every 100 ms. So my goal is to integate the power meter and the stepping motor.  But I met the difficulty of how to reset the Elapsed Time to 0 after every 5 seconds, as posted above.

0 Kudos
Message 7 of 17
(3,291 Views)

@pincpanter  ha scritto:

Use the Reset input terminal instead, but only reset at the first invocation in each sub-loop - that is, when the Iteration terminal outputs 0.


Well, I already said you how to do this, although you apparently missed my suggestion.

However, my feeling is that you don't need to call Elapsed Time at all. Just read 50 samples at 10 Hz.

Post a more complete code to get further suggestions. Your original vi doesn't do much.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
Message 8 of 17
(3,279 Views)

Hi Paolo,

Thank you again for your kind help. I have tried, but I still donot know how to realize " reset at the first invocation in each sub-loop".  Would you please help by revising my orignal vi to realize this?  Or, would you please post an example for me about how to read 50 samples at 10 Hz?  I am sorry that I not familar with the sophisticated function of LabView.  Thanks a lot!

0 Kudos
Message 9 of 17
(3,249 Views)

Are you looking to log the sample for the 5 second read or are you averaging them?

Tim
GHSP
0 Kudos
Message 10 of 17
(3,245 Views)