lab dsp_mac nhu minh_bkdn

7
DIGITAL COMMUNICATIONS LAB MANUALS 2012

Upload: xp2009

Post on 28-Oct-2014

26 views

Category:

Documents


0 download

DESCRIPTION

lab dsp1, mac nhu minh, lab xlth, xu li tin hbieu

TRANSCRIPT

Page 1: Lab Dsp_mac Nhu Minh_bkdn

DIGITAL COMMUNICATIONSLAB MANUALS

2012

Page 2: Lab Dsp_mac Nhu Minh_bkdn

LAB 1: HAMMING CODEIn this lab, we will utilize one error control code, known as the (7,4) Hamming blockcode. (7,4) means that 4 message bits, represented by the vector m, are convertedinto a 7-bit code, represented by the vector x = mG (modulo 2), where G is the"generator matrix" given by:

G =

1 1 0 1 0 0 00 1 1 0 1 0 01 1 1 0 0 1 01 0 1 0 0 0 1

(1)

After the message bits pass through a noisy medium that introduces unknownerrors, we can model the received vector y as follows:

y = x + e (modulo 2) (2)In modulo 2 addition we have 0 + 0 = 1 + 1 = 0; 0 + 1 = 1 + 0 = 1. Therefore

we imagine the error vector e as a binary vector; where a component of e is 1, thereceived y vector differs from the originating x vector. The receiver then needs todecode the data in an attempt to recover the original message bits. This producesa "syndrome", s, which determines what the error vector was (if no errors or only asingle bit error has occurred):

s = yHT (modulo 2) (3)where HT is the transpose of the "parity-check" matrix, H, given by:

H =

1 0 0 1 0 1 10 1 0 1 1 1 00 0 1 0 1 1 1

(4)

The 3-bit syndrome uniquely determines what the error pattern was, for singlebit errors. So since we know what the error was, we can correct it and decrease theprobability of a received bit error for the system!

If the syndrome is perceived as a binary number, it can be converted to decimaland used as an index into the following error-pattern look-up matrix. The decimalvalue of the syndrome now points to the row of E that contains the correspondingerror pattern.

E =

0 0 0 0 0 0 00 0 1 0 0 0 00 1 0 0 0 0 00 0 0 0 1 0 01 0 0 0 0 0 00 0 0 0 0 0 10 0 0 1 0 0 00 0 0 0 0 1 0

(5)

The (7,4) Hamming code is such that, when there is a single error in y, the rowof E chosen with the syndrome matches the e used above to model the relationshipbetween x and y. Therefore, given y, the decoding procedure is:

y (corrected) = y + e (modulo 2) = x + e + e (modulo2) = x (6)since addition modulo 2 of any binary vector to itself results in a vector of zeroes.

1

Page 3: Lab Dsp_mac Nhu Minh_bkdn

Assignment:

Write the following functions, using the Hamming code given above:

• A routine that takes a vector of four binary (0,1) symbols, and returns a vectorof seven bits containing the corresponding valid codeword (encoding);

• A routine that takes a vector of seven bits, decodes them, and returns a vectorof seven bits containing the decoded valid codeword (decoding).

The routines should be properly commented, and example outputs should be given.Question: Why might some of the bits still be in error after coding and decoding

with this (7,4) Hamming code? Explain.

2

Page 4: Lab Dsp_mac Nhu Minh_bkdn

LAB 2: MODULATION - DEMODULATIONWe are ready to transmit the binary data (such as bytes on a computer) over aphysical medium (such as an ethernet cable). In order to do so, a discrete-timesequence must be converted into a continuous-time signal for transmission. This isknown as modulation. Then the modulated signal will be sent to the channel fortransmitting. Figure 1 presents an example of a channel of transmission.

Figure 1: Channel of transmission.

Figure 2: BPSK.

In this lab, we will using BPSK - Binary phase-shift keying. BPSK (figure 2,also sometimes called PRK, Phase Reversal Keying, or 2PSK) is the simplest formof phase shift keying (PSK). It uses two phases which are separated by 180o and socan also be termed 2-PSK. This modulation is the most robust of all the PSKs sinceit takes the highest level of noise or distortion to make the demodulator reach anincorrect decision. It is, however, only able to modulate at 1 bit/symbol and so isunsuitable for high data-rate applications when bandwidth is limited.

Assignment:

