You are on page 1of 61

Anjalai Ammal - Mahalingam Engineering College, Kovilvenni.

Department of Electronics and Communication Engineering

EC8561-Communiation Systems Lab Manual (R-2017)


EC8561 COMMUNICATION SYSTEMS LABORATORY LTPC

OBJECTIVES: 0042
The student should be made:
 To visualize the effects of sampling and TDM
 To Implement AM & FM modulation and demodulation
 To implement PCM & DM
 To simulate Digital Modulation schemes
 To simulate Error control coding schemes

LIST OF EXPERIMENTS:
1. Signal Sampling and reconstruction

2. Time Division Multiplexing

3. AM Modulator and Demodulator

4. FM Modulator and Demodulator

5. Pulse Code Modulation and Demodulation

6. Delta Modulation and Demodulation

7. Line coding schemes

8. Simulation of ASK, FSK, and BPSK generation schemes

9. Simulation of DPSK, QPSK and QAM generation schemes

10. Simulation of signal constellations of BPSK, QPSK and QAM

11. Simulation of ASK, FSK and BPSK detection schemes

12. Simulation of Linear Block and Cyclic error control coding schemes

13. Simulation of Convolutional coding scheme

14. Communication link simulation

TOTAL: 60 PERIODS

OUTCOMES:
At the end of the course, the student should be able to:
 Simulate & validate the various functional modules of a communication system
 Demonstrate their knowledge in base band signalling schemes through
 implementation of digital modulation schemes
 Apply various channel coding schemes & demonstrate their capabilities
 towards the improvement of the noise performance of communication system
 Simulate end-to-end communication Link
S.No. List of Experiments Page no.

1. Signal Sampling
2. Signal Sampling and reconstruction
3. Amplitude modulation
4. AM Modulator and Demodulator
5. FM Modulator and Demodulator
6. Time Division Multiplexing
7. Pulse Code Modulation and Demodulation
8. Delta Modulation and Demodulation
9. Line coding schemes
10. Simulation of ASK, FSK, and BPSK generation
schemes
11. Simulation of DPSK, QPSK and QAM generation
schemes
12. Simulation of signal constellations of BPSK, QPSK
and QAM
13. Simulation of ASK, FSK and BPSK detection
schemes
14. Simulation of Linear Block and Cyclic error control
coding schemes
15. Simulation of Convolutional coding scheme
16. Communication link simulation
EX.No.1
SIGNAL SAMPLING
Aim:
To construct the sampling circuit and verify its result.
Apparatus required:
NAME OF THE EQUIPMENT /
S.NO. RANGE QUANTITY
COMPONENT
1. Transistor BC 107 1
2. Resistor 10k 3
3. Function Generators - 2
4. CRO - 1
5. Bread board - 1
6. Regulated Power supply 0-30V 1
7. Connecting wires - As required

Theory:
The analog signal can be converted to a discrete time signal by a process called
sampling. The sampling theorem for a low pass signal can be stated as,
“A band limited signal of finite energy, which has no frequency component higher than W
Hz is completely described by specifying the values of the signal at instants of time
separatedby1/2Wseconds.Itcanberecoveredfromknowledgeofsamplestakenatthe rate of 2W
persecond.”
Sampling is the process of splitting the given analog signal into different samples of equal
amplitudes with respect to time. There are two types of sampling namely natural sampling,
flat top sampling. Sampling should follow strictly the Nyquist Criterion i.e. the sampling
frequency should be twice higher than that of the highest frequency signal.
fs  2 fm

Where,
fs Minimum Nyquist Sampling rate (Hz)
fmMaximum analog input frequency (Hz).
Circuit Diagram:

Model Graph:

Tabualtion:

Signal Amplitude (V) Time period (ms)

Message signal

Carrier Signal

Sampled Signal
Ex.No. 2 SIGNAL SAMPLING AND ITS RECONSTRUCTION

AIM:

To study the process of signal sampling and its reconstruction techniques.

APPARATUS REQUIRED:

S.No. Name Quantity

1. Sampling and Reconstruction Kit 1

2. Digital Storage Oscilloscope/CRO 1

3. Power supply 1

THEORY:

Sampling is the process of converting a continuous-valued, continuous- time signal


