Showing results for 
Search instead for 
Did you mean: 

stop syncronization of 2 while loops

Hello all!


Now in my project I got a serious problem. I have 2 while loops. One (loop 1) keeps receiving UDP messages


from an external device and send a cetain type of message to another while loop (loop 2). The cycling time of 1st loop is


300ms (it receives a UDP message every 300ms), the cycling time of the 2nd is 30s (30s is the receiving period of the certain type


UDP message sent by loop1, and I used a notifier to transmit this message to loop 2, so the cycling time of second loop is 30s).


At last when the num of the certain type of UDP messages received reaches 4, I want both loops stop, so as the program. However,


at last both loops stopped but the program no!


I'm quite sure it's the problem of the 'stop' of 2 loops, cuz when I don't use the notifier, not to control the cycles of the loop 2,


at last both of the loops stop and the program could stop. But with the control of cycles of loop 2 (I mean the loop passes on cycle


when receiving the certain type of message from loop 1), the whole program doesn't stop when both loops stop.


So in this case, 2 loops with data dependency run with different cycling time, is it possible to syncronize the stop, in order to


stop the whole program when both loops stop. Thanks in advance!




0 Kudos
Message 1 of 5

we need to see some code.

0 Kudos
Message 2 of 5

Hello Mister!


I'm not sure in which way I could show you better my code, since the main vi contains tens of subvi.


This pic doesn't show everything. I should explain that the higher loop is loop one which is receiving UDP


message and send a certain type of UDP message to the lower loop.


If you have a better idea about showing my code better, please tell me. Thank you

0 Kudos
Message 3 of 5

THat image is pretty useless to troubleshoot the problem. What is the purpose of the stop function? Why do you need all these value property nodes?

0 Kudos
Message 4 of 5

Well I guess so, I just don't have a better way to show the code. The Stop function serves to stop the whole program.


The propery nodes are just for connecting different VIs or other stuff, avoiding messy lines, some are not necessary.


I just want to say that, if I wire a num indicator to the 'i' of both loops, at the end of the run (when the number of messages 


reaches 4), the higher loop passes maybe 300 cycles and the lower loop passes 4. I think probably because the end of the


last cyle of the higher loop is not at the same time of that of the lower loop, causing the whole program not terminate. To have


a method to make both the loops stop at the same time, I think that would solve my problem.

0 Kudos
Message 5 of 5