I'm running a while loop and using the DAQmx functions to read cDAQ analog inputs. I'm attempting to create subVIs to organize the code. The while loop runs continuously until i stop the program manually. In cdaq-io-config.vi the array called analog-data inside the while loop gets executed, but passing this data to the main-program.vi doesn't get executed. What's the proper way to handle this? I will likely need to setup another couple of tasks as well as some TDMS file functions. I don't expect those would need to live inside the while loop. Do i create a queue so i can work asynchronously? I read something that said i can create local variables (outside of the loop?) to do this as well but haven't had any luck with that.
Solved! Go to Solution.
What's the proper way to handle this?
When you want to implement a producer-consumer scheme you should employ queues/notifier/channels.
(All those bolded items are explained in example VIs and projects, which come with LabVIEW.)
Do i create a queue so i can work asynchronously? I read something that said i can create local variables (outside of the loop?) to do this as well but haven't had any luck with that.
Yes, you send the data to a queue or an event that you catch in the main.vi
Thanks for the advice. I think I'm close but am still having trouble getting data out of the while loop. I reworked things using a Producer Consumer Design Pattern Template (Events). My read-cdaq-io.vi is inside of the enqueue element. I start by toggling the bool inside the enqueue element and then i can see data being read inside the while loop of the read-cdaq-io.vi. The wire coming out (analog-data) of that vi is still not being executed and as a result no data is being enqueued.
Answer that question: When will (according to DATAFLOW) the data be available in the producer loop of your main VI?
There should be no "default if unwired" tunnels with reference wires!
Why is there an event structure?
Why do you read waveforms for just one sample per channel? Why do you wire waveforms to an array indicator?
Why do you create a queue with a variant as datatype?
Thanks again. I got the queue working after reviewing and addressing points you made in the last post.