Two sinusoidal signals are said to be in quadrature if they have a constant phase difference of 90º. Quadrature signals are widely used in signal processing. A digital quadrature oscillator is just an algorithm that computes the sequence , , or a similar sequence of sinusoids in quadrature. Here is the oscillator frequency in radians per sample. Direct computation of this sequence is very time consuming, because the trigonometric functions have to be evaluated for each sample. Therefore, it is a good idea to use a linear recurrence scheme to compute . Using basic trigonometric identities, we see that

with

However, to actually perform these computations in a digital processor, one has to quantize , meaning that one has to replace by approximations. It is easy to see that if one replaces by some perturbation, then the eigenvalues of are no longer in the unit circle, so the oscillation can grow or decay exponentially and one would need to apply an AGC scheme to keep this method stable.

Here we will look at a new quadrature oscillator by Martin Vicanek that has appeared recently and solves this problem.

Vicanek's idea starts by considering the oscillator for frequency . We write , where is defined as but replacing by and by . We note that , so that if we denote by the recurrence for the original oscillator of frequency , then . Performing the computation, we see that

Vicanek goes on and rewrites the matrix as

where

Actually, this rewriting allows him to reduce the number of multiplications to just 3 (instead of the usual 4) when computing from , but it is also critical for the performance of the method.

Of course, these matrices , and are the same, but what happens when one perturbs is different from what happens when one perturbs or . When studying the stability of these methods, we note that the point where more precision is lost is when computing trigonometric functions. Therefore, we assume on our analysis that are just approximations and that the rest of the operations can be computed exactly.

We will look at real Toeplitz matrices of the form

and see whether the recurrence gives something that can be useful as a quadrature oscillator. A general matrix can be studied in a similar way, but the calculations become more cumbersome. The first condition is that the eigenvalues of have to be in the unit circle, because if not, the recurrence will grow or decay exponentially. Moreover, the eigenvalues cannot be real, because this would only give trivial oscillators with an integer multiple of . The characteristic polynomial of is

Since its zeros are complex conjugates and lie in the unit circle, their product must be 1, so we have

Now we see that the matrices and do not satisfy this condition for general values of . However, satisfies this condition for every .

The zeros of are non-real if and only if its discriminant is negative. Since , this is equivalent to . For the matrix , this translates to the condition , which will satisfied as long as are good approximations, since for their exact values . Moreover, if one computes as , then , which has modulus smaller than as long as .

We denote by and the zeros of . By looking at the coefficient of in , we see that . Let be a (complex) eigenvector such that . This equality implies that

Since and , we see that , so that , because . Multiplying by a suitable scalar, we may assume , so that

(The sign is just for aesthetic reasons in the latter).

Put . Since is real, we have and . Adding these two equalities and dividing by , we get

This implies that the recurrence with gives a quadrature oscillator, because the components of are sinusoids with a constant phase difference of 90º. Similar calculations show that for any initial , the recurrence will also give two sinusoids with a constant phase difference of 90º and amplitudes related by a factor of , so the choice of is not important.

The amplitudes of these two sinusoids are the same if and only if , this is, when . In this case, implies that , so is just the matrix of the rotation of angle . This is really no surprise, because the equality (1) for already defines uniquely, since the vectors and are linearly independent.

In summary, when , , we get and , as we expected. When are just approximations to these values, then is approximately and is approximately .

For many applications, it is important that the amplitudes of the two components of the quadrature oscillator are the same. For instance, if this oscillator is used in a heterodyne mixer, the mixer will exhibit image frequency response if the amplitudes of the two components of the oscillator are not the same. For other applications, this may not be so important. For instance, if the oscillator is used to perform QAM, then a mismatch in the amplitudes will just cause some stretching in the constellation pattern.

In Vicanek's oscillator, if is computed as , then it is easy to check that , so that it will have for whatever choice of . Therefore, it is a good idea to compute in this way and not as , not only to avoid the computation of the trigonometric function, but to ensure that the amplitudes are well matched.

This analysis shows that Vicanek's recurrence , indeed gives a quadrature oscillator of frequency approximately and amplitudes 1 when is approximately and .

We have seen that, to give a good quadrature oscillator, the matrix should be a rotation matrix

even when the parameters that define are perturbed. In the case of Vicanek's oscillator, using the trigonometric identities

we see that has the appropriate form when is computed in terms of , because

One independent way to arrive at this formula for is as follows. Since we know that has to be a rotation matrix as in (2), we want to find real rational functions such that . Then we put and , so that , for some . However, we see that such pair is just a rational parametrization of the algebraic curve , so we are led to the usual choice , .

Another nice thing about Vicanek's oscillator is that it is defined in terms of the tangent function, which satisfies a simple first order differential equation. This implies that if one is doing frequency modulation of the oscillator and the deviation is small, then we may approximate the deviation of the parameter as

Using this approximation, it is not necessary to compute trigonometric functions when the frequency gets updated.

How does Vicanek's oscillator actually perform in numerical simulations? Well, I must say that the results of my tests have been very good.

In one of the tests, I start with (about 70.19Hz at 44100Hz) and run the oscillator for samples (6 hours at 44100Hz). When computing , I introduce a random absolute error of size , and I also introduce an absolute error of in the rest of the computations (including the recursion update). Finally, I take the last samples to analyse. The XY plot of these samples shows that the oscillator maintains a constant amplitude of 1 quite well.

I also compute the FFT of the samples and plot it in dB with the normalization that the constant signal 1 should be 0dB. The plot of Vicanek's oscillator is in blue. The plot in red corresponds to an oscillator computed by evaluating the trigonometric functions at each sample, just for comparison. The first plot shows 2000 bins around the frequency of the oscillator. We can see that the oscillator is slightly wrong in frequency, due to the error on the computation of . However, the error in frequency is actually only 1.35e-5 radians/sample (0.07Hz at 44100Hz). Clearly we are to expect this kind of error with an error of in . We can also see that the phase noise performance of the oscillator is very good.

The second plot shows 2000 bins around the image frequency of the oscillator. The image frequency is just a term for , and the response of the oscillator at this frequency shows to which degree the two components' phases fail to be in quadrature or their amplitudes fail to match. We can see a spike in the response, mainly due to the error in the computation of , but the image response is 100dB down, which is really good.

I have put the MATLAB code for these computations in Gist. I have also played with the parameters, trying different frequencies and errors (also relative error instead of absolute error). As long as the error in each step of the computations is not very large (around is OK in many cases), the oscillator will be stable in frequency and the phase noise will be very good. One can also allow a fairly large error in the computation of , although the image response will not be very good if the error is large. Finally, an error in will just cause an error in frequency of comparable magnitude.

## One Reply to “A look at a new digital quadrature oscillator”