LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to insert delay without using loops, and how can I use variable to store data in labview

 

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.

 

0 Kudos
Message 1 of 6
(3,396 Views)

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.

Adnan Zafar
Certified LabVIEW Architect
Coleman Technologies
Message 2 of 6
(3,382 Views)

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?").


___________________
Try to take over the world!
Message 3 of 6
(3,377 Views)

for delay can also use the function Time Delay, without sequence structure. But I still prefer wait(ms)  🙂

0 Kudos
Message 4 of 6
(3,367 Views)

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.

 

0 Kudos
Message 5 of 6
(3,338 Views)

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

Certified LabVIEW Developer
0 Kudos
Message 6 of 6
(3,335 Views)