Forums

Matlab code needed for SSB demodulation

Started by Rick Lyons June 30, 2012
Hi Guys,
   I'm trying to help someone understand the operation 
of a discrete single-sideband (SSB) demodulation system 
that is being proposed to replace an older analog 
SSB demodulation system.

Having not thought about SSB systems for many years, I've 
been trying to figure out how the "phasing method" of 
SSB demodulation works.  In trying to model this 
"phasing method" using Matlab, I'm producing inconsistent 
results when demodulating upper-sideband SSB signals 
compared to demodulating lower-sideband SSB signals.

In searching the Internet for tutorial SSB demodulation 
information I'm shocked at the inconsistent, contradictory, 
and ambiguous, SSB demod material that's on the 
web.  I've found no web site, including MathWorks 
'File Exchange' pages, that has helped me.

Either I'm misunderstanding the "phasing method" of 
SSB demodulation, or my Matlab code is fouled up. 
I can't figure what I'm doing wrong.

Anyway, does anyone out there have Matlab code that 
models the "phasing method" of SSB demodulation that 
they'd be willing to share with me?

Thanks,
[-Rick-]
On Sat, 30 Jun 2012 02:12:35 -0700, Rick Lyons wrote:

> Hi Guys, > I'm trying to help someone understand the operation > of a discrete single-sideband (SSB) demodulation system that is being > proposed to replace an older analog SSB demodulation system. > > Having not thought about SSB systems for many years, I've been trying to > figure out how the "phasing method" of SSB demodulation works. In > trying to model this "phasing method" using Matlab, I'm producing > inconsistent results when demodulating upper-sideband SSB signals > compared to demodulating lower-sideband SSB signals. > > In searching the Internet for tutorial SSB demodulation information I'm > shocked at the inconsistent, contradictory, > and ambiguous, SSB demod material that's on the web. I've found no web > site, including MathWorks 'File Exchange' pages, that has helped me. > > Either I'm misunderstanding the "phasing method" of SSB demodulation, or > my Matlab code is fouled up. > I can't figure what I'm doing wrong. > > Anyway, does anyone out there have Matlab code that models the "phasing > method" of SSB demodulation that they'd be willing to share with me? > > Thanks, > [-Rick-]
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. With the Weaver method you put your carrier in the middle of the signal of interest, filter at half the desired bandwidth, then mix again with a signal that brings out your desired spectrum. The regular method has the downside that you don't get complete opposite sideband suppression, which makes it hard to listen to a weak signal that's adjacent to a strong one. The Weaver method solves this because the sideband you listen to is for your signal of interest, superimposed on what you're hearing. But the Weaver method has a whistle at the second demod frequency. Search out the Tuscon Area Packet Radio society (TAPR). They're into all sorts of high-tech amateur radio these days, and if I recall correctly they have a software defined radio project. If you can find software from them for that, it'll work right. -- Tim Wescott Control system and signal processing consulting www.wescottdesign.com
>On Sat, 30 Jun 2012 02:12:35 -0700, Rick Lyons wrote: > >> Hi Guys, >> I'm trying to help someone understand the operation >> of a discrete single-sideband (SSB) demodulation system that is being >> proposed to replace an older analog SSB demodulation system. >>
[Snipped by Lyons]
> >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. With the >Weaver method you put your carrier in the middle of the signal of >interest, filter at half the desired bandwidth, then mix again with a >signal that brings out your desired spectrum. > >The regular method has the downside that you don't get complete opposite >sideband suppression, which makes it hard to listen to a weak signal >that's adjacent to a strong one. The Weaver method solves this because >the sideband you listen to is for your signal of interest, superimposed >on what you're hearing. But the Weaver method has a whistle at the >second demod frequency. > >Search out the Tuscon Area Packet Radio society (TAPR). They're into all
>sorts of high-tech amateur radio these days, and if I recall correctly >they have a software defined radio project. If you can find software >from them for that, it'll work right. >-- >Tim Wescott
Hi Tim, Thanks for the advice. I'll follow it. See Ya', [-Rick-]
Tim Wescott <tim@seemywebsite.please> writes:

