You are on page 1of 9

12/09/2017 Creat-Tricks: Beyond the Limit of Imagination: MATLAB: Analog QAM with Stereo Signals

  More    Next Blog» Create Blog   Sign In

Creat­Tricks: Beyond the Limit of Imagination
The journey of a thousand miles begins with a single step and that step begins with a simple thought.

Tuesday, November 6, 2012

About Creat Tricks
MATLAB: Analog QAM with Stereo Signals Sagar Patel

Creat Tricks is a platform to explore innovative
Hello Guys, Ideas. Any Invention is an extracted version of
very tiny and crazy idea. So, This is the way,
I hope you are enjoying there. Today, I am having a lot of work esp. final projects for begins with a "TINY" Thought. And this is a
semester end. My college is off from next week due to Diwali Vacation. So, having a Step towards thousand miles long journey.
lot of work… .............................................................. About
the Blogger: I am an engineer, who want to
Anyway, I am taking some rest. So, wanna get back to MATLAB. chase limits. I like to solve real world problem
We are starting with DSB­SC scheme for modulation and demodulation. And then we using existing resources. I believe that
creativity, smart working, dedication and
will discuss Analog Qudrature Amplitude modulation scheme for sending two different encouragement can make anything possible.
signals at the same frequency band modulated with sinusoid carrier. For one signal to So, i started this blog for all those crazy people
be modulated, we are using cosine and, for another is modulated by Sine. And we will who want to go above the knowledge written in
the book, who want to think beyond the limit of
also write a code in MATLAB to do the analysis. technology and who want to build his own
Let’s look at the simple modulation scheme. creative world. As far as, non­technical things
are concerned, I like having good time with
friends. I like walking in the rain, listening to soft
music, making new friends and meeting new
people. I love Music. And I feel that, "Music is
an Invisible Visualization". I also play drums in
free time. I love travelling and exploring
different culture.

DSB­SC View my complete profile

Pages

Home

Relativity and Time Travel

Creative Arduino Interface

Figure 1. Schematic representations of the amplitude modulation and demodulation schemes: (a) Creative MATLAB Implementation
modulator and (b) demodulator.
Creative Max/MSP Intigration
Here  n  is  time  domain  representing  variable  (continuous  time).    And  Acoswo n  is
carrier wave. And mixer multiplies these two signals in time domain and generates the MusiTronics
output y[n].
Looking the time domain representation of signals…
Blog Archive

►  2016 (1)
►  2013 (2)
▼  2012 (8)
►  December (1)
▼  November (3)
Max/MSP with Arduino:
Multiplexing 8 inputs using ...
Arduino: LED blinking with
variable speed
MATLAB: Analog QAM with
Stereo Signals

►  October (2)
►  September (1)
►  May (1)

Followers
Figure 2: (a) Message signal = m(t) = x[n]. (b) Carrier Signal = c(t) = c[n] =Acoswon. (c) Modulated
Signal = y[n]

http://creat-tricks.blogspot.in/2012/11/quadrature-amplitude-modulation-for.html 1/9
12/09/2017 Creat-Tricks: Beyond the Limit of Imagination: MATLAB: Analog QAM with Stereo Signals
From  Figure  2,  Modulated  signal  is  having  carrier  varing  in  the  amplitude  with Followers (1)
reference  to  the  message  signal.  This  scheme  is  also  called  DSB­SC (Double Side
Band Suppressed Carrier).
DSB­Sc in frequency domain is shown in following figure. Follow

Figure 3. |X(F)| = Magnitude spectrum of message signal and |Y(F)| is Magnitude Spectrum of
modulated signal
From  the  frequency  domain  representation,  message  signal  is  of  bandwidth  FM  and
frequency  of  carrier  is  Fc.  The  Modulated  signal  is  shifted  to  +  and  ­  Fc.  And  the
bandwidth of modulated signal is doubled i.e. 2FM than the modulating signal.
To demodulate the signal at the receiver end, we will multiply the received signal i.e.
y[n]  with  locally  generated  carrier  (can  be  extracted  from  received  signal)  and  then
Low  Pass  filtering  of  the  signal  will  give  the  original  signal  back…  This  way  we  can
send a signal over the channel i.e. wireless or wired.

Analog QAM
It is possible to modulated one signal by sine wave and other by cosine and add them
together  to  get  the  modulated  signal.  By  using  this,  we  can  save  the  requirement  of
different  frequency  band  for  other  signal.  This  is  also  called  Analog  Quadrature
Amplitude modulation (Analog QAM).
Let’s look at the model of QAM.

Figure 4. Schematic representations of the quadrature amplitude modulation