into a continuous-valued, discrete-time signal. As sampling theorem states that as long as
the sampling rate is at least equal to twice the signal frequency, the signal can be faithfully
constructible from the samples. This can be verified here by selecting the different sampling
signals.

The sampling is achieved by an electronic switch that turns ON and OFF at the
different sampling rates and the samples of the analog signals is being transmitted during
the sampling times.

PROCEDURE:

1. Connect the 2 KHz 5V p-p signal generated onboard to the analog input by means of
patch cords provided.
2. Connect the sampling frequency signal in the internal mode, by means of the shorting
pin provided.
3. By varying the carrier signal with different frequencies (2, 4, 8, 16, 32 KHz), observe
the effect of sampling.
4. Take the amplitude and time period of sampled, sample and hold output.
5. Connect the Sample and hold output to the input of the 2/4 th order of LPF.
Model Graph:

Tabualtion:

Signal Amplitude (V) Time period (ms)

Message signal

Carrier Signal

Sampled Signal

Sampled and hold signal

Reconstructed signal
Result:

Thus the sampling process was verified and the readings were plotted.
Ex. No. 3 AMPLITUDE MODULATION AND DEMODULATION

AIM:

To observe the process of amplitude modulation and demodulation.

APPARATUS REQUIRED:

S.No. Name Quantity

1. Amplitude modulation and demodulation Kit 1

2. Digital Storage Oscilloscope/CRO 1

3. Power supply 1

4. Patch cords As required

THEORY:
The process of changing the amplitude of a carrier signal in proportion with the
instantaneous value of the modulating signal is called amplitude modulation (AM). In AM,
the carrier frequency should be relatively higher than the modulating frequency. This type
of modulation is generally used in commercial broadcasting of both video and audio
information. It also finds applications in two-way mobile radio communications such as in
Citizen’s Band radio. AM modulators are non-linear devices having two inputs and one
output. One of the inputs is the high frequency carrier and the other is the low-frequency
information signal, which can be of a single frequency or a band of frequencies as in the
case of speech signals. In general, the modulation index m is given by
𝑽𝒎
𝑴𝒐𝒅𝒖𝒍𝒂𝒕𝒊𝒐𝒏 𝒊𝒏𝒅𝒆𝒙, 𝒎 =
𝑽𝒄

PROCEDURE:

Modulation:

 Connect the patch cord S1 RF output to modulated RF input S3.


 Connect the patch card SF output S2 to AF input S4.
 Vary the RF generator and AF generator.
 Observe the AM output on S5 or TP5.

Demodulation:

 Connect the patch card from Am output S5 to input of demodulator S6.


 Connect the patch cards from ground SG3 to SG4.
 Observe the demodulated output in S7 or Tp7.
 Plot the graph.

MODEL GRAPH:
TABULATION:

Signal Amplitude (V) Time period (ms)

Message signal

Carrier Signal

AM modulated Wave

Demodulated signal
RESULT:
Ex. No. 4 FREQUENCY MODULATION AND DEMODULATION

AIM:

To observe the process of Frequency modulation and demodulation.

APPARATUS REQUIRED:

S.No. Name Quantity

1. Frequency modulation and demodulation Kit 1

2. Digital Storage Oscilloscope/CRO 1

3. Power supply 1

4. Patch cords As required

THEORY:

Frequency modulation can be defined as the process by which the frequency


of the carrier wave is altered in accordance with the instantaneous amplitude of modulating
or message signal.

PROCEDURE:

Modulation:

 Connect the patch cord S01 AF output to Modulating signal input S02.
 Connect ground SG1 to Ground SG2.
 Vary the modulation POT.
 Observe the FM output on S04 or TP4.

Demodulation:

 Connect the patch cords from S04 to Demodulator input S05.


 Connect the patch cord from ground to ground.
 Observe the demodulation output at S06 or TP6.
 Plot the graph.
MODEL GRAPH:

TABULATION:

Signal Amplitude (V) Time period (ms)

Message signal

Carrier Signal

FM modulated Wave

Demodulated signal
RESULT:
Ex. No. 5 TIME DIVISON MULTIPLEXING

AIM:

To observe the process of Frequency modulation and demodulation.

APPARATUS REQUIRED:

S.No. Name Quantity

1. Time division multiplexing Kit 1

2. Digital Storage Oscilloscope/CRO 1

3. Power supply 1

4. Patch cords As required

THEORY:

