LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Wait Function test doesn't seem to be working.

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?

0 Kudos
Message 1 of 8
(3,121 Views)
  • There is only a 10000ms wait in the code attached. The "100" is an indicator and will display the output of the wait function. It does not set any timing.
  • Learn about mechanical action.
  • No need for local variables. If code is duplicated in all cases it belongs outside, just ensure proper execution order.
  • Are you using "continuous run"? Don't!
  • The output of the wait function is a rather random U32 (You use the wrong representation for the indicator). No need to display it.
  • It is not a good idea to stall code for long periods. there are better ways to tell if a time has elapsed.

 

 

Message 2 of 8
(3,112 Views)

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.

 

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 3 of 8
(3,107 Views)

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.

0 Kudos
Message 4 of 8
(3,096 Views)

Edit:  Can't open your VI to see what you are doing. 

Example_VI.png

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 5 of 8
(3,058 Views)

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.

0 Kudos
Message 6 of 8
(3,055 Views)

@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.

  • What is "stuff"? Please be more specific
  • Checking an array is not a calculation. What is it trying to detect?
  • How big is the array?
  • What does it have to do with "indexing"?
  • What do you mean by "realtime"? This is an overloaded word with many meanings.
  • How often is constantly? What is "current" and "up to date"?
  • Are the calculations slow or is the UI not responsive enough? Big difference.
  • How are you benchmarking?
  • What does the program actually do?
0 Kudos
Message 7 of 8
(3,048 Views)

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.  

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 8 of 8
(3,047 Views)