LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to write two signals to file

I am having trouble writing both the raw and filtered signals into an excel file. I have attempted using the merge signal, set dynamic data attributes, and write to measurement file. My signals are both inside of a while loop, so if I place the write to measurement file inside the loop it slows down my data collection and if I place it outside the loop I only get one data point for my raw and filtered signal. I have also attempted using a shift register to build a 2d array and then outside the while loop convert it into dynamic data, set dynamic data attributes, and write to measurement file.

 

 

0 Kudos
Message 1 of 14
(6,126 Views)
  1. Learn how to use TDMS files in LabVIEW, the best option you can get. Besides, you can directly open it into Excel.
  2. Learn how to use a Producer/consumer pattern to decouple the DAQ and File record/Data analyis loops (you need two While loops).
0 Kudos
Message 2 of 14
(6,120 Views)

With the producer/consumer pattern I would have the signals in the producer loop and the write to file in the consumer loop? Can you suggest some examples about how to use the TDMS files? I will attach the producer/consumer pattern that I currently have. I have the element data type set to 2d array because when it was set to waveform I was only getting the raw signal to write to file. However, I'm not getting the 1000 samples per second that I should get when writing to file.

0 Kudos
Message 3 of 14
(6,105 Views)

What are you doing?  You are taking your data points one at a time (at 1KHz), yet you are "wrapping" these single samples first in a Waveform (why use a Waveform for a single point?) and then in the completely-unnecessary Dynamic Data Wire (where you use it then discard it, another collosal waste of CPU cycles and Block Diagram space).  You then take these single samples and write them one-at-a-time to a TDMS file (which means you are trying to update the file every millisecond!).

 

Why are you doing this?  To top it off, you display every point, so your display update at a KHz, much faster than your eye can comprehend.

 

Do you know IBM's famous slogan?  Apply it to this problem ...

 

Bob Schor

 

 

0 Kudos
Message 4 of 14
(6,070 Views)

I have replaced the write to measurement file with the tdms file and I am now able to write both signals to file, but they are listed as untitled and untitled 1. How would I change the names of the columns?

0 Kudos
Message 5 of 14
(6,068 Views)

I have built a force plate with four s-beam load cells, to measure vertical ground reaction forces during running. The force plate will be place under a treadmill belt and serve as the running deck. The reason I need to acquire the 1 sample at 1kHz and record every data point is because a ground reaction force occurs around 200-300 ms. Currently, I need to get both the raw and filtered data points so that I can determine the optimum cutoff frequency for my filter.

0 Kudos
Message 6 of 14
(6,064 Views)

@Playerz1 wrote:

The reason I need to acquire the 1 sample at 1kHz and record every data point is because a ground reaction force occurs around 200-300 ms. Currently, I need to get both the raw and filtered data points so that I can determine the optimum cutoff frequency for my filter.


Are you continually adjusting the "optimum cutoff frequency" of your filter?  How fine-grained does this have to be?  Does it change from run to run, from second to second, or can you take some measurements, do some calculations, then use those (possibly verifying that they are still valid, but not needing to change it mid-trial) for the rest of the study?  It still sounds "incompletely designed" to me (but I'm not an engineer ...).

 

Bob Schor

0 Kudos
Message 7 of 14
(6,039 Views)

Are you doing anything with the filtered signal while the experiment is running?  We also record bio-data at 1KHz, saving all the raw data to disk.  For display purposes during the experiment (to tell us if the recording conditions are good), we display a low-pass filtered version of the data (our eye-balls have a hard time seeing 1KHz blips, but can easily spot a drift or the subject dozing off) during acquisition (we use the "crude-but-effective" method of plotting the average of successive samples of 50 data points, for an update rate of 20 Hz).  Later, after the subject has left and we've had a cup of coffee, we break out the analysis software, do what filtering of the 1KHz data seems appropriate, fit transfer functions etc., and analyze the data.

 

The point is that you might not need to do a sample-by-sample average of your data -- it critically depends on the (scientific or engineering) question you are asking.

 

Bob Schor

0 Kudos
Message 8 of 14
(6,037 Views)

The reason I have the two displays (raw and filtered) is to see if the two signals are similar when the force is applied. I have built both a force plate and an instrumented treadmill, currently I am working on the force plate and determining the optimum cutoff frequency as described in Estimate of the Optimum Cutoff Frequency for the Butterworth Low-Pass Digital Filter (Yu, B., Gabriel, D., Noble, L., & An, K.,1999).  With the equation (optimum cutoff frequency1= 0.071fs - 0.00003fs^2), where fs=1000Hz the estimated cutoff frequency equals 41Hz. So, next I will calculate the relative mean residual between the filtered and raw data, which is why I needed to save the two signals. Essentially, the force plate was built because its a lot more portable than the treadmill and to figure out exactly how to calculate the cutoff frequency. Once, I bring the treadmill to the lab I will have to do this process over because I have built a different force plate into the structure of the treadmill.

 

I think I understand what you are saying though, by not needing to write both the raw and filtered signal to file. Rather, write just the raw signal to file and then run the raw signal through the filter to get the filtered signal during the analysis. But, correct me if I am wrong.

 

 

 

0 Kudos
Message 9 of 14
(5,997 Views)

I have figured out how to write both the raw and filtered signal to file, but I cannot figure out how get a time stamp in my tdms file. Any help would be greatly appreciated!

 

 

0 Kudos
Message 10 of 14
(5,981 Views)