PCS LAB MANUAL 2024-25
PCS LAB MANUAL 2024-25
TECHNOLOGY
(Affiliated To Visvesvaraya Technological University, Belgaum)
Anandanagar, Bangalore-24
PRINCIPLES OF COMMUNICATION
SYSTEMS LAB
MANUAL
FOURTH SEMESTER
SUBJECT CODE: BEC402
2023-2024
Scrutinized by:
Dr. Jagadeesh H S
HOD, ECE
DEPARTMENT OF
ELECTRONICS AND COMMUNICATION ENGINEERING
PRINCIPLES OF COMMUNICATION
SYSTEMS LAB MANUAL
Lab Instructor
Mrs.DivyashreHS
Mr.Shobith Dr. Jagadeesh H S
Professor & Head, Dept. of ECE
ATRIA INSTITUTE OF TECHNOLOGY
ASKB Campus, 1st Main Rd, AGS Colony, Anand Nagar, Hebbal, Bengaluru, Karnataka 560024, India
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING
Semester 4th
1 Understand and analyse concepts of Analog Modulation schemes viz; AM, FM.
2 Design and analyse the electronic circuits for AM and FM modulation and demodulation.
3 Understand the concepts of random variable and random process to model communication
systems.
4 Understand and analyse the concepts of digitization of signals.
COURSE OUTCOMES
CO1 Understand the principles of analog communication systems and noise modelling.
CO2 Identify the schemes for analog modulation and demodulation and compare their performance.
CO3 Design of PCM systems through the processes sampling, quantization and encoding.
CO4 Describe the ideal condition, practical considerations of the signal representation for base
band transmission of digital signals.
CO5 Identify and associate the random variables and random process in Communication system
design.
ATRIA INSTITUTE OF TECHNOLOGY
ASKB Campus, 1st Main Rd, AGS Colony, Anand Nagar, Hebbal, Bengaluru, Karnataka 560024, India
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING
LIST OF EXPERIMENTS
1 Basic Signals and Signal Graphing: a) Unit Step, b) Rectangular, c)
Standard Triangle d)Sinusoidal and e) Exponential Signal.
Illustration of signal representation in time and frequency domains
2 for a rectangular pulse.
3 Amplitude Modulation and demodulation: Generation and display the
relevant signals and its spectrums.
4 Frequency Modulation and demodulation: Generation and
display the relevant signals and its spectrums.
5 Sampling and reconstruction of low pass signals. Display the signals
and its spectrum.
6 Time Division Multiplexing and demultiplexing.
7 PCM Illustration: Sampling, Quantization and Encoding.
8 Generate a)NRZ, RZ and Raised Cosine pulse, b) Generate and plot
eye diagram
Generate the Probability density function of Gaussian distribution
9 function.
10 Display the signal and its spectrum of an audio signal.
1. Basic Signals and Signal Graphing: a) Unit Step, b) Rectangular, c) Sinusoidal
d) Standard Triangle and e) Exponential Signal.
Code Explanation:
B. RECTANGULAR FUNCTION:
1. Defining Parameters:
o t = -5:0.1:5;: Creates a time vector t ranging from -5 to 5 with a step size of 0.1.
o a = -2;: Defines the start time (a) of the rectangle.
o b = 1;: Defines the end time (b) of the rectangle.
2. Generating Rectangular Function:
o ones(size(t)): Creates a vector of ones with the same size as t.
o t >= a & t <= b: Creates a logical vector where elements corresponding to t within the range [a, b] are
True (1), and those outside are False (0).
o The element-wise multiplication .* combines these vectors. Elements in rect_func become 1 only when
the corresponding elements in both vectors are 1 (i.e., within the time range [a, b]).
3. Plotting and Labelling:
o The rest of the code plots the function rect_func and adds labels and a title.
C. SINUSOIDAL FUNCTION:
% Define parameters
t = 0:0.01:2*pi; % Time vector (adjust range and step size as needed)
f = 10; % Frequency in Hz
A = 2; % Amplitude
1. Defining Parameters:
o f = 100;: Defines the frequency (f) of the sinusoid in Hz.
o t = 0:0.001:1;: Creates a time vector t starting from 0 and ending at 1 with a step size of 0.001 seconds.
o A = 2;: Defines the amplitude (A) of the sinusoid.
o phi = pi/3;: Defines the phase shift (phi) of the sinusoid in radians.
2. Generating Sinusoidal Function:
o y = A*sin(2*pi*f*t + phi);: This line calculates the values of the sinusoid at each time point in t.
3. Plotting the Function:
o plot(t, y);: This line plots the generated sinusoidal function (y) versus time (t) adds labels and a title.
o
D. STANDARD TRIANGLE FUNCTION: self-study
clc;
clear all;
% Define parameters
T = 10; % Pulse duration
Fs = 1; % Sampling frequency
t = -2*T:1/(10*Fs):2*T; % Time vector
i. Defining Parameters:
o rect_pulse = rectpuls(t, T): This line utilizes the built-in rectpuls function to generate the rectangular pulse.
The function takes the time vector t and pulse duration T as arguments and returns the corresponding
rectangular pulse values.
iv. Plotting:
o The code utilizes subplots to display both time and frequency domain representations:
o subplot(2,1,1): Plots the rectangular pulse in the time domain using plot(t, rect_pulse).
o subplot(2,1,2): Plots the magnitude spectrum (absolute value) of the FFT using plot(f, abs(rect_pulse_fft)).
3.Amplitude Modulation and demodulation: Generation and display the relevant signals and its
spectrums.
% Define parameters
Fs = 300; % Sampling frequency (Hz)
T = 1/Fs; % Sampling period
t = 0:T:3; % Time vector
% Demodulation
% Envelope detection
envelope = abs(hilbert(modulated_signal));
% Plotting
figure;
% Carrier Signal
subplot(4,2,3);
plot(t, carrier);
title('Carrier Signal');
xlabel('Time (s)');
ylabel('Amplitude');
% Modulated Signal
subplot(4,2,5);
plot(t, modulated_signal);
title('Modulated Signal');
xlabel('Time (s)');
ylabel('Amplitude');
% Demodulated Signal
subplot(4,2,7);
plot(t, demodulated_signal);
title('Demodulated Signal');
xlabel('Time (s)');
ylabel('Amplitude');
% Spectrum Analysis
N = length(t); % Number of samples
f = (-N/2:N/2-1) * Fs / N; % Frequency vector
i. Defining Parameters:
o Fs: sampling frequency
o T: sampling period
o t: time vector from 0 to 1 second.
o message = Am * sin(2*pi*fm*t): Generate message signal with a peak voltage of 1V and 10Hz frequency
o carrier = Ac * sin(2*pi*fc*t): Generate carrier signal with a peak voltage of 1V and 1,000 Hz.
o modulated_signal = ((1 + 0.6*message) .* carrier): modulate the message signal onto the carrier signal
using the standard Amplitude Modulation (AM) formula.
o envelope = abs(hilbert(modulated_signal)): Demodulation using Hilbert Transforms (similar to envelope
detection)
o [b, a] = butter(6, cutoff_freq / (Fs/2), 'low'): 6th order Butterworth LPF specifications
o demodulated_signal = filter(b, a, envelope): the output of the envelope detector is passed through the
Butterworth LPF to remove high-frequency components
o demodulated_signal = demodulated_signal / Ac: normalize the demodulated signal by dividing it by the
carrier amplitude
iii. Plotting:
Figure with subplots to visualize the message signal, carrier signal, modulated signal, and demodulated signal,
as well as their respective spectra.
clear all;
close all;
Fs = 8000; % Sampling rate of signal
Fc = 100; % Carrier frequency
t = linspace(0,1,10000); % Sampling times
x = sin(2*pi*10*t) % Channel 1
dev = 75; % Frequency deviation in modulated signal
y = fmmod(x,Fc,Fs,dev); % Modulate both channels.
z = fmdemod(y,Fc,Fs,dev); % Demodulate both channels.
subplot(411),plot(t,x);
xlabel('time(sec)');
ylabel('amplitude in volts(V)'); title('MODULATING SIGNAL');
subplot(412),plot(t,sin(2*pi*Fc*t));
xlabel('time(sec)'); ylabel('amplitude in volts(V)');
title('CARRIER SIGNAL');
subplot(413),plot(t,y);
xlabel('time(sec)');
ylabel('amplitude in volts(V)'); title('FREQUENCY MODULATED SIGNAL');
subplot(414),plot(t,z);
xlabel('time(sec)');
ylabel('amplitude in volts(V)');
title(' FM DEMODULATED SIGNAL');
5.Sampling and reconstruction of low pass signals. Display the signals and its spectrum.
% Parameters
Fs = 1000; % Sampling frequency for original signal (Hz)
T = 1; % Duration of the signal (seconds)
t = 0:1/Fs:T-1/Fs; % Time vector
f = 1; % Frequency of the low-pass signal (Hz)
% Sampling parameters
Fs_sampled = 20; % Sampling frequency for sampled signal (Hz)
Ts_sampled = 1/Fs_sampled; % Sampling period for sampled signal
t_sampled = 0:Ts_sampled:T-Ts_sampled; % Sampled time vector
subplot(4,2,3);
plot(t, x2);
title('Original Signal 2: Rectangular Wave');
xlabel('Time (s)');
ylabel('Amplitude');
subplot(4,2,5);
plot(t, x3);
title('Original Signal 3: Triangular Wave');
xlabel('Time (s)');
ylabel('Amplitude');
for i = 1:length(t)
x1_demux(i) = x_tdm(3*(i-1)+1);
x2_demux(i) = x_tdm(3*(i-1)+2);
x3_demux(i) = x_tdm(3*(i-1)+3);
end
subplot(4,2,4);
plot(t, x2_demux);
title('Demultiplexed Signal 2: Rectangular Wave');
xlabel('Time (s)');
ylabel('Amplitude');
subplot(4,2,6);
plot(t, x3_demux);
title('Demultiplexed Signal 3: Triangular Wave');
xlabel('Time (s)');
ylabel('Amplitude');
7.Generate the Probability density function of Gaussian distribution function.
% Sampling
sampling_rate = 25; % Sampling rate (samples per second)
Ts = 1/sampling_rate; % Sampling period
n = 0:Ts:T-Ts; % Sample points
sampled_signal = 15*sin(2*pi*f*n);
% Quantization
num_levels = 10; % Number of quantization levels
max_val = max(sampled_signal);
min_val = min(sampled_signal);
quantization_levels = linspace(min_val, max_val, num_levels);
quantized_signal = zeros(size(sampled_signal));
for i = 1:length(sampled_signal)
[~, idx] = min(abs(quantization_levels - sampled_signal(i)));
quantized_signal(i) = quantization_levels(idx);
end
% Encoding
encoded_signal = zeros(1, length(quantized_signal) * log2(num_levels));
for i = 1:length(quantized_signal)
idx = find(quantization_levels == quantized_signal(i));
binary_code = de2bi(idx - 1, log2(num_levels), 'left-msb');
encoded_signal((i-1)*log2(num_levels)+1:i*log2(num_levels)) = binary_code;
end
% Display the encoded signal
disp('Encoded Signal:');
disp(encoded_signal);
Sampling
sampling_rate = 25; % Sampling rate (samples per second)
Ts = 1/sampling_rate; % Sampling period
n = 0:Ts:T-Ts; % Sample points
sampled_signal = 15*sin(2*pi*f*n);
- `sampling_rate` is set to 25 samples per second.
- `Ts` is the sampling period calculated as the inverse of `sampling_rate`.
- `n` is a vector representing the sample points from 0 to `T-Ts` with a step size of `Ts`.
- `sampled_signal` is generated by sampling the sine wave at points defined by `n`.
for i = 1:length(sampled_signal)
[~, idx] = min(abs(quantization_levels - sampled_signal(i)));
quantized_signal(i) = quantization_levels[idx];
end
Encoding
encoded_signal = zeros(1, length(quantized_signal) * log2(num_levels));
for i = 1:length(quantized_signal)
idx = find(quantization_levels == quantized_signal(i));
binary_code = de2bi(idx - 1, log2(num_levels), 'left-msb');
encoded_signal((i-1)*log2(num_levels)+1:i*log2(num_levels)) = binary_code;
end
% Display the encoded signal
disp('Encoded Signal:');
disp(encoded_signal);
- `encoded_signal` is initialized as a zero vector with a length equal to the number of bits required to encode
all quantized levels.
- A loop iterates through each element of `quantized_signal`:
- `idx` finds the index of the current quantized value in `quantization_levels`.
- `de2bi` converts the index to a binary vector.
- The binary vector is placed in the appropriate position within `encoded_signal`.
- The encoded signal is displayed using `disp`.
9.MATLAB code to generate NRZ, RZ, and Raised Cosine wave forms for an 8-bit binary code
% Define parameters
bit_duration = 1; % duration of each bit
samples_per_bit = 100; % number of samples per bit
fs = samples_per_bit / bit_duration; % sampling frequency
% Generate RZ signal
for i = 1:length(binary_number)
if binary_number(i) == '1'
rz_signal((i-1)*samples_per_bit+1:(i-1)*samples_per_bit+samples_per_bit/2) = 1;
rz_signal((i-1)*samples_per_bit+samples_per_bit/2+1:i*samples_per_bit) = 0;
else
rz_signal((i-1)*samples_per_bit+1:i*samples_per_bit) = 0;
end
end
% Plot waveforms
figure;
subplot(3,1,1);
plot(t, nrz_signal, 'LineWidth', 1.5);
title('NRZ Signal');
xlabel('Time');
ylabel('Amplitude');
grid on;
subplot(3,1,2);
plot(t, rz_signal, 'LineWidth', 1.5);
title('RZ Signal');
xlabel('Time');
ylabel('Amplitude');
grid on;
subplot(3,1,3);
plot(t_rc, raised_cosine_signal, 'LineWidth', 1.5);
title('Raised Cosine Signal');
xlabel('Time');
ylabel('Amplitude');
grid on;
10.Display the signal and its spectrum of an audio signal.
Explanation:
1. Load Audio File:
o audioread loads the audio file and stores the audio samples in audio and the sampling frequency in Fs.
2. Time Vector:
o Creates a time vector t corresponding to the audio samples.
3. Plot Audio Signal:
o Plots the audio signal in the time domain.
4. Compute Fourier Transform:
o Calculates the Fourier Transform of the audio signal using fft.
5. Calculate Power Spectrum:
o Computes the single-sided power spectrum using abs(audio_fft/length(audio)) and scales the positive
frequency components by 2 to account for the discarded negative frequencies.
6. Frequency Vector:
o Creates a frequency vector f corresponding to the frequency bins of the power spectrum.
7. Plot Power Spectrum:
o Plots the single-sided power spectrum of the audio signal.
Improvements:
Clearer variable names: Uses more descriptive variable names like audio_fft, P2, P1, and f for better
readability.
Single-Sided Spectrum: Calculates the single-sided power spectrum correctly by scaling the positive frequency
components.
Power Spectrum: Uses abs(audio_fft/length(audio)) to calculate the power spectrum, which is more appropriate
for spectral analysis.
Axis Labels: Provides informative labels for both plots.
Title Updates: Includes "Time Domain" and "Single-Sided Power Spectrum" in the plot titles for clarity.