Mixer math#

Up-conversion#

iq_mixer

At the I and Q ports of the up-conversion mixer we have signals \(I(t)\) and \(Q(t)\) at frequency \(\omega_S\):

\[\begin{split} I(t) &= X_I \cos(\omega_S t) - Y_I \sin(\omega_S t) \\ &= A_I \cos(\omega_S t + \phi_I) \\ Q(t) &= X_Q \cos(\omega_S t) - Y_Q \sin(\omega_S t) \\ &= A_Q \cos(\omega_S t + \phi_Q)\end{split}\]

where the following identities hold:

(1)#\[\begin{split} \begin{cases} A &= \sqrt{X^2 + Y^2} \\ \phi &= \operatorname{atan2}(Y, X) \end{cases} \qquad \begin{cases} X &= A \cos{\phi} \\ Y &= A \sin{\phi} \end{cases}\end{split}\]

At the R port of the mixer, assuming a carrier frequency \(\omega_N\) and zero phase, we get:

\[ R(t) = I(t) \cos(\omega_N t) - Q(t) \sin(\omega_N t)\]

where the minus sign is a convention. Expanding and rearranging, we get:

(2)#\[\begin{split} R(t) &= R_L(t) + R_U(t) \\ R_L(t) &= \frac{1}{2}(X_I + Y_Q) \cos[(\omega_N -\omega_S)t] -\frac{1}{2}(X_Q - Y_I) \sin[(\omega_N -\omega_S)t] \\ R_U(t) &= \frac{1}{2}(X_I - Y_Q) \cos[(\omega_N +\omega_S)t] -\frac{1}{2}(X_Q + Y_I) \sin[(\omega_N +\omega_S)t]\end{split}\]

where \(R_L\) and \(R_U\) are the lower and upper sidebands, respectively.

Zero intermediate frequency#

When \(\omega_S = 0\), at the I and Q ports of the mixer we get:

\[\begin{split} I(t) &= X_I = A_I \cos{\phi_I} \\ Q(t) &= X_Q = A_Q \cos{\phi_Q}\end{split}\]

At the R port:

\[\begin{split} R(t) &= X_I \cos(\omega_N t) -X_Q \sin(\omega_N t) \\ &= A_I \cos{\phi_I} \cos(\omega_N t) -A_Q \cos{\phi_Q} \sin(\omega_N t)\end{split}\]

Special case: same amplitude, same phase#

Choosing \(A_I = A_Q = A\) and \(\phi_I = \phi_Q = \phi\) we get:

\[\begin{split} R(t) &= A \cos{\phi} \cos(\omega_N t) -A \cos{\phi} \sin(\omega_N t) \\ &= \sqrt{2} A \cos{\phi} \cos(\omega_N t + \pi / 4 )\end{split}\]

and a total amplitude \(|R| = \sqrt{2}A|\cos{\phi}|\). Note that the total phase is \(\pi/4\), independent of \(\phi\) (for \(\phi \in [-\frac{\pi}{2},+\frac{\pi}{2}]\), otherwise there’s a sign change).

Some notable cases:

\(\phi\)

\(|R| \; / \; \sqrt{2}A\)

\(0\)

\(1\)

\(\pi/6\)

\(\sqrt{3} / 2\)

\(\pi/4\)

\(1 / \sqrt{2}\)

\(\pi/3\)

\(1 / 2\)

\(\pi/2\)

\(0\)

Special case: same amplitude, \(\pi/2\) phase difference#

Choosing \(A_I = A_Q = A\), \(\phi_I = \phi\) and \(\phi_Q = \phi \mp \pi/2\) we get:

\[\begin{split} R(t) &= A \cos{\phi} \cos(\omega_N t) \mp A \sin{\phi} \sin(\omega_N t) \\ &= A \cos(\omega_N \pm \phi)\end{split}\]

and a total phase \(\pm\phi\), and amplitude \(|R| = A\) independent of \(\phi\). Note the inversion from \(\mp\) to \(\pm\).

Single-sideband modulation (SSB)#

Quick reference

To perform single-sideband modulation, set \(\phi_I\) to whatever you want and:

  • \(\phi_Q = \phi_I + \pi/2\) for lower sideband (LSB);

  • \(\phi_Q = \phi_I - \pi/2\) for upper sideband (USB).

Lower sideband (LSB)#

