12-20-2009 01:45 PM
I am acquiring analog voltage signals and attemting to write to a text file when condition is true, thus there is continuous acquisition. However, the written files only contain 100 samples (the size of my buffer).. I need my files to read samples until the while loop is stopped. How can I go abotu doing this?
Thanks,
TFlax
Solved! Go to Solution.
12-20-2009 02:29 PM
12-21-2009 02:22 PM - edited 12-21-2009 02:23 PM
see response below
12-21-2009 02:24 PM
Hi Tflax,
Without looking at your code, I believe what you are encountering is the fact that you are calling the "Write To Text File" VI multiple times but always passing in the same file reference. This is a problem because whenever you open that reference using the "Open/Create/Replace" VI by default the position that LabVIEW will write to is the beginning of the file. If you would like to write to the end of the file, use the "Set File Position" VI in the advanced file i/o functions. Set the "from" input to "end" and leave the number of bytes unwired (default 0) or wire a 0 and now you will write at the end of the file.
Currently you are writing continuously but over-writing each time. I agree with Dennis that if you are writing continuously we typically recommend a producer/consumer architecture, however if your rate is low enough your method will work fine.
01-04-2010 10:46 AM
I have been able to make this work, but it only writes the buffer size. I am new to labview and programming in general and I have tried to make a producer and consumer design however I dont seem to understand the concept properly and fail to run my program properly... So here's my code before any attempt to producer/consumer design which only writes 100 samples to file. Advice on how to modify it to producer/consumer because Im not even sure where to start.
Thanks,
Tflax
01-04-2010 11:23 AM
Double click on your writ to measurement express vi and go under the Action section and select Save to one file and then under If a file already exists, select Append to file. Hope this helps!
-RW
01-04-2010 11:32 AM
Hi Tflax,
The key here is the mechanical action of the "Start Collect" button. Since the mechanical action was "latch when released" the "true" value would be read once and then go back to false, so the write to measurement file "enable" input would only be true once, hence it would only write to file once.
Check out this KnowledgeBase and the "Mechanical Actions of Booleans.vi" example it mentions.
As for Producer/Consumer, I searched "producer consumer" at ni.com and came up with a description (first result), a tutorial, and an example using DAQmx all on the first page of results. Definitely utilize ni.com search because we have a lot of valuable resources available there.