07-29-2014 08:34 AM
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
07-29-2014 08:53 AM
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".
07-29-2014 08:56 AM
Why not? OK Lets start here:
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:
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!
07-29-2014 08:58 AM
@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
07-29-2014 09:03 AM
@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.
07-29-2014 09:18 AM
Hi crossrulz & Jeff·Þ·Bohrer
Thanks for the reply. I have changed the vi property to "Shared Clone Reentrant Execution" but even then it is not working. Time delay is working only for the first step.... 😞
07-29-2014 09:22 AM
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.
07-29-2014 09:28 AM - edited 07-29-2014 09:34 AM
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.......
07-29-2014 09:48 AM - edited 07-29-2014 09:55 AM
@pratheek wrote:
Hi @crossrulz & @JÞB
Thanks for the reply. I have changed the vi property to "Shared Clone Reentrant Execution" but even then it is not working. Time delay is working only for the first step.... 😞
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 point
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)