Time-division multiplexing (TDM) is a method of transmitting and receiving


independent signals over a common signal path by means of synchronized switches at each
end of the transmission line so that each signal appears on the line only a fraction of time in
an alternating pattern. This method transmits two or more digital signals or analog signals
over a common channel. It can be used when the bit rate of the transmission medium
exceeds that of the signal to be transmitted. This form of signal multiplexing was developed
in telecommunications for telegraphy systems in the late 19th century, but found its most
common application in digital telephony in the second half of the 20th century.

PROCEDURE:

Multiplexing:
 Connect the 4 channel inputs of 250Hz, 500Hz, 1 KHz, 2 KHz to the Multiplexer
inputs CH0, CH1, CH2 and CH3 respectively.
 Observe the time division multiplexed PAM waveform at the output of the
Multiplexer.
 Observe the four different signals placed in their respective time slots.
 Vary each of the amplitude of each channel and see the effect on the TDM waveform.

Demultiplexing:
 Connect the TXCLOCK (Transmitter clock) to RXCLOCK (Receiver clock).
 Connect TXCH) (Transmitter sync) to RXCH0 (Receiver sync).
 Connect the TXD (transmitter data) to RXD (Receiver Data).
 Observe the demultiplexed signals at the receiver across the output of fourth order LPF
at CH0, CH1, CH2 and CH3 respectively.
MODEL GRAPH:

TABULATION:

Signal Amplitude (V) Time period (ms) Frequency (KHZ)

Message signal 1

Message signal 2

Message signal 3

Message signal 4

Multiplexed Signal

Reconstructed signal 1
Reconstructed signal 2

Reconstructed signal 3

Reconstructed signal 4
RESULT:
Ex. No. 6 PULSE CODE MODULATION AND DEMODULATION

AIM:

To observe the process of Pulse code modulation and demodulation.

APPARATUS REQUIRED:

S.No. Name Quantity

1. PCM transmitter Kit 1

2. PCM Receiver Kit 1

3. Digital Storage Oscilloscope/CRO 1

4. Power supply 1

5. Patch cords As required

THEORY:

In Pulse Code Modulation, the message signal is represented by a sequence of coded


pulses. This message signal is achieved by representing the signal in discrete form in both
time and amplitude.
The transmitter section of a Pulse Code Modulator circuit consists of Sampling,
Quantizing and Encoding, which are performed in the analog-to-digital converter section.
The low pass filter prior to sampling prevents aliasing of the message signal.
The basic operations in the receiver section are regeneration of impaired signals,
decoding, and reconstruction of the quantized pulse train. Following is the block diagram
of PCM which represents the basic elements of both the transmitter and the receiver
sections.
PROCEDURE:

Transmitter:
 Connect 500 Hz to CH0 and 1 KHz to CH1.
 Set the speed selection switch to FAST mode.
 Observe the PCM output in TP48.
Receiver:
 Connect the PCM OUTPUT (TP48) from transmitter kit to RX data In Receiver kit
using BS2 patch cord.
 Connect TXCLOCK from transmitter kit to RXCLOCK in receiver kit.
 Connect TXSYNC from transmitter kit to RXSYNC in receiver kit.
 Observe the Reconstructed output at TP 43 and TP 44 for the respective channel
inputs. And Compare it with the inputs at transmitter kit.
RESULT:
Ex. No. 7 DELTA MODULATION AND DEMODULATION
AIM:

To observe the process Delta modulation and demodulation.

APPARATUS REQUIRED:

S.No. Name Quantity

1. Delta Modulation Kit 1

2. Digital Storage Oscilloscope/CRO 1

3. Power supply 1

4. Patch cords As required

THEORY:

In the Differential Pulse Code Modulation (DPCM) process, when the sampling
interval is reduced, the sample-to-sample amplitude difference becomes small, like the
difference is of 1-bit quantization. Hence the step-size will be very small.
Delta modulation is a process mainly used in the transmission of voice information.
It is a technique where analog-to-digital and digital-to-analog signal conversion is seen.
Delta modulation (DM) is an easy way of DPCM. In this technique, the difference between
consecutive signal samples is encoded into n-bit data streams. In DM, the data which is to
be transmitted is minimized to a 1-bit data stream.

