Sie sind auf Seite 1von 18

Faculty of Engineering ELEN443

Digital Communication Project 2

Presented by: Ziad El Samad

Presented to: Dr. Jihad Daba

PART I: BPSK SIMULATOR


Introduction:
Phase-shift keying (PSK) is a method of digital communication in which the phase of a transmitted signal is varied to convey information. The simplest PSK technique is called binary phase-shift keying (BPSK). It uses two opposite signal phases (0 and 180 degrees). The digital signal (carrier) is broken up timewise into individual bits (binary digits). The state of each bit is determined according to the state of the preceding bit. If the phase of the wave does not change, then the signal state stays the same (0 or 1). If the phase of the wave changes by 180 degrees (if the phase reverses) then the signal state changes (from 0 to 1, or from 1 to 0). Because there are two possible wave phases, BPSK is sometimes called biphase modulation.

Figure 1: Generation of BPSK.

Figure 2: BPSK signal in the time domain.

Figure 3: BPSK modulated signal spectrum.

We generated a random unipolar signal with equally probable binary symbols. Then we converted it into a bipolar digital waveform and finally we generated the modulated signal Si(t) using BPSK. At the receiver, we received a noisy signal with WGN so a match filter is used for maximizing the signal to noise ratio (SNR) in the presence of additive stochastic noise. Finally the signal is sampled at the bit period Tb and a decision is made on whether a bit is 1 or 0 depending if the signal is more or less than the computed threshold.

Figure 4: Description of process.

According to figure 4 above, the signal is first sent by the transmitter, then a white Gaussian noise is added to the signal in the AWGN channel. Then we apply filtering using a matched filter and finally it is sampled by the receiver at the correct sampling instants, and compared to an appropriate threshold for a correct interpretation of the binary message.

Formulas we are using:


BPSK signal:

: Amplitude of sinusoidal carrier.


= 100 kbit/s (bit rate). = 1/ (bit period). = k* .
W/Hz (PSD of the WGN).

