LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can i make 2 functions happen sequentially in a loop

Solved!
Go to solution

Hello, i have a problem with this VI. I want to make the 2 subVIs happen one after another in the while loop: when the first one has finished the second one starts, and when it ends the loop starts again. I tried to come up with a solution with a case structure, making the second subVI as a condition for the result of the first one, but it doesnt really work: the second subVI only runs for a couple of seconds when the condition is respected, but since the first subVI runs from start , it stops running after a seconds. What could i do to make the two VIs run sequentially as i said?

Thank you

0 Kudos
Message 1 of 9
(1,090 Views)
Solution
Accepted by topic author domcorrado

If your VIs have error cluster terminals wire them to set the order you want. If not, you can use a Flat Sequence Structure.

Lucian
CLA
0 Kudos
Message 2 of 9
(1,078 Views)
Solution
Accepted by topic author domcorrado

Hi,

 


@LucianM wrote:

If not, you can use a Flat Sequence Structure.


In that case you should rather make those subVIs to use errorIO to enable simple DATAFLOW…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 9
(1,070 Views)

@GerdW wrote:

Hi,

 


@LucianM wrote:

If not, you can use a Flat Sequence Structure.


In that case you should rather make those subVIs to use errorIO to enable simple DATAFLOW…


Yes, if you can edit those subVIs.

Lucian
CLA
0 Kudos
Message 4 of 9
(1,063 Views)

I managed to do it with a flat sequence, gonna also try with the error i/o dataflow and see what fits my case more.

My only problem now is that i have all of this in a while loop to make it run repeatedly, but it just doesnt happen (only runs one time), any idea why?

Download All
0 Kudos
Message 5 of 9
(1,047 Views)

Hi

I think the problem is, that the second loop has a false constant wired to its stop condition. It runs endlessly.

If you make it a true constant it should work.

 

0 Kudos
Message 6 of 9
(1,030 Views)

problem is, if i make it a true constant, the first subVI will start running again instantly, during the time the second subVI still runs, which i dont want to

0 Kudos
Message 7 of 9
(1,018 Views)

No, this is not true! VIs are executed one after the other. Use Highlight Execution to see better what's happening:

LucianM_0-1647521965727.png

 

Lucian
CLA
0 Kudos
Message 8 of 9
(1,011 Views)

@domcorrado wrote:

I managed to do it with a flat sequence, gonna also try with the error i/o dataflow and see what fits my case more.

My only problem now is that i have all of this in a while loop to make it run repeatedly, but it just doesnt happen (only runs one time), any idea why?


Having now seen your code I would suggest that you learn about state machines. With a state machine architecture you can accomplish this task with a single loop - no need for getting stuck inside of inner loops or finding ways to program around that. I've attached what that could look like with your example.

0 Kudos
Message 9 of 9
(1,001 Views)