PROCEDURE:
1. Connect PLA1 to PLAA.
2. Connect channel m1 to CRO to TPA1/TPAA; adjust VR1 to minimum to get zero level
signals.
3. Connect channel 1 to TP1 to channel 2 to TPB1 and adjust VR2 to obtain square wave
half the frequency of the clock rate selected (output at TP1).
4. Connect channel 1 to TP2 and set voltage /div of channel 1 to mV range and observe a
triangle waveform, which is output of integrator. It can be observed that is the clock rate
is increased, amplitude of triangle waveform decreases. This is called minimum step
size.(clock rate can be changed by depressing SW1 switch).
5. Connect channel 1 to TPA1, TPAA; adjust VR1 in order to obtain a 1KHz sine wave of
500 mVpp approximately.
6. Signal approximating 1 KHz is available at the integrator output (TP2); this signal is
obtained by integrating the digital output resulting from delta modulation.
7. Connect channel 1 to TP2 and channel 2 to TPB1; it can be observed that the digital
high makes the integrator output to go upwards and digital low makes the integrator
output to go downwards.
8. With an oscilloscope displaying three traces, it is possible to simultaneously observe the
input signal of the modulation, the digital output of the modulator and the signal
obtained by the integration from the modulator digital output.
Notice that, when the output (feedback signal) is lower that the analog input the
digital output is high, whenever it is low when the analog input is lower that the
integrated output.
9. Increase the amplitude of 1 KHz sine wave by rotating VR1 to Vpp and observe that the
integrator output follows the input signal.
10. Increase the amplitude of 1 KHz sine wave further high, and observe that the integrator
output cannot follow the input signal.
11. Repeat the above-mentioned procedures with different signal sources and selecting
different clock rates and observe the response of the linear delta modulator.

MODEL GRAPH:

TABULATION:

Signal Amplitude (V) Time period (ms)

Message signal

Delta modulated output

Integrator output

Demodulated signal
RESULT:
Ex. No. 8 LINE CODING SCHEMES

AIM:

To characterize the performance of different line coding techniques.

APPARATUS REQUIRED:

S.No. Name Quantity

1. Line coding Kit 1

2. Digital Storage Oscilloscope/CRO 1

3. Power supply 1

4. Patch cords As required

THEORY:
It is required to represent an analog data in binary symbols 0 and 1. The most
commonly used PCM popular data formats are being realized here.

1. NON RETURN TO ZERO SIGNALS:


These are easiest data formats that can be generated. They are called “Non-return to
zero because the signals do not return to zero with the clock. The frequency
components associated with these signals are half of the clock frequency. The
following data formats come under this category.
a. Non-return to zero – LEVEL NRZ – L
b. Non-return to zero – MARK NRZ – M
C. Non-return to zero – SPACE NRZ – S

a. Non-return to zero – LEVEL coding (NRZ – L)


This is the most extensively used waveform in digital logics. The data format is very
simple where all 1’s are represented by high and all 0’s are represented by low. The
data format is directly got at the output of all digital data generation logics and hence
very easy to generate. Here all the transistors take place at the rising edge of the
clock.

b. Non-return to zero –MARK coding (NRZ – M)

This waveform is extensively used in magnetic tape recording. In this data format,
all one’s are marked by change in levels and all zero’s by no transitions., and the
transitions take place at the rising edge of the clock.

1 0 1 1 0 0 0 1 1 0 1
+v
-v NRZ -L

+v NRZ -M
-v
c.Non-return to zero – SPACE coding (NRZ-S ):
This type of waveform is marked by change in levels for ‘zeros’ and no transition of
for ‘ones’ and the transition take place at the rising edge of the clock. This format is
also used in magnetic tape recording

1 0 1 1 0 0 0 1 1 0 1
+v
-v NRZ - L

+v NRZ -S
-v

.
2) RETURN TO ZERO SIGNALS:

These signals are called “Return to zero signals”, since they return to ‘zero’ with the
clock. In this category, only one data format, i.e., the unipolar return to zero (URZ).

a. Unipolar Return to zero coding (URZ) :

This code is unipolar as excursion is between 0V and +V. But logic 1 here is
represented by a pulse which returns to zero (RZ) after a brief period (usually half
bit period) within bit interval. With the URZ, a ‘one’ is represented by a half bit
wide pulse and a ‘zero’ is represented by the absence of a pulse.

1 0 1 1 0 0 0 1 1 0 1
+v NRZ -L
-v

