02-24-2017 11:52 AM
So I'm trying to learn my way around the Wait function, how it operates and such for later use in another project. I've created this small example to work with. But I don't think it's working right. The way I understand the Wait Function works is that it adds whatever milliseconds that are to the left of it onto the milliseconds that are to the right of it. So...if the program iterates and you feed it ten milliseconds on the left then it won't run again until ten milliseconds are counted (added) to the milliseconds on the right.
I have 10,000 milliseconds on the left of the Function (which I think equals 10 secs) and on the right is 100 milliseconds. So it should be 10 seconds till it runs again and the number on the right should equal 10,100. But it just stays 100. What am I doing wrong here? Am I understanding the function correctly?
02-24-2017 12:00 PM - edited 02-24-2017 12:04 PM
02-24-2017 12:04 PM - edited 02-24-2017 12:04 PM
I don't understand your question. The wait mS function waits the number of mS you put on the input.
I have to admit I have never even looked at the output of that function as it does not seem usable for anything to me.
What are you trying to accomplish? There is probably another or better way.
02-24-2017 12:19 PM
RTSLVU wrote:I have to admit I have never even looked at the output of that function as it does not seem usable for anything to me.
I use it quite often. It outputs the same as "tick count" (synchronized to the end of the wait) and can be used to measure relative time (i.e. subtract an earlier tick) without the need of an extra "tick"er and flow control.
02-24-2017 01:34 PM - edited 02-24-2017 01:36 PM
Edit: Can't open your VI to see what you are doing.
02-24-2017 01:37 PM
I have a larger program which happens to have a lot of stuff running in the background. These background calculations are slowing up my program to the point of none use because they are constantly checking an array matrix I have them tied to. I do have to index the array in real-time so that everything is current and up to date. But constantly doing that seems to slow everything to a crawl. So I was thinking I could use the Wait Function so that it wouldn't check the array every millisecond but instead every second or even less. That's about it.
02-24-2017 01:46 PM
@ShogunOrta wrote:
I have a larger program which happens to have a lot of stuff running in the background. These background calculations are slowing up my program to the point of none use because they are constantly checking an array matrix I have them tied to. I do have to index the array in real-time so that everything is current and up to date. But constantly doing that seems to slow everything to a crawl. So I was thinking I could use the Wait Function so that it wouldn't check the array every millisecond but instead every second or even less. That's about it.
This has very little to do with your original question, but it seems that your program architecture is very poor. If you can show us some simplified version of your code, I am sure we can give more targeted advice.
02-24-2017 01:49 PM
Loops will hog the CPU if you don't have a Wait function inside. By adding a wait, even with a 0 ms value, it will cause the loop to release control of the CPU and give the rest of your code a chance to execute.
If you want to delay an action, don't use a Wait because that will halt the execution of your code. Instead, use an elapsed time function.