Lab Manual Digital Communication
Lab Manual Digital Communication
COMMUNICATION
LAB MANUAL
Jenny Patrick
Assistant Professor
Dept of ECE, CEP
PART B
Experiment No:4
PULSE SHAPING AND MATCHED FILTERING
AIM:
THEORY:
In communication systems, data is transmitted as binary bits (ones and zeros). It is easier to
implement a binary system using switches, where turning on a switch represents ‘1’ and
turning it off represents ‘0’. Such simple binary systems essentially represent ones and zeros
as rectangular pulses of finite duration (say τ seconds). A rectangular pulse of finite duration
τ manifests itself as an infinitely extending sinc pulse in the frequency domain (see figure
below). This implies that a rectangular pulse requires infinite bandwidth if it is not to be
distorted during its transmission. Due to the dual nature of Fourier Transform, the following
figure is valid if we alternate the frequency and time domain representations. That is, a
symbol with finite bandwidth will extend infinitely in time. This implies that to send a single
‘1’ or ‘0’ or a series of them (for a multi-level signaling), you would need infinite time
duration. This is absolutely impractical. In practical terms, signals will not extend infinitely
forward and backward in time. But it will definitely be non-zero after the time duration τ.
This implies that the residues of adjacent symbols/signals overlap with each other giving rise
to Inter Symbol Interference (ISI). If the residual energy from the adjacent symbol is very
strong, it becomes impossible to distinguish the present symbol and there is a possibility of it
being misinterpreted altogether. To avoid or reduce this effect, “Pulse Shaping” techniques
are used to make sure that the data carried by the symbols are not affected by the overlapping
Root raised-cosine pulse (RRC): The total effective filter of the transmission system
is the combination of transmit and receive filter , where ∗ is
convolution. This effective filter (and not the individual filters) must fulfil the
Nyquist criterion. We can achieve this goal if both filters have a transfer function
that is equal to the square root of that of the raised cosine filter.
Such a filter is therefore called a root raised cosine (RRC). The combination of both RRC
filters then becomes a raised cosine and thus fulfils the Nyquist criterion. Furthermore,
since the filters are real-valued and symmetric, the RRC is its own matched filter. The
impulse response ofthe RRC filter is given as
Matched Filtering
The receiver’s RF front-end receives analog pulse trains. The information bits need to be
recovered from these pulse trains. This is accomplished in two steps: (i) Mapping from
analog pulse trains to constellation points. (ii) Mapping from complex symbols to bits,
which is Detection.
The received analog signals are matched filtered to create the output complex waveform.
Then thesamples are detected. A representation of this process is shown in Fig.3 below.
MATLAB CODE
close all;
clear;
rolloff = 0.4;
span = 10;
sps = 7;
M = 16;
k = log2(M);
rctFilt = rcosdesign(rolloff, span, sps,'normal');
fvtool(rctFilt,'Analysis','impulse')
BP_Data = 2*randi([0 1], 50, 1) - 1;
UP_s = upfirdn(BP_Data, rctFilt, sps,1);
EbNo = 100;
snr = EbNo + 10*log10(k) - 10*log10(sps);
filtlen = 10;
rxSignal = awgn(UP_s,snr,'measured');
rxSignal = rxSignal + randn(size(rxSignal))*.01;
rxFiltSignal = upfirdn(rxSignal,rctFilt,1,sps);
rxFiltSignal = rxFiltSignal(filtlen + 1:end - filtlen);
figure;
stem(BP_Data,'filled')
hold on
plot(rxFiltSignal,'r')
xlabel('Time'); ylabel('Amplitude');
legend('Transmitted Data','Received Data')
figure;
plot(rxSignal)
legend('Filtered signal through AWGN')
RESULT: Simulated matched filter using matlab and obtained the samples.
Experiment No:5
EYE DIAGRAM
AIM
1. Generate a string of message bits.
2. Use rasied cosine pulse p(t) as the shapig pulse, and generate the corresponding
basebandsignal with a fixed bit duration Tb. You may use roll-off factor as α =
0.4.
3. Use various roll off factors and plot the eye diagram in each case for the received
signal. Makea comparison study among them.
THEORY:
MATLAB CODE
close all;
clear;
rolloff = 0.4;
span = 10;
sps = 7;
M = 16;
k = log2(M);
rctFilt = rcosdesign(rolloff, span, sps,'normal');
fvtool(rctFilt,'Analysis','impulse')
BP_Data = 2*randi([0 1], 50, 1) - 1;
UP_s = upfirdn(BP_Data, rctFilt, sps,1)
EbNo = 100;
snr = EbNo + 10*log10(k) - 10*log10(sps);
filtlen = 10;
rxSignal = awgn(UP_s,snr,'measured');
rxSignal = rxSignal + randn(size(rxSignal))*.01;
rxFiltSignal = upfirdn(rxSignal,rctFilt,1,sps);
rxFiltSignal = rxFiltSignal(filtlen + 1:end - filtlen);
figure;
stem(BP_Data,'filled')
hold on
plot(rxFiltSignal,'r')
xlabel('Time'); ylabel('Amplitude');
legend('Transmitted Data','Received Data')
figure;
plot(rxSignal)
legend('Filtered signal through AWGN')
eyediagram(BP_Data,2);legend('Transmitted signal')
eyediagram(rxSignal,2);legend('Recieved signal')
eyediagram(rxFiltSignal,2);legend('Filtered signal')
RESULT:
Eyediagram is obtained.
EXPERIMENT NO:6
Error Performance of Binary Phase Shift Keying
AIM
BSPK Receiver:
The received BPSK signal is applied to a correlator which is also supplied with a
locally generated reference signal Ø1 (t). The correlated output is compared with a
threshold of zero volts. If x1> 0, thereceiver decides in favour of symbol 1. If x1< 0, it
decides in favour of symbol 0.
MATLAB CODE:
clear ;
close all;
num_bit=1e6;
EbNodB=0:1:10;
for i=1:length(EbNodB);
s=2*(round(rand(1,num_bit))-0.5);
w=(1/sqrt(2*10^(EbNodB(i)/10)))*randn(1,num_bit);
r=s+w;
s_est=sign(r);
sim_BER(i)=(num_bit-sum(s==s_est))/num_bit;
end
the_Ber =0.5*erfc(sqrt(10.^(EbNodB/10)));
semilogy(EbNodB, sim_BER,'-');
hold on
semilogy(EbNodB,the_Ber,'ko');
title('Bit error probability curve for BPSK modulation');
legend('Simulation','Theoretical');
xlabel('EbNo(dB)')
ylabel('BER')
grid on
EXPERIMENT NO:7
AIM
1. Generate a string of message bits.
2. Encode using QPSK with energy per symbol Es and represent it using points in a
signal-space.
3. Simulate transmission of the QPSK modulated signal via an AWGN
channel with variance N0/2in both I-channel and Q-channel.
Detect using an ML decoder and plot the probability of error as a function of SNR per bit
Eb/N0where Es = 2Eb
THEORY
Quadrature Phase Shift Keying
Phase of the carrier takes on one of four equally spaced values such
as π/4, 3π/4,5π/4,7π/4.
Si(t) = √2E/ Tb cos {2 πƒct + (2i – 1)
π/4} , 0≤ t ≤ Tb0 , elsewhere
Where i = 1,2,3,4, & E= Tx signal energy
[Type text] Page 8
ECL 332
QPSK Transmitter
The i/p binary sequence b(t) is represented in polar from with symbols 1 & 0 represented as
+√E/2and -√E/2 .This binary wave is demultiplexed into two separate binary waves
consisting of odd & even numbered I/P bits denoted by b1(t) & b2 (t). b1 (t) & b2(t) are used
to modulate a pair of quadrature carrier or orthogonal Basis function Ø1 (t) & Ø2 (t). The
result is two PSK waves’ .Thesetwo binary PSK waves are added to produce the desired
QPSK signal .
QPSK Receiver
QPSK receiver consists of a pair of correlators with common I/P & supplied with
Locally generated Signal Ø1 (t) & Ø2 (t). The correlator O/P, x1, & x2 are each
compared with a threshold of zero volts.If x1 > 0, decision is made in favour of symbol
‘1’ for upper channel and if x1 > 0, decision ismade in favour of symbol 0. Parallelly Y
[Type text] Page 9
ECL 332
x2 >0, decision is made in favour of symbol 1 for lower channel & if x2 <0, decision is
made in favour of symbol 0. These two channels are combined in a multiplexer to get
the original binary output.
MATLAB CODE:
clear ;
close all;
num_bit=1e6;
EbNodB=0:1:10;
EbNo=10.^(EbNodB/10);
for n=1:length(EbNodB)
si=2*(round(rand(1,num_bit))-0.5);
sq=2*(round(rand(1,num_bit))-0.5);
s=si+1j*sq;
w=(1/sqrt(2*EbNo(n)))*(randn(1,num_bit)+1j*randn(1,num_bit)
);
r=s+w;
si_=sign(real(r));
sq_=sign(imag(r));
ber1=(num_bit-sum(si==si_))/num_bit;
ber2=(num_bit-sum(sq==sq_))/num_bit;
sim_BER(n)=mean([ber1 ber2]);
end
the_Ber = 0.5*erfc(sqrt(10.^(EbNodB/10)));
semilogy(EbNodB, sim_BER,'-');
hold on
semilogy(EbNodB,the_Ber,'ko');
title('BER curve for QPSK modulation');
legend('Simulation','Theoretical');
xlabel('EbNo(dB)')
ylabel('BER')
grid on
RESULT :
Studied and verified the error performance of QPSK
EXPERIMENT:8
Performance of Waveform Coding Using PCM
AIM
THEORY
In Pulse code modulation (PCM) only certain discrete values are allowed for the
modulating signals. The modulating signal is sampled, as in other forms of pulse
modulation. But any sample falling within a specified range of values is assigned a
discrete value. Each value is assigned a pattern of pulses and the signal transmitted by
means of this code. The electronic circuit that produces the coded pulse train from the
modulating waveform is termed a coder or encoder. A suitable decoder must be used at
the receiver in order to extract the original information from the transmitted pulse train.
MATLABCODE
clear;
clear;
close all;
time = 0:.0005:.05;
freq_msg=100;
dc_ofst=2;
signal=sin(2*pi*freq_msg*time)+dc_ofst;
figure;plot(time,signal)
xlabel('time')
ylabel('Amplitude')
title('Signal')
freq_sample=15*freq_msg;
samp_time=0:1/freq_sample:0.05;
samp_signal=dc_ofst+sin(2*pi*freq_msg*samp_time);
hold on
plot(samp_time,samp_signal,'rx')
title('Sampled Signal')
legend('Original signal','Sampled signal');
L=8;
smin=round(min(signal));
smax=round(max(signal));
Quant_levl=linspace(smin,smax,L);
codebook = linspace(0,smax,L+1);
[index,quants] = quantiz(samp_signal,Quant_levl,codebook);
figure;plot(samp_time,samp_signal,'x',samp_time,quants,'.-')
title('Quantized Signal')
legend('Original signal','Quantized signal');
figure;plot(samp_time,index,'.-')
title('Encoded Signal')
for i=1:length(index)
bincode_sig{i}=dec2bin(round(index(i)),7);
end
disp('binary encoded signal')
disp(bincode_sig')
noise=quants-samp_signal;
figure;
subplot(1,2,1)
plot(samp_time,noise,'.-')
title('Noise')
r=snr(index,noise);
snr1=['SNR:',num2str(r)];
disp(snr1)
function [ r ] =Quant_Level( l )
time = 0:.0005:.05;
freq_msg=100;
dc_ofst=2;
signal=sin(2*pi*freq_msg*time)+dc_ofst;
freq_sample=15*freq_msg;
samp_time=0:1/freq_sample:0.05;
samp_signal=dc_ofst+sin(2*pi*freq_msg*samp_time);
L=l;
smin=round(min(signal));
smax=round(max(signal));
Quant_levl=linspace(smin,smax,L);
codebook = linspace(0.7,smax,L+1);
[index,quants] = quantiz(samp_signal,Quant_levl,codebook);
for i=1:length(quants)
bincode_sig{i}=dec2bin(round(quants(i)),3);
end
noise=quants-samp_signal;
r=snr(index,noise);
end
l=[8,16,32,64,128];
for i=1:length(l)
r(i) = Quant_Level(l(i));
end
subplot(1,2,2)
plot(l,r)
xlabel('L')
ylabel('snr')
title('L vs SNR')
RESULT
Performance of PCM is evaluated and calculated the SNR.Also SNR plot is obtained.
PART C
EXPERIMENTNO:9
AIM:
1.To Familiarize with an SDR hardware for reception and transmission of RFsignal.
2.To Familiarize how it can be interfaced with computer.
3.To Familiarize with GNU Radio (or similar software’s like Simulink/ Lab-View) that can
be used to process the signals received through the SDRhardware.
4.To Familiarize available blocks in GNU Radio. Study how signals can begenerated and
spectrum (or power spectral density) of signals can beanalyzed. Study how filtering can be
performed.
THEORY:
Hardware Required
• RTL SDR dongle
• Hack RF one ( if you want to transmit)
• FM Transmitter or some other RF signal source. (Be careful) ( Raspberry pi can be used )
• A PC or a Raspberry Pi
• Chinese clones for original hack rf one are available online at about Rs 8.5 k
• Another possibility is Adalam Pluto board from Analog devices
Software Required