+v
URZ
0v

3) BIPHASE SIGNALS (PHASE ENCODED SIGNALS) :


a) BiPhase – LEVEL (Manchester Coding)
b) Biphase – MARK and
c) Biphase – Space Signals
These schemes are used in magnetic recording, optical communications and in
satellite telemetry links. This phase encoded signals are special in the sense that they are
composed of both the in phase and out-of-phase components of the clock.

a. Manchester Coding (Biphase –L):


Here for logic 1, a positive pulse is followed by a negative pulse i.e. With the
Biphase – L, a ‘one’ is represented by a half bit wide pulse positioned during the first half of
the bit interval and for logic 0, a negative pulse is followed by a positive pulse. i.e. a ‘zero,
is represented by a half bit wide pulse positioned during the second half of the bit interval.
The bandwidth is comparatively better than NRZ scheme due to half-bit transitions.

1 0 1 1 0 0 0 1 1 0 1
+v
-v NRZ - L
+v
-v Bi-phase - L

b. Biphase Mark Coding (Biphase –M):


With the Biphase – M, a transition occurs at the beginning of every bit
interval. A ‘one’ is represented by a second transition, one half bit later whereas a
zero has no second transition.

+v 1 0 1 1 0 0 0 1 1 0 1
NRZ -L
-v

+v
Bi-phase - M
-v

c. Bi-Phase Space coding (Biphase –S):


With a Biphase – S also a transition occurs at the beginning of every bit interval. A
‘zero’ is marked by a second transition, one half bit later, where as a ‘one’ has no second
transition.

+v 1 0 1 1 0 0 0 1 1 0 1
NRZ - L
-v

+v
Bi-phase - S
-v
4 ) Return to zero – Alternate Mark Inversion Coding (RZ-AMI):
This coding scheme is most often used in telemetry systems. This scheme comes under both
the category of return to zero scheme and multilevel scheme. The one’s are represented by
pulse width of half the bit duration existing in the alternate direction whereas zero’s are
represented by absence of the pulse.

PROCEDURE:

 Give the connections as per the experimental set up.


 Observe the clock signal & the data and measure them.
 Observe the standard data & the coded data formats and verify with the known
formats.
RESULT:

Thus different line coding techniques have been characterized.


Simulation programs
ASK Modulation and Demodulation
Program:
clc; clear all; close all;
% generate message signal
m=input ('Enter message bits');
%generate carrier signal
tb=1; fc=10; t=0:tb/100:1;
c=sqrt(2/tb)*sin(2*pi*fc*t);
Subplot(4,1,1);
stem(m);
title('Message signal');
xlabel('n-->');
ylabel('m(n)');
Subplot(4,1,2);
plot(t,c);
title('Carrier signal');
xlabel('t-->');
ylabel('c(t)');
N=length(m);
t1=0;t2=tb;
for i=1:N
t=[t1:0.01:t2];
if m(i)==1
msg=ones(1,length(t));
else
msg=zeros(1,length(t));
end
%modulation
ask_sig(i,:)=c.*msg;
t1=t1+(tb+.01);t2=t2+(tb+.01);
% demodulation
x=sum(c.*ask_sig(i,:));
if x>0
demod(i)=1;
else
demod(i)=0;
end
%plot the ask signal

subplot(4,1,3);
plot(t,ask_sig(i,:));
title('ask signal'); hold on
xlabel('t--->');ylabel('s(t)');
subplot(4,1,4);stem(demod);
title('ask demodulated signal');xlabel('--->');ylabel('d(t)');
end
hold off
OUTPUT:

Enter the message bits: [ 1 0 1 1 0 0 1 1]


PSK Modulation and Demodulation

clc;clear all;close all;

%generate message signal


m=input('enter msg bits');

%generate carrier signal


tb=1; fc=10; t=0:tb/100:1;
c=sqrt(2/tb)*sin(2*pi*fc*t);
Subplot(4,1,1);
stem(m);
title('Message signal');
xlabel('n-->');
ylabel('m(n)');
Subplot(4,1,2);
plot(t,c);
title('Carrier signal');
xlabel('t-->');
ylabel('c(t)');
N=length(m);
t1=0; t2=tb;
for i= 1:N
t=[t1:.01:t2];
if m(i)==1;
msg=ones(1,length(t));

else

msg=-1*ones(1,length(t));

end

% modulation
psk_sig(i,:)=c.*msg;

t1= t1+(tb+.01); t2= t2+(tb+.01);

% Demodulation
x=sum(c.*psk_sig(i,:));
if x>0
demod(i)=1;
else
demod(i)=0;
end
Subplot(4,1,3);

plot(t,psk_sig(i,:));

title('PSK modulated signal');

xlabel('t-->');
ylabel('S(t)');
grid on

hold on
Subplot(4,1,4);
stem(demod);

title('PSK demodulated signal');

xlabel('t-->');
ylabel('m^t)');
end

hold off
Output:

Enter the message bits: [ 1 0 1 1 0 0 1 1]


FSK Modulation and Demodulation

clc; clear all; close all;

%generate message signal


m=input('enter message bits');

%generate carrier signal

tb=1; fc1=5; fc2=2 ;t=0:tb/100:tb;


c1=sqrt(2/tb)*sin(2*pi*fc1*t);
c2=sqrt(2/tb)*sin(2*pi*fc2*t);
Subplot(5,1,1);

stem(m);
title('Message signal');
xlabel('n-->');
ylabel('m(n)');
Subplot(5,1,2);
plot(t,c1);

title('Carrier signal 1');


xlabel('t-->');
ylabel('c(t)');
Subplot(5,1,3);
plot(t,c2);

title('Carrier signal 2');


xlabel('t-->');
ylabel('c(t)');
N=length(m);

t1=0; t2=tb;

for i= 1:N
t=[t1:(tb/100):t2];
if m(i)==1;

msg=ones(1,length(t));
inv_msg= zeros(1,length(t));
else
msg=zeros(1,length(t));
inv_msg= ones(1,length(t));
end

% modulation
fsk_sig1(i,:)=c1.*msg;
fsk_sig2(i,:)=c2.*inv_msg;

fsk=fsk_sig1+fsk_sig2;

t1= t1+(tb+.01); t2= t2+(tb+.01);

% Demodulation
x1=sum(c1.*fsk_sig1(i,:));
x2=sum(c2.*fsk_sig2(i,:));
x=x1-x2;

if x>0
demod(i)=1;
else
demod(i)=0;
end
Subplot(5,1,4);
plot(t,fsk(i,:));

title('FSK modulated signal');

xlabel('t-->');
ylabel('S(t)');
grid on

hold on
Subplot(5,1,5);
stem(demod);

title('FSK demodulated signal');

xlabel('t-->');
ylabel('m^t)');
end

hold off
Output:

Enter the message bits: [ 1 0 1 1 0 0 1 1]


QPSK modulation and demodulation

Program:

clc;clf;clear all; close all;

Tb=1;t=0:(Tb/100):Tb;fc=2;
c1=sqrt(2/Tb)*cos(2*pi*fc*t);
c2=sqrt(2/Tb)*sin(2*pi*fc*t);
N=10;m=[1 1 1 0 0 1 0 0 0 1 ];
t1=0;t2=Tb

for i=1:2:(N-1)
t=[t1:(Tb/100):t2]
if m(i)>0.5

m(i)=1;

m_s=ones(1,length(t));

else
m(i)=0;

m_s=-1*ones(1,length(t));

end
odd_sig(i,:)=c1.*m_s;
if m(i+1)>0.5

m(i+1)=1;

m_s=ones(1,length(t));

else
m(i+1)=0;

m_s=-1*ones(1,length(t));

end even_sig(i,:)=c2.*m_s;
qpsk=odd_sig+even_sig;
subplot(3,2,4);plot(t,qpsk(i,:));
title('QPSK');

xlabel('t---->');ylabel('s(t)');grid on;hold on;

t1=t1+(Tb+0.01);t2=t2+(Tb+0.01);
end

hold off
subplot(3,2,1);stem(m);

title('binary data bits');xlabel('n--->');ylabel('b(n)');

grid on;

subplot(3,2,2);

plot(t,c2);

title('carrier signal 1');


xlabel('t--->');
ylabel('c1(t)');

grid on;
subplot(3,2,3);plot(t,c2);
title('carrier signal2');
xlabel('t--->');
ylabel('c2(t)');

grid on;t1=0;t2=Tb
for i=1:N-1

