0% found this document useful (0 votes)
29 views24 pages

Wireless Communication Lab Manual Corrected Program (1)

The document outlines the curriculum for a Wireless Communication course at DMI College of Engineering, detailing the department's vision, mission, educational objectives, and program outcomes. It includes a syllabus with specific objectives, a list of experiments, and expected outcomes for students, emphasizing practical skills in wireless communication systems and standards. The document also provides detailed procedures and aims for various experiments using SCILAB, focusing on modeling, simulation, and analysis of wireless communication techniques.

Uploaded by

gkplay143
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views24 pages

Wireless Communication Lab Manual Corrected Program (1)

The document outlines the curriculum for a Wireless Communication course at DMI College of Engineering, detailing the department's vision, mission, educational objectives, and program outcomes. It includes a syllabus with specific objectives, a list of experiments, and expected outcomes for students, emphasizing practical skills in wireless communication systems and standards. The document also provides detailed procedures and aims for various experiments using SCILAB, focusing on modeling, simulation, and analysis of wireless communication techniques.

Uploaded by

gkplay143
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 24

DMI COLLEGE OF ENGINEERING

PALANCHUR CHENNAI – 600 123

DEPARTMENT OF ELECTRONICS AND COMMUNICATION


ENGINEERING

ELECTRONICS AND COMMUNICATION ENGINEERING

SEMESTER :V REGULATION: 2021

SUBJECT CODE : EC3501

SUBJECT NAME : WIRELESS COMMUNICATION

NAME :

REGISTER NUMBER :

SECTION :
Vision of the Department

To develop committed and competent technologists in electronics and communication


engineering to be on par with global standards coupled with cultivating the innovations
and ethical values.
Mission of the Department

DM 1: To be a centre of excellence in teaching learning process promoting active


learning with critical thinking.
DM 2: To strengthen the student’s core domain and to sustain collaborative industry
interaction with internship and incorporating entrepreneur skills.
DM 3: To prepare the students for higher education and research oriented activities
imbibed with ethical values for addressing the social need.

PROGRAMME EDUCATIONAL OBJECTIVES (PEO’s)


PEO1: Technical Knowledge: To prepare the students for the successful and productive
career choices in both public and private sectors and to meet the need of the society.

PEO2: Communication and Laboratory Skills: To train the students with good
practical exposure by using modern equipped laboratories and to exhibit good
communication skills.

PEO3: Knowledge of Basic Engineering: Producing successful graduates can adapt


new technologies and attain professional competence through lifelong learning.
PROGRAMME OUTCOMES (PO’s)

PO1 : Engineering Knowledge: Apply the knowledge of mathematics, science, engineering


fundamentals, and an engineering specialization to the solution of complex engineering problems.

PO2 : Problem analysis: Identify, formulate, review research literature, and analyze complex engineering
problems reaching substantiated conclusions using first principles of mathematics, natural sciences,
and engineering sciences.
PO3 : Design/development of solutions: Design solutions for complex engineering problems and design
system components or processes that meet the specified needs with appropriate consideration for the
public health and safety, and the cultural, societal, and environmental considerations.
PO4 : Conduct investigations of complex problems: Use research based knowledge and research
methods including design of experiments in analyzing and interpreting data, and synthesizes the
data to come to valid conclusion.
PO5 : Modern tool usage: Create, select, and apply appropriate techniques, resources, and modern
engineering and IT tools including prediction and modeling of complex engineering activities with
an understanding of the limitations.