Here, two different signals x1[n] and x2[n] are being modulated by Acoswon and Asinwon (i.e.
90o shifted of Acoswon) respectively. So, the output of two mixer will be Ax1[n]coswon and
Ax2[n]sinwon. Now the next stage is to add these two signals to get the modulated signal y[n].

Figure 5. Carrier wave (a) Asinwot (b) Acoswot

http://creat-tricks.blogspot.in/2012/11/quadrature-amplitude-modulation-for.html 2/9
12/09/2017 Creat-Tricks: Beyond the Limit of Imagination: MATLAB: Analog QAM with Stereo Signals
Figure 6. Message Signal (a) x2[n] (b) x1[n]

Figure 7. Modulated Results (a) Ax2[n]sinwon (b) Ax1[n]coswon

Figure 8. Combined signal for transmission i.e. final modulated signal = y[n]

Writing the equation of y[n],

                y[n] = Ax1[n] cos(ωon) + Ax2[n] sin(ωon)

Note  that  the  two  carrier  signals  have  the  same  carrier  frequency  ωo  but  have  a  phase
difference of 90o. In general, the carrier A cos(ωon) is called the in­phase component and
the  carrier  A  in(ωon)  is  called  the  quadrature  component.  The  spectrum  Y  (ejω)  of  the
composite signal y[n] is now given by,

Y (ejω) = A/2 {X1(ej(w­wo)) + X1(j(w+wo))} + A/2j {X2(ej(w­wo)) ­ X2(j(w+wo))}

This signal y[n] is transmitted through channel and it is received by the receiver.

To recover the original modulating signals, the composite signal is multiplied by both the in­
phase (coswon) and the quadrature (sinwon) components of the carrier separately resulting in
two signals:

Figure 9. Demodulator of QAM

The demodulation process requires the carrier locally generated. Here also, the process is same
as  DSB­SC  demodulation.  But  in  upper  path,  the  carrier  which  is  multiplying  with  signal  is
coswon and for lower path it is sinwon. So, at the output of mixer is something like,

                        r1[n] = y[n] cos(ωon) and r2[n] = y[n] sin(ωon)

So,
r1 [n] = A/2 x1[n] + A/2 x1[n] cos (2won) + A/2 x2[n] sin (2won) and
r2[n] = A/2 x2[n] + A/2 x1[n] sin (2won) ­ A/2 x2[n] cos (2won).

Now to get both the signals back, we will pass these signals with low­pass filter with cut­off
frequency = wm. So the output of low­pass filter will be A/2 x1[n] and A/2 x2[n] respectively.

http://creat-tricks.blogspot.in/2012/11/quadrature-amplitude-modulation-for.html 3/9
12/09/2017 Creat-Tricks: Beyond the Limit of Imagination: MATLAB: Analog QAM with Stereo Signals
And  hence,  we  will  get  both  the  signals  at  the  receiver  end  by  transmitting  in  the  same
frequency band.

Now this is the time to implement this scheme in MATLAB.

MATLAB Implementation
For doing this, we will use an audio file (in wav format). This file have two audio component
i.e.  left  and  right  audio.  So,  we  will  get  two  different  signal  like  x1[n]=left  signal  and
x2[n]=right signal.  Now,  we  will  modulate  these  signals  with  sinusoid  signals  of  freq  wo  =
16kHz. But t do that, first we need to understand the problem with matlab to do modulation.
Matlab works with signal in terms of matrix. All matrix are discrete quantities. So, to get the
perfect (not perfect but somewhat more) glimpse of analog signal we will up­sample the signal
by 10. And then we will modulate it add it and transmit it. To understand the modulation and
demodulation  only  we  are  not  considering  the  noise  (In  practice,  the  noise  will  always  be
present). Now, at the other end, received signal is same as transmitted signal because, noise is
not  considered.  So,  to  get  the  original  signal  back,  we  will  multiply  the  signal  with  in­phase
and  quadrature­phase  component  of  wo  frequency.  Then  for  low­pass  filter  we  will  design
Butterworth low­pass filter having pass band frequency 4kHz and stop band = 10kHz. The next
thing  is  to  down  sample  the  signal  to  remove  the  extra  samples  which  we  have  added  at  the
modulation  time.  Now  we  will  get  the  left  and  right  signal  back.  To  get  the  original  audio
signal back i.e. stereo signal, we will structure the matrix of received left and right file. And
then we will listen the audio.
Following are the figures, which will help to learn in better way with graphical representation.

Figure 10. Stereo signal with left and Right channel signal and their zooming version

Figure 11. Left signal and Up­Sampled with interpolation (Zooming Version)