Your task is to generate a sequence of 10000 bits in Matlab, modulate that sequenceusing BPSK, let the resulting signal to pass through the channel, where additivewhite Gaussian noise will be added. You will then receive a signal at the receiverend, demodulate it to recover another sequence. Check if this received sequence isthe same at the original one?

In order to accomplish this in our simulation, we must convert a sequence of’1’s and ’0’s into a sequence of ’+1’ and ’-1’, and then multiply by A, which is theamplitude of the carrier. In the first simulation we use only the single value A = 2,in the final simulation we use A =

[0.5, 1√

2, 1,

√2, 2, 2

√2, 4

].

You may want to use the function randn of Matlab in the processing of generatingthe original sequence. This function generates random numbers with zero mean anda Gaussian distribution of unit variance. With some others commands, you will getthe “0”s and “1”s sequence.

3

Page 5: Lab Dsp_mac Nhu Minh_bkdn

As for the additive white Gaussian noise, again, you can using the previouslymentioned randn function to generate a noise centering around zero and has avariance of 1 which tells us how much the random numbers vary about the mean.Thus in the zero mean case, as we have here, the variance is the mean square valueof the noise.

Once the signal arrives at the receiver, it must convert the continuous time signalback into a discrete one through an analog-to-digital conversion called demodulationor detection. We will use a simple threshold detector referred to as a slicer. Itsthreshold is 0V , so any signal above 0V will be interpreted as a ’1’ and any signalbelow 0V will be interpreted as a ’0’ (figure 3).

Figure 3: Demodulation.

Since this is a simulation, we have the original data sequence and can comparethe two received sequences to it to determine exactly how many errors occurred.This gives us an indication as to the probability of error for the particular signalenergy per bit to noise power density ratio we were using. For each value of Acompute the SNR in dB, plot the probability of message bit error vs. Eb

N0.

4

Page 6: Lab Dsp_mac Nhu Minh_bkdn

LAB 3: COMMUNICATION SYSTEMA simple communication system is presented in figure 4.

Figure 4: Communication system.

In the previvous sections you have already simulated the Channel Encoder &Channel Decoder; Modulation & Demodulation; as well as the Additive White Gaus-sian Noise. In this lab, you are required to put all of these blocks together to formthis system of communication.

Assignment:

1. Your task is to generate a sequence of N bits in Matlab, modulate the uncodedsequence using BPSK (of amplitude A), let the resulting signal pass throughthe channel, where additive white Gaussian noise will be added. You will thenreceive a signal at the receiver end, demodulate it to recover a demodulatedsequence. Check if this received sequence is the same at the original one? Foreach value of A and N compute the SNR in dB, plot the probability of messagebit error vs. Eb

N0. This is the performance of your system without channel

coding.

2. Using the same sequence generated in the previous task, now you should code itusing Hamming code before sending to the channel, then modulate the codedsequence using BPSK (of amplitude A), let the resulting continuous signalpass through the channel, where additive white Gaussian noise will be added.You will receive a noisy signal at the receiver end, demodulate it to recovera demodulated sequence. You will finally decode that sequence to obtain thereceiving sequence. Check if this received sequence is the same at the originalone? For each value of A and N compute the SNR in dB, plot the probabilityof message bit error vs. Eb

N0. This is the performance of your system with

channel coding (Hamming code).

3. Data:

• The amplitude of BPSK modulation is A =[0.5, 1√

2, 1,

√2, 2, 2

√2, 4, 4

√2].

• The number of bits is N = [20, 1000, 10000, 50000, 100000, 200000]. Checkif the value of N has an effect on the probability of message bit error?

• Note: Since the simulation will take time, you are recommended to avoidwasting a lot of time by being sure that the first simulation of N = 1000is correct before proceeding with the array of N .

5

Page 7: Lab Dsp_mac Nhu Minh_bkdn

4. Discussion:

• Check if the value of N has an effect on the probability of message biterror? You should be able to see that the validity of the results dependson not only your choice of A, but also your data stream length. Why?Think about why a simulation with a choice of parameters that yieldof no errors is not very useful (what is the error probability for thoseparameters? Is it valid?). How many bits would you need to simulatewith to detect a probability of error of 10−7? Choosing a very long datastream may become computationally prohibitive.

• Comment on how closely your data matches the theoretical curves shownin figure 5 (for the "Uncoded BPSK" and "(7,4) Hamming").

• In your conclusion, discuss how forward error control coding comparesto simply raising the signal to noise ratio for a digital communicationsystem. Be sure to mention power savings versus bandwidth.

Figure 5: Block code performance.

6