LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Labview, how to buffer blocks of external data

I am using redpitaya for data acquisition, its buffer has 16348 samples but I need more to do a high precision FFT , therefore I would need a buffer in Labview for about 800 thousand samples, therefore I need to append the blocks I am receiving from the redpitaya but there is a distortion between blocks, is any function in Labview that may help me to properly align the end of a block with the beginning of the next?

 

thanks

0 Kudos
Message 1 of 8
(194 Views)
Highlighted

Hi tecno,

 

basic LabVIEW knowledge: use BuildArray to concatenate arrays.

 

(When you know the needed size of your data before reading them from your RedPitaya then you could also InitArray of desired size and use ReplaceArraySubset to fill in those samples at the right place…)

Best regards,
GerdW
CLAD expired, using 2009SP1 + LV2011SP1 + LV2017 (+LV2018 sometimes) on Win7+cRIO
Kudos are welcome Smiley Wink

Message 2 of 8
(113 Views)

Hi GerdW:

 

I think the problem I have will not be solved with BuildArray, lets say we are sampling a 10 Khz sine wave, the end of the block of 16384 samples will not coincide with the beginning of the next block, it will make a distortion, and depending on the frequency a big spike, there is a pic attached, you can see at the beginning the amplitude is 0.45 and at the end is -0.45, if you change frequency the amplitudes are different

 

Thanks

0 Kudos
Message 3 of 8
(88 Views)

What do you know about your blocks of samples?  Is it correct to assume that, within a block, the time difference between successive samples is the same?  In other words, within a block, there is a constant sampling frequency?

 

What (if anything) do you know about the spacing between blocks of samples?  Those of us who sample using LabVIEW and modern A/D hardware are used to "continuous" sampling, where the time between the last sample of a block and the first sample of the next block is exactly the same as the time between any other successive samples.  This makes it easy to combine 100 16,384 arrays of data into a continuous 1,638,400 array of samples, with no gaps.

 

If you do have gaps of known size (say 100 samples), a not-unreasonable thing to do would be to create an intermediate array of 16,484 samples, with the last 100 being a constant.  When you do the FFT, you'll get a spike corresponding to the equally-spaced constant bits, but you can filter this out.

 

Best, of course, is to get rid of the gaps.  Can your hardware do that?

 

Bob Schor

0 Kudos
Message 4 of 8
(82 Views)

@tecno404 wrote:

I am using redpitaya for data acquisition, its buffer has 16348 samples but I need more to do a high precision FFT ,


Sigh.  I need to learn to read the Original Post more carefully!  What do you mean by a "high precision FFT"?  Do you want a better estimate of the amplitude and phase of a particular frequency, do you want a wider range of frequencies (particularly at the low frequency end), or do you want to distinguish the spectrum difference between two closely spaced frequencies?

 

If you keep the sampling rate the same and simply lengthen your sample size (say from 16384, 2^14, to 2^18, this will change the low frequency end of your Spectrum. 

 

If you think that your signal is relatively stationary (i.e. the spectrum does not change much as a function of time), you can improve the estimate of your spectrum by taking repeated blocks of 16384 and averaging them.  It helps, of course, if they are "adjacent" blocks, as this will give them a known phase with respect to the other blocks.  

 

If your blocks are not adjacent, but you know the spacing accurately, you can use this information to adjust the phase offsets.  If you don't know the spacing, you might be able to "work backwards" and, assuming the spectrum remains stationary (or near-stationary), work out what offset value would produce the overall smallest phase shift.

 

This is an interesting question/problem, and (I hope) it could serve as a "teachable moment" to understand Signals and their Spectra better.

 

Bob Schor

 

0 Kudos
Message 5 of 8
(67 Views)

Bob:

 

Yes, the sampling frequency is the same within a block, I am guessing the spacing between blocks is almost the same, I don't have continuous sampling, it is block by block, I will try the intermediate array.

 

Thanks for your interest

0 Kudos
Message 6 of 8
(52 Views)

Bob:

 

thanks for your long email, I want to distinguish between two closed frequencies and I agree with you this is a teachable moment on the FFT and spectrum, very interesting.

 

 

Thanks and Best regards

0 Kudos
Message 7 of 8
(49 Views)

Here's a "hand-waving" way to understand how Spectrum is related to Sampling:

  • Assume you sample at frequency fs ("frequency of sampling") for a total length of time T.
  • If N is the number of samples you took at frequency fs for time T, then fs = N/T (because "samples-per-second" = samples (N) per (/) second (T).  Alternatively, N = fs * T.
  • The lowest frequency you can measure is one cycle that occupies the entire sampling interval T, or 1/T.
  • The highest frequency you can measure is when the points alternate high, low, high, low.  Since you need at least two points (a high and a low) to determine that "something happened), you can resolve N/2 waves in your sample of time T for a frequency of (N/2) / T = fs/2, half the sampling frequency.  Does the name "Nyquist" ring any bells?  

Bob Schor

  • When you compute a spectrum (say, by doing an FFT), you start with N data points, but get "only" N/2 Frequency components going from 1/T to (N/2)/T, 1/T to fs/2.  What happened to the other data?  Well, each "point" of the spectrum has two values, often called "amplitude" and "phase".  [Here comes a bad pun]  If this seems a little Complex, just accept it for the time being, and trust that the Math will work out.

 

0 Kudos
Message 8 of 8
(30 Views)