t=[t1:(Tb/100):t2]
x1=sum(c1.*qpsk(i,:));
x2=sum(c2.*qpsk(i,:));
if (x1>0&&x2>0)

demod(i)=1;

demod(i+1)=1;

elseif(x1>0&&x2<0)
demod(i)=1;
demod(i+1)=0;

elseif(x1<0&&x2<0)
demod(i)=0;
demod(i+1)=0;
elseif(x1<0&&x2>0)
demod(i)=0;
demod(i+1)=1;

end
t1=t1+(Tb+0.01);
t2=t2+(Tb+0.01);

end subplot(3,2,5);
stem(demod);
title('QPSK demod');
xlabel('n--->');
ylabel('b(n)');

grid on;
Signal constellation of BPSK,QPSK and QAM

BPSK:
clearall;
closeall;
clc; M=2;

x=randint(1000,1,M);
y1=pskmod(x,M);
y1n=awgn(y1,10,'measured');
scatterplot(y1n);
y1r=pskdemod(y1n,M);
[num_error,er_rate]=symerr(x,y1r)

OUTPUT:
QAM:
clear all;
close all;
clc;
M=16;

x=randint(1000,1,M);
y1=qammod(x,M);
y1n=awgn(y1,10,'measured');
scatterplot(y1n);
y1r=qamdemod(y1n,M);
[num_error,er_rate]=symerr(x,y1r)

OUTPUT:
QPSK: Clear
all; Close all;
clc;

b=2;
M=2^b;

ss=[0 0; 0 1; 1 1; 1 0;];
Tb=1;
Ts=b*Tb;
Nb=32;
Ns=b*Nb;
T=Ts/Ns;
LB=4*Ns;

LBN1=LB-Ns+1;
Es=2; sqEs=sqrt(Es);
wc=8*pi/Ts; t=[0:Ns-
1]*T; wcT=wc*T;

phases=2*pi/M*[0:M-1];

gs='>^<vs*x+d';

nd=0;

for m=1:M, sw(m,:)=sqrt(2*Es/Ts)*cos(wc*t+phases(m));

end

su=sqrt(2/Ts)*[cos(wc*t); -sin(wc*t)];

suT=su*T; SNRdBs=[1:10];
MaxIter=10000;
foriter=1:length(SNRdBs)
SNRbdB=SNRdBs(iter);

SNR=10^(SNRbdB/10);
N0=2*(Es/b)/SNR;
sigma2=N0/2;

sgmsT=sqrt(sigma2/T);
sws=zeros(1,LB);
yr=zeros(2,LB); nobe=0;

for k=1:MaxIter
i=ceil(rand*M);

s=ss(i,:);
for n=1:Ns sws=[sws(2:LB)
sw(i,n)]; wct=wcT*(n-1);
bp_noise=randn*cos(wct)-randn*sin(wct);
rn=sws(end-nd)+sgmsT*bp_noise;
yr=[yr(:,2:LB) suT(:,n)*rn];

end