http://creat-tricks.blogspot.in/2012/11/quadrature-amplitude-modulation-for.html 4/9
12/09/2017 Creat-Tricks: Beyond the Limit of Imagination: MATLAB: Analog QAM with Stereo Signals

Figure 12. Frequency Response of Cosine wave

Figure 13. Frequency Response of Sine wave

Figure 14. Left and Right wave with carrier and modulated wave

http://creat-tricks.blogspot.in/2012/11/quadrature-amplitude-modulation-for.html 5/9
12/09/2017 Creat-Tricks: Beyond the Limit of Imagination: MATLAB: Analog QAM with Stereo Signals

Figure 15. Separately Modulated wave and their addition i.e. final transmitted wave

Figure 16. Frequency Spectrum of Message signal, Carrier and Modulated wave.

Figure 17. Spectra of Received signal and their multiplication with in­phase and quadrature
component of frequency wo.(Here for rec1 and rec2 the higher freq component is overwriting. i.e.
actually higher freq. component is at 3.2kHz. But due to insufficient FFT samples it is showing ar
1.2kHz)
  

http://creat-tricks.blogspot.in/2012/11/quadrature-amplitude-modulation-for.html 6/9
12/09/2017 Creat-Tricks: Beyond the Limit of Imagination: MATLAB: Analog QAM with Stereo Signals

Figure 18. Butterworth Low­Pass Filter Response (Fp=4kHz and Fs = 10kHz)

Figure 19. Frequency Spectrum of Received signal, Multiplied received signal with carrier overlaying
the bandpass response and low pass filtered signal.

Figure 20. Received Signal 1 = Left (Upper one), Received signal 2 = Right (Middle One) and
Generated Stereo Signal (Lower one)

The code for this program is
272 subplot(313);
273 plot(t',final);
274 title('Stereo Signal (Left = B and Right = G) in Time Domain');
275 xlabel('Time (Seconds)');ylabel('Amplitude');
276 %% Plotting Error Signal (We have not included AWGN. So Error = 0)
277 E_l = s_l ­ lft_dwn;
278 E_r = s_r ­ rht_dwn;
279 E_str = signal ­ final;
280 figure(13);
281 t=0:1/fs:Time­(1/fs);
282 subplot(311);
283 plot(t,E_l);
284 title('Error in Left Signal in Time Domain');
285 xlabel('Time (Seconds)');ylabel('Amplitude');
286 subplot(312);
http://creat-tricks.blogspot.in/2012/11/quadrature-amplitude-modulation-for.html 7/9
12/09/2017 Creat-Tricks: Beyond the Limit of Imagination: MATLAB: Analog QAM with Stereo Signals
286 subplot(312);
287 plot(t,E_r);
288 title('Error in Right Signal in Time Domain');
289 xlabel('Time (Seconds)');ylabel('Amplitude');
290 subplot(313);
291 plot(t',E_str);
292 title('Error in Stereo Signal (Left = B and Right = G) in Time Domain'
293 xlabel('Time (Seconds)');ylabel('Amplitude');
294 %% Listening to the Saperate channels
295 display('Left Received and Down­sampled Signal <press any="any" key="key">'
296 pause;
297 sound([lft_dwn' zeros(length(lft_dwn),1)],fs);
298 display('Left Signal');
299 pause;
300 display('Right Received and Down­sampled Signal <press any="any" key="key">'
301 pause;
302 sound([zeros(length(rht_dwn),1) rht_dwn'],fs);
303 display('Right Signal');
304 pause;
305 %% Playing a stereo Signal
306 display('Received Stereo Signal <press any="any" key="key">');
307 pause;
308 sound(final,fs);

Guys, I hope that you will run this code and I am pretty sure that you will enjoy…
If you would like to do some innovation like adding an additive white Gaussian noise, changing the
filter type i.e. chebysev, Elliptic, Bessel,etc.
Thank you buddy… Bye…

Posted by Sagar Patel at 12:41 AM 

Labels: Creative MATLAB Implementations

1 comment:
Islamic point December 24, 2013 at 7:46 PM

nice... visit 
http://islamicpoint2013.blogspot.com/

Reply

Enter your comment...  

Comment as:  Select profile...


 
Publish Preview

Newer Post Home


Older Posts

Subscribe to: Post Comments (Atom)

Follow by Email

Email address... Submit

There was an error in this gadget

Awesome Inc. theme. Powered by Blogger.

http://creat-tricks.blogspot.in/2012/11/quadrature-amplitude-modulation-for.html 8/9
12/09/2017 Creat-Tricks: Beyond the Limit of Imagination: MATLAB: Analog QAM with Stereo Signals

http://creat-tricks.blogspot.in/2012/11/quadrature-amplitude-modulation-for.html 9/9

You might also like