> On Sat, 30 Jun 2012 02:12:35 -0700, Rick Lyons wrote: > >> Hi Guys, >> I'm trying to help someone understand the operation >> of a discrete single-sideband (SSB) demodulation system that is being >> proposed to replace an older analog SSB demodulation system. >> >> Having not thought about SSB systems for many years, I've been trying to >> figure out how the "phasing method" of SSB demodulation works. In >> trying to model this "phasing method" using Matlab, I'm producing >> inconsistent results when demodulating upper-sideband SSB signals >> compared to demodulating lower-sideband SSB signals. >> >> In searching the Internet for tutorial SSB demodulation information I'm >> shocked at the inconsistent, contradictory, >> and ambiguous, SSB demod material that's on the web. I've found no web >> site, including MathWorks 'File Exchange' pages, that has helped me. >> >> Either I'm misunderstanding the "phasing method" of SSB demodulation, or >> my Matlab code is fouled up. >> I can't figure what I'm doing wrong. >> >> Anyway, does anyone out there have Matlab code that models the "phasing
aaa>> method" of SSB demodulation that they'd be willing to share with me?
>> >> Thanks, >> [-Rick-] > > 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? -- Randy Yates Digital Signal Labs http://www.digitalsignallabs.com
On Saturday, June 30, 2012 5:12:35 AM UTC-4, Rick Lyons wrote:
> Hi Guys, > I'm trying to help someone understand the operation=20 > of a discrete single-sideband (SSB) demodulation system=20 > that is being proposed to replace an older analog=20 > SSB demodulation system. >=20 > Having not thought about SSB systems for many years, I've=20 > been trying to figure out how the "phasing method" of=20 > SSB demodulation works. In trying to model this=20 > "phasing method" using Matlab, I'm producing inconsistent=20 > results when demodulating upper-sideband SSB signals=20 > compared to demodulating lower-sideband SSB signals. >=20 > In searching the Internet for tutorial SSB demodulation=20 > information I'm shocked at the inconsistent, contradictory,=20 > and ambiguous, SSB demod material that's on the=20 > web. I've found no web site, including MathWorks=20 > 'File Exchange' pages, that has helped me. >=20 > Either I'm misunderstanding the "phasing method" of=20 > SSB demodulation, or my Matlab code is fouled up.=20 > I can't figure what I'm doing wrong. >=20 > Anyway, does anyone out there have Matlab code that=20 > models the "phasing method" of SSB demodulation that=20 > they'd be willing to share with me? >=20 > Thanks, > [-Rick-]
Seems a simple, no impairment, baseband model of SSB mod/demod of phasing m= ethod using Matlab is trivial. Once you've created an analytic signal from= the real input (which is as simple as using Matlab's hilbert() function in= the Signal Processing Toolbox) you have the baseband SSB signal. Demod is= simply the real part of this signal. A passband model is almost as simple= , requiring only an up mixer like: x =3D real(exp(j*wc/ws*t)) where wc is t= he carrier freq, ws is the sampling freq, and t a time vector. Demod down = mixer: mssbhat =3D exp(j*(-wc)/ws*t). As simple as this is, in terms of your question I'm probably missing someth= ing fundamental about what you're asking. function [musb,mlsb,mhatu,mhatl] =3D demo_ssb(m) % m is the baseband (modulating) signal % Baseband transmitter model musb =3D myhilbert(m); mlsb =3D conj(musb); % Baseband receiver model mhatu =3D real(musb); mhatl =3D real(mlsb); function y =3D myhilbert(x) % Note: x is a row vector and length(x) must be even X=3Dfft(x); W=3D[1 2*ones(1,length(x)/2-1) 1 zeros(1,length(x)/2-1)]; Y =3D X.*W; y =3D ifft(x); return
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. 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) } 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). 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). to get the LSB, you start with v(t) = xi(t)*cos(w0*t) + xq(t)*sin(w0*t) = Re{ (xi(t) - j*xq(t)) * e^(j*w0*t) } and do the same thing. we used to do it with an AM receiver by just moving our "local oscillator" frequency (that mixed it into the IF and that kick-ass crystal-lattice filter) just a few kHz. and we tuned it by ear, because during vowels the spoken voice is a lot like the singing voice which is quasi-periodic and nearly harmonic. when the frequency components are offset by a non-zero constant, they sound a little inharmonic, and that was the source of the donald duck sound. we never had phase sync, so ham-radio SSB always had a little of the quack, quack sound. not quite the same as a guitar phase-shifter, but it was "phasey". without that local oscillator, SSB sounded like encrypted audio (you knew it was voice-related because the amplitude modulation had the cadence of spoken voice but it sounded like dog shit). totally unintelligible as was SSB that was detuned sufficiently (the latter was *really* quacky.) i wonder if there is something about the throat of ducks that has strong resonances ("formants" we call them) at frequencies not harmonically related? how does both detuned SSB and ducks both have a superficially similar "quack"? -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."
   [Snipped by Lyons]