PO6 : The Engineer and society: Apply reasoning informed by the contextual knowledge to assess
societal, health, safety, legal and cultural issues and the consequent responsibilities relevant to the
professional engineering practice.
PO7 : Environment and sustainability: Understand and correctly interpret the impact of engineering
solutions in global, societal and environmental contexts and demonstrate the knowledge of a need
for sustainable development.
PO8 : Ethics: Understand ethics of life and professions and abide by them. Proficiency in
multidisciplinary domains for devising the solution of real time problems, ability to work with
national and international organizations and to understand the impact of engineering solutions.
PO9 : Individuals and Teamwork: Function effectively as an individual, and as a member or leader in
diverse teams, and in multidisciplinary settings.
PO10: Communications: Communicate effectively on complex engineering activities with the
engineering community and with society at large, such as, being able to comprehend and write
effective reports and design documentation, make effective presentations, and give and receive clear
instructions.
PO11: Project management and finance: Demonstrate knowledge and understanding of the engineering
and management principles and apply these to one’s own work, as a member and leader in a team,
to manage projects and in multidisciplinary environments.
PO12: Lifelong learning: Recognize the need for, and have the preparation and ability to engage in
independent and lifelong learning in the broadest context of technological change.

SYLLABUS
OBJECTIVES: The student should be made to:

● To study and understand the concepts and design of a Cellular System.


● To Study And Understand Mobile Radio Propagation And Various Digital Modulation Techniques.
● To Understand The Concepts Of Multiple Access Techniques And Wireless Networks

LIST OF EXPERIMENTS:

1. Modeling of wireless communication systems using Matlab(Two ray channel and Okumura –Hata
model)
2. Modeling and simulation of Multipath fading channel
3. Design, analyze and test Wireless standards and evaluate the performance measurements such as BER,
PER, BLER, throughput, capacity, ACLR, EVM for 4G and 5G using Matlab
4. Modulation: Spread Spectrum – DSSS Modulation & Demodulation
5. Wireless Channel equalization: Zero-Forcing Equalizer (ZFE),MMSE Equalizer(MMSEE),Adaptive
Equalizer (ADE),Decision Feedback Equalizer (DFE)
6. Modeling and simulation of TDMA, FDMA and CDMA for wireless communication

OUTCOMES: At the end of the course, the student should be able to:
 Apply the cellular concepts to improve the Coverage And Capacity In Cellular Systems.
 Understand the basic Radiation mechanisms to reduce the path loss and fading effect in mobile
radio propagation
 Apply the digital modulation techniques In Fading And Multipath Channels to improve the Bit
Error Rate
 Analyze 4G and 5G wireless standards for system performance using the channel parameters
 Investigate a cellular system based on resource availability and traffic demands to optimize the
use of the channel capacity in telecommunication networks

INDEX
Page
Sl.No. Name of the Experiment
No.

CYCLE 1 - EXPERIMENTS

1 1. Modeling of wireless communication systems using Matlab(Two ray


channel and Okumura –Hata model)

2 2. Modeling and simulation of Multipath fading channel

3 3. Design, analyze and test Wireless standards and evaluate the


performance measurements such as BER, PER, BLER, throughput,
capacity, ACLR, EVM for 4G and 5G using Matlab

CYCLE 2 - EXPERIMENTS

4 4. Modulation: Spread Spectrum – DSSS Modulation &


Demodulation

5 5. Wireless Channel equalization: Zero-Forcing Equalizer


(ZFE),MMSE Equalizer(MMSEE),Adaptive Equalizer (ADE),Decision
Feedback Equalizer (DFE)

6 6. Modeling and simulation of TDMA, FDMA and CDMA for


wireless communication

Ex. No: 1 Date:


AIM:
To model a wireless communication systems using Matlab(Two ray channel and
Okumura –Hata model)
APPARATUS REQUIRED:
HARDWARE : Personal Computer SOFTWARE : SCILAB
PROCEDURE:
1. Start the SCILAB program.
2. Open new M-file
3. Type the program
4. Save in current directory
5. Compile and Run the program
6. If any error occurs in the program correct the error and run it again
7. For the output see command window\ Figure window 8. Stop the program.
PROGRAM: (Modeling of wireless communication systems using Matlab(Two ray
channel and Okumura –Hata model))

%Program
Modeling Wireless Communication System with Two-Ray Ground Reflection and
Okumura-Hata Model

% Parameters
frequency = 900e6; % Carrier frequency in Hz (e.g., 900 MHz)
distance = linspace(1, 1000, 100); % Distance between transmitter and receiver in meters
heightTx = 50; % Height of the transmitter in meters
heightRx = 1.5; % Height of the receiver in meters
txPower = 20; % Transmitter power in dBm

