06-06-2018 03:09 AM
Hello.
I need to data acquisition and write the file. My VI consists of two while loops. The first loop receives data from FPGA and performs signal processing. The running time of this cycle is 1 second. The second loop writes the file. A queue is used to transfer data between loops. I need to record the signal for 1 minute. If I start VI and start recording a file, then when recording time is 1 minute I always get a signal recording with duration of 1 second. How to do the accumulation of data from the first cycle and write them to a file in second loop.
06-06-2018 03:42 AM - edited 06-06-2018 03:44 AM
hi there and welcome to the forum!
first some critique: please don't post screenshots of code .. and escpecially no spaghetti code.
attach your vi or better a mockup of your problem (often just by doing this step one finds faulty code).
also to better check your code and its dataflow paradigm have everything going left to right,
no up and down please (e.g. your destroy queue subvi).
from you description (the image is not very informative) you are on the right track.
one acquisition loop that writes to a queue,
second loop for reading/flushing from the same queue and writing to file/tdms.
without more information it is just guessing what the cause is.
on thing i saw that strikes me odd is your Error Feedback Node.
EDIT: also, you create/replace your tdms file every loop iteration, that might be it, can you verify, that you only get the last measurement in your tdms file?
regards
06-06-2018 04:13 AM
Your LabVIEW code will be much easier for you to read/understand (and will help others, too) if you learn to use (lots of) sub-VIs, preferably that "do one thing", and organize them in folders and the LabVIEW Project file.
The notion of having two parallel loops doing parts of your code "in parallel" is a major strength of LabVIEW. However, you need to also organize each loop better. You will help yourself if you try to keep your VIs compact, your wires as straight as possible, and data flow moving left-to-right. The Diagram Cleanup button (the Broom symbol on the upper Task Bar) can be helpful, but laying it out neatly yourself, in my opinion, is better.
Many parallel tasks (and yours, in particular) have the following logical structure:
@jwscs suggested that you might be creating, writing, and closing your TDMS file every time through the (Consumer) Loop, which might be your problem. If so, move the Create to the Consumer's "Initialize" code, leave the Writing in the Loop, and move the Close to the Cleanup code. And get those wires straight, and start using sub-VIs!
Bob Schor
06-07-2018 09:11 AM
Hi Bob. Thanks for the response and recommendations. I will take them into account in my work. I made a change to VI on the advice of @jwscs. As a result, I was able to write a file longer than the period of the first data acquisition while loop. However, the recording time of the signal set in VI does not correspond to the time of the recorded signal. If a recording time of 1 second is set in VI, then the recorded file contains only 200 ms. Also, the recording time of a signal depends on the number of samples. Maybe I'm setting the queue parameters incorrectly. I did VI immetting the work of my VI and discovered the same problem.
How to reconcile the work of two cycles and transfer through the queue to record a file with a given signal size?
06-07-2018 09:31 AM - edited 06-07-2018 09:38 AM
The VI you uploaded looks like it should work - just be aware that you're generating 1000 samples at a sampling frequency of 1kHz, every 50ms. This results in producing what the timestamps suggest is (1s / 50ms) = 20s of data per second of acquisition.
Perhaps that's the problem you're seeing. I changed the wait in the top loop to 1000ms and although the graph is much less smooth (because it only updates once per second) the result in the TDMS file became 10s when I set the recording to 10s.
The option to have quick updates and appropriate sampling would be to keep the wait at a low-ish value (perhaps 100ms, or 50ms) and then lower the number of samples in the waveform. The combination of the two sampling values controls the data rate in a peculiar way (at least to me). I'd suggest reading the "Detailed Help" available either via the right-click menu, or the Context Help (Ctrl+h).
A couple of other quick points: