LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to control sample rate, data acquision export to excel

Hi all,

 

I have a question regarding sample rate and writing data to excel. I am running a simple program that pulses an exciter and measure fundamental frequency during decay of a resonator. I want to export the data to excel but how do I control the amount of data and sample rate of data acquision to export to excel? I am able to successfully write data to excel but I have no control over the sample rate of the data. 

 

Does anyone have any suggestions?

 

Thanks in advance

0 Kudos
Message 1 of 16
(2,165 Views)

First please save your program to an older version of LabVIEW.  At least 2017 maybe 2012. I could ask 20 questions but many of them will probably become apparent when I can open the code.

0 Kudos
Message 2 of 16
(2,147 Views)

Wire the enable input terminal of the Write To Measurement File Express VI to the output of a constantly repeating True value. You can use the Elapsed Time Express VI or use a multiple of the loop iteration terminal.

-----------------------------------------------------------------

If you can not measure it, you can not improve it.
- Lord Kelvin
0 Kudos
Message 3 of 16
(2,131 Views)

Hi,

 

I have uploaded a file compatible with 2012.

 

Please could you let me know your thoughts.

 

Kind regards

0 Kudos
Message 4 of 16
(2,098 Views)

Thank you for the reply, I have implemented your method with the constantly repeating True value. It seems that the maximum sample rate for data acquision to excel it 0.1second. Reducing this time does not increase the amount of samples above 0.1seconds. Do you have any thoughts on this? I want to be able to record data and analyse it, are there any alternative methods to see this data?

 

Kind regards

0 Kudos
Message 5 of 16
(2,097 Views)

Where to start. .  .

 

Maybe you are just doing hobby projects or you only have to do this one project then you are never going to use LabVIEW again.  If you plan on using LV in the long run.  GET RID OF THE EXPRESS VIs.   Everything that you are doing in that program can be done using regular LV programming.

 

I have dump data to file programs that can run continuously at 20 kS/s (probably faster) sample rates.  They write to file in chunks generally once a second sometimes once every 10 seconds.

 

Right now the reason that the data is going out at 0.1 sec is because you are acquiring 100 data points at 1kS/s.  Maybe write to Excel can not write any faster due to overhead of opening the file, etc. I am not sure as I only use it from time to time and when I do it is a more complicated structure (multiple tabs with embedded images, etc.)  

 

Second consider writing to text files rather than Excel.  If you do them as tab delimited text and make the file extension .txt you can drag and drop them into Excel and they will open right up.  That being said you should be able to use Excel files for this.

 

Right click on your DAQmx task and select "Create DAQmx Code"  That will create the code  Remove the do while loop that it created because you said acquire 100 points continuously.  Drag the Untitled 1 subvi out of of the main loop.  Drag the clear task out of the loop to the right.  Now your program sets up an acquisition, goes into the loop where it starts the task, takes the data and processes it.

 

Open that untitled 1 subVI and and open the diagram.  Copy everything in it and replace the untitled 1 subVI with this code.  On the sample clock setup change the continuous samples to finite samples because that is the structure that you are using.

 

Next go right click in your diagram and select

 

Signal Processing -> Waveform Measure

 

This has all of the signal processing stuff that you are doing in your program.

 

Once you get all of those discrete values that you need use build array to build your output data stream.

 

The other question is what is your output.  When I simulated your input function with 10 cycles of a sine wave and created a numeric indicator for the output of your merge  just before you wrote to a measurement file I got a single value.

 

For writing multiple data values to a file where each array of values is generated in each iteration of your loop I use the general structure of create a file and write the column headings to the file, pass the file refnum into the loop.  Then point to the end of the file and write the next line of data.  You create the line of data by taking the 1D array of data and using the string function of array to spreadsheet string.

 

There are other similar posts regarding acquiring data etc. on this forum.  Go back and look at them looking for the advice given by others regarding getting started writing DAQmx code, etc.

 

PS Learn to write in state machine format for programs like this.  It makes it easier to keep track of things.

 

Init

Set up data file

Set up acquisition

Take data

Process data

Write data to file

What next

Exit

Error(default)

 

Start at init.  At what next loop back to take data except when you want to exit.  Close the file and DAQ task in the exit and error states.

 

0 Kudos
Message 6 of 16
(2,081 Views)

Hello,

 

Thank you for your reply, much appreciated. I am using Labview to obtain data for mechanical experimental work. I have very limited experience with Labview and any kind of programming, so please bare with me. 

 

I have changed my VI and have uploaded a copy.

 

I am now writing the data to a text file but it only records data once. How to I continually write data to the file?

 

Kind regards and thank in advance

0 Kudos
Message 7 of 16
(2,041 Views)

Please save your program to a previous version.  2012 everybody can read it I am on 2019.

 

If you are saving one line of data do the following

 

Do not close the file when you set it up and write the header.  Pass the file ref number to the write data to file state.

 

In the write data to file state use

 

File -> Adv File Funct -> Set File Position

 

Wire the file ref # into it and Right click on the "from" input and create a constant for where and select end.

 

Write the data to the file using

 

File -> Write text to file

 

exit the state without closing the file

 

0 Kudos
Message 8 of 16
(2,031 Views)

Hi,

 

I have attached the file as a previous version.

 

I really don't understand your explanation. I want to continuously write the data to the text file. I am currently only able to write 1 line of data. I want to be able to choose the rate at which we write the data.

 

Thank you for your help,

 

Kind regards

0 Kudos
Message 9 of 16
(2,025 Views)

Here I modified your code.  That should give you 50 lines of output.

0 Kudos
Message 10 of 16
(2,018 Views)