tl;dr - At the bottom of this page you can find scripts for calibrating a mixer for imbalances. The mathmatical model explaining the IQ imbalances that can be found here is mostly based on: [Calibration of mixer amplitude and phase imbalance in superconducting circuits][https://aip.scitation.org/doi/full/10.1063/5.0025836]
Suppose we have a local oscillator (LO) with a frequency of , it can be described as:
When we pass it through an ideal IQ mixer, the output will be:
With is defined according to the inputs at the I & Q ports:
Example: : It is common have and . This makes and:
As can be seen, applying a Cosine & Sine at the I & Q ports will shift the frequency of the LO and add a phase.
Rewriting the equation, and assuming , we get write:
In the frequency domain we can write it in matrix form:
Where . Note that generally speaking, this creates two sidebands at the two sides of . We will treat the upper sideband as the signal, and the lower as the image, which can be removed by a proper choice of . Note that represent the signal while represents the image.
Example: : Looking back at the previous example (without the phase):
The choice above removed the image sideband and kept only the signal sideband.
The math we described above arise from the mixing of two branches:
- The signal at the I port is multiplied by the cosine of the LO
- The signal at the Q port is multiplied by the sine of the LO
In an ideal mixer, it is assumed that these two branches are identical both in amplitude and in phase. When the mixer is not ideal this can be modeled as:
Where and are the relative amplitude and phase mismatch between the two branches. Note that and restore the ideal mixer equation.
In addition to the branches' imbalance, non-ideal mixers also have LO leakage which can be modeled as:
In the frequency domain, this takes the form of:
With and .
Note that the non-ideal mixer will have leakage terms at and at the image sideband. Adding a constant term to can cancel the LO leakage term. Applying the appropriate gain and phase offsets to the I & Q channels can remove the image term.
The notation so far was best for having an intuitive understanding of the effects of imbalance. However, it is easier to follow a slightly different notation, for the actual correction. We will treat the imbalance as having a symmetric effect directly on the I & Q inputs, such that:
With and being the amplitude and phase imbalances. In order to correct the imbalance, we need to multiply by a correction matrix that will cancel the imbalance matrix. The correction matrix can be calculated by taking the inverse of the imbalance matrix:
While the matrix has four elements, it is only dependent on the two imbalance parameters. There is a function named 'IQ_imbalance_correction' which takes these two parameters and calculates the above matrix.
The ideal behavior of an IQ mixer used for down-conversion is:
With is defined according to the inputs at the I & Q ports according to:
Where 'LPF' indicates a Low Pass Filter. The imbalance comes similarly:
Looking again in the frequency domain, we can write:
With and . Where . is the contribution from the signal which, in an ideal mixer, would have gone strictly to . is the contribution from the image which, in an ideal mixer, would have gone strictly to .
The matrix above can be further decomposed as:
We can see that the matrix can be decomposed into two terms: The 1st which causes the leakage between the sidebands and the 2nd which only scales the results. We can ignore the 2nd term as the scaling is not important for practical applications. Furthermore, we note that the leakage term only depends on a single parameter .
Manual Up-conversion Calibration - This scripts shows the basic commands used to calibrate the IQ mixer. It plays a CW pulse in an infinite loop. The calibration should be done by connecting the output of the mixer to a spectrum analyzer and minimizing the LO leakage term at and image term at .
Automatic Up-conversion Calibration - This scripts shows an example for an automatic mixer calibration code on an external spectrum analyzer, written for several models: Keysight Fieldfox, Keysight N9001 and Rohde & Schwarz FPC. The script was tested with Keysight Fieldfox N9917A. It plays a CW pulse in an infinite loop, while probing the spectrum analyzer (SA) for the data, and minimizes the LO leakage and image using SciPy minimize toolbox with a Nelder-Mead algorithem.
Note: : It is important to have the LO source, the SA and the OPX locked to the same external reference clock.
Most SA implement the same SCPI instrument commands. These commands are written here as reference.
- "SENS:BAND:VID:AUTO 1" - Sets the video bandwidth to be automatic (same as the regular bandwidth)
- "SENS:BAND:AUTO 0" - Sets the bandwidth to be manual
- "SENS:BAND ???'" - Sets the manual bandwidth to ???
- "SENS:SWE:POIN ???" - Sets the number of points for the sweep to be ???
- "SENS:FREQ:CENT ???" - Sets the center frequency to ???
- "SENS:FREQ:SPAN ???" - Sets the frequency span to ???
- "INIT:CONT OFF;*OPC?" - Sets the SA to single trigger (turn continuous off)
- "INIT:CONT ON" - Sets the SA to continuous mode
- "INIT:IMM;*OPC?" - Perform a single sweep
- "CALC:MARK1:ACT" - Activate marker #1
- "CALC:MARK1:X ???" - Sets marker #1 to frequency ???
- "CALC:MARK1:Y?" - Query marker #1
- "TRACE:DATA?" - Gets the full trace
- "SENS:MEAS:CHAN CHP" - Sets the measurement to Channel Power
- "SENS:MEAS:CHAN None" - Disables the measurement
- "SENS:CME:RRCF 0" - Turns of RRC Filter for the measurement
- "SENS:CME:IBW ???" - Sets the integration bandwidth for the measurement to ???
- "SENS:CME:AVER:ENAB 0" - Disables averaging for the measurement
- "CALC:MEAS:DATA?" - Gets the data from the measurement
The code does not touch the Y scale of the SA, or the trigger settings. If needed, these have to be defined manually.
The code can easily be adapted to other spectrum analyzers which use the VISA interface by creating a class for them in the auto_mixer_tools_visa.py file. The class contains the commands above, which should be quite similar in other models and brands.
The code starts with three important variables:
address- The address for the SA, opened using visa.
bDoSweeps- If True, performs a large sweep before and after the optimization.
method- If set to 1, checks power using a channel power measurement. If set to 2, checks power using a marker.
When method = 1, the script uses a
channel power measurement and is considered faster & more reliable. It integrates
over a bandwidth which reduces noise for the same measurement time. In this code, it integrates over ten data points.
The second method uses a marker to check the power at a specific frequency. It only looks at one data point and is therefore a bit more prone to noise. Due to fluctuations, it will report a better suppression then actually achieved. Nevertheless, it produces similar results and is more easy to adapt between brands.
All the parameters that may be modified are at the beginning of the file, but most of them can just be kept as is:
- In most cases, only the
addressto the SA needs to be modified.
- The bandwidth, defined by the
measBW, can also be changed. Lowering the
measBWwould give better suppression, but it'll take longer. There is always a tradeoff between speed and results, and it also depends on the model of the SA used.
bDoSweepscan be changed to
Falseto disable the full sweeps before and after the optimizations.
The code continues with the creation of the calibration object, using the command
calib = KeysightFieldFox(address, qm) and the method is then being set using
calib.method = method.
The calibration object defines the QUA program, and three functions:
- get_amp() - Gets the amplitude of the current measurement.
- get_leakage(i0, q0) - Sets the DC offsets to i0 & q0 and gets the amplitude using get_amp()
- get_image(g, p) - Sets the gain and phase mismatch to g & p and gets the amplitude using get_amp()
Afterwards, the program is executed and the SA object is created. The parameters are being set for a large sweep to see the initial spectrum. We set the bandwidth to 1 kHz and we sweep a bit more than twice the IF frequency, this is such that we'll be able to see spurs coming from higher harmonics (if they are not negligible, the IF & LO power need tuning)
After getting the initial trace, we turn on the Channel Power measurement and configure it to be around the LO frequency. In the second method, we activate a marker and put it on the LO frequency. We then run the Nelder-Mead algorithm to minimize the leakage.
It then repeats for the image minimization, and finally takes another large trace to see the final spectrum after the minimization. Shown below is a demo run of the algorithm, it took ~20 seconds each for the LO and image, lowering them to <-70 dBc (relative to the signal).
The spurs at are at around -50 dBc, they can be reduced by decreasing the power arriving at the IQ ports.
Note - In the image below the noise floor is at ~-65 dBc, but the optimization is done at a much lower bandwidth which sets the noise floor at ~80-90 dBc.