∿ LEARN DSPFrom signal to HF transceiver
Lab / lesson

Positive and negative frequencies

How the direction of rotation is related to frequency and to receiver tuning.

← A complex number as a vector: I and Q

Why a receiver must tell the two directions apart

Let a receiver be tuned to 7.100 MHz. Two signals are 1 kHz below and 1 kHz above the tuning frequency. The receiver must tell them apart to select the necessary signal.

For this, it is easy to describe frequencies relative to the tuning frequency:

Input frequencyDifference from the tuning frequency
7.099 MHz−1 kHz
7.100 MHz0 Hz
7.101 MHz+1 kHz

In the complex representation, we can show this difference as rotation: a positive difference turns counterclockwise, a negative difference turns clockwise. In this lesson, we examine how to write such a signal. We discuss how to shift the radio frequency to zero in the next lesson.

Frequency as a change of angle

For a complex tone with amplitude 1 and initial phase 0:

z[n]=ej2πfn/Fs.z[n]=e^{j2\pi fn/F_s}.

Between adjacent samples, the angle changes by

Δθ=2πfFsradians per sample.\Delta\theta=2\pi\frac{f}{F_s}\quad\text{radians per sample}.

When f>0f>0, the angle increases: the vector turns counterclockwise. When f<0f<0, the angle decreases: the vector turns clockwise. The sign of the frequency shows the direction, and the absolute value shows the number of turns per second.

For a positive number ff, we write both cases:

z+[n]=e+j2πfn/Fs,z−[n]=e−j2πfn/Fs.z_+[n]=e^{+j2\pi fn/F_s},\qquad z_-[n]=e^{-j2\pi fn/F_s}.

They are conjugates: z−[n]=z+∗[n]z_-[n]=z_+^*[n]. Here this is true because the amplitudes are the same and both initial phases are zero.

+f: counterclockwise
IQz₊[1] = 0.707 + j0.707
−f: clockwise
IQz₋[1] = 0.707 − j0.707

I is the same: 0.707 · Q is opposite: +0.707 and −0.707

In the diagram, f=1f=1 kHz, Fs=8F_s=8 kS/s. The left vector makes a +45∘+45^\circ step, the right vector makes a −45∘-45^\circ step. Change the sample number one step at a time and look at the coordinates.

nnAngle of z+z_+Angle of z−z_-z+[n]z_+[n]z−[n]z_-[n]
00°0°1111
145°−45°0.707+j0.7070.707+j0.7070.707−j0.7070.707-j0.707
290°−90°jj−j-j
3135°−135°−0.707+j0.707-0.707+j0.707−0.707−j0.707-0.707-j0.707

Which coordinate tells these signals apart

Compare the columns: the real parts are the same, and the imaginary parts are opposite. This is a known property of cosine and sine:

cos⁡(−θ)=cos⁡θ,sin⁡(−θ)=−sin⁡θ.\cos(-\theta)=\cos\theta,\qquad \sin(-\theta)=-\sin\theta.

If you keep only II, the two rotations shown give the same arrays. The QQ coordinate lets you tell them apart. We will need exactly this for signals on the two sides of the tuning frequency.

Rotation relative to the tuning frequency

Think of a vector at 7.101 MHz and an observer who turns in the same direction at 7.100 MHz. Relative to the observer, the vector makes only 1000 additional turns per second: +1+1 kHz.

A vector at 7.099 MHz, on the other hand, falls behind by 1000 turns per second: the frequency offset is −1-1 kHz. When the frequencies are equal, the relative angle stays constant. It is not necessarily zero: it depends on the initial phases of the signal and of the reference rotation.

This is a geometric model of a frequency shift (downconversion). In practice, multiplication of complex signals does it. The frequency of the reference oscillator is the LO (local oscillator) frequency. For now, the numbers in MHz describe the radio frequencies of the device; we do not try to sample them directly at Fs=8F_s=8 kS/s. This sample rate is sufficient only for our slow rotations near zero.

Complex samples also have aliasing

At Fs=8F_s=8 kS/s, a +7+7 kHz rotation turns per sample by

360∘70008000=315∘.360^\circ\frac{7000}{8000}=315^\circ.

This rotation goes to the same point as −45∘-45^\circ. Thus a +7+7 kHz complex tone gives the same samples as a −1-1 kHz tone, if the amplitude and initial phase are the same.

At this FsF_s, the pair I,QI,Q tells +1+1 kHz and −1-1 kHz apart, but it cannot tell apart frequencies that differ by an integer multiple of FsF_s. If you keep only II, you also lose the difference between these two directions.

Lab: we compare two rotations

The script shows the vectors, their real parts and the accumulated phase:

uv run labs/02/02-positive-negative-frequency.py --show

Rotations with positive and negative frequency

For the positive frequency, the accumulated phase increases. For the negative frequency, it decreases. The real parts are the same. Try a 90∘90^\circ step instead of 45∘45^\circ:

uv run labs/02/02-positive-negative-frequency.py --f 2000 --show --output-dir /tmp/dsp-negative-frequency

The script prints the maximum differences between the real parts, and between z−z_- and the conjugate of z+z_+. Both values must be near zero, within the calculation error.

Self-check

The tuning frequency is 7.100 MHz. The signal is already shifted to baseband: each frequency is an offset from the tuning frequency.

For a signal at 7.102 MHz, find the frequency difference “signal minus tuning”. In which direction does its vector turn in the new coordinate system?

Explanation

The frequency offset is 7.102−7.100=+27.102-7.100=+2 kHz. When f>0f>0, the angle increases: the vector turns counterclockwise and makes 20002000 turns per second.

The same question for a signal at 7.098 MHz.

Explanation

7.098−7.100=−27.098-7.100=-2 kHz. The absolute value is the same as for the previous signal, 20002000 turns per second, but the direction is opposite: clockwise.

A signal at exactly 7.100 MHz has a constant amplitude and initial phase. What happens to its relative angle?

Explanation

The frequency offset is 00 Hz, so the vector does not move. Its angle is equal to the initial phase of the signal relative to the receiver oscillator. If you shift the oscillator phase, this angle changes, but the signal stays the same.

The +2+2 kHz and −2-2 kHz signals from the first questions have the same amplitudes and zero initial phases. Which coordinate lets you tell them apart?

Explanation

The angles of the two signals are +θ+\theta and −θ-\theta, so the vectors are mirror images across the II axis. The horizontal coordinates are the same, and the vertical coordinates are opposite. Thus only QQ shows the direction of rotation.

Next lesson: a cosine as a sum of two rotations →