LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Ask for help on how to stop a program in time when a subvi has to run in a relatively long time

For example, I want to time for a period in a subvi, say 10 seconds, and I want to stop the main vi in time. How to accomplish this task? Is there any examples I can refer to?

0 Kudos
Message 1 of 8
(4,204 Views)

If you want to stop the main VI while a subVI is running, simply use the producer / consumer design.

 

While the consumer loop may be locked up by the subVI, you still can use the producer loop to set a shared variable to make the subVI stop.  Just add code in the subVI to check the shared variable.

 

 

George Zou
Message 2 of 8
(4,197 Views)

Hi,

      The attached is one simple example I have seen:-

 

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Thanks as kudos only:)
Download All
0 Kudos
Message 3 of 8
(4,194 Views)

Look at another one:-

 

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Thanks as kudos only:)
Download All
Message 4 of 8
(4,188 Views)

Hi danil,

 

- The 1st example has no features that stop the mainVI after a given period of time, so it doesn't fit as an example for the question...

- Your 2nd example doesn't work because it violates the dataflow paradigm. You can't exit the mainVI as the event structure is blocked by your subVI...

 

Do you also test your "examples" before posting them?

Do you ever read the question of the OP before posting unrelated VIs?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 8
(4,169 Views)

It seems to be working what we are trying.Can you please show the correct one that obeys dataflow paradigm.So that I can also study.

Sorry I just gave him a producer-consumer example.

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Thanks as kudos only:)
0 Kudos
Message 6 of 8
(4,164 Views)

Hi danil,

 

zou already explained how to program the solution.

I would just use a (functional) global variable instead of a shared one for simplicity...

 

Simplest solution using a global variable:

check.png

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 8
(4,158 Views)

Hi GerdW,

               Thanks for your suggestion.

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Thanks as kudos only:)
0 Kudos
Message 8 of 8
(4,145 Views)