% Free Space Path Loss (FSPL)


lambda = physconst('LightSpeed') / frequency; % Wavelength in meters
fspl = (4 * pi * distance / lambda).^2;

% Two-Ray Ground Reflection Model


d_crossover = (4 * heightTx * heightRx * frequency) / physconst('LightSpeed'); %
Crossover distance
d_crossover_index = find(distance >= d_crossover, 1);
tworay_model = zeros(1, length(distance));
tworay_model(1:d_crossover_index) = fspl(1:d_crossover_index);
tworay_model(d_crossover_index+1:end) = fspl(d_crossover_index+1:end) + ...
40 * log10(distance(d_crossover_index+1:end)/d_crossover);

% Okumura-Hata Model (Urban Area)


pathLossUrban = 69.55 + 26.16 * log10(frequency/1e6) - 13.82 * log10(heightTx) ...
- (1.1 * log10(frequency/1e6) - 0.7) * heightRx + (1.56 * log10(frequency/1e6) - 0.8);
% Total Path Loss in Urban Area (Combine Two-Ray and Okumura-Hata models)
pathLossUrban = pathLossUrban + tworay_model;

% Received Signal Power


receivedPower = txPower - pathLossUrban;

% Plotting the Results


figure;
plot(distance, receivedPower, 'b', 'LineWidth', 2);
xlabel('Distance (m)');
ylabel('Received Signal Power (dBm)');
title('Wireless Channel Modeling with Two-Ray and Okumura-Hata Model');
grid on;
OUTPUT( Modeling of wireless communication systems using Matlab(Two ray
channel and Okumura –Hata model)

RESULT:
Thus the SCILAB programs for Modeling of wireless communication (Two ray channel
and Okumura –Hata model) was written and the results were plotted.

Ex. No: 2 Date:


AIM:
To Model and simulate of Multipath fading channel using SCI LAB
APPARATUS REQUIRED:
HARDWARE : Personal Computer
SOFTWARE : SCILAB

PROCEDURE:
1. Start the SCILAB program.
2. Open new M-file
3. Type the program
4. Save in current directory
5. Compile and Run the program
6. If any error occurs in the program correct the error and run it again
7. For the output see command window\ Figure window 8. Stop the program.
To Model and simulate of Multipath fading channel using SCI LAB
%Program
*Model and simulate of Multipath fading channel*

clear
f_c=1e3;%carrier frequency(no modulation)
time_1 = (linspace (0, 10, 1000));%time
signal_in = sin (2 * pi *f_c* time_1);%sine wave

plot (time_1, signal_in, 'b');grid on;%blue=signal_in


xlabel('time');ylabel('amplitude');
title('Rayleigh fading channel with two path sine wave input')
hold on
for ii = 1:10%# iterations
tau=round(50*rand(1,1)+1);% variable delay(phase shift)
g1=1;%fixed gain
g2=round(.5*rand(1,1)+1);%variable gain or attenuation
signal_out=g1*signal_in + g2*[zeros(1,tau) signal_in(1:end-tau)];

plot (time_1,(signal_out),'r')%red=signal_out
pause (2)%~ seconds
end
hold off

OUTPUT( To Model and simulate of Multipath fading channel using SCI LAB)
RESULT:

Thus the SCILAB programs To Model and simulate of Multipath fading channel using
SCI LAB function written and the results were plotted.

Ex. No: 3 Date:


AIM:
To Design, analyze and test Wireless standards and evaluate the performance
measurements such as BER, PER, BLER, throughput, capacity, ACLR, EVM for 4G
and 5G using SCI LAB
APPARATUS REQUIRED:
HARDWARE : Personal Computer
SOFTWARE : SCILAB

PROCEDURE:
1. Start the SCILAB program.
2. Open new M-file
3. Type the program
4. Save in current directory
5. Compile and Run the program
6. If any error occurs in the program correct the error and run it again
7. For the output see command window\ Figure window 8. Stop the program.
To Model and simulate of Multipath fading channel using SCI LAB
%Program
* To Design, analyze and test Wireless standards and evaluate the performance
measurements such as BER, PER, BLER, throughput, capacity, ACLR, EVM for
4G and 5G using SCI LAB *
% Parameters
numBits = 1e6; % Number of bits to transmit
EbNo_dB = 0:2:20; % Eb/No in dB (varying SNR values)
SNR_dB = EbNo_dB + 10*log10(1); % Convert Eb/No to SNR in dB
SNR = 10.^(SNR_dB/10); % Convert SNR from dB to linear scale

% Generate random bits (0s and 1s)


dataBits = randi([0, 1], 1, numBits);

% BPSK Modulation
modulatedSignal = 2 * dataBits - 1; % Map 0s to -1 and 1s to +1
% BER Simulation
ber = zeros(size(SNR));
for i = 1:length(SNR)
% AWGN Channel
noisePower = 1 / SNR(i); % Calculate noise power based on SNR
noise = sqrt(noisePower) * randn(1, numBits); % Generate Gaussian noise
receivedSignal = modulatedSignal + noise;
% BPSK Demodulation
receivedDataBits = receivedSignal > 0;
% Bit Error Rate (BER) Calculation
numErrors = sum(dataBits ~= receivedDataBits);
ber(i) = numErrors / numBits;
end

% Plot BER vs. SNR


figure;
semilogy(EbNo_dB, ber, 'bo-');
xlabel('Eb/No (dB)');
ylabel('Bit Error Rate (BER)');
title('BER vs. Eb/No for BPSK');
grid on;
OUTPUT (To Design, analyze and test Wireless standards and evaluate the performance
measurements such as BER, PER, BLER, throughput, capacity, ACLR, EVM for 4G
and 5G using SCI LAB)

RESULT:
Thus the SCILAB programs To Design, analyze and test Wireless standards and evaluate
the performance measurements such as BER, PER, BLER, throughput, capacity, ACLR,
EVM for 4G and 5G using SCI LAB written and the results were plotted.

Ex. No: 4 Date:


AIM:
To write and execute a SCI lab code for Spread Spectrum – DSSS Modulation
& Demodulation .
APPARATUS REQUIRED:
HARDWARE : Personal Computer
SOFTWARE : SCILAB
PROCEDURE:
1. Start the SCILAB program.
2. Open new M-file
3. Type the program
4. Save in current directory
5. Compile and Run the program
6. If any error occurs in the program correct the error and run it again
7. For the output see command window\ Figure window 8. Stop the program.
To Model and simulate of Multipath fading channel using SCI LAB
%Program
* To write and execute a SCI lab code for Spread Spectrum – DSSS Modulation
& Demodulation .*
h= 60;
%% Time Pereiod of Simulation :
t = linspace(0, 0.2, 100000);
%% Message Signal :
Am = 14;
fm = 200;
ym = Am*cos(2*pi*fm*t);
figure;
subplot(4, 1, 1);
plot(t(1:10000), ym(1:10000));
title('Message Signal');
xlabel('time(t)');
ylabel('Amplitude');
%% Carrier Signal :
Ac = Am/h;
fc = 2000;
yc = Ac*cos(2*pi*fc*t);
subplot(4, 1, 2);
plot(t(1:10000), yc(1:10000));
title('Carrier Signal');
xlabel('time(t)');
ylabel('Amplitude');
%% Modulated Signal :
y = ammod(ym, fc, 100000, 0, Ac);
subplot(4, 1, 3);
plot(t(1:10000), y(1:10000));
title('Modulated Signal');
xlabel('time(t)');
ylabel('Amplitude');
%% Demodulated Signal :
z = amdemod(y, fc, 100000, 0, Ac);
subplot(4, 1, 4);
plot(t(1:10000), z(1:10000));
title('Demodulated Signal');
xlabel('time(t)');
ylabel('Amplitude');
ylim([-10, 10]);
OUTPUT (T To write and execute a SCI lab code for Spread Spectrum – DSSS
Modulation & Demodulation .)

Ex. No: 5 Date:


AIM:
To analyze and design Zero-Forcing Equalizer (ZFE),MMSE
Equalizer(MMSEE),Adaptive Equalizer (ADE),Decision Feedback Equalizer (DFE)
using a SCI lab .
HARDWARE : Personal Computer
SOFTWARE : SCILAB

PROCEDURE:
1. Start the SCILAB program.
2. Open new M-file
3. Type the program
4. Save in current directory
5. Compile and Run the program
6. If any error occurs in the program correct the error and run it again
7. For the output see command window\ Figure window 8. Stop the program.
To Model and simulate of Multipath fading channel using SCI LAB
%Program
* To analyze and design Zero-Forcing Equalizer (ZFE),MMSE
Equalizer(MMSEE),Adaptive Equalizer (ADE),Decision Feedback Equalizer (DFE)
using a SCI lab ..*
%% Input initialization
clc
close all
clear all

N = 10^4 % number of bits or symbols


ip = rand(N,1)>0.5; % generating 0,1 with equal probability

%% Choosing the modulation techniques


for j = 1:3

if j == 1
[mod,demod] = fsk();
type = ' FSK ';
elseif j== 2
[mod,demod] = bpsk();
type = ' BPSK ';
else
[mod,demod] = qpsk();
type = ' QPSK ';
end

s = step(mod,ip);
Eb_N0_dB = [-3:35]; % multiple Eb/N0 values

%% Noise addition , equalization and error calculation


for i = 1:length(Eb_N0_dB)

n = 1/sqrt(2)*[randn(length(s),1) + j*randn(length(s),1)]; % white gaussian noise, 0dB


variance
h = 1/sqrt(2)*[randn(length(s),1) + j*randn(length(s),1)]; % Rayleigh channel

% Channel and noise Noise addition


y = h.*s + 10^(-Eb_N0_dB(i)/20)*n;
%y = h.*s;

% equalization
yHat = y./h;
%yHat = equ(y);

op = step(demod,yHat);

% counting the errors


nErr(i) = size(find([ip-op]),1);

end

%% BER CALCULATION

simBer = nErr/N; % simulated ber


%theoryBerAWGN = 0.5*erfc(sqrt(10.^(Eb_N0_dB/10))); % theoretical ber
EbN0Lin = 10.^(Eb_N0_dB/10);
theoryBer = 0.5.*(1-sqrt(EbN0Lin./(EbN0Lin+1)));

%% Figures
% plot
figure(j)
%semilogy(Eb_N0_dB,theoryBerAWGN,'cd-','LineWidth',2);
hold on
semilogy(Eb_N0_dB,theoryBer,'bp-','LineWidth',2);
semilogy(Eb_N0_dB,simBer,'mx-','LineWidth',2);
axis([-3 35 10^-5 0.5])
grid on
legend('Rayleigh-Theory', 'Rayleigh-Simulation');
xlabel('Eb/No, dB');
ylabel('Bit Error Rate');
head = strcat('BER for',type,'modulation in Rayleigh channel using Zero Forcing' );
title(head);
%figure()
%plot(op)
end
%% Function setup
%{
% for BPSK
function [mod,demod] = bpsk()
mod = comm.BPSKModulator();
demod = comm.BPSKDemodulator();
end

% for fsk
function [mod,demod] = fsk()
mod = comm.FSKModulator();
demod = comm.FSKDemodulator();
end

% for qpsk

function [mod,demod] = qpsk()


mod = comm.QPSKModulator();
mod.BitInput = true;
demod = comm.QPSKDemodulator();
demod.BitOutput = true;
end
%}

% Decision Feedback Equalizer (DFE) for Wireless Communication

% Parameters
numTapsFeedforward = 5; % Number of feedforward filter taps
numTapsFeedback = 3; % Number of feedback filter taps
mu = 0.01; % Step size (adjust as per convergence and stability)

% Generate transmitted signal (e.g., BPSK modulation)


dataBits = randi([0, 1], 1, 1000); % Random binary data
modulatedSignal = 2 * dataBits - 1; % BPSK modulation (0 to -1, 1 to +1)

% Channel (e.g., multipath fading channel with AWGN)


channel = [0.5, 0.3, -0.1]; % Channel coefficients
receivedSignal = conv(modulatedSignal, channel, 'same'); % Convolution with channel

% Add noise to the received signal


SNR_dB = 20; % Signal-to-noise ratio in dB
SNR_linear = 10^(SNR_dB/10); % Convert SNR from dB to linear scale
noisePower = 1 / SNR_linear;
noise = sqrt(noisePower/2) * (randn(1, length(receivedSignal)) + 1i * randn(1,
length(receivedSignal)));
receivedSignal = receivedSignal + noise;

% Initialize equalizer coefficients


feedforwardCoefficients = zeros(1, numTapsFeedforward);
feedbackCoefficients = zeros(1, numTapsFeedback);

% DFE Equalization
equalizedSignal = zeros(size(receivedSignal));
for n = max(numTapsFeedforward, numTapsFeedback) + 1:length(receivedSignal)
% Feedforward filter operation
feedforwardInput = receivedSignal(n:-1:n-numTapsFeedforward+1);
feedforwardOutput = feedforwardCoefficients * feedforwardInput.';

% Feedback filter operation


feedbackInput = equalizedSignal(n-1:-1:n-numTapsFeedback);
feedbackOutput = feedbackCoefficients * feedbackInput.';

% Decision and error calculation


equalizedSignal(n) = feedforwardOutput + feedbackOutput;
decision = sign(equalizedSignal(n)); % Hard decision (BPSK)
error = modulatedSignal(n) - decision;

% Update feedforward and feedback filter coefficients


feedforwardCoefficients = feedforwardCoefficients + mu * error * feedforwardInput;
feedbackCoefficients = feedbackCoefficients + mu * error * feedbackInput;
end

% Demodulate equalized signal


demodulatedSignal = equalizedSignal > 0;

% Bit Error Rate (BER) Calculation


numErrors = sum(dataBits ~= demodulatedSignal);
BER = numErrors / length(dataBits);

disp(['Bit Error Rate (BER): ', num2str(BER)])

M = 4; % QPSK
numSymbols = 10000;
numTrainingSymbols = 1000;
chtaps = [1 0.5*exp(1i*pi/6) 0.1*exp(-1i*pi/8)];
EbN0 = 20;
data = randi([0 M-1], numSymbols, 1);
tx = pskmod(data, M, pi/4);
rx = awgn(filter(chtaps,1,tx),25,'measured');
eq =
comm.LinearEqualizer('Algorithm','CMA','AdaptWeights',false,'InitialWeightsSource','Pr
operty')
wgts = mmseweights(eq,chtaps,EbN0)
eq.InitialWeights = wgts;

[y,err,weights] = eq(rx);
constell = comm.ConstellationDiagram('NumInputPorts',2);
constell(rx,y)
plot(abs(err))
grid on; xlabel('Symbols'); ylabel('|e|')
errevm = comm.EVM;
evm = errevm(tx,y)
subplot(3,1,1); stem(real(weights)); ylabel('real(weights)'); xlabel('Tap'); grid on; axis([1
8 -0.5 1])
line([eq.NumTaps+0.5 eq.NumTaps+0.5], [-0.5 1], 'Color', 'r', 'LineWidth', 1)
title('Equalizer Tap Weights')
subplot(3,1,2); stem(imag(weights)); ylabel('imag(weights)'); xlabel('Tap'); grid on;
axis([1 8 -0.5 1])
line([eq.NumTaps+0.5 eq.NumTaps+0.5], [-0.5 1], 'Color', 'r', 'LineWidth', 1)
subplot(3,1,3); stem(abs(weights)); ylabel('abs(weights)'); xlabel('Tap'); grid on; axis([1 8
-0.5 1])
line([eq.NumTaps+0.5 eq.NumTaps+0.5], [-0.5 1], 'Color', 'r', 'LineWidth', 1)
OUTPUT (To analyze and design Zero-Forcing Equalizer (ZFE),MMSE
Equalizer(MMSEE),Adaptive Equalizer (ADE),Decision Feedback Equalizer (DFE)
using a SCI lab .

RESULT:
Thus the SCI lab code to analyze and design Zero-Forcing Equalizer
(ZFE),MMSE Equalizer(MMSEE),Adaptive Equalizer (ADE),Decision Feedback
Equalizer (DFE) was written and the results were plotted.
Ex. No: 6 Date:
AIM:
To model and simulate of TDMA, FDMA and CDMA for wireless
communication using SCI lab.
HARDWARE : Personal Computer
SOFTWARE : SCILAB
PROCEDURE:
1. Start the SCILAB program.
2. Open new M-file
3. Type the program
4. Save in current directory
5. Compile and Run the program
6. If any error occurs in the program correct the error and run it again
7. For the output see command window\ Figure window 8. Stop the program.
To Model and simulate of Multipath fading channel using SCI LAB
%Program
* To model and simulate of TDMA, FDMA and CDMA for wireless communication
using SCI lab % CDMA Multiplexing Simulation
clear; clc;
% Parameters
fs = 1000; % Sampling frequency (in Hz)
T = 1; % Duration of simulation (in seconds)
num_users = 3; % Number of users
% Generate user signals
t = 0:1/fs:T-1/fs; % Time vector

% User 1
user1_data = randi([0, 1], 1, length(t)); % Generate random data
user1_signal = 2 * user1_data - 1; % BPSK modulation (0 -> -1, 1 -> 1)

% User 2
user2_data = randi([0, 1], 1, length(t)); % Generate random data
user2_signal = 2 * user2_data - 1; % BPSK modulation (0 -> -1, 1 -> 1)

% User 3
user3_data = randi([0, 1], 1, length(t)); % Generate random data
user3_signal = 2 * user3_data - 1; % BPSK modulation (0 -> -1, 1 -> 1)

% Create spreading codes for users (randomly generated)


spread_code_len = length(t);
spread_code_user1 = randi([0, 1], 1, spread_code_len); % User 1 spreading code
spread_code_user2 = randi([0, 1], 1, spread_code_len); % User 2 spreading code
spread_code_user3 = randi([0, 1], 1, spread_code_len); % User 3 spreading code

% Spread user signals using spreading codes


spread_user1_signal = user1_signal .* spread_code_user1;
spread_user2_signal = user2_signal .* spread_code_user2;
spread_user3_signal = user3_signal .* spread_code_user3;

% Sum all spread signals to get the CDMA multiplexed signal


cdma_signal = spread_user1_signal + spread_user2_signal + spread_user3_signal;

% Demodulation (de-spreading) for each user


demod_user1_signal = cdma_signal .* spread_code_user1;
demod_user2_signal = cdma_signal .* spread_code_user2;
demod_user3_signal = cdma_signal .* spread_code_user3;

% Integrate and dump (accumulate and average) to get the original data
integrated_user1_data = sum(reshape(demod_user1_signal, [], length(user1_data)), 1) /
spread_code_len;
integrated_user2_data = sum(reshape(demod_user2_signal, [], length(user2_data)), 1) /
spread_code_len;
integrated_user3_data = sum(reshape(demod_user3_signal, [], length(user3_data)), 1) /
spread_code_len;

% Thresholding to recover binary data


received_user1_data = integrated_user1_data >= 0;
received_user2_data = integrated_user2_data >= 0;
received_user3_data = integrated_user3_data >= 0;

% BER (Bit Error Rate) calculation for each user


ber_user1 = sum(received_user1_data ~= user1_data) / length(user1_data);
ber_user2 = sum(received_user2_data ~= user2_data) / length(user2_data);
ber_user3 = sum(received_user3_data ~= user3_data) / length(user3_data);

% Display BER for each user


disp(['User 1 BER: ', num2str(ber_user1)]);
disp(['User 2 BER: ', num2str(ber_user2)]);
disp(['User 3 BER: ', num2str(ber_user3)]);

% Plotting the signals


figure;
subplot(4, 1, 1);
plot(t, user1_signal);
title('User 1 Signal');

subplot(4, 1, 2);
plot(t, user2_signal);
title('User 2 Signal');

subplot(4, 1, 3);
plot(t, user3_signal);
title('User 3 Signal');

subplot(4, 1, 4);
plot(t, cdma_signal);
title('CDMA Multiplexed Signal');
sgtitle('CDMA Multiplexing Simulation');

% Design and simulation of Frequency Division Multiplexing in MATLAB


clc;
clear all
close all

samples=1000;
% number of users
nos=8;
% modulating signal frequency in Hz
mfreq=[30 40 50 60 70 80 90 100];
% carrier frequency allocated to the different users in Hz
cfreq=[300 600 900 12000 1500 1800 2100 2400];

% choose frequency deviation


freqdev=10;

% generate modulating signal


t=linspace(0,1000,samples);
parfor i=1:nos
m(i,:)=sin(2*pi*mfreq(1,i)*t)+2*sin(pi*8*t);
end

% Generate the modulated signal


parfor i=1:nos
y(i,:)=fmmod(m(i,:),cfreq(1,i),10*cfreq(1,i),freqdev);
end

% pass the modulated signal through the channel

ch_op=awgn(sum(y),0,'measured');

% demodulate the received signal at the base station


parfor i=1:nos
z(i,:)=fmdemod(y(i,:),cfreq(1,i),10*cfreq(1,i),freqdev);
end

% display the transmitted signal and received signal at the base station
% figure

C = {'k','b','r','g','y',[.5 .6 .7],[.8 .2 .6],[.3 .2 .2]}; % Cell array of colros.


for i=1:nos
figure (1)
hold on
plot(y(i,:),'color',C{i});
xlabel('time index'); ylabel('amplitude'); title('Signal from different users combined in
the channel');
figure
subplot(3,1,1)
plot(m(i,:)) % modulating signal
xlabel('time index'); ylabel('amplitude'); title('modulating Signal from user');
subplot(3,1,2)
plot(y(i,:),'color',C{i}); % modulated signal
xlabel('time index'); ylabel('amplitude'); title('modulated Signal from user');
subplot(3,1,3)
plot(z(i,:),'color',C{i}); % demodulated signal
xlabel('time index'); ylabel('amplitude'); title('demodulated Signal from user at the base
station');
end
figure
plot(ch_op) % combination of all modulated signals passed through the channel
xlabel('time index'); ylabel('amplitude'); title('Signal after passing through the channel');

% Create the individual signals


fs = 1000; % Sampling frequency (in Hz)
t = 0:1/fs:1; % Time vector from 0 to 1 second

signal1 = sin(2*pi*10*t); % A sine wave of frequency 10 Hz


signal2 = cos(2*pi*20*t); % A cosine wave of frequency 20 Hz
signal3 = square(2*pi*5*t); % A square wave of frequency 5 Hz

% Combine the signals using Time Division Multiplexing


tdm_signal = signal1 + signal2 + signal3;

% Visualization
figure;
subplot(4,1,1);
plot(t, signal1);
title('Signal 1 (10 Hz)');
xlabel('Time (s)');
ylabel('Amplitude');

subplot(4,1,2);
plot(t, signal2);
title('Signal 2 (20 Hz)');
xlabel('Time (s)');
ylabel('Amplitude');

subplot(4,1,3);
plot(t, signal3);
title('Signal 3 (5 Hz)');
xlabel('Time (s)');
ylabel('Amplitude');

% Plot the TDM signal


subplot(4,1,4);
plot(t, tdm_signal);
title('Time Division Multiplexing (TDM) Output');
xlabel('Time (s)');
ylabel('Amplitude');

sgtitle('Time Division Multiplexing (TDM) Simulation');


OUTPUT (To model and simulate of TDMA, FDMA and CDMA for wireless
communication using SCI lab.
.

RESULT:

Thus the SCI lab code to To model and simulate of TDMA, FDMA and CDMA
for wireless communication using SCI lab.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy