LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Error trying to close multiple loops with one stop button

Hello, I'm working on a projekt where I have 6 different loops running at the same time. I wish to have one stop button, to close them all.

 

I followed the guide on this link:

 

https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z0000019LmXSAU&l=da-DK

 

And I'm using local variables method to do it. It has been working fine throughout the entire work progress, but when I transfered it to my workgroup, it suddenly didn't work anymore. None of the loops we're running and you have to press the stop button twice, to even close it now. 

 

Anyone know what happened? Maybe have a way to fix this? Thanks. 

 

It's an assignment for my final project, so I am not allowed to share the VI. Hope someone can help anyway.

0 Kudos
Message 1 of 6
(2,371 Views)

You need to attach your actual code instead of an empty VI. You can strip out the rest of the code, just leave the loops, the stop button and all the local variables.

 

(Your empty VI (even appropriately named "empty.vi") is completely bug-free and runs perfectly. :D)

 

As has been said, a race condition is the most likely reason of your problem, but it could be anything. Is there a place where the button gets reset back to false via a local variable? Are you ensuring that this can only happen after ALL loops have completed? Why do you need six parallel loops? Maybe some loops could be combined. What are the lop rates of the various loops? Is one very slow?

Message 2 of 6
(2,352 Views)

Hey, I accidently posted this twice. I really appreciate your comment, I have found a fix in the other thread:

 

"I fixed it by making 'tag' channel writer/readers, but I still had the problem with having to press it twice before stopping. I also fixed that afterwards, by making a sequence structure telling the value to be true, before sending a signal through the channel. Not sure why it worked, but it did?

 

Thanks for the replies and trying to help"

0 Kudos
Message 3 of 6
(2,340 Views)

@tubidubidoo wrote:

Not sure why it worked, but it did?


That means you still need to learn. Programming is an exact science and if you don't understand why it works, there might still be hidden bugs that will show at some other time, e.g. during the critical rocket launch.

 

Also, your original approach using locals should have worked just fine if done right. Rewriting the entire thing with channels instead of applying a 10 second fix is not efficient use of time, and since you still have general problems in understanding LabVIEW, you could have failed equally with the new approach. 😉

 

Also, if you refer to another thread, include a link as I just did.

0 Kudos
Message 4 of 6
(2,328 Views)

The local variable method needs the control to have the right mechanical action; either "Switch when pressed" or "Switch when released". 

If the control has a "Latch when pressed" or "Latch when released" type action then it will likely not stop all slave loops.  

Perhaps in your original code you had the correct switch type action, then when you "transfered it" the stop button had the default "Latch when released" mechanical action type, and therefore didn't work correctly.

Troy - CLD "If a hammer is the only tool you have, everything starts to look like a nail." ~ Maslow/Kaplan - Law of the instrument
0 Kudos
Message 5 of 6
(2,262 Views)
You cannot have locals with latch action booleans, so the only wrong mode here could be "switch until released" and similar (and the button is not held down long enough).
0 Kudos
Message 6 of 6
(2,254 Views)