18
EC-555 ADVANCED COMMUNICATION SYSTEM 2014 1 Department of Elect. and Comm. Engg. , Dr. B R Ambedkar National Institute of Technology, Jalandhar Experiment No:-[1] EXPERIMENT: - To generate line equation and signal with AWGN noise. SOFTWARE REQUIRED: - Matlab 7.12.0. THEORY:- Here a straight line equation having slope ‘m’ and constant ‘c’ is generated . Secondly a cosine signal is generated and after addition of AWGN(Additive White Gaussian Noise) its response is shown. MATLAB CODE:- close all; clear all; clc; % RAMP FUNCTION t=0:0.01:5; a=4; N=a*t; subplot(2,2,1); plot(t,N); title('Ramp Funcion'); xlabel('Time'); ylabel('Amplitude'); %SINE FUNCTION f=1; y=sin(2*pi*f*t); subplot(2,2,2); plot(t,y); xlabel('Time'); ylabel('Amplitude'); title('Sine Funcion'); %Noise addition z=awgn(y,5); subplot(2,2,3); plot(t,z); xlabel('Time'); ylabel('Amplitude'); title('Noise signal'); subplot(2,2,4); plot(t,y,t,z); xlabel('Time'); ylabel('Amplitude'); title('Noise & sine signal');

Rakshk Acs Lab

Embed Size (px)

DESCRIPTION

Lab

Citation preview

Page 1: Rakshk Acs Lab

EC-555 ADVANCED COMMUNICATION SYSTEM 2014

1 Department of Elect. and Comm. Engg. , Dr. B R Ambedkar National Institute of Technology, Jalandhar

Experiment No:-[1] EXPERIMENT: - To generate line equation and signal with AWGN noise. SOFTWARE REQUIRED: - Matlab 7.12.0. THEORY:-Here a straight line equation having slope ‘m’ and constant ‘c’ is generated . Secondly a cosine signal is generated and after addition of AWGN(Additive White Gaussian Noise) its response is shown. MATLAB CODE:-close all; clear all;clc; % RAMP FUNCTION t=0:0.01:5; a=4;N=a*t; subplot(2,2,1);plot(t,N);title('Ramp Funcion');xlabel('Time'); ylabel('Amplitude'); %SINE FUNCTIONf=1;y=sin(2*pi*f*t); subplot(2,2,2);plot(t,y);xlabel('Time'); ylabel('Amplitude'); title('Sine Funcion'); %Noise additionz=awgn(y,5); subplot(2,2,3);plot(t,z); xlabel('Time'); ylabel('Amplitude'); title('Noise signal'); subplot(2,2,4);plot(t,y,t,z);xlabel('Time'); ylabel('Amplitude'); title('Noise & sine signal');

Page 2: Rakshk Acs Lab

EC-555 ADVANCED COMMUNICATION SYSTEM 2014

2 Department of Elect. and Comm. Engg. , Dr. B R Ambedkar National Institute of Technology, Jalandhar

RESULTS:-

-

Page 3: Rakshk Acs Lab

EC-555 ADVANCED COMMUNICATION SYSTEM 2014

3 Department of Elect. and Comm. Engg. , Dr. B R Ambedkar National Institute of Technology, Jalandhar

Experiment No:-[2] EXPERIMENT: - To generate ASK signal.

SOFTWARE REQUIRED: - Matlab 7.12.0. THEORY:-ASK is a type of modulation or shift keying in which the strength (amplitude) of the carrier wave is varied to represent 1 or 0 pulses. Here a high amplitude represents a 1 and a low amplitude is a 0.

MATLAB CODE:-clear all;close all; clc; x=input('Enter the input digital sequence');N=length(x);t=0.01:0.01:N; % Carrier generatec=sin(2*pi*t);% Binary sequence generatefor i=1:1:Nm((i-1)*100+1:i*100)=x(i);end % ASK generation y=c.*m; % Display Binary sequencesubplot(3,1,1);plot(m);xlabel('time');ylabel('amplitude'); title('digital input signal');% Display Carrier signal subplot(3,1,2);plot(c); xlabel('time');ylabel('amplitude'); title('sinusoidal signal');subplot(3,1,3);plot(y);xlabel('time');ylabel('amplitude'); title('ASK modulated signal');

