From 11:00 PM CDT Friday, Nov 8 - 2:30 PM CDT Saturday, Nov 9, 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: 

System Timer value

Solved!
Go to solution

Hi all,

I have a frame inside a loop. I do an operation, then I want to wait 200ms from the previous operation. So I take the system time via Tick Count function,just after the operation self. The Tick Count is sent to a shift register. The previous value is subtracted to the new value and the result is subtracted to 200 ms. The loop is executed till the total time is greater than 100'000 ms. I notice that the loop is executed approximatively 1000 time. Why?

If I don't use the tick count, but I wait only 200 ms, then the loop is executed approximatively 500 times, that is reasonable.

Can you explain because Tick Count fails?

 

0 Kudos
Message 1 of 6
(2,573 Views)

I would want to see some code to be sure, but I'm guessing your loop executes in less time than a millisecond.  So the comparison between current time, and the shift register time may be equal.  Meaning not one entire millisecond has elapsed.  For such a small wait I would just use a wait 200ms function instead of a loop compairing time.  If your wait time is longer (like 5 seconds) I may use the loop so I can also check to see if a stop condition is met.  The OpenG wait has this built in with the ability to abort the wait if an occurance happens.

0 Kudos
Message 2 of 6
(2,568 Views)

Look at the probes: the time elapsed in one loop should be approximatively 100 ms, then the wait function should wait 100ms. But there will be done more than  500 loops, as you can see in the probe 3.

Why?

test_regolazione_D.png

0 Kudos
Message 3 of 6
(2,549 Views)

In this way the execution is perfect. Simpler, Easier...that's the right way, but I don't know because in the other way doesn't work.

test_regolazione_D.png

0 Kudos
Message 4 of 6
(2,545 Views)
Solution
Accepted by topic author FabioBone

Hi Fabio, in your first code the difference of two subsequent tick reads will be about the full cycle, i.e. wait + operation.

This introduces a feed-back: if one wait lasts about 100 ms, the next tick will be read about 200 ms later, so the wait time will be nearly null. Subsequent tick read will be 100 ms later, so 100 ms wait, and so on.

This behaviour is easy to catch if you display the whole wait time story with a proper array indicator.

Your second solution is far better. Just remark that the very first wait may last any time from 0 to 200 ms; you can avoid this by putting the wait function before the operation.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 5 of 6
(2,533 Views)

It's clear now. Thanks!

0 Kudos
Message 6 of 6
(2,512 Views)