首页 > > 详细

代做UESTC 4004 Digital Communications Lab 1: Modulation/Demodulation代做Matlab编程

项目预算:   开发周期:  发布时间:   要求地区:

Digital Communications

(UESTC 4004)

Lab 1: Modulation/Demodulation

This lab introduces you to the phase shift keying modulation technique. You shall transmit a signal using binary phase shift keying (BPSK) and then demodulate the received signal using BPSK demodulation. Bit Error Rate (BER) of BPSK will be calculated and plotted. Finally, the process is repeated for quadrature phase-shift keying (QPSK).

BINARY PHASE SHIFT KEYING (BPSK)

1.1 Source

This component generates 10000 information-bearing uncoded bits, which are randomly drawn from the binary set {0, 1} with the equal probability. 

Use the MATLAB code below to generate the bits.

num_bits = 10000;    % Number of bits in a frame

bits = rand(1, num_bits) > 0.5; % Generated information bits

1.2 Modulator

This component maps binary bits to BPSK symbols. The uncoded bits are fed into a BPSK modulator to yield BPSK symbols.

Use the MATLAB code below to generate the BPSK modulated bits. 

bpsk_sig = -2*(bits-0.5);   % Modulated data

1.3 Thermal Noise.

This component adds complex Gaussian noise onto the communication signal. The noise is random and should have zero mean, unity power and should vary symbol-by-symbol. Assume Signal-to-Noise Ratio (SNR) of 0 dB.

Use the MATLAB code below to obtain the received BPSK signal with noise added. 

SNR_dB = 0;    % let SNR be 0 dB

N0 = 1/10^(SNR_dB/10);  % Noise power with signal power of 1.   

a = length(bpsk_sig);

Noise = sqrt(N0/2)*(randn(1,a)+1i*randn(1,a)); % AWGN Noise

Rx_bpsk_sig = bpsk_sig + Noise;    % Received signal 

Please not the multiplying factor sqrt(N0/2) in the Noise equation is used to generate normalised noise values with amplitude sqrt(N0). Sqrt is used to convert power to amplitude. Remember the relationship between power and amplitude.

Task 1.1: Plot the first 10 bits of the received binary data using the MATLAB code below.         [1]

stem(Rx_bpsk_sig(1:10));

1.4 Demodulation.

This component first reproduces original symbols from distorted signals through employment of the minimum-distance detection algorithm.

Use the MATLAB code below to demodulate the signal.

Demod_bpsk_bits = Rx_bpsk_sig < 0;  % Demodulated BPSK signal

1.5 Bit Error Rate (BER)

This component calculates the BER by comparing the demodulated signal with the original bits produced by Source. The definition of BER is,

Use the MATLAB code below to calculate the BER.

Error_bits_bpsk = bits - Demod_bpsk_bits; % Find errors bits

BER_bpsk = sum(abs(Error_bits_bpsk))/num_bits;  % BER

Task 1.2. Write down the number of error bits. Does it remain the same when you run the code multiple times? If not, why?  [1]

1.6 BER vs SNR

Write a MATLAB code to calculate the BER for SNR values [0: 2: 10] dB.

Hint 1: You should use the components from Section 1.1-1.5 to loop through the SNR values [0: 2: 10] dB and calculate BER for each SNR value.

Hint 2: Note that you have obtained the BER of BPSK for signal-to-noise (SNR) of 0 dB by following the steps in Section 1.1-1.5.

Hint 3: You should use the “for loop”.

Task 1.3. Plot the BER as a function of SNR for SNR = [0 : 2 : 10] dB using the MATLAB code below. Add axes labels and title to the figure. [1] 

semilogy(SNR,BER_bpsk,'-');

Task 1.4. Search through MATLAB Help to find another way of BPSK modulation and demodulation. Write the code for BPSK modulation and demodulation using these built-in functions. [1]  

QUADRATURE PHASE SHIFT KEYING (QPSK)

2.1 Source

Generate 10000 information bits as in Section 1.1.

2.2 Modulator

This component maps binary bits to QPSK symbols. The generated bits are fed into a QPSK modulator to yield QPSK symbols.

Use the MATLAB code below to modulate the bits.

% Split the bits into two streams

Bits1 = bits(1:2:end);

Bits2 = bits(2:2:end);        

% QPSK pi/4 radians constellation

qpsk_sig = ((Bits1==0).*(Bits2==0)*(exp(1i*pi/4))+(Bits1==0).*(Bits2==1)...

*(exp(3*1i*pi/4))+(Bits1==1).*(Bits2==1)*(exp(5*1i*pi/4))...

+(Bits1==1).*(Bits2==0)*(exp(7*1i*pi/4)));

Task 2.1. Plot the modulated data constellation using the MATLAB code below. [1] 

plot(real(qpsk_sig),imag(qpsk_sig),'o');

2.3 Thermal Noise.

This component adds complex Gaussian noise onto the communication signal. The noise is random and should have zero mean, unity power and should vary symbol-by-symbol. Assume SNR of 0 dB.

Use the MATLAB code below to obtain the received QPSK signal with noise added.

SNR_dB = 0;     % let SNR be 0 dB

N0 = 1/10^(SNR_dB/10);  % Noise variance with signal power of 1.

a = length(qpsk_sig);

Noise = sqrt(N0/2)*(randn(1,a)+i*randn(1,a)); % AWGN Noise 

Rx_qpsk_sig = qpsk_sig + Noise;    % Received signal

Task 2.2. Plot the received data constellation using the MATLAB code below and repeat for SNR values of 10dB and 20dB. [1]

plot(real(Rx_qpsk_sig(1:100)),imag(Rx_qpsk_sig(1:100)),'*');     

What difference do you observe with the change in SNR? Explain the reason for the difference. [1]  

2.4 Demodulation.

This component first reproduces original symbols from distorted signals through employment of the minimum-distance detection algorithm. 

Use the MATLAB code below to demodulate the signal.

Bits4 = (real(Rx_qpsk_sig)<0);

Bits3 = (imag(Rx_qpsk_sig)<0);   

Demod_qpsk_bits = zeros(1,2*length(Rx_qpsk_sig));

% Demodulated bits

Demod_qpsk_bits(1:2:end) = Bits3;

Demod_qpsk_bits(2:2:end) = Bits4;

2.5 Bit Error Rate (BER)

This component calculates the BER by comparing the demodulated signal with the original bits produced by Source. The definition of BER is,

Use the MATLAB code below to calculate the BER 

Error_bits_qpsk = bits - Demod_qpsk_bits; % Calculate Bit Errors

BER_qpsk = sum(abs(Error_bits_qpsk))/num_bits;  % BER

2.6 BER vs SNR

Write a MATLAB code to calculate the BER for SNR values [0: 2: 10] dB.

Hint 1: You should use the components from Section 2.1-2.5 to loop through the SNR values [0: 2: 10] dB and calculate BER for each SNR value.

Hint 2: Note that you have obtained the BER of QPSK for signal-to-noise (SNR) of 0 dB by following the steps in Section 2.1-2.5.

Hint 3: You should use the “for loop”.

Task 2.3. Plot the BER as a function of SNR for SNR = [0:2:10] dB using the “semiology” function below. Add axes labels and title to the figure. [1]    

semilogy(SNR,BER_qpsk,'--');

Task 2.4. Compare the BER vs SNR curves for BPSK and QPSK by plotting them on the same graph. What modulation scheme would you prefer if you wanted to have reduced error rates? What disadvantage will you face with your selection, if any. [2]

 

 

 

软件开发、广告设计客服
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-23:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 9951568
© 2021 www.rj363.com
软件定制开发网!