Page 4: Rakshk Acs Lab

EC-555 ADVANCED COMMUNICATION SYSTEM 2014

4 Department of Elect. and Comm. Engg. , Dr. B R Ambedkar National Institute of Technology, Jalandhar

RESULTS: - Enter the input digital sequence [1 0 1 0 1 0 1 0 0 1 0 1 0 1 0 1]

Page 5: Rakshk Acs Lab

EC-555 ADVANCED COMMUNICATION SYSTEM 2014

5 Department of Elect. and Comm. Engg. , Dr. B R Ambedkar National Institute of Technology, Jalandhar

Experiment No:-[3a] EXPERIMENT: - To generate BPSK signal.

SOFTWARE REQUIRED: - Matlab 7.12.0. THEORY:-In BPSK phase of the carrier is switched depending upon the input digital signal. The waveform produced here is a NRZ(non-return-to-zero) binary waveform, produced through NRZ level encoder. MATLAB CODE:-close all; clear all;clc; x=input('Enter the input binary sequence');N=length(x);% Binary sequence generatex(x==0)=-1; t=0.01:0.01:N; % Carrier generatec=sin(2*pi*t);for i=1:1:Nm((i-1)*100+1:i*100)=x(i);end % PSK generation y=c.*m; subplot(3,1,1);plot(t,m); xlabel('time');ylabel('amplitude'); title('digital input signal');subplot(3,1,2);plot(t,c); xlabel('time');ylabel('amplitude'); title('sinusoidal signal');subplot(3,1,3);plot(t,y);xlabel('time');ylabel('amplitude'); title('PSK modulated signal');

Page 6: Rakshk Acs Lab

EC-555 ADVANCED COMMUNICATION SYSTEM 2014

6 Department of Elect. and Comm. Engg. , Dr. B R Ambedkar National Institute of Technology, Jalandhar

RESULTS: - Enter the input binary sequence [1 0 1 0 1 0 1 0 1 0 1 0 1 0 1]

Page 7: Rakshk Acs Lab

EC-555 ADVANCED COMMUNICATION SYSTEM 2014

7 Department of Elect. and Comm. Engg. , Dr. B R Ambedkar National Institute of Technology, Jalandhar

Experiment No:-[3b] EXPERIMENT: - Performance evaluation of BPSK in AWGN environment.

SOFTWARE REQUIRED: - Matlab 7.12.0. THEORY:-After generating BPSK signal it is passed through noise and at different SNR values the BER(Bit Error Rate) is shown. MATLAB CODE:-%transmittL=input('how much length do you want: '); x=randint(L,1,2); L1=input('how much range of snr do you want in db: '); y=pskmod(x,2);%psk modulationm=1:L1; ber=zeros(1,L1);for snr=1:L1y1 = awgn(y,snr); % Add white Gaussian noise while through channel. y2=zeros(length(y1),1);%receive for i=1:length(y1)if real(y1(i))>0y2(i)=1;elsey2(i)=-1; end end z=pskdemod(y2,2);% psk demodulationn=0; for i=1:L if(x(i)~=z(i))n=n+1; end end ber(snr)=(n/L);end figure; semilogy(m,ber); RESULTS: - how much length do you want: 100000how much range of snr do you want in db: 20

Page 8: Rakshk Acs Lab

EC-555 ADVANCED COMMUNICATION SYSTEM 2014

8 Department of Elect. and Comm. Engg. , Dr. B R Ambedkar National Institute of Technology, Jalandhar

Page 9: Rakshk Acs Lab

EC-555 ADVANCED COMMUNICATION SYSTEM 2014

9 Department of Elect. and Comm. Engg. , Dr. B R Ambedkar National Institute of Technology, Jalandhar

Experiment No:-[4] EXPERIMENT: - To generate FSK signal.

