DSPRelated.com
Forums

Time varying phase correction

Started by Frank McDermott August 24, 2011
On Aug 25, 10:44&#4294967295;am, Frank McDermott <frankjosephmcderm...@gmail.com>
wrote:
> Thanks for the suggestions guys. > > I feel pretty dumb for not thinking of Vladimir's suggestion. I probably thought doing multiple cross-correlations would slow things down immensely since it seems to be the bottleneck with regards to computation currently. &#4294967295; > > Glen is right that I think I'd have to do more than just split the data set since it seems for some worst case scenarios the data can shift +1, -1, and then back to +1 over the course of a data set. &#4294967295;Out of 100 datasets, the worst case scenario was a 5 sample drift. &#4294967295;However if you overlay all datasets you can see the drift is about a definitive mean which makes me think Tim's idea of referencing to an ideal carrier is a good one (did you suggest this idea in another post? I think I read it somewhere on comp.dsp and thought it sounded like a good idea). > > I am wondering about re-sampling now. &#4294967295;This touches on the questions of accuracy that mnentwig brought up. &#4294967295;The datasets are actually sampled equally with respect to optical frequency (the clock signal that drives the ADC is generated from a reference interferometer). &#4294967295;The data sets are FFT'd, window'ed about the carrier, and then iFFT'd to extract certain parameters. &#4294967295;Would all resampling have to occur at integer multiples of the sampling frequency? &#4294967295;What sort of noise addition would I expect from the interpolation? > > -Frank
Your resampling factor doesn't need to be an integer; there are efficient fractional resampling methods available. If you can express the resampling factor as a rational number, you can use an integer- ratio interpolator followed by a decimator, which can be implemented efficiently using a polyphase structure. If you need an arbitrary (i.e. not easily expressed as rational) resampling ratio, you could take a look at polynomial interpolation (see Gardner, "Interpolation in Digital Modems, Part I"). Jason
I've managed to use the suggested idea of sub-dividing my data sets up and doing the cross correlation between the sub-sets.  This accurately identifies the time dependent phase shift.  After identification I then minimize the number of shifts by grouping neighbouring subsets with equal shifts.

(As an aside: this method still seams a bit kludgy - determining the correct number of subdivisions seems to be based on trial and error - would it be possible to derive this information from the difference of the hilbert transform of the two signals?)

I naively thought I'd be able to then shift each subdivision individually (by the method mentioned above , ifft(fft(Dsub)*exp(i*2*pi*tsub))))  and then bring them back together in the time domain, however this results in phase discontinuities that show up in the final data analysis (the data is windowed about the carrier and phase is derived to find group delay and these discontinuities show up as sinc like impulses at the edges of the shifted subsets.

Would resampling mitigate these discontinuities? 
My DSP knowledge is severely lacking and I don't understand how I would go about using the time dependent shifts I've determined and use that to resample.   I thought resampling would only fix a constant phase shift.

-Frank
in a nutshell, resampling recreates a continuous waveform, making some
assumptions. You can then resample the continuous-time waveform wherever
you like, even go backwards.

Try the piece of code here
http://www.dsprelated.com/showcode/208.php
- put your dataset into inData, a row vector
- the number of samples doesn't change, set nIn = nOut = size(inData, 2)
- set outTimeAtInput to the resampling locations in your dataset. Putting
1:nIn there should give the input vector unchanged as a first test.
- use an odd order, between 5(use this first) to 11
- note, it wraps around. Use zero padding, if that's a problem.

BTW, from a numerical point of view, the code snippet can be improved by
using the Horner scheme and the zeros of the polynomials instead of
multiplying it out ("conv"). 
It doesn't really matter, but if I had to rewrite it in C or the like, I'd
do it differently.

If the interpolation accuracy remains the bottleneck at order 11 (I doubt
it), a polyphase filter will do a better job. If the timing estimate is
accurate, of course.
Hello,

you could try the following program, Octave or Matlab:
http://www.dsprelated.com/blogimages/MarkusNentwig/comp.dsp/slowJitterComp.m

what it does is
- estimate the timing error at each positive zero crossing in signal and
reference
- interpolate the "correct" sampling time for each sample
- then interpolate the input signal at the interpolated sampling time

I'm getting typical errors around -35 dB, maybe this is already enough.

Apparently, timing error estimation is the limiting factor.
Plenty of room for improvement, though.
Thanks for all the help Markus.
I've gotten some good results with the first code you posted.  One thing I've noticed is that there is a timing offset that depends on the order, but once that is taken into account it works well. 

My current method does a number of overlapping subset cross-correlations of the data sets to find the time dependent subsample phase shifts.  These shifts are fit with a polynomial and that is then used for the Lagrange interpolation re-sampling. 

Currently this works well up to a number of datasets but then when a data set that comes along with a large amount of phase drift the method can warp the dataset markedly which then warps future datasets and this warping accumulates till the data is worse than if I didn't compensate for the phase drift.  This points to needing to do comparison with an ideal reference as Tim suggested.

I'll check out the code you just posted.  Thanks again for the help, the papers you cited in the first code helped me fill some large gaps in my knowledge.

-Frank