To get \(R_U=0\) in Eq. (2), we want

(3)#\[\begin{split}\begin{cases} X_I - Y_Q &= 0 \\ X_Q + Y_I &= 0 \end{cases}\end{split}\]

Then \(I(t)\) and \(Q(t)\) should have the same amplitude

\[ A_I^2 = X_I^2 + Y_I^2 = Y_Q^2 + (-X_Q)^2 = A_Q^2\]

let’s call the amplitude \(A\). We can rewrite Eq. (3) as

\[\begin{split} \begin{cases} \cos{\phi_I} &= +\sin{\phi_Q} \\ \cos{\phi_Q} &= -\sin{\phi_I} \end{cases}\end{split}\]

which is solved by \(\phi_Q = \phi_I + \pi/2\).

Substituting into \(R_L(t)\) from Eq. (2) we get:

\[\begin{split} R_L(t) &= X_I \cos[(\omega_N -\omega_S)t] + Y_I \sin[(\omega_N -\omega_S)t] \\ &= A \cos{\phi} \cos[(\omega_N -\omega_S)t] + A \sin{\phi} \sin[(\omega_N -\omega_S)t] \\ &= A \cos[(\omega_N -\omega_S)t - \phi ]\end{split}\]

Upper sideband (USB)#

Analogous to the previous section. To get \(R_L=0\) in Eq. (2), we want

(4)#\[\begin{split}\begin{cases} X_I + Y_Q &= 0 \\ X_Q - Y_I &= 0 \end{cases}\end{split}\]

Then \(I(t)\) and \(Q(t)\) should have the same amplitude

\[ A_I^2 = X_I^2 + Y_I^2 = (-Y_Q)^2 + X_Q^2 = A_Q^2\]

let’s call the amplitude \(A\). We can rewrite Eq. (4) as

\[\begin{split} \begin{cases} \cos{\phi_I} &= -\sin{\phi_Q} \\ \cos{\phi_Q} &= +\sin{\phi_I} \end{cases}\end{split}\]

which is solved by \(\phi_Q = \phi_I - \pi/2\).

Substituting into \(R_U(t)\) from Eq. (2) we get:

\[\begin{split} R_U(t) &= X_I \cos[(\omega_N +\omega_S)t] -Y_I \sin[(\omega_N +\omega_S)t] \\ &= A \cos{\phi} \cos[(\omega_N +\omega_S)t] -A \sin{\phi} \sin[(\omega_N +\omega_S)t] \\ &= A \cos[(\omega_N +\omega_S)t + \phi ]\end{split}\]

Down-conversion#

General case#

At the R port of the mixer, we have an incoming signal \(R(t)\) at frequency \(\omega_R\):

\[\begin{split} R(t) &= X_R \cos(\omega_R t) - Y_R \sin(\omega_R t) \\ &= A_R \cos(\omega_R t + \phi_R)\end{split}\]

where the identities of Eq. (1) hold.

At the I and Q ports of the down-conversion mixer we get the signals \(I(t)\) and \(Q(t)\), assuming a carrier frequency \(\omega_N\) and zero phase:

\[\begin{split} I(t) &= +R(t) \cos(\omega_N t) \\ Q(t) &= -R(t) \sin(\omega_N t)\end{split}\]

where the minus sign is a convention. Expanding and rearranging, we get:

\[\begin{split} 2I(t) &= X_R \cos[(\omega_R -\omega_N)t] - Y_R \sin[(\omega_R -\omega_N)t] \\ &= A_R \cos[(\omega_R -\omega_N)t + \phi_R] \\ 2Q(t) &= Y_R \cos[(\omega_R -\omega_N)t] + X_R \sin[(\omega_R -\omega_N)t] \\ &= A_R \cos[(\omega_R -\omega_N)t + \phi_R - \frac{\pi}{2}]\end{split}\]

where we have omitted high-frequency components at frequency \(\omega_R+\omega_N\). See the section Spurs in down-conversion below for a complete analysis of those spurious components.

Zero intermediate frequency#

In the special case when the incoming RF signal and down-conversion carrier have the same frequency \(\omega_R = \omega_N\), the I and Q ports of the mixer output the two quadratures of the original baseband signal:

\[\begin{split} I(t) &= \frac{1}{2} X_R = \frac{1}{2} A_R \cos{\phi_R} \\ Q(t) &= \frac{1}{2} Y_R = \frac{1}{2} A_R \sin{\phi_R}\end{split}\]

