05-27-2019 07:14 AM
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.
05-27-2019 07:53 AM - edited 05-27-2019 07:58 AM
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?
05-27-2019 08:14 AM
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"
05-27-2019 08:36 AM
@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.
05-28-2019 06:26 PM
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.
05-28-2019 08:09 PM