ni.com is currently experiencing unexpected issues.

Some services may be unavailable at this time.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

write to measurement file at every n iterations

Solved!
Go to solution

Hi guys,

I would like some help with saving data in labview 2010 SP1 (base development system). I am using a "Write to measurement fil express VI" inside a while loop and the data out from the DAQmn Read is wired to the signal in of the "Write to measurement fil express VI".

The way I have wired it is the VI saves the data as a text file after it has recorded 100 samples (the nuber of samples to read in this case was set to 100). I would like to know if there is a way to control the rate at which the express VI saves the data. As in, I want the express VI to save the data at specified time interval or at every nth iteration. I have attached the main VI and its 2 sub-VIs for reference. Please let know if anyone can help me resolve this issue. Thank you for your time and inputs in this regard.

 

Raj

Download All
0 Kudos
Message 1 of 9
(9,381 Views)

Adding to the previous post, I do know of one solution for this issue which is using the Producer-Consumer architecture. However, I am fairly new to labview and do not know exactly how to make use of such an architecture. I'd avoid it if there is another way of solving this issue of saving data to text file at every nth case of the while loop. Thanks for your help.

 

Raj

0 Kudos
Message 2 of 9
(9,376 Views)
Solution
Accepted by Rajesh_Hariharan

BH.png


Saving 1000 words


"Should be" isn't "Is" -Jay
Message 3 of 9
(9,371 Views)

Thanks for the prompt reply Jeff. It works. I'd like to however have the option of recording the data only when I click on the record button rather than having the VI automatically save the data as soon as the code id executed. Can you please suggest how I can achieve this?

0 Kudos
Message 4 of 9
(9,367 Views)

OR "Record" and  the "=0" outputs.

just that simple.


"Should be" isn't "Is" -Jay
0 Kudos
Message 5 of 9
(9,364 Views)

Hello jeff, Im trying to use your advice. What are you comparing on the quotiant and remainder.  Iterations "n" and ? (The 32 bit integer) 

 

Also the green new_file drop down in the write to measurement file what is that for?

 

 I do not see that I am using Labview 2011.


Thanks

0 Kudos
Message 6 of 9
(9,323 Views)

Robert,
First, you must understand that the above code resides inside a loop. The blue square i terminal is known as the iteration terminal. It provides the current loop iteration count, starting from zero.

 

The first input (x) to the Quotient & Remainder Function comes from this iteration count (i) terminal of the loop.

 

The second input (y) to the Quotient & Remainder Function comes from the control N.

 

We wish to write to the measurement file every N iterations of the loop. If we take our current iteration count (i) and divide by our desired N, every Nth iteration of the loop, the remainder will be zero. For all other iterations, the remainder will be non-zero.

 

That being said, we check the remainder and compare it to zero. If it is zero, we will send a True value to the Enable terminal on the Write To Measurement File Express VI. Any time a True value is sent, we will write to file. Anytime a False value is sent, nothing will be written to the file.


The green new_file input on the Write To Measurement File Express VI is used when the "Save to series of files (multiple files)" radio button is selected in the Configure dialog box of this Express VI. When "Save to one file" is selected, this option does not apply, and so it is not included in the input list, which is why you are not seeing this.

 

This new_file input is used to tell the Write To Measurement File Express VI when to start writing to a new file.

 

Jared A.
Applications Engineer
National Instruments
Message 7 of 9
(9,302 Views)

I believe this code writes only the data in the current loop to the file... in other words, if you're writing every 10 loops...

 

Loop 1: don't write data

Loop 2: don't write data

...

Loop 10: write data acquired in loop 10 (but not data from loops 1:9).

 

Is that correct? If so, how would I go about modifying this code so that it writes all the data that's been gathered since the last write? In other words...

 

Loop 1: don't write data

Loop 2: don't write data

...

Loop 10: write data 1:10

Loop 11: don't write data

....

Loop 20: write data 11:20

...

0 Kudos
Message 8 of 9
(8,195 Views)

@solobo wrote:

I believe this code writes only the data in the current loop to the file... in other words, if you're writing every 10 loops...

 

Loop 1: don't write data

Loop 2: don't write data

...

Loop 10: write data acquired in loop 10 (but not data from loops 1:9).

 

Is that correct? If so, how would I go about modifying this code so that it writes all the data that's been gathered since the last write? In other words...

 

Loop 1: don't write data

Loop 2: don't write data

...

Loop 10: write data 1:10

Loop 11: don't write data

....

Loop 20: write data 11:20

...


Conversation moved to here: http://forums.ni.com/t5/LabVIEW/Write-data-to-file-every-10-or-N-loops/m-p/3159034/highlight/false#M...


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 9 of 9
(8,161 Views)