Single-sideband modulation (SSB)#

The incoming RF signal \(R(t)\) could contain a lower \(R_L\) and an upper \(R_U\) sideband:

\[\begin{split} R(t) &= R_L(t) + R_U(t) \\ R_L(t) &= X_L \cos[(\omega_N -\omega_S)t] -Y_L \sin[(\omega_N -\omega_S)t] \\ R_U(t) &= X_U \cos[(\omega_N +\omega_S)t] -Y_U \sin[(\omega_N +\omega_S)t]\end{split}\]

where the sidebands are offset by \(\omega_S\) from the central carrier at frequency \(\omega_N\). Typically we have that \(\omega_S \ll \omega_N\).

After demodulation in the IQ mixer with a carrier at frequency \(\omega_N\), we get at the I and Q ports:

(5)#\[\begin{split} 2I(t) &= (X_L + X_U) \cos(\omega_S t) - (Y_U - Y_L) \sin(\omega_S t) \\ 2Q(t) &= (Y_L + Y_U) \cos(\omega_S t) - (X_L - X_U) \sin(\omega_S t)\end{split}\]

where we have neglected high-frequency terms at \(2\omega_N \pm \omega_S\).

Eq. (5) can be summarized in terms of the X and Y quadratures of the measured signals at the I and Q ports:

(6)#\[\begin{split} \begin{cases} X_I &= \frac{1}{2} (X_L + X_U) \\ Y_I &= \frac{1}{2} (Y_U - Y_L) \\ X_Q &= \frac{1}{2} (Y_L + Y_U) \\ Y_Q &= \frac{1}{2} (X_L - X_U) \end{cases}\end{split}\]

Finally, we can invert Eq. (6) to obtain the X and Y quadratures of the incoming RF signal:

(7)#\[\begin{split} \begin{cases} X_L &= X_I + Y_Q \\ Y_L &= X_Q - Y_I \\ X_U &= X_I - Y_Q \\ Y_U &= X_Q + Y_I \end{cases}\end{split}\]

The utility function utils.untwist_downconversion() uses the relations in Eq. (7) to calculate the original upper and lower sidebands from the measured I and Q signals.

Spurs in down-conversion#

We described in the previous section Down-conversion how the down-conversion process generates low-frequency components at frequency \(\omega_R - \omega_N\), where \(\omega_R\) is the frequency of the incoming RF signal and \(\omega_N\) is the frequency of the down-converting carrier generator. These components are output from the I and Q ports, and we’ll call them \(I_{diff}(t)\) and \(Q_{diff}(t)\).

However, the down-conversion process generates also high-frequency components at frequency \(\omega_R + \omega_N\), which we’ll call \(I_{sum}(t)\) and \(Q_{sum}(t)\) and can be viewed as spurious signals. Overall, we have that \(I(t) = I_{diff} + I_{sum}\) and \(Q(t) = Q_{diff} + Q_{sum}\). In the previous section we neglected the high-frequency components, so we had assumed \(I(t) \approx I_{diff}\) and \(Q(t) \approx Q_{diff}\).

Typically, we select a carrier frequency very close to the signal frequency, i.e. \(\omega_R-\omega_N \ll \omega_R+\omega_N\), so \(I_{diff}\) and \(I_{sum}\) are very far apart in frequency space. In external, analog frequency down-conversion with IQ mixers and local oscillators the terms \(I_{sum}\) and \(Q_{sum}\) at frequency \(\omega_R+\omega_N\) fall outside the analog bandwidth of the I and Q ports of the mixer and are heavily attenuated, so are usually negligible. In Presto, however, the frequency down-conversion happens in the digital domain and therefore the terms at \(\omega_R+\omega_N\) are not attenuated: \(I_{sum}\) and \(Q_{sum}\) are still present in the data, and are possibly aliased down to a lower frequency.

In this section, we will rewrite the Down-conversion equations without neglecting the high-frequency spurious terms.

General case#

At the R port of the mixer, we have an incoming signal \(R(t)\) at frequency \(\omega_R\):

\[\begin{split} R(t) &= X_R \cos(\omega_R t) - Y_R \sin(\omega_R t) \\ &= A_R \cos(\omega_R t + \phi_R)\end{split}\]

