LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Write to txt file at variable rate

Solved!
Go to solution

Hi,

 

I've application that need slower (100 Hz) datalogging initially and then increase the datalogging rate to high (10 KHz) after some time.

 

I have been trying incorporate variable DAQ rate but with not success. I also tried to maintain contant DAQ rate but write txt file at diffrent rate.

 

Now, without any success, I am now trying to write two txt file with low and high rate.

 

I would greatly apprecaite, if somebody can direct me to correct logic to accomplish the task.

 

Find bellow the sample test VI that I am trying to implement the requested feature. This VI Write data to a txt file with time stamp matching DAQ rate in first column.

 

TestVI.JPG

 

Thanks in advance.

 

 

0 Kudos
Message 1 of 13
(4,986 Views)
I recommend placing the file writer in a second while loop. File writing can take a variable amount of time depending on what other tasks the O/S is handling. Connect the data acquisition thread to the file writing thread with a queue. Moving the file writer into a second loop will improve the accuracy of the sample rate of the DAQ.

Adam Przybilla
Consulting Engineer

Aegis Group
Service Disabled Veteran Owned Small Business
tel 206.447.4175
fax 206.624.9448
www.AegisGrp.com
a product and technology development company
Message 2 of 13
(4,978 Views)

Thanks for the suggetion.

 

I tried to implement the parallel loop producer consumer architecture but am getting some error.

 

I cant connect the obtain queue VI.

 

TestVI1.JPG

0 Kudos
Message 3 of 13
(4,973 Views)
can u please post ur code?
Balaji PK (CLA)
Ever tried. Ever failed. No matter. Try again. Fail again. Fail better

Don't forget Kudos for Good Answers, and Mark a solution if your problem is solved.
Message 4 of 13
(4,964 Views)
Your obtain queue VI needs a datatype input (second from the top on the left).  In your case, this is an array of waveforms.  You can easily create this by right clicking on the output of your DAQ step where you obtain the data and selecting Create Constant.
Message 5 of 13
(4,949 Views)

Here is the code in which i am trying to implement the parallel loop producer-consumer architectuer to write txt file at set DAQ rate or something else.

 

Its not working and the obtain queue VI needs datatype input.

 

The file write is not working as well. Formatting is not correct.

 

Thanks

Ganesh 

 

0 Kudos
Message 6 of 13
(4,925 Views)

Hi ganesh,

 

     For obtain queue you need to give the queue name and data type.In the consumer loop you are not dequeueing the data,you are using the preview data(In source code). so your data was not getting dequeued and it appends with the previous data and the queue is bulilding.I attached the example hopes it help.

Message Edited by Baji on 07-21-2009 02:13 PM
Balaji PK (CLA)
Ever tried. Ever failed. No matter. Try again. Fail again. Fail better

Don't forget Kudos for Good Answers, and Mark a solution if your problem is solved.
Message 7 of 13
(4,908 Views)
 
Balaji PK (CLA)
Ever tried. Ever failed. No matter. Try again. Fail again. Fail better

Don't forget Kudos for Good Answers, and Mark a solution if your problem is solved.
Message 8 of 13
(4,902 Views)

Thanks for the help.

 

Going foward, I am looking in to possibility of two consumer loops. One consumer loop should log data at high rate and the other at slow rate with user control to choose the data logging rate.

 

Presently I am trying to achieve obove task by using remainder of the time in a case structure. Its like selective writing.

 

As the data is logged into strings, its not working as required.

 

Take a look at the simple logic to achieve to datalogging rates.  

 

Please recommend better ways to achieve this task. Thanks in advance.logic.JPG

0 Kudos
Message 9 of 13
(4,882 Views)
The easy way is acquire the signal from the DAQ at the higher sampling rate.Downsample the Acquired data in the producer loop with the required sampling rate and enqueue in the queue to the consumer loop for logging.
Balaji PK (CLA)
Ever tried. Ever failed. No matter. Try again. Fail again. Fail better

Don't forget Kudos for Good Answers, and Mark a solution if your problem is solved.
0 Kudos
Message 10 of 13
(4,867 Views)