03-14-2013 07:48 AM
Hi all,
I am new to Labview and I realized that quite often I am in condition to require a delay beween two functions or elements.. how can we insert a delay in such cases?
I know how to use delays in a loop. but don't know how to inser some time delay between two elements.
I have one more question, I know its a bad practice to post 2 questions in 1 thread.
How can I use a temporary variable to store data, So far I am storing it in an indicator by making it invisible in front panel and making local variable of that indicator, is it the right way to do it ?
Thanks in advance.
03-14-2013 08:30 AM
The easiest way to have a delay is to use a sequence structure with a 'wait (ms)' vi.
Yes, that is a way to do it. Just make sure there are no race conditions.
03-14-2013 08:39 AM
Generally, LV doesn't have variables in the same sense that most languages do. You can use indicators to perform the same function as variables, but as Adnan pointed out, you run the risk of having race condition and it creates data copies, which is a problem if you have a lot of data. In most cases, you should use wires to perform the function of variables, which is to store data and make it available to the different functions in your code. Instead of thinking about variables, you need to think about data (something like "I have the data coming out of this function. Where does it need to go?").
03-14-2013 09:44 AM
for delay can also use the function Time Delay, without sequence structure. But I still prefer wait(ms) 🙂
03-14-2013 11:37 PM
In time delay , there is no port for in and out , there is error in and error out , but not every function in labview has error our, how to inser time delay in those cases?
say the output of ADD operator should reach the input of MULTIPLY operator after 1 ms then in this case how can I proceed? as add and multiply operators dnt have error in or error out port?
Thanks in advance.
03-15-2013 12:00 AM
Hello,
Let's step back a bit. I believe it's possible (and much better) to re-design your program so that the delays are not necessary. Inserting a delay of 1ms is still a race condition: There might come a time when 1ms isn't enough anymore, and then it will be very hard to debug your program.
Can you share a sample of your code, to demonstrate why you currently need a delay? Are you using lots of local variables and/or global variables?
This is an important aspect of LabVIEW: LabVIEW uses dataflow programming. An operator (or any other VI) will not execute untill all of its inputs are ready. Unfortunately, this guarantee is lost if you use local/global variables