LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

loop in subVI to be stopped by control in calling VI.


Tzench wrote:

The main program is not a loop. I've known the problem about dataflow since the beginning, and I thought the action engine could be a way around it. Could it be, if I use the case-structure?

 

I've been working a little with references, but I cant get the Control Refnum in the subVI to understand what it is supposed to refer to. Can anyone help me with this?


 

Hi Tzench,

 

You are "jumping from the frying pan into the fire" by abandoning the AE approach and trying to go with the control reference approach. I suggest you stop and get a good understanding of what we have been saying about using the AE in you application.

 

If you really want to ignore the AE and use another approach the take some time to study Ton's Nugget on Dynamic Event Registration found here.

 

Just trying to help,

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 11 of 24
(1,054 Views)
I have made this action engine. It does not work. All in all I don't see how I can get around the data flow problem as long as I have a loop in the subVI.
Download All
0 Kudos
Message 12 of 24
(1,045 Views)

In your ‘GetStopSwitch.vi’ put a loop round your LV2 vi – (put a small time delay in as well) connect the output of your LV2 vi to the Stop terminal of the loop. Now in your SetStopSwitch vi, connect the Stop switch to your LV2 vi and it will all work.

 

Run your SetStopSwitch once with false, this will initialise the LV2 vi. Now run the GetStopSwitch vi. This will continue running until you run the SetStopSwitch vi with the switch turned on.

0 Kudos
Message 13 of 24
(1,029 Views)

Two tips for your AE.

 

1.  No need to branch the boolean inside each case of the case structure.  Just wire the indicator to the right hand shift register.

2.  Use an Enum as your control rather than a ring.  By doing this, each case of the structure can be identified by the action name rather than an arbitrary number such as 0 and 1.

0 Kudos
Message 14 of 24
(1,021 Views)
Like this? I'm not familiar with the expression 'LV2'.
0 Kudos
Message 15 of 24
(1,007 Views)

Sorry, LV2 is your 'StopSwitch.vi.' LV2 is short for LabVIEW 2 – it was a method of providing Global Variable functionality before there were Globals in the early versions of Labview (before my time). They are still prefered over the built in Globals, you can find much discussion in the forum on this.

 

Your code looks OK but when I tried it with your earlier two vi’s it would not run. There was a mismatch with the Get/Set constant, there was a red dot on the terminal to show this. Change all your Ring controls to Enum, as Ravens Fan suggests (constants and controls) and the three programs work fine.

0 Kudos
Message 16 of 24
(1,001 Views)

I din't really understand how the loop in GetStopSwitch is supposed to work. The conditional terminal is wired to the output of StopSwitch, which will only be TRUE if the stop-button is pressed. If the stop-button is not pressed you are stuck in the loop until it is. This means the main program will do until you stop it.

 

At the moment neither feature works. The program does nothing until it does not stop.Smiley Wink

Download All
0 Kudos
Message 17 of 24
(999 Views)
Maybe I don’t fully understand what your overall structure needs to be, your original post says:  ‘I have a loop in a subVI that is supposed to run until a stop-button is pressed in the calling VI’ The three small programs you have appear to me to be achieving this. You now say: ‘If the stop-button is not pressed you are stuck in the loop until it is.’  These two statements seem to be opposite requirements. Maybe you need parallel loops in your subvi, one to monitor the Main Program Stop switch and another to perform your subvi code?
0 Kudos
Message 18 of 24
(984 Views)
What I meant was stuck in the loop of GetStopSwitch. Otherwise, you have understood me quite correct.
0 Kudos
Message 19 of 24
(980 Views)
This is my subVI. Since GetStopSwitch was introduced it has not performed any action what so ever.
0 Kudos
Message 20 of 24
(972 Views)