You are on page 1of 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:







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.


Converting between binary and integer sequences

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

Remember that M-PSK modulation has M different symbols and each symbol can can therefore represent k = log2 M bits. while binary 0101 is an integer equal to five.g. Some rights reserved. In order to form groups of k bits we can reshape the sequence m into a matrix. . Remember that e. See the following figure: 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 first two ellipses). Subsequently we can convert each of these groups into an integer sequence using bi2de(). 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. Now how many bits should we group together.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 first need to group k bits together that will form an integer. binary 000 is an integer equal to zero.

Some rights reserved. After the signal is modulated (into y) we shall add noise.1).2 Convert back To convert back we use de2bi() and reshape(). her we do have to consider where to put the mod significant bit. By doing y = pskmod(x.M) this function does M-PSK modulation of the information in x denne funksjonen QAM modulerer signalet x[n]. 3 Modulation.Matlab Laboritory Exercise Page 3 • Find a general setting for reshaping any sequence m into matrix that groups k = log2 M bits. And the solution is to use for instance: p = reshape(de2bi(x. However. .’right-msb’). • Convert your sequence m into an integer sequence x for M = 2 2. and noise Now we can modulate x.length(m). demodulation. name the new sequence p. Exercise: • Convert x back to binary form. We shall use two methods for calcluating the noise added: • Signal-to-noise ratiostøy 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. • How can we compare m and p? • Count the number of errors between m and p. M = 16.

and note also that these are dB values. Note. This can be done using the following function: [number.q) This function finds the number of errors. 4. And the final plot may look likethe plot in Figure 1.}. and also calculates the bit error rate (BER). For each point in plot the system has been simulated to find at least 100 errors. We will therefore plot it for different values of SNR and Eb /N0 . 2. Digital Signal Processing Labs Oslo University College c 2009 Ola Jetlund.The BER is a good measure of how good a modulation technique is. 3.’measured’) Demodulation is performed subsequently using pskdemod(). ratio] = biterr(p. 4 Evaluation Let’s repeat the entire system: Noise e Source m y Sender + r p Receiver In order to evaluate this system we shall compare p and q.10*log10(1) For SNR the following function will add noise: r = awgn(y. Some rights reserved. . .snr. . the logarithmic scale which we get by using the semilogy instead of the plot Notice that the BER is plotted for Eb /N0 = {1. .Matlab Laboritory Exercise Page 4 k = log2(M) SNR = EbNo + 10*log10(k) .

Digital Signal Processing Labs Oslo University College c 2009 Ola Jetlund. .Matlab Laboritory Exercise Page 5 Figure 1: Forholdet mellom støyniv˚ aet og bitfeil. Some rights reserved.

• Plot the BER versus Eb /N0 for both of them. Digital Signal Processing Labs Oslo University College c 2009 Ola Jetlund.1 The real work 2PSK aka BPSK Exercise: • Plot the BER versus Eb /N0 and SNR (in two different) figures. • Compare the results. .Matlab Laboritory Exercise Page 6 5 5. 5. Some rights reserved. Exercise: • Use 4PSK with and without Gray coding. Put all BER versus Eb /N0 in the same figure. • Compare the the three different PSK modulation techniques.3 Oppppst we forgot Gray’s Anatomy The pskmod() does not use Gray coding as standard. and all BER versus SNR in another figure. 5.2 4PSK and 8PSK Exercise: • Also plot the BER versus Eb /N0 and SNR.