SOFTWARE REQUIRED: - Matlab 7.12.0. THEORY:-In FSK binary ‘1’ is represented by high frequency carrier and binary ‘0’ is represented by low frequency carrier and for the generation of FSK, NRZ coding will be used. MATLAB CODE:-close all; clear all;clc; fc1=input('Enter the freq of 1st carrier:'); fc2=input('Enter the freq of 2nd carrier:'); fp=input('Enter the freq of Periodic Binary pulse:');amp=input('Enter the amplitude:'); amp=amp/2;t=0:0.001:1; % For Generating 1st Carrier Sine wavec1=amp.*sin(2*pi*fc1*t);% For Generating 2nd Carrier Sine wavec2=amp.*sin(2*pi*fc2*t);subplot(4,1,1); plot(t,c1) xlabel('Time')ylabel('Amplitude'); title('1st Carrier signal'); subplot(4,1,2) plot(t,c2);xlabel('Time'); ylabel('Amplitude'); title('2nd Carrier signal');m=amp.*square(2*pi*fp*t)+amp;%For message signal subplot(4,1,3) plot(t,m); xlabel('Time'); ylabel('Amplitude'); title('message signal'); for i=0:1000 %here we are generating the fsk if m(i+1)==0 mm(i+1)=c2(i+1); else mm(i+1)=c1(i+1); endend subplot(4,1,4) %For Plotting The Modulated waveplot(t,mm)xlabel('Time')ylabel('Amplitude')

Page 10: Rakshk Acs Lab

EC-555 ADVANCED COMMUNICATION SYSTEM 2014

10 Department of Elect. and Comm. Engg. , Dr. B R Ambedkar National Institute of Technology, Jalandhar

title('FSK Modulated Wave') Enter the freq of 1st carrier:40 Enter the freq of 2nd carrier:20Enter the freq of Periodic Binary pulse:5Enter the amplitude:2 RESULTS: -

Page 11: Rakshk Acs Lab

EC-555 ADVANCED COMMUNICATION SYSTEM 2014

11 Department of Elect. and Comm. Engg. , Dr. B R Ambedkar National Institute of Technology, Jalandhar

Experiment No:-[5] EXPERIMENT: - Performance evaluation of QPSK in AWGN environment.

SOFTWARE REQUIRED: - Matlab 7.12.0. THEORY:-After generating QPSK signal it is passed through noise and at different SNR values the BER(Bit Error Rate) is shown. MATLAB CODE:-%QPSK Transmitt L=input('how much length do you want: '); x=randint(L,1,4); L1=input('how much range of snr do you want in db: '); y=pskmod(x,4,0,'gray');scatterplot(y);m=1:L1; ber=zeros(1,L1);y3=unique(y); L3=length(y3);y4=zeros(1,L3);for snr=1:L1y1 = awgn(y,snr); % Add white Gaussian noise while through channel. y2=zeros(length(y1),1); %QPSK Receive for i=1:length(y1)for j=1:L3y4(j)=abs(y1(i)-y3(j));end a=find(y4==min(y4)); y2(i)=y3(a); end z=pskdemod(y2,4,0,'gray'); n=0; for i=1:L if(x(i)~=z(i))n=n+1; end RESULTS: - how much length do you want: 100000how much range of snr do you want in db: 20

Page 12: Rakshk Acs Lab

EC-555 ADVANCED COMMUNICATION SYSTEM 2014

12 Department of Elect. and Comm. Engg. , Dr. B R Ambedkar National Institute of Technology, Jalandhar

Page 13: Rakshk Acs Lab

EC-555 ADVANCED COMMUNICATION SYSTEM 2014

13 Department of Elect. and Comm. Engg. , Dr. B R Ambedkar National Institute of Technology, Jalandhar

