Showing posts with label Theory. Show all posts
Showing posts with label Theory. Show all posts

Thursday, November 23, 2017

The Hilbert Transform and SSB Modulation

(Below are some brief notes to myself on the Hilbert Transform's use for the "phasing" version of SSB modulation.)

The "Phasing" method of SSB generation was a popular way of generating SSB in the early days of Amateur Radio SSB operation.

Some transmitters, such as the Heathkit TX-1, were designed to utilize outboard phasing accessories, such as the Heathkit SB-10, shown below.  (The TX-1 and SB-10 were my first SSB station while in high school).


Other early SSB transmitters had their phasing networks built in, such as the Hallicrafters HT-37 and the Central Electronics CE-100V.

The phasing method requires that the audio frequencies in the voice signal be shifted by 90 degrees.  In those early transmitters, this shift was accomplished with an analog phase-shift network.  Typically its setup would involve a nulling process using several knobs.

Now, with digital signal processing, the requisite 90 degree shift of the audio signal can be accomplished much more accurately and without tuning using a Hilbert Transform.

Below are two visual representations of the math underlying SSB generation via the Hilbert Transform in terms of sines and cosines.  For visualization I find it useful to express sines and cosines in their complex-exponential form.  E.g:

cos(2πfot) = (ej2πfot + e−j2πfot)/2

and

sin(2πfot) = j*(e-j2πfot - ej2πfot)/2

Note that j =  ejπ/2.   When multiplying (e-j2πfot - ej2πfot)/2 by j, the "π/2" term in j's complex-exponential representation results a +90 degree rotation of each of the two exponentials in (e-j2πfot - ej2πfot)/2.  The result is that the negative-frequency exponential (e-j2πfot) is rotated by +90 degrees, and the positive-frequency exponential (- ej2πfothas a total rotation of 270 degrees: 90 degrees due to the multiplication with j, and an additional 180 degrees due to the minus sign in front of it.

Or, in other words, the positive-frequency exponential is rotated by -90 degrees rather than +90 degrees.

Here's a visual representation of LSB generation:

(Click on image to enlarge)

And second, USB generation:

(Click on image to enlarge)

If the input audio were a sawtooth waveform, the image below shows the signals at various stages of the modulation process.

(Click on image to enlarge)
Note, in the image above, that the resulting SSB signal can have amplitudes larger than the peak values of its input audio (due to the Hilbert Transform's phase shifting).

This difference in input versus output signal magnitudes can be seen more easily in the image, below.  The sawtooth input has had its peak magnitude defined to be 1.0.  The peak value of the modulator's output, however, is 1.8.

A significant difference!

(Click on image to enlarge)

Therefore, because the level of the modulator's output IQ signal level can differ dramatically from the input audio's signal level, feed-forward transmitter gain control is ideally accomplished using the magnitude of the modulator's output IQ signal, rather than the magnitude of the input audio signal.

This conclusion is also true for the Weaver method of SSB generation.


Resources:

http://flylib.com/books/en/2.729.1/hilbert_transform_definition.html

http://k6jca.blogspot.com/2017/02/sdr-notes-weaver-modulation-and.html


Standard Caveat:

I might have made a mistake in my designs, equations, schematics, models, etc.  If anything looks confusing or wrong to you, please feel free to comment below or send me an email.

Also, I will note:

This information is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Friday, February 17, 2017

SDR Notes: Weaver Modulation and Demodulation

There are two techniques commonly used for modulating and demodulating SSB signals:  filtering out the unwanted sideband with a filter, and cancelling the unwanted sideband by using a phasing technique that includes shifting the audio frequencies by 90 degrees.


In 1956 Donald Weaver published a third method in the Proceedings of the IRE ("A Third Method of Generating and Detecting Single Side Band Signals", Dec. 1956).



Although this technique has now been around for more than 50 years, it was never widely utilized in commercial SSB products.

This lack of adoption by commercial manufacturers might be, in part, due to the requirements placed upon the analog design and implementation of a Weaver Modulator/Demodulator -- the low-pass filters should be matched, as any phase errors between the two will result in appearance of the opposite, unwanted sideband along with the desired sideband.  And imbalance or DC offset can cause the low frequency oscillator to "bleed through" into the audio passband.

Given these requirements, it is not too surprising that manufacturers preferred, for example, the straight-forward technique of simply filtering out the unwanted sideband with a crystal or mechanical filter at the radio's IF frequency.

But what might be difficult to implement in the analog domain becomes trivial in the digital domain -- filters are exactly matched, DC offsets can be eliminated, and thus Weaver modulation and demodulation become an excellent choice for implementation in a digital transceiver.

Now let's take a closer look at Weaver's technique...


Weaver Modulation:

Here's is the block diagram for Weaver's Modulator, as described in U.S. Patent 2,928,055:


And here is its implementation:



Three comments:

1.  The block diagram shows sine and cosine signals driving the balanced modulators.  Note that these signals are implemented in the schematic with two oscillators:  one at the AF frequency and one at the RF frequency, and these oscillators are each shifted + or - 45 degrees (depending upon which "branch" (upper or lower) of the modulator they drive) to achieve the requisite 90 degree phase shift between upper and lower branches.

2. Assuming the phase of the output transformers sum the signals from the two branches rather than subtract, the modulator above generates USB.  To generate LSB, either the phase of the audio into the "sine" branch must be inverted, or the RF output from the "sine" branch must be inverted.

3.  With respect to I and Q, the branch mixed with the cosine signals would be the (In-phase) channel, while the branch mixed with the sine signals would be the Q (Quadrature) channel.


Weaver Modulator Theory:

Let's look at how the operation of a Weaver Modulator is typically described.  From a 73 Magazine article (Feb. 1977), here is a block diagram very similar to Weaver's original:


And here is its associated spectrum diagram showing the step-by-step conversion from Audio to USB:


Note that the outputs of Balanced Modulators A2 and B2 each contain two versions of the shifted audio spectrum.  The spectrum of Modulator A2's output has two "positive" spectrums, one whose frequencies are reversed from the other.  The spectrum of Modulator B2's output also has two spectrums, one with reversed frequencies from the other, but in addition to the reversed frequencies one also has reversed amplitudes ("upside-down").

If these outputs are then added, spectrums that have a common frequency orientation and identical amplitudes will add, while spectrums with a common frequency orientation but reversed amplitudes will cancel (sum to zero), thus cancelling one of the sidebands.

I was curious how the Q channel (i.e. modulator B2 in the block diagram, above) inverted the spectrum amplitude, so I thought I'd look into circuit operation a bit more deeply.  As a visual representation I came up with this diagram:


This diagram represents a USB modulator.  Note that every time a signal is multiplied by a sine, its phase shifts by 90 degrees (I represent this as a 90 degree rotation), and this  phase shift is key to understanding how the "upside-down" spectrum is created.

In other words, if one were to think of Weaver Modulator operation in terms of sines and cosines, where the Audio input is a cosine signal, then, the first Q mixer's output would consist solely of sines:


The second Q mixer would convert these sines back to cosines:

(Equations from here)

But note!  Now there is a negative sign in front of the final cosine term.  If you were to write the equations of signal transformation for both I and Q branches, from audio to RF, and then sum them (per the block diagram), it is this negative sign result in the Q channel that causes the cancellation of one sideband.

(Personally, I prefer my visual representation over the equations, as the latter, as one expands them, can quickly become cumbersome.)

Here's a similar diagram for LSB generation:




Note that the LSB generator inverts the Audio signal in the Q path, prior to the first Q-channel mixer.  To create LSB, this inversion can either be at the beginning of the Q-channel path (prior to the first Q-channel mixer, as shown above), or at the end of the Q-channel path (after the second Q-channel mixer, but prior to the final adder).

The diagrams above, representing how a Weaver Modulator might be implemented in an FPGA, can look daunting.  For a different approach, let's look at Weaver Modulation from the perspective of "Complex" signals, which allows us to examine Weaver Modulation without the complication of spectrums folding back upon themselves:

USB Generation:


And LSB Generation:


Notes:

1.  The signs of the oscillator frequencies for the two final multipliers have been swapped (negative for positive, positive for negative) in the LSB version, compared to the USB version.

2.  The Complex Conjugate of a complex exponential function simply changes the sign of that function's frequency, from positive to negative, or from negative to positive, as shown below:


(For a very useful tutorial on Complex signals, go here).

Forward to demodulation!


Weaver Demodulation:

(This will be a very short section.)

From Weaver's Patent:


Looks very similar to the modulator, doesn't it?

Because there are no phase inversions in the diagram above of  RF prior to the first modulators or Audio following the final modulators, then this demodulator would demodulate a USB signal.

To demodulate an LSB signal, instead of adding top ("I") and bottom (Q") branches to create audio, you would instead subtract the bottom branch (Q) from the top branch (I).

As you can see, demodulation is essentially just the reverse of the modulation process.  And with that, I now end my discussion!


Resources:

"A Third Method of Generation and Detection of Single-Sideband Signals," Weaver, Proceedings of the IRE, Dec., 1956.  The original article!
Weaver's Patent 2928055
A 9 MHz Digital SSB Modulator, IV3NWV
AN1981, Philips.  Contains description of Weaver Modulator and Demodulator.
SSB Demodulation, Pandora SDR.  A nice visual on Weaver Demodulation.
"The Third Method of S.S.B.", Wright, W1PNB, QST, Sept., 1957
"SSB:  The Third Method," Wilson, WB0JXY/0, 73 Magazine, Feb., 1977

Quadrature Signals:  Complex, but not Complicated, Richard Lyons


Standard Caveat:

I might have made a mistake in my designs, equations, schematics, models, etc.  If anything looks confusing or wrong to you, please feel free to comment below or send me an email.

Also, I will note:

This design and any associated information is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Tuesday, October 18, 2016

SDR Notes: The Mixer Mathematics of Digital Down Conversion

(This post originally started as notes to myself, placed here so that I would not lose or forget them.)

The Digital Down Converter (DDC) is a basic block of FPGA-implemented SDR radios.  Per Wikipedia:
A digital down-converter (DDC) converts a digitized, band limited signal to a lower frequency signal at a lower sampling rate in order to simplify the subsequent radio stages. 
Below is an illustration of a DDC stage (don't worry about the math -- it will be explained later in this post):

(Click on image to enlarge)

Note that, for demonstration purposes, the equations assume a simple cosine as the input signal.

This post will look at the math involved in the Mixer.  I will leave the low-pass filter and sample-rate conversion for later posts.


First, some basics...

Basic Down-Conversion Mixing:

Historically, down-conversion has been done in the analog domain with a "real" oscillator signal (e.g. cos(ωot)).  Let's first look at this type of basic mixer before tackling mixing in the Digital (and Complex) domain.

For demonstration purposes, I'll simplify the receive-signal to be a just simple cosine signal at a single frequency:  cos(ωit).


This mixer's math is straightforward.  Let the output of the mixer be y(t).

y(t) = cos(ωit)*cos(ωot)

We can use Trigonometric identities to express this equation in terms of sums and differences of frequencies:

y(t) = (cos((ωi−ωo)t))/2 + (cos((ωio)t))/2

But this basic form of mixing has a problem if one would like to down-convert an incoming RF signal directly to base-band:  both the desired signal and its image will appear in the base-band spectrum (which, for the typical shortwave receiver, is the audio spectrum we want to hear).

This type of conversion is known as "Direct Conversion."  For an example, see Rick Campbell's R1 receiver.

Visually, here's how the frequencies shift, shown as a single-sided spectrum (which one would see if one did a "Trigonometric" Fourier Transform on the RF input.  Refer to equation 27 in this paper by Robert Marcus for more detail)::


Note the overlap of the two signals down at base-band...our "desired" signal would be interfered with by any signal at its "image" on the other-side of the oscillator's frequency!

And if we were to consider the Mixer's input to be a band of frequencies:


You can see the spectrum fold-back with the result being the desired signal and its undesired image occupying the same base-band frequencies.  A single-sided spectrum graph has no negative frequencies, and any "calculated" negative frequencies become positive frequencies via the Trig identity: cos(−ωit) = cos(ωit).

We can get around this image problem by working in the domain of Complex Numbers (numbers with a real and an imaginary component).  Specifically, we will use exponentials with complex arguments.


Complex Exponentials -- A Quick Review of Some Important Identities:

Euler's Formula:

e = cos(θ) + jsin(θ)

Similarly,

e−jθ = cos(θ) - jsin(θ)

From Euler's Formula it can be shown that:

cos(θ) = (e + e−jθ)/2

sin(θ) = j(e−jθ − e)/2

Let's consider a real signal at a single frequency fo (Hz), and let's express this signal simply as a cosine: cos(2πfot).

Using the identities above this signal can be expressed in exponential form:

cos(2πfot) = (ej2πfot + e−j2πfot)/2

Below is a representation, in the complex frequency-domain, of this signal :

And, for completeness, here are a two more illustrations:

First, to complement the cosine representation above, here is a complex frequency-domain representation of a sine wave signal of the same frequency:

Second, we can use both of these illustrations of the signals in the complex frequency-domain to generate a visual representation of Euler's Formula, showing how the imaginary sine terms are rotated (when multiplied by j) to the real axis and then added to the real cosine terms:

(Click on image to enlarge)

Note that multiplying sin(2πfot) by j rotates the sine's complex frequency-domain imaginary components "clockwise" by 90 degrees to the real plane. If we were to instead multiply sin(2πfot) by -j, the rotation would be 90 degrees counter-clockwise, with the results again being on the real plane, but pointing in the opposite direction, and our final result (after adding the real components together) would represent Euler's Formula for a negative frequency, -fo, instead of fo.


Frequency Conversion using Complex Numbers in Exponential Form:

Let's use the above equations to shift signal frequencies.

First, for ease of demonstration, let's define an input RF signal, x(t), to be a simple cosine at a single frequency, fi Hz.  I.e.:

 x(t) = cos(2πfit)

To minimize my typing, I will express this signal's frequency as its radian equivalent, where ωi = 2πfi.

x(t) = cos(ωit)

Using the identities above we can express cos(ωit) as the sum of two complex exponential numbers:

cos(ωit) = (eit + e−jωit)/2

Now let's now define our oscillator's signal as a complex exponential:

eot

(Note that from Euler's Formula eot  = cos(ωot) + jsin(ωot)).

Our next step is to multiply together the input signal and the oscillator signal.  We will call the output y(t).

y(t) =  cos(ωit) * eot

Replacing the input signal with its equivalent complex exponential form, the output equation becomes:

y(t) = [(eit + e−jωit)/2]*eot

Finally, let's finish the multiplying.  The result is:

y(t) = (ej(ωio)t + ej(−ωio)t)/2

Note that the frequency components in the arguments of both exponentials have been shift up by ωo.

By the way, we can use Euler's Formula to express this result in terms of sines and cosines:

y(t) = [cos((ωio)t) + jsin((ωio)t)]/2 + [cos((-ωio)t) + jsin((-ωio)t)]/2

You can also derive the same result using only sines, cosines, and trigonometric identities and not complex exponentials, but the math is more cumbersome.


OK, so an NCO's output that is a complex-exponential with an argument whose frequency is +ωwill shift the incoming signal's frequency up by ωo.  What happens if the NCO's frequency is negative, i.e. -ωo?

Using the same approach as above, the DDC's output can be shown to be:

y(t) = (ej(ωi−ωo)t + ej(−ωi−ωo)t)/2

In other words, both of the input signal's complex exponentials are shifted down in frequency by ωo. Voila, a Digital Mixer!

Again, note that y(t) can be expressed as the sum of sines and cosines.  Using the identities at the start of this post:

y(t) = [cos((ωio)t) + jsin((ωio)t)]/2 + [cos((ωio)t) - jsin((ωio)t)]/2

which is exactly equivalent to y(t) = (ej(ωi−ωo)t + ej(−ωi−ωo)t)/2.


Mixing with Complex Exponentials:

With a view towards understanding SDR building blocks, let's look at a Digital Mixer using the down-conversion math I've just discussed, and which shifts signal frequencies in the digital (rather than analog) realm.

Below is a Digital Mixer block diagram using complex numbers.  Let's drive the RF input with a simple cosine signal, cos(ωot):


Note that the oscillator's output is a complex exponential with a negative frequency in its argument.  This negative frequency, as I've discussed earlier in this post, will down-convert incoming RF.

The input signals' spectrum (shown below as two-sided, with negative frequencies, per the frequencies in the complex arguments in the exponential form of the input signal) will shift down:

(Click on image to enlarge)

The illustration below shows a more general case for a band of frequencies at the DDC's input:

(Click on image to enlarge)

Note that, unlike the analog mixer described at the start of this post, this spectrum has both positive and negative frequencies.  In other words, we do not (yet) have an issue with "image wrapping" while we remain in the complex domain.

Another take on the same topic, from "Complex Signal Processing is Not -- Complex," by Ken Martin, showing the same:


Note (again) that the input consists of only real, not complex, numbers, but the output Y(t) will be in complex form, with both real and imaginary components.

Regarding the mixer (c) in the image above, we can express its two outputs (yr(t) and yq(t)) in terms of sines and cosines.

First, for simplicity of analysis let's define the input xr(t) to be a simple cosine at frequency ωr:

x(t) = cos(ωrt)

Noting that the oscillator frequency is ωi in this example, the output yr(t) is therefore:


yr(t) = cos(ωrt)*cos(ωit)

which, using trig identities, expands to:

yr(t) = cos((ωr−ωi)t)/2 + cos((ωri)t)/2

Now let's do the same to derive yq(t), the imaginary term...noting that −sin(ωit) = sin(−ωit), yq(t) becomes:

yq(t) = sin((ωr−ωi)t)/2 − sin((ωri)t)/2

Is this result equivalent to the result derived (above) using complex-exponential equations?

Essentially, yes it is!

Let's multiply the yq(t) channel by j (i.e. add a phase shift of 90 degrees with, say, a Hilbert Transform) and call this output yq(t)' (note the 'prime').  Its equation is:

yq(t)' = jsin((ωr−ωi)t)/2 − jsin((ωri)t)/2

If we then add yr(t) and yq(t)', the result is:

yr(t) + yq(t)' = [cos((ωr−ωi)t) + jsin((ωr−ωi)t)]/2 + [cos((ωri)t)  jsin((ωri)t)]/2

Which, from Euler's Formula, we know is exactly equivalent to:

yr(t) + yq(t)' = (ej(ωr−ωi)t + ej(−ωr−ωi)t)/2.

and which is exactly equivalent in form to the equation we derived earlier:

y(t) = (ej(ωi−ωo)t + ej(−ωi−ωo)t)/2

In other words, the trigonometric signals representing yr(t) and yq(t) are the fundamental mathematical elements (when the sine terms are multiplied by j) that constitute the Digital Mixer's operation when expressed in complex-exponential form.


Links and Other Resources:


Representing a signal as the sum of two exponentials:  http://ece.mst.edu/media/academic/ece/documents/classexp/ee216labs/EE216_Lab4.pdf

The Significance of Negative Frequencies in Spectrum Analysis, Robert Marcus, IEEE Transactions on Electromagnetic Compatibility, Dec. 1967.  (A copy can be found here).

Good tutorial on Complex Number in Radio applications:  Complex Signal Processing is Not -- Complex, Ken Martin


Standard Caveat:

I could have easily made a mistake in any of the above text, equations, or drawings.  If something looks wrong or is confusing, please feel free to contact me.  Thanks!