Update I/Q Modulation authored by Sander Snoo's avatar Sander Snoo
---
title: I/Q Modulation
---
In many cases, qubit resonance frequencies are much higher than the maximum output frequency of the AWG. I/Q modulation is a method to up-convert the output signal of the AWG to a much higher frequency. The frequency of a microwave (MW) source is added to the output of the AWG in a process called I/Q mixing.
TODO:
* formulas I/Q modulation
* offset I and Q
* gain, phase corrections
\ No newline at end of file
The AWG generates an in-phase and a quadrature (I/Q) signal that are mixed with the I/Q output of a MW source. See [In-phase and quadrature components](https://en.wikipedia.org/wiki/In-phase_and_quadrature_components).
![IQ_mixing](uploads/133d6d3789174f646cb2e129a05fe85c/IQ_mixing.png){width=354 height=207}
The output of this mixer is:
$`y(t) = I(t) cos(\omega_c t) - Q(t) sin(\omega_c t)`$
IQ modulation can be used to create a single frequency output signal which is higher of lower in frequency
than the MW source. For this the IQ modulation signals should be sinusoids with a 90 degrees shift.
$`I(t) = A(t) cos(\omega_m t + \phi(t))`$
$`Q(t) = A(t) sin(\omega_m t + \phi(t))`$
$`y(t) = A(t) [cos(\omega_m t + \phi(t)) cos(\omega_c t) - sin(\omega_m t + \phi(t)) sin(\omega_c t)]`$
$`y(t) = A(t) cos((\omega_c + \omega_m) t + \phi(t))`$
IQ modulation allows frequency multiplexing, because it is a linear operation.
The I and Q components can contain multiple frequencies which will all be shifted with $`f_c`$.
IQ modulation can also be used for fast chirps (frequency sweeps), because phase
and frequency of the I and Q components can be swiftly changed by the AWG.
# I/Q modulation in pulse_lib
Users of pulse_lib don't have to care about the calculation of I and Q outputs.
They can specify the desired MW pulses after IQ modulation and pulse_lib calculates the I and Q output signals for the AWG.
The user has to specify the I and Q output channels of the AWG as an I/Q pair and pass the frequency of the vector signal generator, the LO frequency.
For coherent qubit control every qubit needs a channel with the resonant frequency of the qubit.
Example defining a qubit control channel 'q1' on I/Q output pair 'IQ1':
```Python
pulse.define_iq_output("IQ1", awg.name, i_ch_num, q_ch_num, marker_name="M_IQ")
pulse.set_iq_lo("IQ1", mw_source.frequency)
pulse.define_qubit_channel("q1", "IQ1", 12.34e9)
```
# I/Q modulation errors
The I/Q mixing is not a perfect process and additional frequencies will be generated.
Ideally, the I/Q mixer creates single side-band signal.
![ideal_modulation](uploads/8b5b39f3a3fc54cf3b6156e2efeedcbd/ideal_modulation.png){width=900 height=212}
*Ideal I/Q modulation of single sideband*
In practice the signals and electrical components are not perfect. Small differences between amplifiers,
filters and path length result in small errors in the I/Q output.
The I and Q output of the AWG can have a voltage offset, a (frequency dependent) gain difference and
a (frequency dependent) phase difference. The output signal after modulation will contain the carrier frequency
and the mirror side-band.
![real_modulation](uploads/704a0eac1aa034f74edb2c69dba114f5/real_modulation.png){width=900 height=216}
*IQ modulation in practice containing the carrier frequency and a mirrored side-band.*
## Offset error
A voltage offset in the AWG output results in the output of the carrier frequency.
$`y(t) = [a+cos(\omega_m t)] cos(\omega_c t) - [b + sin(\omega_m t)] sin(\omega_c t)]`$
$`y(t) = cos((\omega_c + \omega_m) t) + a \cdot cos(\omega_c t) - b \cdot sin(\omega_c t)`$
![IQ_offset_error](uploads/a1a291c09c6fe90fb333b7e50f8e8052/IQ_offset_error.png){width=413 height=309}
*Remainder of carrier frequency due to offset error.*
## Gain error
A difference in gain between I and Q components add the mirrored side-band frequency,
$`f_c - f_m`, to the output.$
$`y(t) = (1 + a) cos(\omega_m t) cos(\omega_c t) - sin(\omega_m t) sin(\omega_c t)`$
$`y(t) = (1+\frac{a}{2}) cos((\omega_c + \omega_m) t) + \frac{a}{2} cos((\omega_c - \omega_m) t)`$
![IQ_gain_error](uploads/7859cbec3d28450170e098c3dbba9110/IQ_gain_error.png){width=409 height=311}
*Mirrored side-band due to gain error*
## Phase error
When the phase difference between the I and Q components is not exactly 90 degrees then the mirrored
side-band frequency is output as well. The resulting output is similar to the output with a gain error.
$`y(t) = cos(\omega_m t + \frac{a}{2}) cos(\omega_c t) - sin(\omega_m t - \frac{a}{2}) sin(\omega_c t)`$
$`y(t) = cos(\frac{a}{2}) cos((\omega_c + \omega_m) t) - sin(\frac{a}{2}) sin((\omega_c - \omega_m) t)`$
# IQ corrections in pulse_lib
A vector signal generator will have options to correct the offset, phase and gain error of the IQ input, but only with a frequency independent correction.
Pulse_lib can also correct for these errors, where gain and phase corrections are frequency dependent.
Example:
Add gain and phase offset to qubit channels.
```Python
pulse.set_qubit_correction_phase("q1", phase_correction)
pulse.set_qubit_correction_gain("q1", correction_I, correction_Q)
```