05-24-2019 07:20 AM
Hello,
i created the VI for signal aquisition with NI 6009.
In first while loop, signal is aquired, and samples are saved in csv. (working good)
In second while loop i have need to save only samples starting when signal pass 0 for the first time, and ends when signal pass 0 fifth time.
Problem is that sometimes, i have all samples in second loop, and sometimes some samples are lost.
I belive that buffer cause the problem, because cannot save all samples.
Can someone advise how to overcome this problem.
If i put lower sampling rate, result are a little bit better, but still insufficient . And I need solid solution.
Please check VI and example in att.
Thank you on your help.
Milan
05-24-2019 08:34 AM
Don't have time for thorough analysis or response. Two major points:
1. DATAFLOW!!! The array makes a dataflow dependency such that your 2nd loop *cannot* start executing until after your 1st loop has *finished* executing. (And the 1st loop can only terminate when you click your stop button.)
2. Do some research on the Producer / Consumer pattern that uses 2 *independent* loops with no dataflow dependency.
- Kevin P
05-24-2019 08:37 AM
You don't understand the Principle of Data Flow, the central "idea" that lets LabVIEW do such a good job as an "Engineering Workbench" (the last two letters of "LabVIEW"). You also don't understand the Concept of Time in LabVIEW, and how data acquisition is designed to be done in LabVIEW.
First, DAQ. You have (correctly, I think) set up your DAQ routine to collect samples at 1kHz, and to acquire them 1000 at a time (which means that every second, you get 1000 points). You collect them inside a While Loop (but aren't collecting the entire sample, which is a "mis-understanding" error), save them to a file, and output nothing until you stop sampling (that's part of the Principle of Data Flow).
Drat. I don't have enough time to write a mini-essay on understanding DAQmx, thinking through your problem by concentrating on what you want to do and knowing enough LabVIEW to determine better determine how you want to do it, the Principle of Data Flow and how it can enable parallel processing, etc. So I'm going to simplify this and suggest one way to approach this.
Let's say you set up your DAQ to always collect 1000 samples at a time. This takes precisely 1 second. I'm going to suggest you build a State Machine. I'm giving only the 30,000 ft (or 10,000 m) view of this -- look up LabVIEW State Machine to fill in the gaps.
Here I encounter a semantic problem -- there is the "State" of the "State machine" (i.e. "what does it do next?") and the "State" of the "Problem", namely "Have I crossed threshold for saving?".
Notice that this displays no data. You can add that in later -- the important "What" you need to figure out is how to start and stop data saving.
Bob Schor
06-03-2019 07:50 AM
Hello,
just to inform you that I solved problem.
I used producer-consumer design, to reduce time in producer loop.
Thanks for your sugestions and advice.
Best regards.
Milan
06-03-2019 11:02 AM
Glad that you got it working.
I'll point out what seems to be a fairly crushing problem with the VI you uploaded just in case it appears in a future VI you write: your stop condition for the first loop is a button which will end the loop when it becomes true - this value is then passed out of the loop and into the second where it will immediately stop the second loop at the end of the first iteration.
In the mean time, you'll only get the first element via the indexing input, which prevents you managing to process any of the data.