Experiment No 4-12
Experiment No 4-12
3. Generation of a signal and verify its sampling and reconstruction process. CO2
6. Generation of Unipolar NRZ, Polar NRZ, Unipolar RZ, and Polar RZ line CO3
codes.
7. Study of the effect of companding on quantization SNR of speech CO3
waveforms.
8. Generation and detection of Delta modulated signal. CO3
11. Generation and detection of Direct Sequence Spread Spectrum (DSSS). CO5
EXPERIMENT NO. 4
Pulse Amplitude Modulation (PAM) is the simplest pulse modulation scheme. In pulse
amplitude modulation system, the amplitude of a carrier pulse train is varied in accordance with
the instantaneous level of the modulating signal.
This type of modulation is used as the first step in converting an analog signal to a discrete signal
or in cases where it may be difficult to change the frequency or phase of the carrier. In this case
the carrier is a pulse train rather than a sine wave and the spectrum of the carrier consists of several
components at 2np/T where T is the time between pulses. The applet below shows a PAM signal
and how it varies with modulating signal amplitude and frequency. In this case each component of
the carrier's spectrum has become an AM spectrum. Notice that the spectrum contains a component
at the modulating frequency, which makes the PAM signal relatively easy to demodulate. Pulse-
amplitude modulation, acronym PAM, is a form of signal modulation where the message
information is encoded in the amplitude of a series of signal pulses.
BLOCK DIAGRAM:
PROCEDURE:
OUTPUT WAVEFORM:
OBSERVATION TABLE:
RESULT: Thus, the PAM signal was generated using PAM modulator.
EXPERIMENT NO. 5
CONNECTION DIAGRAM:
THEORY:
Pulse code modulation is a process of converting an analog signal into digital. The voice or
any data input is first sampled using a sampler (which is a simple switch) and then quantized.
Quantization is the process of converting a given signal amplitude to an equivalent binary number
with fixed number of bits. This quantization can be either mid-tread or mid-raise and it can be
uniform or non-uniform based on the requirements. For example, in speech signals, the higher
amplitudes will be less frequent than the low amplitudes. So higher amplitudes are given less step
size than the lower amplitudes and thus quantization is performed non-uniformly. After
quantization the signal is digital and the bits are passed through a parallel to the serial converter
and then launched into the channel serially.
At the demodulator the received bits are first converted into parallel frames and each frame
is de-quantized to an equivalent analog value. This analog value is thus equivalent to a sampler
output. This is the demodulated signal.
In the kit this is implemented differently. The analog signal is passed through an ADC
(Analog to Digital Converter) and then the digital codeword is passed through a parallel to serial
converter block. This is modulated PCM. This is taken by the Serial to Parallel converter and then
through a DAC to get the demodulated signal. The clock is given to all these blocks for
synchronization. The input signal can be either DC or AC according to the kit. The waveforms can
be observed on a CRO for DC without problem.
BLOCK DIAGRAM:
WAVEFORM
PROCEDURE:
OUTPUT WAVEFORM:
OBSERVATION TABLE:
RESULT: Thus, the PCM signal was generated using PCM modulator and the message signal
was detected from PCM signal by using PCM demodulator.
EXPERIMENT NO. 6
AIM: Generation of Unipolar NRZ, Polar NRZ, Unipolar RZ, and Polar RZ line codes.
APPARATUS REQUIRED: Data encoding Trainer Kit, Power supply, CRO or DSO, Connecting
leads.
Theory:
Data as well as signals that represents data can either be digital or analog. Line coding is
the process of converting digital data to digital signals. By this technique we converts a sequence
of bits to a digital signal. At the sender side digital data are encoded into a digital signal and at the
receiver side the digital data are recreated by decoding the digital signal. The symbol ‘1’ and ‘0’
can be represented in various formats in different levels and waveforms. The selection of
coding technique depends on system band width, system ability to pass dc level information,
error checking facility.
Unipolar Non return to zero (NRZ) – It is unipolar line coding scheme in which positive voltage
defines bit 1 and the zero voltage defines bit 0. Signal does not return to zero at the middle of the
bit thus it is called NRZ.
Polar schemes –
NRZ-L and NRZ-I – These are somewhat similar to unipolar NRZ scheme but here we use two
levels of amplitude (voltages). For NRZ-L(NRZ-Level), the level of the voltage determines the
value of the bit, typically binary 1 maps to logic-level high, and binary 0 maps to logic-level low,
and for NRZ-I(NRZ-Invert), two-level signal has a transition at a boundary if the next bit that we
are going to transmit is a logical 1, and does not have a transition if the next bit that we are going
to transmit is a logical 0. Note – For NRZ-I we are assuming in the example that previous signal
before starting of data set “01001110” was positive. Therefore, there is no transition at the
beginning and first bit “0” in current data set “01001110” is starting from +V.
Return to zero (RZ) – It uses three values positive,negative,and zero. In this scheme signal goes
to 0 in the middle of each bit. Note – The logic we are using here to represent data is that for bit 1
half of the signal is represented by +V and half by zero voltage and for bit 0 half of the signal is
represented by -V and half by zero voltage. Main disadvantage of RZ encoding is that it requires
greater bandwidth. Another problem is the complexity as it uses three levels of voltage. Instead,
it has been replaced by the better-performing Manchester and differential Manchester schemes.
Biphase (Manchester and Differential Manchester ) – Manchester encoding is somewhat
combination of the RZ (transition at the middle of the bit) and NRZ-L schemes. The duration of
the bit is divided into two halves. The voltage remains at one level during the first half and moves
to the other level in the second half. The transition at the middle of the bit provides synchronization.
Differential Manchester is somewhat combination of the RZ and NRZ-I schemes. There is always
a transition at the middle of the bit but the bit values are determined at the beginning of the bit. If
the next bit is 0, there is a transition, if the next bit is 1, there is no transition.
DC LAB MANUAL Page 8
ELECTRONICS & COMMUNICATION ENGG.
WAVEFORM:
OBSERVATION:
RESULTS: Thus the different coding techniques were studied and observed for a given binary
data, and their corresponding waveforms plotted.
CONCLUSION:From the above experiment, we conclude that by using these techniques we can
encode our data easily which helps to secure our data.
EXPERIMENT NO. 7
THEORY:
Companding
In Analog to Digital Convertor (ADC), the quantizer used is uniformly spaced against
amplitude axis. This allows uniform resolution or step size for the entire range of the signal. The
resulting error or quantization noise is also same for all the amplitude levels. While this appears to
be a very logical way of quantizing signal if quantization error / noise is perceived uniformly across
all amplitude levels, there are occasions when it is not actually so. For example, human auditory
system follows what can be related to a logarithmic process in which high amplitude sounds do not
require the same resolution as low amplitude sounds. The human ear is more sensitive to
quantization noise in small amplitude signals than the large ones.
Companding is combination of two terms compressing and expanding. In the context of
quantization, this refers to compressing the higher amplitude signal first through a non-uniform
quantization process and then expanding it to get back the signal. To obtain non-uniform
quantization a two-step process may be followed - first pass the signal through a compressor and
then compress it by a uniform quantizer.
In speech coding, in an attempt to follow the human auditory system A-law and mu-law
companding are used. Both apply logarithmic quantization functions to adjust the bit resolution in
proportion to the level of the input signal. Smaller signals are represented with greater precision or
more data bits and larger signals with less data bits. The result is fewer bits per sample to maintain
an audible signal-to-noise ratio (SNR). Note the term 'audible'. Audible SNR is the perceived SNR
and not actual SNR.
For computational ease, A-law and m-law companding match logarithmic curve with a
piece-wise linear approximation. This first sets eight straight-line segments along the curve to
produce a close approximation to the logarithm function. Each segment is known as a chord. Within
each chord, the piece-wise linear approximation is divided into equally size quantization intervals
called steps. The step size between adjacent codewords is doubled in each succeeding chord. Also
encoded is the sign bit for the original integer. The result is an 8-bit logarithmic code composed of
a 1-bit sign bit, a 3-bit chord, and a 4-bit step.
A-Law Compander
A-law is the CCITT recommended companding standard that is used across Europe and rest
of the countries except Japan, Canada and North America. Limiting the linear sample values to 12
magnitude bits, the A-law compression is defined by Equation 1, where A is the compression
parameter (A=87.7 in Europe), and x is the normalized signal to be compressed.
μ-Law compander
The United States and Japan use m-law companding. In that, the linear sample values are
limited to 13 magnitude bits, the m-law compression is defined by Equation 2, where μ is the
compression parameter (μ =255 in the U.S. and Japan) and x is the normalized signal to be
compressed.
The companding process for m-law is similar to that of A-law. The major differences are:
(i) μ-law encoders typically operate on linear 13-bit magnitude data, as opposed to 12-bit magnitude
data with A-law, (ii) before chord determination a bias value of 33 is added to the absolute value
of the linear input data to simplify the chord and step calculations, (iii) the definition of the sign bit
is reversed, and (iv) the inversion pattern is applied to all bits in the 8-bit code.
MATLAB CODE:
% ?-law Companding
companded = sign(x) .* log(1 + mu * abs(x)) ./ log(1 + mu);
% Plot Results
figure;
subplot(3, 1, 1);
plot(x);
title('Original Signal');
xlabel('Sample Index');
ylabel('Amplitude');
subplot(3, 1, 2);
plot(companded);
title('Companded Signal (Mu-law)');
xlabel('Sample Index');
ylabel('Amplitude');
subplot(3, 1, 3);
plot(expanded);
title('Expanded Signal (Decompanding)');
xlabel('Sample Index');
ylabel('Amplitude');
% A-law Companding
companded = zeros(size(x));
for i = 1:length(x)
if abs(x(i)) < 1/A
companded(i) = sign(x(i)) * A * abs(x(i)) / (1 + log(A));
else
DC LAB MANUAL Page 13
ELECTRONICS & COMMUNICATION ENGG.
% Plot Results
figure;
subplot(3, 1, 1);
plot(x);
title('Original Signal');
xlabel('Sample Index');
ylabel('Amplitude');
subplot(3, 1, 2);
plot(companded);
title('Companded Signal (A-law)');
xlabel('Sample Index');
ylabel('Amplitude');
subplot(3, 1, 3);
plot(expanded);
title('Expanded Signal (Decompanding)');
xlabel('Sample Index');
ylabel('Amplitude');
OUTPUT WAVEFORM:
RESULT: Studied the principle of companding using A law and mu law compander.
EXPERIMENT NO. 8
AIM: To study and perform delta modulation and demodulation.
CONNECTION DIAGRAM:
THEORY:
Delta modulation is the DPCM technique of converting an analog message signal to a digital
sequence. The difference signal between two successive samples is encoded into a single bit code.
The block and kit diagrams show the circuitry details of the modulation technique. A present
sample of the analog signal x(nT) is compared with a previous sample and the difference output
is level shifted, i.e. a positive level (corresponding to bit 1) is given if difference is positive and
negative level (corresponding to bit 0) if it is negative. The comparison of samples is
accomplished by converting the digital to analog form and then comparing with the present
sample. This is done using an Up counter and DAC as shown in block diagram. The delta
modulated signal is given to up counter and then a DAC and the analog input is given to OPAMP
and a LPF to obtain the demodulated output.
BLOCK DIAGRAM:
WAVEFORM:
OBSERVATION TABLE:
Transmitter/ Receiver
Freq.
Amp.
RESULT: Thus the analog message signal in its digital form was transmitted and again the
original analog message signal was reconstructed at the receiver by using Delta modulator and
Demodulator.
EXPERIMENT NO. 9
AIM: Generation and detection of ASK, FSK, and PSK signals using MATLAB.
THEORY:
Amplitude Shift Keying (ASK) is a type of Amplitude Modulation which represents the
binary data in the form of variations in the amplitude of a signal. Any modulated signal has a high
frequency carrier. The binary signal when ASK modulated, gives a zero value for Low input while
it gives the carrier output for High input. The following figure represents ASK modulated
waveform along with its input.
ALGORITHM:
MATLAB CODE:
ASK
clc;
close all;
clear all;
n=10; % length of bit stream
b=[1 0 0 1 1 1 0 0 0 1]
f1=1;
f2=2;
t=0:1/30:1-1/30;
%ASK
sa1=sin(2*pi*f1*t);
E1=sum(sa1.^2);
sa1=sa1/sqrt(E1); %unit energy
sa0=0*sin(2*pi*f1*t);
%MODULATION
ask=[];
for i=1:n
if b(i)==1
ask=[ask sa1];
else
ask=[ask sa0];
end
end
figure(1)
subplot(211)
stairs(0:10,[b(1:10) b(10)],'linewidth',1.5)
axis([0 10 -0.5 1.5]); title('Message Bits'); grid on;
xlabel('Time');
ylabel('Amplitude')
subplot(212)
tb=0:1/30:10-1/30;
plot(tb, ask(1:10*30),'b','linewidth',1.5)
title('ASK Modulation');grid on;
xlabel('Time');
ylabel('Amplitude')
FSK-
clc;
clear all;
close all;
n=100;
x=[ones(1,20) zeros(1,20) ones(1,20) zeros(1,20) ones(1,20)];
subplot(4,1,1);
plot(x);
title('input signal'); xlabel('number of samples'); ylabel('amplitude');
f=1*10^6;
fs=20*10^6;
for i=0:n-1
d(i+1)=sin(2*pi*(f/fs)*i);
end
subplot(4,1,2);
plot(d);
title('carrier signal'); xlabel('number of samples'); ylabel('amplitude');
for i=0:n-1
if(x(i+1)==1)
x(i+1)=sin((2*pi*(f/fs)*i));
else
x(i+1)=sin((2*pi*((4*(f/fs)))*i));
end
end
subplot(4,1,3); plot(x);
title('FSK Signal');
xlabel('number of samples');
ylabel('amplitude');
for i=0:n-1
if(x(i+1)==sin((2*pi*(f/fs)*i)))
x(i+1)=1;
else
x(i+1)=0;
end
end
subplot(4,1,4); plot(x); title('FSK demodulated Signal'); xlabel('number of samples');
ylabel('amplitude');
PSK –
clc;
clear all;
close all;
n=100;
x=[ones(1,20) zeros(1,20) ones(1,20) zeros(1,20) ones(1,20)];
subplot(4,1,1);
plot(x); title('input signal');
xlabel('number of samples');
ylabel('amplitude');
f=1*10^6;
fs=10*10^6;
for i=0:n-1
d(i+1)=sin(2*pi*(f/fs)*i);
end
subplot(4,1,2); plot(d);
title('carrier signal');
xlabel('number of samples');
ylabel('amplitude');
for i=0:n-1
if(x(i+1)==0)
x(i+1)=sin(2*pi*(f/fs)*i);
else
x(i+1)=sin(2*pi*(f/fs)*i+pi);
end
end
subplot(4,1,3);
plot(x);
title('PSK Signal');
xlabel('number of samples');
ylabel('amplitude');
for i=0:n-1
if(x(i+1)==sin(2*pi*(f/fs)*i)) x(i+1)=0;
else
x(i+1)=1;
end
end
subplot(4,1,4);
plot(x);
title('demodulated Signal');
xlabel('number of samples');
ylabel('amplitude');
OUTPUT:
ASK-
FSK-
PSK –
RESULT: Thus, the simulation of FSK was performed in MATLAB and corresponding waveform
were plotted successfully.
EXPERIMENT NO. 10
AIM: Generation and detection of DPSK signals using MATLAB.
THEORY:
Differential phase shift keying (DPSK), a common form of phase modulation conveys
data by changing the phase of carrier wave. In DPSK, there is no absolute carrier phase
reference, instead transmitted signal itself used as phase reference. For example, in
differentially encoded BPSK a binary '1' may be transmitted by adding 180° to the current
phase and a binary'0' by adding 0°to the current phase. For a signal that has been differentially
encoded, there is an obvious alternative method of demodulation. Instead of demodulating as usual
and ignoring carrier-phase ambiguity, the phase between two successive received symbols is
compared and used to determine what the data must have been. When differential encoding is used
in this manner, the scheme is known as differential phase-shift keying (DPSK).
ALGORITHM:
PROGRAM:
clc; clear all; close all;
n=100;
x=[ones(1,20) zeros(1,20) ones(1,20) zeros(1,20) ones(1,20)];
subplot(4,1,1);
plot(x);
title('input signal');
xlabel('number of samples');
ylabel('amplitude');
f=1*10^6;
fs=10*10^6;
DC LAB MANUAL Page 26
ELECTRONICS & COMMUNICATION ENGG.
for i=0:n-1
d(i+1)=sin(2*pi*(f/fs)*i);
end
subplot(4,1,2); plot(d);
title('carrier signal');
xlabel('number of samples');
ylabel('amplitude');
for i=0:n-1
if(x(i+1)==0)
x(i+1)=sin(2*pi*(f/fs)*i);
else
x(i+1)=sin(2*pi*(f/fs)*i+pi);
end
end
subplot(4,1,3);
plot(x);
title('PSK Signal');
xlabel('number of samples');
ylabel('amplitude');
for i=0:n-1
if(x(i+1)==sin(2*pi*(f/fs)*i))
x(i+1)=0;
else
x(i+1)=1;
end
end
subplot(4,1,4); plot(x);
title('demodulated Signal');
xlabel('number of samples');
ylabel('amplitude');
OUTPUT:
RESULT: Thus, the simulation of DPSK was performed in MATLAB and corresponding
waveforms were plotted successfully.
EXPERIMENT. 11
AIM: Generation and detection of Direct Sequence Spread Spectrum (DSSS).
THEORY:
ALGORITHM:
1. Define the PN bitstream.
2. Define the input bitstream.
3. Obtain the DSSS stream.
4. Plot the PN bitstream, input bit stream and DSSS stream.
PROGRAM:
PNbit_stream;
for i=1:1:8
for j=1:4:32
for k=1:1:4
a(j)=xor(PNbit_stream(k+j-1),input_signal(i));
a(j);
end
end
end
subplot(3,1,1);
stem(PNbit_stream);
title('PNbit_stream');
subplot(3,1,2);
stem(input_signal);
title('input_signal');
subplot(3,1,3);
stem(a);
title('DSSS');
OUTPUT:
RESULT:Thus, the simulation of Direct Sequence Spread Spectrum was performed in MATLAB
and corresponding waveforms were plotted successfully.
EXPERIMENT. 12
THEORY:
In Frequency Hoping Spectrum, available channel bandwidth is broken into a large number
of non-overlapping frequency slots. Data is modulated onto time-varying, Pseudo random carrier
frequencies. Transmitter “hops” between different narrowband Channels with centre frequency fi,
and bandwidth B (instantaneous bandwidth). Spectrum BW (bandwidth) over which hopping
occurs is called the total hopping. Data sent by hopping transmitter carrier to seemingly random
channels which are known only to desired receiver. On each channel, data bursts are sent using
conventional narrowband modulation hopping period/hop duration.
There are generally two types of hopping schemes employed in FHSS-
Fast Hopping: In this scheme the hopping rate is kept equal to or greater than the Data rate. The
hopping rate should not be many time faster than the data rate. Generally, it can be 2-3 times faster
than the data rate.
Slow Hopping: In this scheme the hopping rate is kept lower than the data rate. Also, the data rates
which can be supported by FHSS system are quite lower than the data rates supported by DSSS
systems.
PROGRAM:
clc
clear all;
% Generation of bit pattern
s=round(rand(1,25)); % Generating 25 bits
signal=[];
carrier=[];
t=[0:2*pi/119:2*pi]; % Creating 120 samples for one cosine
for k=1:25
if s(1,k)==0
sig=-ones(1,120); % 120 minus ones for bit 0
else
sig=ones(1,120); % 120 ones for bit 1
end
c=cos(t);
carrier=[carrier c];
signal=[signal sig];
end
subplot(4,1,1);
plot(signal);
axis([-100 3100 -1.5 1.5]);
title('\bf\it Original Bit Sequence');
c1=[c1 c1 c1 c1 c1 c1 c1 c1 c1 c1 c1 c1];
c2=cos(t2);
c2=[c2 c2 c2 c2 c2 c2];
c3=cos(t3);
c3=[c3 c3 c3 c3];
c4=cos(t4);
c4=[c4 c4 c4];
c5=cos(t5);
c5=[c5 c5];
c6=cos(t6);
switch(c)
case(1)
spread_signal=[spread_signal c1];
case(2)
spread_signal=[spread_signal c2];
case(3)
spread_signal=[spread_signal c3];
case(4)
spread_signal=[spread_signal c4];
case(5)
spread_signal=[spread_signal c5];
case(6)
spread_signal=[spread_signal c6];
end
end
subplot(4,1,3)
plot([1:3000],spread_signal);
axis([-100 3100 -1.5 1.5]);
title('\bf\it Spread Signal with 6 frequencies');
OUTPUT-
RESULT:
Thus, the simulation of Frequency Hopping Spread Spectrum (FHSS) was performed in
MATLAB and corresponding waveforms were plotted successfully.