> >Seems a simple, no impairment, baseband model of SSB mod/demod of phasing
m=
>ethod using Matlab is trivial.
Hi, because I'm using the dsprelated.com web site to access the newsgroup here, I'm unable to determine to whom I'm replying.
>Once you've created an analytic signal from= > the real input (which is as simple as using Matlab's hilbert() function
in=
> the Signal Processing Toolbox) you have the baseband SSB signal. Demod
is=
> simply the real part of this signal. A passband model is almost as
simple=
>, requiring only an up mixer like: x =3D real(exp(j*wc/ws*t)) where wc is
t=
>he carrier freq, ws is the sampling freq, and t a time vector. Demod down
=
>mixer: mssbhat =3D exp(j*(-wc)/ws*t). > >As simple as this is, in terms of your question I'm probably missing
someth=
>ing fundamental about what you're asking. > >function [musb,mlsb,mhatu,mhatl] =3D demo_ssb(m) >% m is the baseband (modulating) signal > >% Baseband transmitter model >musb =3D myhilbert(m); >mlsb =3D conj(musb); > >% Baseband receiver model >mhatu =3D real(musb); >mhatl =3D real(mlsb); > > >function y =3D myhilbert(x) >% Note: x is a row vector and length(x) must be even >X=3Dfft(x); >W=3D[1 2*ones(1,length(x)/2-1) 1 zeros(1,length(x)/2-1)]; >Y =3D X.*W; >y =3D ifft(x); >return
What your code seems to be doing is: [1] Accept a real-valued baseband input sequence 'm'. [2] Create a positive-freq-only baseband, analytic, version of 'm'. [3] Create a negative-freq-only baseband, analytic, version of 'm'. [4] Take the real parts of those two analytic signals to duplicate the original real-valued baseband 'm'. Yep, I'll certainly agree that these operations are trivial. 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. Thanks for your post. [-Rick-] PS. As far as I can tell, your 'myhilbert()' function does not produce the same results as Matlab's 'hilbert()' function. Or am I missing something?
Hi Randy,

>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? > >-- >Randy Yates
Yes, I think you are correct. I've modeled that exact process. And because we can discard the imaginary part of the complex-filtering result, based on my modeling it seems we only need to perform real-valued filtering. However, because the process described above is simpler than any SSB demod process I've found on the web, I'm suspicious that I'm doing something wrong in my Matlab modeling. That's why I wanted to have a look at other people's SSB demod Matlab code and compare it with mine. Thanks Randy, [-Rick-]
>PS. As far as I can tell, your 'myhilbert()' >function does not produce the same results >as Matlab's 'hilbert()' function. Or am >I missing something?=20
Yes, it differs due to a careless typo on my part. The line before the return statement should read: y =3D ifft(Y); instead I carelessly wrote: y =3D ifft(x); With this correction results should match Matlab's hilbert() function to wi= thin rounding.
>Hi, > because I'm using the dsprelated.com web site to >access the newsgroup here, I'm unable to determine >to whom I'm replying.=20
Yes, I'm a long time reader (and big fan) of your posts, books, tips and tr= icks etc. I'm not much of a poster but thought I could help out with this = particular question. I'm accessing this forum through Google Groups which = not only makes it impossible for you to know to whom you're replying but al= so seems to corrupt my text with what looks like formatting characters. So= rry for that. If you're still having problems and explain more about the inconsistencies = you're seeing in your model perhaps I could better help. Sincere regards. Mark
"Rick Lyons" <R.Lyons@n_o_s_p_a_m.ieee.org> writes:

> Hi Randy, > >>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? >> >>-- >>Randy Yates > > Yes, I think you are correct. I've modeled that > exact process. And because we can > discard the imaginary part of the complex-filtering > result, based on my modeling it seems we only need > to perform real-valued filtering. > > However, because the process described above is > simpler than any SSB demod process I've found on > the web, I'm suspicious that I'm doing something > wrong in my Matlab modeling. That's why I wanted > to have a look at other people's SSB demod Matlab > code and compare it with mine.
Rick, maybe the hard part of the problem is FINDING THE CARRIER FREQUENCY! I just ASSUMED one knows the carrier frequency. In reality, I don't know what you'd do to get a carrier lock on a SSB (suppressed carrier) signal.
> Thanks Randy,
As Robert and Fred say, FWIW, YMMV. And when are we gonna drink some beer together? -- Randy Yates Digital Signal Labs http://www.digitalsignallabs.com