ycsk=sum(yr(:,LBN1:LB)')';

ifiter==9&k<300

subplot(221), hold on, plot(ycsk(1), ycsk(2), gs(i))

end
th=atan2(ycsk(2),ycsk(1));
ifth<-pi/M, th=th+2*pi;
end

[themin,lmin]=min(abs(th-phases));

d=ss(lmin,:);
nobe=nobe+sum(s~=d);
ifnobe>100, break; end
end
pobe(iter)=nobe/(k*b);
end

plot(sqEs*exp(j*phases)+j*eps,'ro')
SNRbdBt=0:0.1:10;
SNRbt=10.^(SNRbdBt/10);

pobet=(1+(b>1))/b*erfc(sqrt(b*SNRbt)*sin(pi/M));

subplot(222);

semilogy(SNRbdBt,pobet,'k-',SNRdBs,pobe,'b*')

title(['BER for ' num2str(M) '-PSK Signaling'])


OUTPUT:

BER for 4-PSK Signaling


0
4
10

2
-2

10

-4

10
-2

-6

-4 10
-4 -2 0 2 4 0 5 10
ERROR CONTROL CODES

%linear block code

clc;

clear all;

close all;

% Input Generator Matrix


g=input('Enter The Generator Matrix: ')

disp ('G = ')

disp ('The Order of Linear block Code for given Generator Matrix is:')
[n,k] = size(transpose(g))

for i = 1:2^k
for j = k:-1:1

if rem(i-1,2^(-j+k+1))>=2^(-j+k)
u(i,j)=1;
else
u(i,j)=0;
end

end
end
u;

disp('The Possible Codewords are :')

c = rem(u*g,2)

disp('The Minimum Hamming Distance dmin for given Block Code is= ')

d_min = min(sum((c(2:2^k,:))'))

% Code Word

r = input('Enter the Received Code Word:')

p = [g(:,n-k+2:n)];

h = [transpose(p),eye(n-k)];

disp('Hammimg Code')

ht = transpose(h)

disp('Syndrome of a Given Codeword is :')


s = rem(r*ht,2)

for i = 1:1:size(ht)

if(ht(i,1:3)==s)
r(i) = 1-r(i);
break;

end
end

disp('The Error is in bit:')

disp('The Corrected Codeword is :')

r
OUTPUT:

Enter The Generator Matrix: [ 1 1 1 1 0 0 0; 0 1 0 0 1 0 0; 0 1 1 0 0 1 0; 1 0 1 0 0 0 1]

g=

1 1 1 1 0 0 0
0 1 0 0 1 0 0
0 1 1 0 0 1 0
1 0 1 0 0 0 1

G=

The Order of Linear block Code for given Generator Matrix is:

n=

k=

The Possible Codewords are :

c=

0 0 0 0 0 0 0
1 0 1 0 0 0 1
0 1 1 0 0 1 0
1 1 0 0 0 1 1
0 1 0 0 1 0 0
1 1 1 0 1 0 1
0 0 1 0 1 1 0
1 0 0 0 1 1 1
1 1 1 1 0 0 0
0 1 0 1 0 0 1
1 0 0 1 0 1 0
0 0 1 1 0 1 1
1 0 1 1 1 0 0
0 0 0 1 1 0 1
1 1 0 1 1 1 0
0 1 1 1 1 1 1

The Minimum Hamming Distance dmin for given Block Code is=

d_min =

Enter the Received Code Word:[1 0 1 1 0 0 1]

r =1 0 1 1 0 0 1
Hammimg Code

ht =

1 0 0
0
0 10 0
0 0 1
1 0 0
0 1 0
0 0 1

Syndrome of a Given Codeword is :

s=

0 1 0

The Error is in bit:

i=

The Corrected Codeword is :

r=

1 0 0 1 0 0 1
% Cyclic Codes

clc;
clear all;
close all;
n=3, k=2;
input=randint(10,k,[0 1]);
disp('input'); disp (input);
code=encode(input,n,k,'cyclic|binary');
disp('encoded message');
disp (code);
error=randerr(10,n, [0 1; .6 .4]);
disp('error');
disp(error);
noise=rem(code+randerr(10,n,[0 1; .6 .4]),2);
disp('noise'); disp(noise);
output=decode(noise,n,k,'cyclic');
disp('output');
disp(output);
[numerr,ratio]=biterr(output,input);
disp(['The bit error rate is',num2str(ratio)]);
err_words=find(ratio~=0);
disp(err_words);
n=
3

1 0
input
1 1
0 1
1 1
0 0
1 0
1 1
1 1
0 0
1 0

encoded message
1 1 0
0 1 1
1 0 1
0 1 1
0 0 0
1 1 0
0 1 1
0 1 1
0 0 0
1 1 0

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

noise
0 11 10
11 1 1
0 1 0
0 0 1
1 1 0
0 0 1
1 1 1
0 0 0
1 0 0
output

1 0
1 1

1 1

1 0

0 1

1 0

0 1

1 1

0 0

0 0

The bit error rate is0.25

1
Convolutional codes

clc;

clear all;

close all;

x=input('Enter the input sequence');

h=input('Enter the impulse sequence');

m=length(x);

n=length(h);

X=[x,zeros(1,n)];

H=[h,zeros(1,m)];

for i=1:n+m-1

y(i)=0

for j=1:m

if(i-j+1>0)

y(i)=y(i)+X(j)*H(i-j+1);

else

end

end

end

Output:

Enter the input sequence [1 0 0 1 1]

Enter the impulse sequence [1 1 0 1 0 1]

y=

1 1 1 1 1 1 1 1 0
Communication Link Simulation

Block Diagram:

Output:

You might also like