11-16-2022 04:12 PM
I have 2 loops in the same VI. Lets say I want to keep them separate. But I want to send information from both loops to each other. Is this the way to do it? I know backwards wires are frowned upon. Maybe this is just stupid in general and if I'm doing this, I just need to use 1 loop 🤔
11-17-2022 01:43 AM
Firstly i am not fan of using Channel Writer, But tried this long back to understand on the communication flow. It supports only one way communication if you want to have a two way communication then you need to go with Multiple Channel wire (At least 2)
11-17-2022 05:26 AM
In short, yes that is how it is done.
Lets compare it to some kind of reference based solution:
Is this better? Can you see where the data is going?
Channel wires are an improvement that at least lets you see the data flow by wires. What is not apparent is the direction of data. It is better than reference based solutions but I would like channel wires to show the direction of data.
But you will eventually find that each while loop will/should be a sub-VI. This sub-VI is a process that responds to "messages", an actor. Try to standardize the connections between the actors and perhaps do what I do, put some arrows near the wires to show the direction:
These directions will never change or only change if you change the design, so it doesn't matter that much that they aren't a part of the channel wire.
11-17-2022 07:48 AM
Some more thoughts:
Your example could look something like this with just some layout standardization. Readable enough in my opinion:
As you can see, I did not use a channel Tag but a stream. I think you will find that in most cases it is better to send and act on new data in the channel rather than read it regardless of if it changed or not. (this code is not complete but needs some UI events or loop waits, loop stop and so on.)
In fact, I almost always use a Messenger channel instead. Then you can send messages and data in the same channel and the loops becomes actors.
I recommend viewing the LabVIEW examples. In Find examples, search for ”channels” and also ”measure and log”. The latter has a good step-by step procedure for an idea how to design a measure and log application. It has its flaws but will get you going.
Another thing to consider: Will you really need the data back in the first loop? If its only for display, then consider creating another loop for that. The “measure and log” example shows that.
11-18-2022 03:38 PM
A few (minor) comments on Channel Wires and how to better understand them:
Bob "Channel Enthusiast since 2015" Schor