10-30-2020 10:54 AM
I have more than two while loops in a VI. Attached is a simplified version. First there is initialization, here a number then while loop do something with it and will stop when I click stop button. However once stopped it can not be restarted unless the second while loop is also stopped and hence the outer most while loop triggers again. The outer most loop is optional but I don't see any other work around. Is there a way to start any of the inner while loops without having to stop rest of them.
10-30-2020 11:06 AM
Hi Charles,
@CharlesChavandish wrote:
Is there a way to start any of the inner while loops without having to stop rest of them.
Yes.
10-30-2020 12:11 PM
All you really need is one loop, i.e. the outer loop that you think is not needed. Have a look at state machines.
Can you attach a simplified VI that is more closely related to the real problem? Both your inner loops are constant folded, just burn 100% of a CPU core, and don't do anything interesting. You would get exactly the same result if you would delete the two inner loops.
It would seem more interesting to take a step back and describe what you want to to, not how you want to do it. What are typical control values. How often do they change? How is the VI operated during the run? What should happen as a function of user interaction? I am sure we could come up with a great solution. Currently, it seems you are barking up the wrong tree.
10-30-2020 12:15 PM
@GerdW wrote:
Hi Charles,
@CharlesChavandish wrote:
Is there a way to start any of the inner while loops without having to stop rest of them.
Yes.
SpoilerTo run code parts independently from each other you should place them in different loops…
In addition to this, you should learn about a state machine architecture. Your loops should be separate and your case structures should be inside the loops.
10-30-2020 12:19 PM
@altenbach wrote:
All you really need is one loop, i.e. the outer loop that you think is not needed. Have a look at state machines.
Can you attach a simplified VI that is more closely related to the real problem? Both your inner loops are constant folded, just burn 100% of a CPU core, and don't do anything interesting. You would get exactly the same result if you would delete the two inner loops.
It would seem more interesting to take a step back and describe what you want to to, not how you want to do it. What are typical control values. How often do they change? How is the VI operated during the run? What should happen as a function of user interaction? I am sure we could come up with a great solution. Currently, it seems you are barking up the wrong tree.
I made the assumption that this was example code and that the actual code needs to be running independently. I agree that for the code given there is no need for the inner loops. A state machine is appropriate in any event.
11-11-2020 10:59 AM
Thank you very much for your reply.
I am quite new with LabVIEW and I am working on multiple projects. I learned about state machine architecture and trying to implement it for my problem. Of course, the toy VI I have attached does not do any justice, since my original project is quite complicated and uses drivers provided by the manufacturer, there is little point in posting it as it is. I will make something more resembling it and perhaps you can guide me. Thank you for your patience, and willingness to help me.