Experiment No:-[6] EXPERIMENT: - To generate QAM with AWGN noise. SOFTWARE REQUIRED: - Matlab 7.12.0. THEORY:-Quadrature amplitude modulation (QAM) is both an analog and a digital modulation scheme. It conveys two analog message signals, or two digital bit streams, by changing (modulating) the amplitudes of two carrier waves, using the amplitude-shift keying (ASK) digital modulation scheme or amplitude modulation (AM) analog modulation scheme. The two carrier waves, usually sinusoids, are out of phase with each other by 90° and are thus called quadrature carriers or quadrature components — hence the name of the scheme. The modulated waves are summed, and the final waveform is a combination of both phase-shift keying (PSK) and amplitude-shift keying (ASK), or (in the analog case) of phase modulation (PM) and amplitude modulation. In the digital QAM case, a finite number of at least two phases and at least two amplitudes are used.

TRANSMITTER

RECEIVER

MATLAB CODE:-close all; clear all; clc; % Create a random digital messageM=input('Enter the value of M : ');%M = 16; % Alphabet sizex = randi([0 M-1],500,1); % Random symbols % Use M-QAM modulation. hMod = modem.qammod(M); hDemod = modem.qamdemod(hMod); % Create a scatter plot and show constellation scatterPlot = commscope.ScatterPlot('SamplesPerSymbol',1,... 'Constellation',hMod.Constellation);scatterPlot.PlotSettings.Constellation = 'on';

Page 14: Rakshk Acs Lab

EC-555 ADVANCED COMMUNICATION SYSTEM 2014

14 Department of Elect. and Comm. Engg. , Dr. B R Ambedkar National Institute of Technology, Jalandhar

% Modulatey = modulate(hMod,x);plot(x,y);title('modulated signal');

xlabel('time axis'); ylabel('amplitude');% Transmit signal through an AWGN channel. ynoisy = awgn(y,1,'measured'); % Create scatter plot from noisy data.update(scatterPlot,ynoisy); % Demodulate ynoisy to recover the message.z=demodulate(hDemod,ynoisy);plot(x,z); title('Demodulated signal'); xlabel('time axis'); ylabel('amplitude'); % Check symbol error rate. [num,rt] = symerr(x,z); RESULTS: - Enter the value of M : 4num = 126rt = 0.2520

Page 15: Rakshk Acs Lab

EC-555 ADVANCED COMMUNICATION SYSTEM 2014

15 Department of Elect. and Comm. Engg. , Dr. B R Ambedkar National Institute of Technology, Jalandhar

Page 16: Rakshk Acs Lab

EC-555 ADVANCED COMMUNICATION SYSTEM 2014

16 Department of Elect. and Comm. Engg. , Dr. B R Ambedkar National Institute of Technology, Jalandhar

Experiment No:-[7] EXPERIMENT: - To simulate the transmitter and receiver for ASK BPSK, FSK QPSK and QAMand measure BER. SOFTWARE REQUIRED: - Matlab 7.12.0. THEORY:-In Simulink, it is very straightforward to represent and then simulate a mathematical model representing a physical system. Models are represented graphically in Simulink as block diagrams. One of the primary advantages of employing Simulink (and simulation in general) for the analysis of dynamic systems is that it allows us to quickly analyze the response of complicated systems that may be prohibitively difficult to analyze analytically. Simulink is able to numerically approximate the solutions to mathematical models that we are unable to, or don't wish to, solve "by hand." In general, the mathematical equations representing a given system that serves as the basis for a Simulink model can be derived from physical laws. MATLAB SIMULINK MODEL:- ASK

Page 17: Rakshk Acs Lab

EC-555 ADVANCED COMMUNICATION SYSTEM 2014

17 Department of Elect. and Comm. Engg. , Dr. B R Ambedkar National Institute of Technology, Jalandhar

BPSK

FSK

QPSK

Page 18: Rakshk Acs Lab

EC-555 ADVANCED COMMUNICATION SYSTEM 2014

18 Department of Elect. and Comm. Engg. , Dr. B R Ambedkar National Institute of Technology, Jalandhar

QAM

RESULTS: - We successfully simulate the transmitter and receiver for ASK BPSK, FSK QPSK and QAM and measure BER.