LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Spotting discontinuities in digitally sampled periodic data

Hi,

 

What would be the best approach in order to find discontinuities in periodic data.

 

My input data is a block of output values from an ADC on a PCB to be tested, and there may be a step change in frequency mid-way through the sample.  I want to be able to find where this step change occurs in order to be able to break the sample up for analysis.

 

For example, a possible input could look like the attached text file.  This is the output of a logic analyser connected to the output of the ADC.  In this case, the block is 8192 samples long, and the frequency discontinuity occurs between samples 4095 and 4096.  See the attached PNG for a graphical representation of this.

 

Can anybody recommend the best approach in order to programmatically determine where the discontinuity lies?

 

Cheers,

Dan

 

Message Edited by DanB1983 on 09-02-2009 04:06 AM
Dan
CLD
Download All
0 Kudos
Message 1 of 8
(3,682 Views)

Hi there

 

In case the signal has a periodical shape (*) before and after the discontinuity i suggest this:

 

- take a moving subset of the data with constant number of elements, e.g. 256 samples where the first element moves with i x 128 samples

- apply a hanning window to the subset

- create the power spectrum of the subset

- calculate the standard deviation between power spectrum i and power spectrum i+1

- find max of standard deviation

 

By doing so you'll find the two consecutive subsets where the difference between the frequency spectrums is at a maximum. This will be the subsets where the switch to the next periodical subsignal (*) takes place.

Best regards
chris

CL(A)Dly bending G-Force with LabVIEW

famous last words: "oh my god, it is full of stars!"
0 Kudos
Message 2 of 8
(3,657 Views)

No replies yet, so a quick update on what I've tried so far.

 

See the attached VIs - a bit klugey, but they serve their purpose.

 

This reads the text file in (using subVI "text file reader 3"), and extracts the 8192 samples and puts them in a 1D array of length 8192.

 

In an attempt to search for the location of the discontinuity, it splits the block of 8192 samples up into an integer number of smaller blocks - in this case 128 blocks, each with a of length 64 samples.

 

It then carries out an FFT on each of these smaller blocks, and uses the peak detector block to find the fundamental frequency bin of each of the smaller blocks.  In this way, we can know to the nearest 128 samples where the discontinuity occurs.

 

It would then be my intention to split the larger array up, simply discarding the 128 samples that contain the discontinuity, and carrying out further analysis on the remaining arrays either side.

 

Some notes:

 

The delay inside the 'for' loop is deliberately long, to illustrate the FFTs being carried out on each of the smaller blocks of samples.

 

By splitting into these smaller blocks, I lose frequency resolution.  With the original 8192 samples, I could resolve to fs/4096 = 102.4MHz/4096 = 25kHz.  However, with the block size of 64, I can only resolve to 3200kHz.  Therefore if the discontinuity in frequency is less that 3200kHz, I will not find it.  This is the trade off between frequency resolution and "sample resolution".

 

 

Dan
CLD
Download All
0 Kudos
Message 3 of 8
(3,655 Views)

Chris,

 

I hadn't seen your reply when I last posted.

 

I will try your approach.

 

However, I will still have the issue of reduced frequency resolution within the smaller block size.

 

Dan

Dan
CLD
0 Kudos
Message 4 of 8
(3,652 Views)
If you use the phase instead of amplitude it seems to work even better. See attachment.
Best regards
chris

CL(A)Dly bending G-Force with LabVIEW

famous last words: "oh my god, it is full of stars!"
Message 5 of 8
(3,638 Views)

Thanks for that.

 

Yes I agree, the phase approach gives a much clearer peak than the amplitude approach (in this case).

 

It might not always be the case - what springs to my mind is if the frequency discontinuity looked more like the change in frequencies in a modulated FSK signal http://en.wikipedia.org/wiki/File:Fsk.svg (i.e. no phase discontinuity). 

 

That's for another day though!

 

I appreciate your help.

 

 

Dan
CLD
0 Kudos
Message 6 of 8
(3,618 Views)

DanB,

 

Your original image also looks suspiciously undersampled at the higher frequency.  Does your sampling rate meet the Nyquist criterion for the higher frequency?

 

You could zero pad your subsets to recover the frequency resolution. Padding to 8192 would get back to the 25 Hz resolution.  Since the original sampling supported that, you are not "getting something for nothing."  Put 4032 zeros in front of the 128 samples and 4032 after the samples.  This is equivalent to rectangular windowing so there will be some spectral leakage.

 

When I tried the zero padding, I see the amplitude of bin number ~3600 jump up when the high frequency signal appears. 

 

Lynn 

Message 7 of 8
(3,603 Views)

Lynn,

 

Yes, you are right - in fact both signals are deliberately undersampled.

 

I use a sampling rate of 102.4MS/sec, and I know my intermediate freq (i.e. the input to the ADC) will always lie between 108MHz and 148MHz, so it is trivial to translate the output of the ADC from the 1st Nyquist zone up to the 3rd Nyq zone.

 

As for zero padding - yes, good idea.  I will investigate its effectiveness.

 

Dan

Dan
CLD
0 Kudos
Message 8 of 8
(3,598 Views)