Sei sulla pagina 1di 6

Matlab Laboritory Exercise

Page 1

Digital Modulation in MATLABTM


This tutorial outlines the process of modulating binary (digital) information onto a continuous medium (such as radio waves) using digital modulation. The tutorial focuses on Phase Shift Keying (PSK) modulation.

A brief system introduction

PSK modulation in Matlab can be simulated using the pskmod() function and demodulation can be performed using pskdemod(). The pskmod() produces a sequence of channel symbols (e.g. {s3 , s3 , s5 , s6 , s1 , . . .}). This channel symbols live inthe complex plane and are represented by their I-channel and Q-channel plane. The I and Q representations together form nothing more exciting than a complex number. The following system model will be used:
Noise

e
Source

y
Sender

p
Receiver

The Source generates random bits (binary zeros and ones). This information m is fed to the Sender that PSK-modulates and produces y. This signal is transmitted onto a noisy channel which is disturbed by additive noise (AWGN), e. The resulting signal r is received and demodulated into a binary sequence p that should be identical to m if no errors happened. However, the demodulator and modulator functions in Matlab assumes do not operate on binary sequences. For instance the modulator function takes (minimum) two arguments: pskmod(x,M). Here x is the input signal and M is the size of the modulation, i.e. it performs M-PSK modulation. From the help text it is stated that x can contain only integers between 0 and M 1. In other words we do need to convert our binary information m to a integer sequence x and our demodulated integer sequence (lets call it w) to a binary sequence p. Lets step away from the modulation and channel and do only the binary/integer/binary conversions.

2
2.1

Converting between binary and integer sequences


Convert

To have something to convert lets produce a binary sequence: Digital Signal Processing Labs Oslo University College c 2009 Ola Jetlund. Some rights reserved.

Matlab Laboritory Exercise

Page 2

Exercise: Create a sequence m with N = 8192 elements consisting of only zeros and ones

Now to convert from binary to integer we rst need to group k bits together that will form an integer. Remember that e.g. binary 000 is an integer equal to zero, while binary 0101 is an integer equal to ve. Now how many bits should we group together. Remember that M-PSK modulation has M different symbols and each symbol can can therefore represent k = log2 M bits. In order to form groups of k bits we can reshape the sequence m into a matrix. Subsequently we can convert each of these groups into an integer sequence using bi2de(). See the following gure:

1 0 1 0 0 1 1 1 1 0 1 0 0 1 0 0

reshape()

1 1 0 1 1 1 0 0

0 0 1 1 0 0 1 0

bi2de()

3 0 3 0 0 3 1 1

We must however make sure that there are the same number of elements in the input and output of reshape (the rst two ellipses). This can be controlled (since length of m is a power of 2): Exercise: For k = 2 how many rows are there in the reshaped version of m?

Digital Signal Processing Labs Oslo University College c 2009 Ola Jetlund. Some rights reserved.

Matlab Laboritory Exercise

Page 3

Find a general setting for reshaping any sequence m into matrix that groups k = log2 M bits. Convert your sequence m into an integer sequence x for M = 2

2.2

Convert back

To convert back we use de2bi() and reshape(). However, her we do have to consider where to put the mod signicant bit. And the solution is to use for instance: p = reshape(de2bi(x,right-msb),length(m),1); Exercise: Convert x back to binary form, name the new sequence p. How can we compare m and p? Count the number of errors between m and p.

Modulation, demodulation, and noise

Now we can modulate x. By doing y = pskmod(x,M) this function does M-PSK modulation of the information in x denne funksjonen QAM modulerer signalet x[n], M = 16. After the signal is modulated (into y) we shall add noise. We shall use two methods for calcluating the noise added: Signal-to-noise ratiosty forhold per symbol Ratio of bit energi to noise Eb /N0 The following relation converts between the two:

Digital Signal Processing Labs Oslo University College c 2009 Ola Jetlund. Some rights reserved.

Matlab Laboritory Exercise

Page 4

k = log2(M) SNR = EbNo + 10*log10(k) - 10*log10(1) For SNR the following function will add noise: r = awgn(y,snr,measured) Demodulation is performed subsequently using pskdemod().

Evaluation

Lets repeat the entire system:


Noise

e
Source

y
Sender

p
Receiver

In order to evaluate this system we shall compare p and q. This can be done using the following function: [number, ratio] = biterr(p,q) This function nds the number of errors, and also calculates the bit error rate (BER).The BER is a good measure of how good a modulation technique is. We will therefore plot it for different values of SNR and Eb /N0 . And the nal plot may look likethe plot in Figure 1. Note, the logarithmic scale which we get by using the semilogy instead of the plot Notice that the BER is plotted for Eb /N0 = {1, 2, 3, 4, . . .}, and note also that these are dB values. For each point in plot the system has been simulated to nd at least 100 errors. Digital Signal Processing Labs Oslo University College c 2009 Ola Jetlund. Some rights reserved.

Matlab Laboritory Exercise

Page 5

Figure 1: Forholdet mellom styniv aet og bitfeil.

Digital Signal Processing Labs Oslo University College c 2009 Ola Jetlund. Some rights reserved.

Matlab Laboritory Exercise

Page 6

5
5.1

The real work


2PSK aka BPSK

Exercise: Plot the BER versus Eb /N0 and SNR (in two different) gures.

5.2

4PSK and 8PSK

Exercise: Also plot the BER versus Eb /N0 and SNR. Put all BER versus Eb /N0 in the same gure, and all BER versus SNR in another gure. Compare the the three different PSK modulation techniques.

5.3

Oppppst we forgot Grays Anatomy

The pskmod() does not use Gray coding as standard. Exercise: Use 4PSK with and without Gray coding. Plot the BER versus Eb /N0 for both of them. Compare the results.

Digital Signal Processing Labs Oslo University College c 2009 Ola Jetlund. Some rights reserved.

Potrebbero piacerti anche