LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

two parallel different subvi running at the same time

Highlighted

Hello everyone,

I would like to make two different subVIs running simultaneously exactly at the same time

I explain : since they're different they won't have obligatory the same inputs so necessarily one will run before the other but I need that even if the inputs of one of them arrive before, it waits until the other's come as well so as to start exactly at the same time.

My program consists of two subVIs, one of a stepper motor and the other of an ink-jet printer and its printhead will be placed on the movable portion of the stepper motor and as the motor moves, the ink-jet printer starts to print continuously.

Neither the printer nor the motor can start before the other, otherwise either the text won't be at its adequate place on the product or since it's an ink-jet one if it stops moving it will print everything on the same column which is not readable.

In other terms how can I make multithreading with labview?

Please I need your help as soon as possible.

Thank you in advance 🙂

0 Kudos
Message 1 of 18
(2,667 Views)
Highlighted

Put a Wait for Notification in each VI. Start both VIs. The "working" code in each is set to run after the notification is received. The main program generates the notification when everything is ready.

 

Lynn

0 Kudos
Message 2 of 18
(2,661 Views)
Highlighted

LabVIEW is parallel by default. You can syncronize with a flat sequence structure as shown below.

parallel task2.png

The "Move motor 1" VI above won't run until the Calc print head pos. "thread"  at the bottom left is finished.

0 Kudos
Message 3 of 18
(2,644 Views)
Highlighted

Depending on what runs before these subVIs, you might be able to share the last input you expect to reach the two VIs.  For example, you can have an error fed as an input that comes from the same point.  They both receive it at the same time and get started computing.

0 Kudos
Message 4 of 18
(2,634 Views)
Highlighted

Hi Yasmine,

Find the Rendezvous under the Synchronization pallete.  Use it to make your sub-VIs wait at a common location.

See example attached.

 

Hope it helps,

Cheers! 

 

P.S. The example runs two copies of one "reentrant" subVI.

Download All
0 Kudos
Message 5 of 18
(2,602 Views)
Highlighted

Thank you very much for all your responses 🙂

I will try these different alternatives and tell you if it woks with my VI's functionality.

 

Have a good day.

0 Kudos
Message 6 of 18
(2,596 Views)
Highlighted

To respond to the person that suggested a common error wire. Actually if I used the simplest thing which is the error cluster, nothing ensures me that this error will be the last input to arrive to the two subVIs. Isn't it?

0 Kudos
Message 7 of 18
(2,588 Views)
Highlighted

@Yasmine90 wrote:

To respond to the person that suggested a common error wire. Actually if I used the simplest thing which is the error cluster, nothing ensures me that this error will be the last input to arrive to the two subVIs. Isn't it?


but is it a problem? A subVI will only execute if ALL of the input nodes got values.

0 Kudos
Message 8 of 18
(2,570 Views)
Highlighted

Good morning,

Please tell me how can I use the notifier in my case?

Should I put the wait on notification in both subVIs and put obtain notfier and send notification in the main VI?

Could you please show me an example of a notifier shared between a main VI and subVIs? Is it the same procedure as producer consumer?

0 Kudos
Message 9 of 18
(2,560 Views)
Highlighted

Yes I know it's not that the problem. Like you said a subVI waits until all its inputs are available to execute so it depends only on its own inputs not other subVIs' inputs. I want to make two different subVIs start executing at the same time even if one receives all its inputs before the other has, I have to make it wait that the other subVI receives all its inputs as well and then start together. see?

0 Kudos
Message 10 of 18
(2,547 Views)