Pcs Lab Manual
Pcs Lab Manual
LAB MANUAL
Code : BEC402
Semester : 4
Year : 2024-25
Scheme : 22
01 Basic Signals and Signal Graphing: a) unit Step, b) Rectangular, c) standard triangle
05 Sampling and reconstruction of low pass signals. Display the signals and its spectrum.
08 Generate a)NRZ, RZ and Raised cosine pulse, b) Generate and plot eye diagram
Aim:
To study the function of basic signals and signal graphing of a) unit Step,
Software Used:
Theory:
a) Unit Step Signal (u(t)) – A signal that is zero for t<0t < 0t<0 and one for t≥0t \geq
0t≥0, commonly used to represent system activation.
b) Rectangular Signal – A pulse-like signal that remains constant for a specific duration
and zero otherwise, often used in switching operations.
c) Standard Triangle Signal – A piecewise linear signal that increases and then
decreases symmetrically, resembling a triangular shape.
Program:
t=-10:10;
y=[zeros(1,10),ones(1,11)];
stem(t,y);
ylabel('u(t)');
ramp function
subplot(3,4,3);
t=-10:0.5:10;
y=t;
stem(t,y);
title('ramp function');
xlabel('t(sec)');
ylabel('r(t)');
impulse function
subplot(3,4,2);
t=-10:10;
y=[zeros(1,10),ones(1,1),zeros(1,10)];
stem(t,y);
title('impulse function');
xlabel('t(sec)');
ylabel('i(t)');
subplot(3,4,7);
t=linspace(-10,10);
y=exp(0.1*t);
plot(t,y);
ylabel('e(t)');
rectangular function
subplot(3,4,8);
t=-10:10;
y=[zeros(1,9),ones(1,3),zeros(1,9)];
stem(t,y);
title('rectangular function');
xlabel('t(sec)');
ylabel('r(t)');
cosine function
subplot(3,4,5);
t=linspace(-
10,10);
y=1+cos(t);
plot(t,y);
title('cosine function');
xlabel('t(sec)');
ylabel('c(t0');
sinc function
subplot(3,4,9);
t=linspace(-10,10);
y=sinc(2*pi*0.1*t); plot(t,y);
title('sinc function');
xlabel('t(sec)');
ylabel('sinc(t)');
subplot(3,4,6);
t=linspace(0,10);
y=exp(-t);
plot(t,y);
title('falling exponential
function'); xlabel('t(sec)');
ylabel('e(t)');
sine function
subplot(3,4,4);
t=linspace(-10,10); y=sin(t);
plot(t,y);
title('sine function');
xlabel('t(sec)');
ylabel('s(t)');
triangular function
subplot(3,4,10);
t=-10:10;
output=((1-2*abs(t))/20);
plot(t,output);
Result :
Thus the study and analysis of the functions and graphing of basic signals, including a) Unit Step, b)
Rectangular, c) Standard Triangle, d) Sinusoidal, and e) Exponential signals, have been carried out
EXPERIMENT 2
Aim:
Software Used:
Theory:
A rectangular pulse is a fundamental signal widely used in signal processing and communication
systems. It has a well-defined width and amplitude in the time domain, and its frequency domain.
In Time-Domain Representation: A rectangular pulse is defined with a finite width and plotted.In
Frequency-Domain Representation: The Fast Fourier Transform (FFT) computes the signal’s
frequency spectrum.
Program:
t=-10:10;
y=[zeros(1,9),ones(1,3),zeros(1,9)]; subplot(2,1,1);
stem(t,y);
xlabel('time');
ylabel('amplitude');
subplot(2,1,2);
plot(t,fftshift(abs(x))); xlabel('frequency');
ylabel('magnitude');
Result:
Theory:
Amplitude Modulation (AM) is a technique where the amplitude of a high-frequency carrier
signal is varied in proportion to the message signal (information signal). Amplitude
Demodulation is the process of extracting the original message signal from the modulated
carrier.
Program:
clc;
clear;
close all;
% Parameters
fm = 10;
fc = 100;
fs = 1000;
m = 0.5;
T = 1;
t = 0:1/fs:T;
% Signals
message = cos(2 * pi * fm * t);
carrier = cos(2 * pi * fc * t);
am_signal = (1 + m * message) .* carrier;
% Plot Signals
subplot(3,1,1); plot(t, message); title('Message Signal'); grid on;
subplot(3,1,2); plot(t, carrier); title('Carrier Signal'); grid on;
subplot(3,1,3); plot(t, am_signal); title('AM Modulated Signal'); grid on;
% Demodulation using Envelope Detection
demod_signal = abs(hilbert(am_signal));
figure; plot(t, demod_signal, t, message, '--');
title('Demodulated Signal'); grid on;
Output:
Result:
Thus amplitude modulation and demodulation of a signal and its spectrum is been generated
and displayed.
Experiment -4
Frequency Modulation and Demodulation
Aim:
To generate and display the relevant frequency modulation and demodulation signal and its
spectrum
Software Used:
Octave
Theory:
Frequency Modulation (FM) is a technique where the frequency of a carrier signal is
varied in proportion to the instantaneous amplitude of the message signal while keeping the
amplitude constant. FM demodulation is the process of extracting the original message signal
from the modulated waveform. Frequency modulation is achieved by integrating the message
signal and applying it to the carrier. The demodulation is achieved using the Hilbert transform
to extract the instantaneous phase, followed by differentiation.
Program:
clc;
clear;
close all;
% Parameters
fs = 1000; % Sampling frequency
T = 1; % Duration in seconds
t = 0:1/fs:T; % Time vector
Am = 1; % Amplitude of message signal
fm = 10; % Frequency of message signal
Ac = 1; % Amplitude of carrier signal
fc = 100; % Frequency of carrier signal
kf = 1000; % Frequency sensitivity factor
% Message signal
m = Am * sin(2 * pi * fm * t);
% Carrier signal
c = Ac * sin(2 * pi * fc * t);
% Frequency Modulation
s = Ac * cos(2 * pi * fc * t + kf * cumsum(m) / fs);
% Frequency Demodulation using Phase Detector and Differentiation
inst_phase = unwrap(angle(hilbert(s))); % Extract instantaneous phase
demod_raw = diff(inst_phase) * fs / (2 * pi * kf); % Differentiate phase to get frequency
% Low-pass filter for smoothing
[b, a] = butter(5, (fm * 2) / fs, 'low');
demod = filtfilt(b, a, [demod_raw demod_raw(end)]); % Match original signal length
% Plot signals
figure;
subplot(4,1,1);
plot(t, m);
title('Message Signal');
xlabel('Time (s)');
ylabel('Amplitude');
grid on;
subplot(4,1,2);
plot(t, c);
title('Carrier Signal');
xlabel('Time (s)');
ylabel('Amplitude');
grid on;
subplot(4,1,3);
plot(t, s);
title('FM Signal');
xlabel('Time (s)');
ylabel('Amplitude');
grid on;
subplot(4,1,4);
plot(t, demod);
title('Demodulated Signal');
xlabel('Time (s)');
ylabel('Amplitude');
grid on;
Output:
Result:
Thus, frequency modulation and demodulation of a signal and its spectrum is been generated
and displayed.
Experiment 5
Sampling and reconstruction of low pass signals
Aim:
To perform sampling and reconstruction of low pass signals and also to display the signals
and its spectrum.
Software Used:
Octave version 8.3
Theory:
Sampling
Sampling is the process of converting a continuous-time signal into a discrete-time signal by
taking periodic samples at a fixed interval. According to the Nyquist sampling theorem, a
signal can be perfectly reconstructed if it is sampled at a rate at least twice its highest
frequency component (Nyquist rate)
fs≥2fm
If the sampling rate is lower than this, aliasing occurs, causing distortion in the reconstructed
signal.
Reconstruction
Reconstruction is the process of converting the discrete-time samples back into a continuous-
time signal. This is typically achieved using an ideal low-pass filter that removes higher
frequency components introduced during sampling and retains only the original frequency
components of the signal. Proper sampling and reconstruction ensure accurate signal recovery
without distortion.
Program:
% Sampling and Reconstruction of a Low-Pass Signal
% Original Signal
fs = 1000; % Sampling frequency
t = 0:1/fs:0.05; % Time vector
f_signal = 50; % Signal frequency
x = sin(2*pi*f_signal*t); % Original signal
subplot(3,1,1); plot(t, x, 'b'); title('Original Signal'); grid on;
% Sampling of Signal
fs_sampled = 200; % Lower sampling rate
t_sampled = 0:1/fs_sampled:0.05;
x_sampled = sin(2*pi*f_signal*t_sampled); % Sampled Signal
subplot(3,1,2); stem(t_sampled, x_sampled, 'r'); title('Sampled Signal'); grid on;
% Reconstruction of Signal
x_reconstructed = interp1(t_sampled, x_sampled, t, 'spline'); % Reconstructed Signal
subplot(3,1,3); plot(t, x_reconstructed, 'g'); title('Reconstructed Signal'); grid on;
figure;
Output:
Result:
Thus, the sampling and reconstruction of low-pass signals were carried out, and their signal
and spectrum were displayed.
Experiment -6
Time Division Multiplexing and Demultiplexing
Aim:
To perform time division multiplexing and demultiplexing for two different signals
Software Used:
Octave version 8.3
Theory:
Time Division Multiplexing (TDM) is a technique used in telecommunications and data
transmission where multiple signals share the same communication channel by dividing time
into separate slots. Each signal gets a dedicated time slot, ensuring that multiple signals can
be transmitted over the same medium without interference.
Time Division Multiplexing (TDM):
TDM works by assigning each signal a specific time slot in which it can transmit data. The
process happens so fast that it appears as if all signals are being transmitted simultaneously.
Time Division Demultiplexing (TDM):
Demultiplexing is the reverse process of multiplexing, where a demultiplexer (DEMUX)
extracts individual signals from the combined transmission based on their designated time
slots.
Program:
clc;
clear;
close all;
x = 0:0.5:4*pi;
sig1 = 8 * sin(x);
l = length(sig1);
sig2 = 8 * triang(l)';
% Transposed to match dimensions
% Plot Original and Sampled Signals
figure;
subplot(2,2,1);
plot(sig1);
grid on;
title('Sinusoidal Signal'); xlabel('Samples'); ylabel('Amplitude');
subplot(2,2,2); plot(sig2); grid on; title('Triangular Signal'); xlabel('Samples');
ylabel('Amplitude');
subplot(2,2,3); stem(sig1); grid on; title('Sampled Sinusoidal Signal'); xlabel('Samples');
ylabel('Amplitude');
subplot(2,2,4); stem(sig2); grid on; title('Sampled Triangular Signal'); xlabel('Samples');
ylabel('Amplitude');
% Time Division Multiplexing (TDM)
n = min(length(sig1), length(sig2)); % Ensure both signals have the same sample count
sig = [sig1(1:n); sig2(1:n)];
tdmsig = reshape(sig, 1, []);
figure;
stem(tdmsig); grid on; title('TDM Signal'); xlabel('Samples'); ylabel('Amplitude');
% Demultiplexing
demux = reshape(tdmsig, 2, []);
sig3 = demux(1, :);
sig4 = demux(2, :);
figure;
subplot(2,1,1); plot(sig3); grid on; title('Recovered Sinusoidal Signal'); xlabel('Samples');
ylabel('Amplitude');
subplot(2,1,2); plot(sig4); grid on; title('Recovered Triangular Signal'); xlabel('Samples');
ylabel('Amplitude');
Output:
Result:
Thus, time division multiplexing and demultiplexing was performed using two different
signals.
Experiment -7
PCM Illustration: Sampling, Quantization and Encoding
Aim:
To perform pulse code modulation using sampling, quantization and encoding.
Software Used:
Octave version 8.3
Theory:
PCM (Pulse Code Modulation) is a digital signal processing technique used to convert an
analog signal into a digital format. It involves three main steps:
1. Sampling – The continuous analog signal is sampled at discrete time intervals,
typically at a rate determined by the Nyquist theorem (at least twice the highest
frequency of the signal).
2. Quantization – The sampled values are approximated to the nearest level within a
finite set of discrete levels. This introduces quantization error.
3. Encoding – The quantized values are then converted into binary code for digital
representation and transmission.
Program:
% PCM Illustration: Sampling, Quantization, and Encoding
clc;
clear;
close all;
% Generate a Continuous Signal
fs = 1000; t = 0:1/fs:1; f = 5; x = sin(2*pi*f*t);
% Sampling
fs_sampled = 20;
ts = 0:1/fs_sampled:1;
x_sampled = sin(2*pi*f*ts);
% Quantization
num_levels = 8;
q_step = 2 / num_levels;
x_quantized = round(x_sampled / q_step) * q_step;
% Encoding
encoded_values = dec2bin((x_quantized - min(x_quantized)) / q_step, log2(num_levels));
% Plot results
figure;
subplot(3,1,1); plot(t, x, 'b', ts, x_sampled, 'ro'); grid on; title('Sampling');
subplot(3,1,2); stem(ts, x_quantized, 'g'); grid on; title('Quantization');
subplot(3,1,3); stem(ts, x_quantized, 'g');
text(ts, x_quantized, encoded_values, 'VerticalAlignment', 'bottom');
grid on; title('Encoding');
Output:
Result:
Thus, pulse code modulation using sampling, quantization and encoding was performed.
Experiment 8
Generate a) NRZ, RZ and Raised cosine pulse, b) Generate and plot eye diagram
Aim:
a) To generate Non-Return-to-Zero (NRZ), Return-to-Zero (RZ), and Raised Cosine pulse
signals.
b) To generate and plot the Eye Diagram for different line coding schemes or filters.
Software Used:
Octave version 8.3
Theory:
Pulse Shaping:
Pulse shaping is a technique used in digital communication to control the spectral
characteristics of the transmitted signal, reducing intersymbol interference (ISI) and
improving bandwidth efficiency.
NRZ (Non-Return-to-Zero):
In NRZ signaling, the signal level remains constant throughout the bit interval. It does
not return to zero between bits, making it bandwidth efficient but more susceptible to
synchronization issues.
RZ (Return-to-Zero):
In RZ signaling, the signal returns to zero in the middle of each bit period. This provides
better synchronization but occupies more bandwidth compared to NRZ.
Raised Cosine Pulse:
The raised cosine filter is widely used for pulse shaping in digital communication. It
minimizes ISI while effectively utilizing bandwidth. The roll-off factor (α) controls the
excess bandwidth.
Eye Diagram:
An eye diagram is a graphical representation of a digital signal from an oscilloscope. It
is used to evaluate the quality of the signal in the presence of noise, timing jitter, and ISI. The
"eye" opening provides insight into the optimal sampling time and the signal integrity.
Program:
MATLAB Program to Generate and Plot an NRZ Signal
% Define the binary data sequence
data = [1 0 1 1 0 0 1 0 1]; % Example binary sequence
% Parameters for the signal
data = [1 0 1 1 0 0 1 0 1];
bit_rate = 1; % Bit rate in bits per second
bit_duration = 1 / bit_rate; % Duration of each bi
% Define time vector for one bit duration
samples_per_bit = 100; % Number of samples per bit (adjustable)
t_bit = linspace(0, bit_duration, samples_per_bit);
% Initialize NRZ signal
nrz_signal = [];
% Generate NRZ signal
for bit = data
if bit == 1
nrz_signal = [nrz_signal ones(1, samples_per_bit)]; % High level for '1'
else
nrz_signal = [nrz_signal zeros(1, samples_per_bit)]; % Low level for '0'
end
end
% Time vector for the entire signal
t = linspace(0, bit_duration * length(data), length(nrz_signal));
plot(t, nrz_signal, 'LineWidth', 2);
ylim([-0.5 1.5]);
xlabel('Time (s)');
ylabel('Amplitude');
title('NRZ Signal');
grid on;
Output:
Output:
Generate and plot eye diagrams
% Generate random binary data
data_length = 1000;
data = randi([0, 1], 1, data_length);
% Parameters
samples_per_symbol = 10;
bit_rate = 1;
bit_duration = 1 / bit_rate;
Program:
clear all;
close all;
clc;
x = 0:0.01:2; % Range of x values
n = 1; % Mean
sd = 2; % Standard deviation
% Compute Gaussian PDF
g = (1 / (sd * sqrt(2 * pi))) * exp(-(x - n).^2 / (2 * sd^2));
% Plot
plot(x, g, 'b', 'LineWidth', 2);
xlabel('x');
ylabel('Amplitude');
title('Gaussian distribution function');
grid on;
Output:
Result:
Thus, the probability density function of gaussian distribution function is generated.
Experiment -10
Display the signal and its spectrum of an audio signal
Aim:
To generate and display the signal and its spectrum of an audio signal.
Software Used:
Octave version 8.3
Theory:
An audio signal is a representation of sound, typically in the form of a time-varying voltage or
current that corresponds to the air pressure variations of the sound wave. Audio signals are
generally analog in nature, but they can also be represented digitally for processing and
analysis.
In signal processing, analyzing both the time-domain and the frequency-domain characteristics
of an audio signal is essential. The time-domain representation shows how the signal amplitude
varies with time, while the frequency-domain representation (or spectrum) reveals the different
frequency components present in the signal.
The frequency analysis is typically done using the Fourier Transform. For digital signals, the
Fast Fourier Transform (FFT) algorithm is used to efficiently compute the Discrete Fourier
Transform (DFT). The FFT decomposes a signal into its constituent sinusoidal components,
allowing us to observe which frequencies are present and their relative amplitudes.
Key concepts involved:
Sampling: The process of converting an analog signal into a digital signal by taking
discrete samples.
Nyquist Theorem: To avoid aliasing, the sampling rate must be at least twice the
maximum frequency present in the signal.
FFT: A mathematical algorithm that transforms a time-domain signal into its frequency-
domain representation.
By displaying the time-domain waveform and the frequency spectrum of an audio signal, one
can analyze its content, such as pitch, tone quality, and noise characteristics. This is particularly
useful in audio engineering, music processing, and speech analysis applications.
Program:
audioFile = 'your_audio_file.wav'; % Change this to your audio file path [y, Fs] =
audioread(audioFile);
subplot(2, 1, 1);
plot(t, y);
title('Time-Domain Signal'); xlabel('Time (s)'); ylabel('Amplitude');
Y = fft(y);
f = (0:N-1) * Fs / N;
% You can also use the following line to display the spectrum in dB scale
% plot(f, 20*log10(abs(Y)));
% ylabel('Magnitude (dB)');
Output:
Result:
Thus, the signal and its spectrum of an audio signal was generated and displayed.
CONTENT BEYOND SYLLABUS
Pre-emphasis and De-emphasis
Aim:
To study the effect of pre-emphasis and de-emphasis circuits on a modulated signal and to
observe the improvement in signal-to-noise ratio (SNR) after passing through these circuits.
Software Used:
Octave version 8.3
Theory:
In communication systems, especially frequency modulation (FM), pre-emphasis and de-
emphasis techniques are used to reduce the effect of noise in the transmitted signal.
Pre-emphasis is the process of amplifying the high-frequency components of the
message signal before transmission. This is done because high-frequency components
are more susceptible to noise.
The pre-emphasis circuit is typically a high-pass filter that increases the amplitude of
higher frequencies.
De-emphasis is the reverse process applied at the receiver end, where the high-
frequency components are attenuated to restore the original signal. The de-emphasis
circuit is typically a low-pass filter.
Program:
clc;
clear;
% Parameters
fs = 10000; % Sampling frequency
t = 0:1/fs:1-1/fs; % Time vector
subplot(3,1,1);
plot(t(1:1000), x_noisy(1:1000));
title('Original Signal with Noise');
xlabel('Time (s)');
ylabel('Amplitude');
subplot(3,1,2);
plot(t(1:1000), pre_emphasized(1:1000));
title('After Pre-emphasis');
xlabel('Time (s)');
ylabel('Amplitude');
subplot(3,1,3);
plot(t(1:1000), de_emphasized(1:1000));
title('After De-emphasis (Recovered Signal)');
xlabel('Time (s)');
ylabel('Amplitude');
Result:
The experiment successfully demonstrated the functioning of pre-emphasis and de-emphasis
circuits. It was observed that:
High-frequency noise was effectively reduced after applying the de-emphasis filter.
The original signal was recovered with improved signal-to-noise ratio (SNR),
validating the effectiveness of these techniques in communication systems.
Pulse Position Modulation
Aim:
To generate and analyze a Pulse Position Modulated (PPM) signal using a given message signal
and to study the demodulation process to recover the original signal.
Software Used:
Octave version 8.3
Theory:
Pulse Position Modulation (PPM) is a type of digital pulse modulation technique where the
position of a pulse is varied according to the amplitude of the message signal, while the
amplitude and width of the pulse remain constant.
In PPM, the time delay (position) of each pulse with respect to a reference pulse is
proportional to the amplitude of the modulating signal.
PPM is derived from Pulse Width Modulation (PWM), and it is typically generated
by first generating a PWM signal and then converting it to PPM.
One of the main advantages of PPM is that it is less affected by noise in the
transmission channel compared to other modulation techniques like PAM or PWM,
since the information is encoded in the time position rather than in amplitude or width.
PPM is commonly used in applications such as optical communication, remote
control systems, and wireless communication.
Program:
clc; clear;
% Parameters
fm = 5; % Message frequency (Hz)
fs = 1000; % Sampling frequency (Hz)
t = 0:1/fs:1; % Time vector (1 second duration)
Am = 1; % Message amplitude
% Plotting
figure;
subplot(2,1,1);
plot(t, msg);
title('Message Signal');
xlabel('Time (s)');
ylabel('Amplitude');
subplot(2,1,2);
plot(t, ppm);
title('Pulse Position Modulated (PPM) Signal');
xlabel('Time (s)');
ylabel('Amplitude');
ylim([-0.2 1.2]);
sgtitle('PPM Modulation');
Output:
Result:
The experiment successfully demonstrated the generation and demodulation of a PPM signal. It
was observed that:
The position of each pulse varied according to the message signal amplitude.
The demodulated output closely resembled the original message signal, validating
the effectiveness of PPM.
The experiment confirmed that PPM offers better noise immunity compared to PAM
and PWM, especially in time-critical digital communication systems.