Wednesday, November 5, 2014

Phase Delay and Group Delay


One benefit of having used OneNote for around a year is that it can be referenced pretty easily for blog post ideas.  Today I'll be writing about phase and group delay through filters

I was looking into making a fractional delay filter at work the other day, and thought it was useful to have some pictures about what phase delay and group delay was.

Wikipedia defines phase delay as the time delay of the phase, where group delay is the time delay of the amplitude envelope.

A nearby textbook defines it as the difference in phase, at a particular frequency,  between an input sinusoidal and the output sinusoidal.

Make sense? Eh. Maybe. Let's make it more complicated before looking at pictures

In FIR filters, group / phase delay is a function of the sampling time and the number of taps:

   group delay = (S-1)*ts/2, where S is the number of taps

Group Delay is also the negative derivative of the phase delay

Let's look at an example:
    I've created a filter in Octave with the signal processing package, coeff=fir1(42,.5).  The frequency response is as follows:


Frequency Response



Paying attention to the phase response, we see it is linear.  An FIR filter if I've ever seen one!

So if I create a 15MHz sine wave sampled at 100MHz........with a ts of 1/100e6=0.01us


Input 15MHz @ 100MHz sampling

Based on the phase response above, 15MHz/50MHz=.3, and at .3 on the phase response gives a 1000 degree phase delay at 15MHz.   


Signal Output

Looking at this picture, we see that there is now ~21 sample delay from the first peak of the input signal to the peak of the output signal, or relative to the output signal, the input signal has processed ~3 360 degree cycles, or ~1000 degrees of phase delay.

Group delay wise, at fractional frequency .4, it looks like we're at ~-1500 degrees. This gives a slope of -3750 degrees per fractional frequency, or -65.43 radians per fractional frequency. Going back to the equation of a line,

           radians = -65.43 (radians / fractional frequency) * (fractional frequency wrt pi radians)

We end up with an extra pi element that needs to be divided out to get rid of radians and scaling for sampling time to get units of time.  This makes the group delay of -(-65.43/3.1415*ts) = .20833us for this filter.  Since the sampling frequency is 100MHz, the sampling time is .01us, a 21 sample delay = .21us.  

This also matches the formula above, of (42-1)*ts/2 giving a group delay of .205us