is the reference signal. The theoretical bit error ratefor BPSK: The experimental bit error probability is (

; where r=H[si( ), ( )]

is the number of errors. H(.,.) is the Hamming distance and n is the total number of bits over a sufficiently larger time . and

We choose the number of bits n so that

is very small typically 1%

Simulation:
First we calculate the sampling of S1 and S2 that are A1 and A0 and the threshold is calculated by =(A1+A0)/2; therefore it is equal to zero since A1 is equal to A0. Then we generate a bit stream of equal number of 1s and 0s and then randomize this sequence using the MATLAB function randperm. The number of bits n = 100 is chosen large in order to have a very small bit error rate. A unipolar waveform of amplitude the generated sequence. is plotted resembling

Unipolar Waveform 2 1.5 1 0.5 0 -0.5 -1 -1.5 -2

7 x 10

8
-5

Figure 5: Unipolar Waveform Generated.

Now we will convert the unipolar waveform into bipolar digital waveform and then modulate it.
Bipolar Waveform 2 1.5 1 0.5 0 -0.5 -1 -1.5 -2

7 x 10

8
-5

Figure 6: Bipolar Waveform Generated.


BPSK Modulated Waveform 2 1.5 1 0.5 0 -0.5 -1 -1.5 -2

7 x 10

8
-5

Figure 7: Bipolar Waveform after BPSK Modulation.

We add an additive white gaussian noise to the signal receivedusing the MATLAB function awgn.
Received Noisy Waveform 40 30 20 10 0 -10 -20 -30 -40

7 x 10

8
-5

Figure 8: Modulated BPSK Waveform after AWGN.

Then we use a Matched Filter thatmultiplies the received noisy signal with the reference signal in order to filter the noise of the signal and reconstruct the signal.

Waveform after Matced Filter 8000 6000 4000 2000 0 -2000 -4000 -6000 -8000

7 x 10

8
-5

Figure 9: Noisy Waveform after Matched Filter.

Finally decision is made by comparing the signal value ateach interval to a threshold and accordingly the signal is reconstructed.

Reconstructed Waveform 2 1.5 1 0.5 0 -0.5 -1 -1.5 -2

7 x 10

8
-5

Figure 10: Reconstructed Waveform after Decision.

The signal to noise ratio per sample and the probability of error is calculated. A comparison between the theoretical and the experimental BER is made.The value of n should be chosen so that the ratio should be small approximatly 1%.The BER is plotted against the SNR = Eb/N0 and N the number of bits.

Figure 11: Pe in function of SNR.

bit error probability and experimental bit error probability:

Theoretically: Our aim is to have DeltaPe/Pe less than 1%. For samples = 50000 bits (m = 100 times n=500) Pe = errors/(samples*100) = 0.2398 DeltaPe = 200*sqrt(errors)/(samples*100*100)=0.0025 DeltaPe = Pe = 0.0105 * 100 = 1.05% (should be less than 1%) So we should take more than 50000 samples.

Using theortical formula

Experimentally from MATLAB:

So theoretically BER = 0.0789 and experimentally BER = 0.0778

PART II: Comparative Performance Analysis Between PSK, FSK and ASK:

The transmitted waveforms of the 3 modulations are: PSK: ASK: Assuming Tb is a multiple of 1/fc. FSK: Assuming and for 0 t Tb ; i=1,2 for 0 t Tb ; i=1,2 for 0 t Tb ; i=1,2

0.5 0.45 0.4 0.35 0.3 0.25 0.2 0.15 0.1 0.05 0 -30 ASK PSK FSK -25 -20 -15 -10 -5 0 5 10 15 20

Figure 11: BER in function of SNR (Eb/N0).

We notice the curve plots have the waterfall shape. The PSK modulation achieves the lowest bit error rate among the three. FSK comes second and then ASK.

Appendix: (Code)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %Part I z=1; %constant global variable %to run the code on several p = [ 0.01:0.1:0.71 0.75 1:4:100] for p = 1 %number of bits computed in each loop n = 500; %number of loops m = 100; %bit rate Rb(z) = p*100 * 10^3; %bit period Tb = 1/Rb(z); nTs = 100; %sampling period T = 0:Tb/nTs:n*m*Tb-Tb/nTs; Ta= 0:Tb/nTs:m*n*Tb -Tb/nTs; Ac = 1; fc = 200*10^3; Ts = Tb/nTs; %PSD of AWGN N0 = 2*10^(-5);

syms t; %reference signal rs = sqrt(2*Rb)*cos(2*pi*fc*t); %original signal s = Ac*cos(2*pi*fc*t); f1 = s*rs; f0 = -s*rs; A1 = int(f1,0,Tb); A0 = int(f0,0,Tb); lamda = (A1+A0)/2; lamda = eval(lamda); %computing SNR Eb = 2*Ac^2*Tb; EboN0(z) = 10*log10(Eb/N0); SNR_sample = EboN0(z) - 10*log10(Tb/(2*Ts)); yup=[]; ybp=[]; ymd=[]; rn=[]; rnf=[]; rnfd=[]; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %Part I - 1: Generating Unipolar Signal for k = 1:m

for i = 1:n if i<= n/2 v(i)=1; else v(i)=0; end end v=v(randperm(length(v)));

nT = 1; for i = 1:length(v) for j = nT:nT+nTs-1 y(j)= Ac * v(i); end nT= nT+nTs; end nT = 1; yup=[yup y]; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %Part I - 2: Converting Unipolar to Bipolar nT=1; for i = 1:length(v) if v(i)==1 for j = nT:nT+nTs-1 y(j)= Ac; end else for j = nT:nT+nTs-1 y(j)= -Ac; end end nT= nT+nTs; end ybp=[ybp y]; nT = 1; for i = 1:length(v) if v(i)==1 for j = nT:nT+nTs-1 y(j)= Ac*cos(2*pi*fc*T(j)); end else for j = nT:nT+nTs-1 y(j)= -Ac*cos(2*pi*fc*T(j)); end end nT= nT+nTs; end ymd=[ymd y];

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %Part I - 3: Adding WGN to Signal and filter it with MF r = awgn(y,SNR_sample,'measured'); rn=[rn r];

rs = sqrt(2*Rb(z))*cos(2*pi*fc*T); for i=1:length(r) r(i)=r(i)*rs(i); end rnf=[rnf r]; intr = zeros(1,n); nT = 1; for i = 1:n for j = nT:nT+nTs-1 if j<=length(r) intr(i) = intr(i)+r(j); end end nT = nT+100; end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %Part I - 3: Adding WGN to Signal and filter it with MF %decision making for i=1:n if intr(i)<= lamda intr2(i)= 0; else intr2(i) = 1; end end %reconstructing signal nT=1; for i = 1:length(intr2) if intr2(i)==1 for j = nT:nT+nTs-1 intr3(j)= Ac; end else for j = nT:nT+nTs-1 intr3(j)= -Ac; end end nT= nT+nTs; end rnfd=[rnfd intr3]; [erb(k) ,ber] = symerr(intr2,v); end

serb = sum(erb);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %Calculating Pe, DeltaPe, BER and ratio(should be aproximatly 1% and below) x = 0.5*sqrt(2*Eb/N0); Pe(z)=0.5*erfc(x/sqrt(2)); deltaP = 200 * sqrt(serb)/(m*n*100); BER(z) = serb/(m*n) ratio = deltaP/Pe(z) z=z+1; end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %Plotting figure; hold on; plot(T,yup,'g'); axis([0 8*Tb -2 2]); title('Unipolar Waveform'); figure; hold on; plot(T,ybp,'g'); axis([0 8*Tb -2 2]); title('Bipolar Waveform'); figure; hold on; plot(T,ymd,'g'); axis([0 8*Tb -2 2]); title('BPSK Modulated Waveform'); figure; hold on; plot(T,rn,'g') axis([0 8*Tb -40 40]); title('Received Noisy Waveform'); figure; hold on; plot(T,rnf,'g'); axis([0 8*Tb -8000 8000]); title('Waveform after Matced Filter'); figure; hold on; plot(T,rnfd,'g'); axis([0 8*Tb -2 2]); title('Reconstructed Waveform'); figure; hold on;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %Part II z=1; N0 = 2*10^(-5); Ac = 1; for p = [ 0.01:0.1:0.71 0.75 1:4:100] Rb = p*100 * 10^3; Tb=1/Rb; %energy of ASK EdA = 0.5*Ac^2*Tb; %energy of PSK EdP = 2*Ac^2*Tb; %energy of FSK EdF = Ac^2*Tb; EdoN0A(z) = 10*log10(EdA/N0); EdoN0P(z) = 10*log10(EdP/N0); EdoN0F(z) = 10*log10(EdF/N0); xA = 0.5*sqrt(2*EdA/N0); PeA(z)=0.5*erfc(xA/sqrt(2)); xP = 0.5*sqrt(2*EdP/N0); PeP(z)=0.5*erfc(xP/sqrt(2)); xF = 0.5*sqrt(2*EdF/N0); PeF(z)=0.5*erfc(xF/sqrt(2)); z=z+1; end plot(EdoN0A,PeA,EdoN0P,PeP,EdoN0F,PeF); legend('ASK','PSK',2,'FSK',3);

Das könnte Ihnen auch gefallen