11-17-2014 04:27 PM
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 🙂
11-17-2014 04:30 PM
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
11-17-2014 05:15 PM
LabVIEW is parallel by default. You can syncronize with a flat sequence structure as shown below.
The "Move motor 1" VI above won't run until the Calc print head pos. "thread" at the bottom left is finished.
11-17-2014 05:58 PM
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.
11-18-2014 01:51 AM
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.
11-18-2014 02:21 AM
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.
11-18-2014 02:53 AM
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?
11-18-2014 03:50 AM
@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.
11-18-2014 03:54 AM
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?
11-18-2014 04:51 AM
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?