Forums

Matlab code needed for SSB demodulation

Started by Rick Lyons June 30, 2012
On Sun, 01 Jul 2012 22:31:08 -0400, robert bristow-johnson wrote:

> On 7/1/12 7:39 PM, Randy Yates wrote: >> Tim Wescott<tim@seemywebsite.please> writes: >> >>> There's at least two variants on the phasing method that I know of: >>> the regular old method and the Weaver method. The regular is where >>> you mix down in quadrature right at the carrier frequency, then >>> filter, phase shift, and add (or subtract) for upper (or lower) >>> sideband. >> >> I don't know exactly how the phase shifting and filtering perform part >> of the demodulation, but could you simply >> >> a) complex-mix the input signal by the carrier frequency b) >> complex-filter the result to 0 to Fb, where Fb is the highest >> modulating frequency >> c) take the real part? >> >> > i'm unfamiliar with Weaver or Tim's "regular". i know how we did it in > analog with ham-radio gear in the 70s. with an IF frequency of, i > dunno. it's wasn't 455 kHz (that was my old shortwave radio). i think > it was around 3 MHz and we had a helluva sharp "crystal-lattice filter" > with piezo "XTAL"s.
Ahh, you need to look back 10 or 20 years. The way it was done then involved down-converting in quadrature, and a network of all-pass filters (you could buy one from B&W to plug into an octal tube socket). The filters would shift your audio into two channels that were phase-shifted 90 degrees apart for the audio frequency band. (And no, I wasn't around then. I just have a collection of ARRL handbooks that hits about once per decade from 1933 to 2008 or so) -- My liberal friends think I'm a conservative kook. My conservative friends think I'm a liberal kook. Why am I not happy that they have found common ground? Tim Wescott, Communications, Control, Circuits & Software http://www.wescottdesign.com
On Tue, 03 Jul 2012 04:59:40 -0500, Rick Lyons wrote:

>>On 7/1/12 r b-j wrote: > > [Snipped by Lyons] > > Hi Robert, > >>i'm unfamiliar with Weaver or Tim's "regular". i know how we did it in >>analog with ham-radio gear in the 70s. with an IF frequency of, i >>dunno. it's wasn't 455 kHz (that was my old shortwave radio). i think >>it was around 3 MHz and we had a helluva sharp "crystal-lattice filter" >>with piezo "XTAL"s. >> >>with a good baseband filter, you can do it with a *real* mix. >> >>let xq(t) be the Hilbert transform of xi(t). the real IF (for USB) is >> >> >> v(t) = xi(t)*cos(w0*t) - xq(t)*sin(w0*t) >> >> = Re{ (xi(t) + j*xq(t)) * e^(j*w0*t) } > > Ok. That seems to be the standard way of generating a real-valued upper > sideband SSB signal at an RF freq of w0. > >>now you can multiply ("mix" using old-fashioned comm lingo) v(t) with >>cos(w0*t) (assuming you have no sync problem) and filter out the >>high-frequency images leaving only the base band. >> >> >> v(t)*cos(w0*t) = xi(t)*(cos(w0*t))^2 - xq(t)*sin(w0*t)*cos(w0*t) >> >> = 1/2*( xi(t) + xi(t)*cos(2*w0*t) - xq(t)*sin(2*w0*t) ) >> >>it's not hard to get xi(t) from that to an arbitrary postive limit of >>error (and some delay). > > Yes, and *THAT* is what's surprising me. All the 'SSB demod' literature > I've found so far describes SSB demodulation as needing Hilbert > transformation, complex down-conversion, and some sort of digital > filtering. But my Matlab modeling seems to indicate that SSB > demodulation can be performed by simple real-valued mixing (your > cos(w0*t)) and lowpass filtering. (Of course, this is assuming a copy of > the 'w0' carrier freq is available at the receiver.) > > At this point I don't understand why all the SSB demod literature's > methods (including Frerking's book) are significantly more complicated > than what you described above. > >>in fact, if you were to do this using complex arithmetic, from a real >>IF, v(t), you end up doing it mathematically equivalently, because you >>have to separate xi(t)*cos(w0*t) from xq(t)*sin(w0*t) and that requires >>"mixing" and filtering v(t).
This is pretty much what Tauno said, but: I can't remember the details, but I _do_ remember grinding through the math on this when I was still actively building amateur-band radios. To get opposite-sideband suppression you need to do the phase shift at audio, or at whatever frequency you chose to do your image-reject. There's pretty much no way around it -- which I why I remember, because I was pretty disappointed. The easiest way to figure this out is to start with a CW signal at a transmit frequency and a constant-frequency beat-frequency oscillator frequency. Then solve for the resulting signal, and note that it does (or does not) drop out when the transmit frequency drops below (or rises above) the BFO frequency. I'd do it all in trig; doing it in complex notation with Euler's identity would work but you'll have to do a lot more housekeeping. To receive SSB _without_ caring about the opposite sideband, you just stick your antenna lead into a mixer, then amplify the crap out of the resulting audio. This is called a "direct conversion" receiver, and they work very well except that they receive on both sidebands at once, which makes things difficult in a crowded band. There's one dodge that has been done successfully, which is to use a pair of DC receivers driven by the same LO, but in quadrature. You feed each receiver output to one channel of a stereo head set, and then (if you're listening to Morse code) you perceive the incoming signals as having direction, which apparently does a tremendous amount of good at picking them out of noise and interference. -- My liberal friends think I'm a conservative kook. My conservative friends think I'm a liberal kook. Why am I not happy that they have found common ground? Tim Wescott, Communications, Control, Circuits & Software http://www.wescottdesign.com
On 3.7.12 8:24 , Tim Wescott wrote:
> On Sun, 01 Jul 2012 22:31:08 -0400, robert bristow-johnson wrote: > >> On 7/1/12 7:39 PM, Randy Yates wrote: >>> Tim Wescott<tim@seemywebsite.please> writes: >>> >>>> There's at least two variants on the phasing method that I know of: >>>> the regular old method and the Weaver method. The regular is where >>>> you mix down in quadrature right at the carrier frequency, then >>>> filter, phase shift, and add (or subtract) for upper (or lower) >>>> sideband. >>> >>> I don't know exactly how the phase shifting and filtering perform part >>> of the demodulation, but could you simply >>> >>> a) complex-mix the input signal by the carrier frequency b) >>> complex-filter the result to 0 to Fb, where Fb is the highest >>> modulating frequency >>> c) take the real part? >>> >>> >> i'm unfamiliar with Weaver or Tim's "regular". i know how we did it in >> analog with ham-radio gear in the 70s. with an IF frequency of, i >> dunno. it's wasn't 455 kHz (that was my old shortwave radio). i think >> it was around 3 MHz and we had a helluva sharp "crystal-lattice filter" >> with piezo "XTAL"s. > > Ahh, you need to look back 10 or 20 years. The way it was done then > involved down-converting in quadrature, and a network of all-pass filters > (you could buy one from B&W to plug into an octal tube socket). The > filters would shift your audio into two channels that were phase-shifted > 90 degrees apart for the audio frequency band. > > (And no, I wasn't around then. I just have a collection of ARRL > handbooks that hits about once per decade from 1933 to 2008 or so) >
The B&W thing was in an octal tube package with the type 2Q4. The phasing method was not too popular because it is extremely difficult to maintain the balance needed between the two channels. An added nuisance was to maintain the carrier balance in the mixer/modulators. It was easier to use a single balanced modulator and a crystal filter (or in the luxury Collins equipment, mechanical filter) to keep the unwanted sideband out. With digital processing, the balance is a non-issue. Two similar processing paths are similar with perfect balance. The same considerations apply to the audio phase handling with the Weaver-Brown ('third') method, where an extra quadrature conversion is used for the Hilbert transform. When done with analog components, the carrier balance problems quickly created an annoying whine in the signal. -- -Tauno Been there, done that ...
On 7/3/2012 4:38 AM, Tauno Voipio wrote:
> On 3.7.12 7:03 , Jerry Avins wrote: >> On 7/2/2012 7:57 AM, Rick Lyons wrote: >> >>> ... What I'm tryin' to do is understand, >>> and model, the various schemes I've encountered >>> on the Internet for demodulating real-valued >>> bandpass SSB signals. >> >> I listened to SSBSC with my short-wave portable by using the BFO. It >> works well when it is tuned to the where the suppressed carrier would >> have been. Otherwise, quack quack. Distortion is low provided the BFO >> level is high enough. I once built an analog SSB phasing detector for >> use with weak AM signals that was straight out of the ARRL Handbook. The >> brain is a wonderful filter. By sending the upper sideband to one ear >> and the lower to the other, an AM signal made unintelligible by noise >> came through well. The brain extracted what was common to both ears and >> ignored what was different. If the problem was an interfering signal on >> one side of the carrier, the other sideband could be sent to both ears. >> >> Jerry > > BFO is just one of the frequencies combined to effect the carrier > substitution. Actually, the name comes from the time of CW Morse > code usage, when the BFO was used on an AM receiver to make the > transmission audible (instead of the pffft pffft ...).
Of course. Using it to demodulate SSB was just a trick, like slope detection for NBFM.
> In the early days of SSB, there were commercial systems using > a small amount of pilot carrier for receiver phase locking. Also, > a DSBSC (double sideband suppressed carrier) transmission has > enough redundancy to permit phase locking. It it also necessary > to have an exact frequency and a good phase lock to detect a > DSB signal with little distortion. The analog phase lock AM > reception built by Jerry belongs into this group. We used similar > receivers to listen to Radio Luxembourg in the era of European > state monopoly radios.
I think these "tricks" fall into the "more things in heaven and earth, Horatio ..." category, but they also taught us to be creative in squeezing performance out of our equipment. (My receiver was a National NC-183.) Jerry -- Engineering is the art of making what you want from things you can get. &#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;

Hi Guys,
  Thanks for all your replies to
my original post.

[-Rick-]
On Mon, 2 Jul 2012 14:31:49 -0700 (PDT), lito844@gmail.com wrote:

>Most hams know, for voice communications, a clean speech signal is intelligible >even with 200 Hz or more carrier frequency error. > >I've pasted a simple demo passband SSB model with link to voice cut used to test. >The example I ran used 250 Hz carrier frequency error at the receiver LO. > Sounds funny but still intelligible. > >function [musb,mlsb,mpbu,mpbl,mhatu,mhatl,mhatam] = demo_ssb(m,ferr)
[Code snipped by Lyons] Hi Mark, Your Matlab code is a really terrific demo of single sideband demodulation Thanks, [-Rick-]
> Hi Mark, > Your Matlab code is a really terrific > demo of single sideband demodulation > > Thanks, > [-Rick-]
Hi Rick, I'm glad you found it helpful. Mark
When I was young I was convinced I would get rich by making a device to cure feedback howl in PA systems by introducing a small frequency shift in the signal. I applied the analog inputs to 2 parallel banks of allpass filters to get 90 degrees of phase shift  and then multiplied by a sin and cos carrier generated by a state variable oscillator. The multiplication was done with analog multipliers. Yikes!

I was a nice theory but it didn't work so well. The feedback howl was replaced by feedback chirps. if I changed the frequency by a large amount then there was some benefit but the singer had that Mis-tuned ssb sound. Even in the 70's this was not acceptable (although I'm pretty sure that sound was used in the famous 70's song "muskrat love"). 

I always wanted to try this with a modulating signal made by passing noise through a low pass filter. Never tried it but I suspect it wouldn't work very well either. 

One of many failed get-rich-quick schemes!

Bob
On Sat, 07 Jul 2012 14:24:35 -0700, Robert Adams wrote:

> When I was young I was convinced I would get rich by making a device to > cure feedback howl in PA systems by introducing a small frequency shift > in the signal. I applied the analog inputs to 2 parallel banks of > allpass filters to get 90 degrees of phase shift and then multiplied by > a sin and cos carrier generated by a state variable oscillator. The > multiplication was done with analog multipliers. Yikes! > > I was a nice theory but it didn't work so well. The feedback howl was > replaced by feedback chirps. if I changed the frequency by a large > amount then there was some benefit but the singer had that Mis-tuned ssb > sound. Even in the 70's this was not acceptable (although I'm pretty > sure that sound was used in the famous 70's song "muskrat love").
You can get that "whoop whoop whoop" from a separate SSB transmitter and receiver, too. -- Tim Wescott Control system and signal processing consulting www.wescottdesign.com
Yes I have heard that as well.
Another cool use of frequency shifting was pioneered by Bob Orban, who designed the standard broadcast audio compressors that became ubiquitous on the 70's.  Take an audio spectrum and shift it up to a few hundred kHz, and apply it to a soft limiter. If the original spectrum consisted of a mix of sine waves, the limiter will produces intermod tones that are down in the audio band or up around twice the carrier. Apply this limited signal to a band pass filter to remove all the intermod components and then shift the whole thing back down to audio. Presto, you have a limiter with no intermod distortion.  Very clever.

Bob