LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Start two sub VIs with delay to each other

Hi,

I have the following problem: Two tasks have to be performed and I would like to control the relative time between the start of the two tasks. So, I have two sub VIs which I would like to start with a certain delay to each other. This delay should be controllable from the front panel and also allow "negative" values corresponding to a situation where the order of the two tasks is reversed. What would be your approach to achieve this?

 

Thanks,

Peter

0 Kudos
Message 1 of 6
(2,702 Views)

One approach would be two case structures, where the exectuion of one is delayed using Stall Data Flow.vim. The case structures would call different tasks based on whether the relative time is negative or not.

task_delay.png

 

If you don't have a newer version of LabVIEW with malleable VIs, substitute Stall Data Flow with a flat sequence structure containing a Wait (ms).




Certified LabVIEW Architect
Unless otherwise stated, all code snippets and examples provided
by me are "as is", and are free to use and modify without attribution.
0 Kudos
Message 2 of 6
(2,678 Views)

If you have any shared input to the two VIs, like an error wire, I'd also suggest Stall Data Flow (2017 onwards) or Flat Sequence Structure and Wait (ms) (earlier versions).

 

I'd put this on both branches of the input and wire a zero constant and your control to a Swap node, then enable it if the control value is less than zero.

 

Ensure after the swap node you take the absolute values before passing to the wait structure.


GCentral
Message 3 of 6
(2,644 Views)

@cbutcher wrote:

Ensure after the swap node you take the absolute values before passing to the wait structure.


I knew I'd missed something!




Certified LabVIEW Architect
Unless otherwise stated, all code snippets and examples provided
by me are "as is", and are free to use and modify without attribution.
0 Kudos
Message 4 of 6
(2,640 Views)

Here's a snippet showing my suggestion.

On closer reflection, only one of the values needs to be checked for an Absolute Value, since the other is positive or zero by construction.

exampleDelay.png


GCentral
0 Kudos
Message 5 of 6
(2,633 Views)

You guys are making it too complicated.  You just need a Negate.


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
Message 6 of 6
(2,594 Views)