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.
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.
01-23-2013 11:26 AM
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?
Solved! Go to Solution.
01-23-2013 11:41 AM - edited 01-23-2013 11:41 AM
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.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
01-24-2013 01:59 AM
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?
01-24-2013 02:24 AM
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.
01-24-2013 03:09 AM
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.
01-25-2013 02:06 AM
It's clear now. Thanks!