LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Time Delay works for only one step

HI

 

I have a vi (not programmed by me but I was told to make few changes in it) in which there is a time delay. When I apply time delay it works for the first step and the delay doesnot work for the later steps. I tried to make few changes but it is effecting the other parts of the vi. I'm fairly new to Labview. Could someone please tell me what modifications do I need to do for the time delay to work perfectly. Thank you in advance

 

Best Regards

Pratheek

 

 

0 Kudos
Message 1 of 9
(3,204 Views)

Your Time.vi is set to be non-reentrant.  What this means is that only one instance of it can run at a time.  So if you call it twice, the first one will start running but the second call must wait until the first is complete before it can start.  To change the reentrancy, go to the VI Properties and then to the Execution section.  You want to choose "Shared Clone Reentrant Execution".


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 9
(3,192 Views)

Why not?  OK Lets start here:

Capture.PNG

There is nothing wrong with being new to LabVIEW or programming in general but lets just ask ourselves "Is this code readable?"

 

Bare in mind that this is the ONLY code in case 0 of the outermost of many nested Stacked Sequence Structures.  So why have a vi with two outputs only using 1 and that one terminal on the LEFT of the con pane?

 

You may find the style guide a useful resource to improve your code http://www.ni.com/pdf/manuals/321393d.pdf#labview_style_guide

 

Your timer is crazy busted try this instead:

Delay.png

Thats a snippet.  just drag-n-drop to a BD (Depending on your browser you may need to drag it to your desktop first then drag it to a Block Diagram)

 

Now lets get into why you have some race conditions because you failed to enforce dataflow and abused the idea of what a local variable is for.  Yup, Localitis!


"Should be" isn't "Is" -Jay
0 Kudos
Message 3 of 9
(3,187 Views)

@crossrulz wrote:

Your Time.vi is set to be non-reentrant.  What this means is that only one instance of it can run at a time.  So if you call it twice, the first one will start running but the second call must wait until the first is complete before it can start.  To change the reentrancy, go to the VI Properties and then to the Execution section.  You want to choose "Shared Clone Reentrant Execution".


Pre Allocated

 

Get them their own data space so the local variable doesn't bang its head


"Should be" isn't "Is" -Jay
Message 4 of 9
(3,185 Views)

@JÞB wrote:

@crossrulz wrote:

Your Time.vi is set to be non-reentrant.  What this means is that only one instance of it can run at a time.  So if you call it twice, the first one will start running but the second call must wait until the first is complete before it can start.  To change the reentrancy, go to the VI Properties and then to the Execution section.  You want to choose "Shared Clone Reentrant Execution".


Pre Allocated

 

Get them their own data space so the local variable doesn't bang its head


I knew somebody was going to say something there.  They really don't have their own data space that they need to maintain.  So it doesn't really matter which reentrant type they choose.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 5 of 9
(3,178 Views)

Hi 

 

0 Kudos
Message 6 of 9
(3,166 Views)

Depends what you want the Delay to do. 

IF for example you want this:

wait

then read something

then wait

then write something.

 

it is a serialized action, and you want to connect the wait functions with a wire, like an error wire, 

here is one.

 

 

It would be really nice if you got the author of this VI to read a little bit about labview structures, It is not very readable. 

 

The reason I'm critizising this is that on your time delays, you don't know which starts first, the UI is polling on everything, and the execution order is random. 

 

All of the cases wired to boolean controls for example, can easily be moved into an event structure. 

 

For me local variables are a "no-no". I can accept one of them, but not any more than one.

This is because that one breaks the LabView dataflow, and it gets more difficult debugging and coding as the application grows.  

 

In the future, you migth want to look at labview state machines, producer/consumer structure and QDSM structures.

 

 

 

Good luck with fixing the problem. 

0 Kudos
Message 7 of 9
(3,160 Views)

HI mersdal

 

I'm using Labview 2010. Could you please save it to previous version and repost it......This vi was programmed almost 8 years ago. I'm not much familiar with labview and this vi si completely confusing me 😞 . The wait function works like....... it should wait for specified time and take the reading again and plot to the graph.......

0 Kudos
Message 8 of 9
(3,156 Views)

@pratheek wrote:

Hi 

 


I guess with a greedy loop like that it does not really matter how many cores you burn at the same time so shared or pre-allocted is a rather moot pointSmiley Surprised

Drop in the vi I gave you.  then start unwinding those local variables that are causing all your race conditions and actually use The error chain to enforce some data dependancy.

an older version is available here sourced in 2009 saved in 2010

 

WARNING: that vi has no coersion on the dbl seconds input...do not wire a value less than 1e-4.  (Yup I had that code about 10 years before some C++ coder thought they could use it for sub-millisecond timing)


"Should be" isn't "Is" -Jay
0 Kudos
Message 9 of 9
(3,146 Views)