From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Continuously running a dynamically called VI

Solved!
Go to solution

I have a producer consumer loop, and in one of the cases I am calling a VI dynamically, i.e create a reference of the VI and use the Invoke Node method to run the VI. But I want the VI to continuously run. But for me the producer consumer is continuously running but the dynamic vi just runs once and stops. Also I have not used the close reference. So what should I do for the program to run continuously. Thanking You.

 

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

Maybe the dynamically called VI needs a while loop?

 

(I hope you are not talking about the "run continuously" button. That's just a debugging tool.)

 

It is possible that you have little experience and we can help. Please tell us what you are actually trying to achieve, maybe show some code. There probably are much better solutions to whatever you are trying to do.

0 Kudos
Message 2 of 9
(3,347 Views)

No, I am not talking about the run continuously button, I know what that is. Here I will attach a pic. help please.png

See the place that I have marked, that is dynamically calling VI. You can also see its in a while loop. So I want it continuously run in every loop. Also the top loop is the consumer loop and the bottom is the producer loop. Even though while loop is iterating, the run VI only works once. So how can I continuously run it, that is keep on running until I press the stop button. 

0 Kudos
Message 3 of 9
(3,344 Views)

@govindsankar wrote:

No, I am not talking about the run continuously button, I know what that is. Here I will attach a pic. help please.png

See the place that I have marked, that is dynamically calling VI. You can also see its in a while loop. So I want it continuously run in every loop. Also the top loop is the consumer loop and the bottom is the producer loop. Even though while loop is iterating, the run VI only works once. So how can I continuously run it, that is keep on running until I press the stop button. 


Could you post Write Temp 1 - Copy.vi block diagram image/snippet here? It may help easy to debug it.

0 Kudos
Message 4 of 9
(3,339 Views)
Solution
Accepted by topic author govindsankar

Hi govind,

 

I want it continuously run in every loop.

You wan tto start that VI with each iteration of your consumer loop? Why?

 

Even though while loop is iterating, the run VI only works once.

Why is it running only once? Do you get any error messages?

 

So how can I continuously run it, that is keep on running until I press the stop button. 

Start the VI once - before the consumer loop.

Have it run in its own loop. Transfer data using a queue/notifier…

 

Btw. why do you create a new OOP instance in each iteration?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 5 of 9
(3,330 Views)
Solution
Accepted by topic author govindsankar

I think you want each iteration to instantiate a clone of the dynamic VI?

 

You'll need to make the VI reentrant, and open the reference with 8 as input. Then you need to manage the references you'll be opening. The started VI could do that itself (stop when done)… Note that if the VI starting the clones doesn't keep the reference, and the clone doesn't open a reference, the clone is removed automatically...

Message 6 of 9
(3,319 Views)

I was able to do what you told me to do. That is start the loop separately in one condition and have that vi run its own loop. The way I have done is a switch called thermo board 1. When I click on it an event is triggered that enqueues two cases one is the case for the run vi and other is a blank case in the beginning called start. So first the run vi occurs which will run the vi in the background and then it will go to start where nothing happens and it stays idle. This is exactly what I wanted which Mr GerdW has helped me achieve. But now the problem is with event triggering. When I try the event as button thermo board 1 value change, that event occurs twice, so in our case consumer loop it will go to run vi and runs the vi, then goes to start and again goes to run vi, so when it is trying to run a vi that is already running, an error is formed. So I change the event from value change to mouse down for the button and it works properly only once run vi is triggered and then goes to start state and stay idle. So I can program with mouse down, but for learning purposes i need to know what is the difference between value change and mouse down for a push button Boolean. Why is value change event happening twice whereas mouse down only once and goes to timeout. 

0 Kudos
Message 7 of 9
(3,312 Views)
Solution
Accepted by topic author govindsankar

Hi govind,

 

When I try the event as button thermo board 1 value change, that event occurs twice

What is the mechanical action of that button?

Set it to a "latch when pressed/released" mode to get just one event…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 8 of 9
(3,307 Views)

Mechanical action was switch until released, so that it will work as a push button. Yeah but your method to change it to latch when released worked. Thank You. I need to now learn more about dynamically calling VIs. If anyone has any good link or site for that kindly let me know. 

0 Kudos
Message 9 of 9
(3,290 Views)