At the I and Q ports of the down-conversion mixer we get the signals \(I(t)\) and \(Q(t)\), assuming a carrier frequency \(\omega_N\) and zero phase:

\[\begin{split} I(t) &= +R(t) \cos(\omega_N t) \\ Q(t) &= -R(t) \sin(\omega_N t)\end{split}\]

where the minus sign is a convention. Expanding and rearranging, we get:

\[\begin{split} I(t) &= I_{diff}(t) + I_{sum}(t) \\ 2I_{diff}(t) &= X_R \cos[(\omega_R -\omega_N)t] - Y_R \sin[(\omega_R -\omega_N)t] \\ &= A_R \cos[(\omega_R -\omega_N)t + \phi_R] \\ 2I_{sum}(t) &= X_R \cos[(\omega_R +\omega_N)t] - Y_R \sin[(\omega_R +\omega_N)t] \\ &= A_R \cos[(\omega_R +\omega_N)t + \phi_R]\end{split}\]

Similarly, for \(Q(t)\) we get:

\[\begin{split} Q(t) &= Q_{diff}(t) + Q_{sum}(t) \\ 2Q_{diff}(t) &= Y_R \cos[(\omega_R -\omega_N)t] + X_R \sin[(\omega_R -\omega_N)t] \\ &= A_R \cos[(\omega_R -\omega_N)t + \phi_R - \frac{\pi}{2}] \\ 2Q_{sum}(t) &= -Y_R \cos[(\omega_R +\omega_N)t] - X_R \sin[(\omega_R +\omega_N)t] \\ &= A_R \cos[(\omega_R +\omega_N)t + \phi_R + \frac{\pi}{2}]\end{split}\]

Zero intermediate frequency#

When \(\omega_R = \omega_N\), at the I and Q ports of the mixer we get:

\[\begin{split} I(t) &= I_{diff}(t) + I_{sum}(t) \\ 2I_{diff}(t) &= X_R = A_R \cos(\phi_R) \\ 2I_{sum}(t) &= X_R \cos(2 \omega_R t) - Y_R \sin(2 \omega_R t) \\ &= A_R \cos(2 \omega_R t + \phi_R)\end{split}\]
\[\begin{split} Q(t) &= Q_{diff}(t) + Q_{sum}(t) \\ 2Q_{diff}(t) &= Y_R = A_R \sin(\phi_R) \\ 2Q_{sum}(t) &= Y_R \cos(2 \omega_R t) - X_R \sin(2 \omega_R t) \\ &= A_R \cos(2 \omega_R t + \phi_R + \frac{\pi}{2})\end{split}\]

Single-sideband modulation (SSB)#

The incoming RF signal \(R(t)\) could contain a lower \(R_L\) and an upper \(R_U\) sideband:

\[\begin{split} R(t) &= R_L(t) + R_U(t) \\ R_L(t) &= X_L \cos[(\omega_N -\omega_S)t] -Y_L \sin[(\omega_N -\omega_S)t] \\ R_U(t) &= X_U \cos[(\omega_N +\omega_S)t] -Y_U \sin[(\omega_N +\omega_S)t]\end{split}\]

After demodulation in the IQ mixer with a carrier at frequency \(\omega_N\), we get at the I and Q ports:

\[\begin{split} I(t) &= I_{diff}(t) + I_{sum}(t) \\ 2I_{diff}(t) &= (X_L + X_U) \cos(\omega_S t) - (Y_U - Y_L) \sin(\omega_S t) \\ 2I_{sum}(t) &= X_L \cos[(2\omega_N-\omega_S) t] - Y_L \sin[(2\omega_N-\omega_S) t] \\ &+ X_U \cos[(2\omega_N+\omega_S) t] - Y_U \sin[(2\omega_N+\omega_S) t]\end{split}\]
\[\begin{split} Q(t) &= Q_{diff}(t) + Q_{sum}(t) \\ 2Q_{diff}(t) &= (Y_L + Y_U) \cos(\omega_S t) - (X_L - X_U) \sin(\omega_S t) \\ 2Q_{sum}(t) &= -Y_L \cos[(2\omega_N-\omega_S) t] - X_L \sin[(2\omega_N-\omega_S) t] \\ &+ -Y_U \cos[(2\omega_N+\omega_S) t] - X_U \sin[(2\omega_N+\omega_S) t]\end{split}\]