I have two short questions that probably can be answered by experts on the board here:
a) I currently have a VI with several channels (8) of incoming analog data. I want the user of the VI to give the option which values to log to file. He can check a checkbox.
Currently I'm using the 'select' function, if its true it passes on the analog value, if false it passes a 0, but I dont want it to appear in my array at all because logged zeros are kinda useless.
Whats the way to do this?
b)As a programming habit, when I want to pass values between various running loops I tend to make an invisible indicator in that loop (string, numeric etc), and then use a property node of that indicator for the value in other loops. Is this a good way to do this? Works though.
for a) the following picture shows one solution to log only several channels
for b) the queue-VIs are a very good (fast, easy to use, needs little ressources) way to pass data between different loops. Please see at the examples shipped with LabVIEW (Help->Find Examples).
a) the code posted above can also be implemented using a select instead of the case structure. Wire the output of the build array to the true input, and the output of the shift register to the false input.
b) Property nodes is about the worst solution. Local variables are better in performance. Both lead to race conditions, which is very bad. Take a look in the breakpoint forum at the thread 'why local variables are bad'.
You can use queues as suggested, but also notifiers are the right tool in some cases. Have a look (= search for) at what is called 'producer/consumer design pattern'.
Post some example code here, and we will post back how to make it 'the right way'.
For extra Information on b)
You can use property nodes, local variables, global variables and Queues etc etc to pass data from one loop to another however some are MUCH more efficient than others. Probably something like this..
| Local Var
| Global Var
| Property Node
[Schubert - got there before me! Also using your shift register for solution a) - Another trick on top is to use a feedback node 😉 ]
Ok Guys thanks for the fast and helpful replies. I'm still learning Labview so I'm looking into the queues. But if a property node is so bad, why is the option in there?
Thanks again for all the help! I will post a VI once I've implemented the suggested code.
I've been learning labview by using the " advanced propramming techniques" book the last week, are there any suggestions for other GOOD books or courses?
And one last question, what is an easy way to get in the logged file a header above each column with data indicating which channel it is?
To learn, continue posting and reading this forum. As book, I would recommend you 'LabVIEW for Everyone'.
The Value-Property isn't useless, it is very cool if you work with control references. IIRC Ben wrote a nugget on this. He also has a Tag cloud to find these.
Here is a Tag cloud that may have some interesting links.
Take home leason:
Controls and indicators in LabVIEW should only be used to enter infor or display a value. They are not intended for storing data. All data in LV lives in wires.
Sorry, I left out Action engines, LV2 Globals and shared variables etc out of the picture as i didnt want to overwhelm the guy!