I have a question about... best practices I guess... I've been making data aquisition VIs with data logging, and I usually make two while loops, one loop collects all my data and displays plots of the data (this loop executes faster), and my other loop I just use to write my data out to a file every second (this is my slpwer loop) ok, here's my question... I've been basically using a local variable to pass all my data from my fast loop to my slower loop. But when I look through LabVIEW material I don't see it done this way much (or at all) I usually see people using something called queue's to pass the data from one loop to another. Do I need to switch to queues?
If the only problem is race conditions, I don't mind, because I'm logging my data only once per second, and my data acquisition loop is fast so if I get the data from the previous iteration and not right away when I call it, I don't mind (my data isn't changing that fast anyway)
"Slow", "I don't care" lend me to believe you can get away with using locals to transfer the data, but it is not a "best practive" becuase when you bump up the speed and care about loosing data, that mechanism will start to fail.
The queue is the prefered approach.
its like what you need in your car.. CRDI (QUEUE) or normal injection (locals)
Local Variable may seems to be easy to setup, but if you get into a habit of using it, it will hunt you. Queue seems a bit involve to setup at time (relatively), but it is the definitely the preferred way.
i recently started to use the "action engine" (thanks to Ben for the great nugget !). So give it a try !
(if you have a version previous to 9, unfortunately there is a strange bug to the AE, when using waveforms in cluster, otherwise it is great ! it is my most used tool after the state machine !)
An easy way to get started using the queue in your architecture is to start with a Producer/Consumer temaplate as well as running some of the queue examples.
In LabVIEW go to File >> New...
In the dialog box expand VI >> From Template >> Frameworks >> Designe Patterns and select Producer/Consumer Design Pattern (Data)
This will set you up to fill in your code in the slow (consumer) and fast (producer) loop.
Also, take a look at the Queue Basics.vi in the Example Finder.