# Filter Design for Phase Response

How can I design an all pass filter to have a constant phase shift over a bandwidth centered around a carrier? I don't care about phase shift outside the band. I would like to have the filter in time domain. This is not a straightforward job right? Any keywords, design methods, external links are appreciated.

Edit: i need it to be causal. Data comes in real time in time frames. thanks

• I don't think it's possible to build a causal filter that has a constant phase shift over some bandwidth. That would imply a filter that has zero time delay through the filter. I think you should rephrase your question. Do you mean "constant phase shift" or "constant group delay"? Dec 18 '15 at 13:46
• It can be done. It's like designing a Hilbert transformer, you just need to add some delay. So you'll get an (approximately) constant phase shift plus a constant delay. The latter is usually no problem as long as the delay isn't excessive. Dec 18 '15 at 14:08
• @RichardLyons: Another of your misconceptions, sorry: a constant phase shift does NOT mean zero time delay. A filter with a constant phase shift $\theta$ (i.e. its frequency response is $e^{-j\theta}$ for $\omega>0$) produces an output $\sin(\omega_0t-\theta)$ for an input signal $\sin(\omega_0t)$. What's the delay? You got it, it is $\theta/\omega_0\neq 0$! Dec 20 '15 at 19:39

It's instructive to see what an ideal filter adding a constant phase shift would look like. If $\theta$ is the desired phase shift, the corresponding ideal frequency response is

$$H(e^{j\omega})=\begin{cases}e^{-j\theta}&,\quad 0<\omega<\pi\\ e^{j\theta}&,\quad-\pi<\omega<0\end{cases}\tag{1}$$

Using the sign function $\text{sign}(\omega)$, the frequency response $(1)$ can be rewritten as

$$H(e^{j\omega})=\cos\theta-j\,\text{sign}(\omega)\sin\theta,\quad -\pi<\omega <\pi\tag{2}$$

With the DTFT correspondence

$$-j\,\text{sign}(\omega)\Longleftrightarrow g[n]=\begin{cases}\frac{2}{\pi n},&\quad n\text{ odd}\\ 0,&\quad n\text{ even}\end{cases}\tag{3}$$

the impulse response corresponding to $H(e^{j\omega})$ is given by

$$h[n]=\cos\theta\cdot\delta[n]+\sin\theta\cdot g[n]\tag{4}$$

where $g[n]$ is the sequence on the right-hand side of Eq. $(3)$, which is the impulse response of an ideal discrete-time Hilbert transformer. Eq. $(4)$ shows that an ideal phase shifter can be implemented as a weighted parallel connection of a wire ($\cos\theta\cdot\delta[n]$) and a Hilbert transformer.

So your problem can be solved by using any of the many available designs of discrete-time Hilbert transformers. Note that you can get much better performance for a given filter order by taking into account that the approximation needs only be accurate in the given frequency band. For a frequency-domain design method this just means that in the formulation of the desired response given in $(1)$ you replace the positive frequencies by the frequency interval of interest and leave the rest as a "don't care" region. The same is done for the negative frequencies.

• Matt L.: I'm definitely interested in learning about a causal digital filter that has a constant phase response over some portion of its passband. But I'm having trouble understanding what a "weighted parallel connection of a wire" is. Is there any chance you can give us a numerical example of your above h[n] impulse response? That is, can you give us the actual numerical values of an example h[n] sequence? Dec 19 '15 at 11:29
• @RichardLyons: Finally you want to learn! A good start would be to read sentences till the end: "... weighted parallel connection of a wire (...) AND a Hilbert transformer." And concerning filters with a constant phase shift, please also read my comment to above question: you can approximate a constant phase shift as closely as you like, but of course you'll need to add some delay, which is usually no problem. You should know what a Hilbert transformer is, and that it implements a constant phase shift (plus some delay); nothing magic about it. Dec 20 '15 at 19:27