Uploaded by Nawal Sah

Lab manual for DCN B.ED ICT

advertisement
Lab Manual
(5th semester BICTE-JJMC)
Experiment-1
Aim: Generate Sine and Square Waves and Analysis using MATLAB
Procedure:
1. Go to the MathWorks website (https://www.mathworks.com/) and click on the "Get MATLAB"
button.
2. Create an account or sign in to an existing account.
3. Select the appropriate version of MATLAB for your operating system (Windows, Mac, or Linux)
and download the installer.
4. Run the installer and follow the on-screen instructions to complete the installation process.
5. Once MATLAB is installed, launch the application. You will be prompted to activate the software
using a license. If you have a student or trial license, you can activate the software using that.
6. Once you have MATLAB open, you can generate wave by running the code I provided earlier.
7. You can also use the built-in functions in MATLAB to generate wave. You can use sine and
square function to generate sine and square wave respectively. Here's an example:
t = linspace(0,2*pi,500); % create a time vector from 0 to 2*pi
y = sin(t); % create a sine wave
plot(t,y); % plot the sine wave
8. Finally, to perform wave analysis, you can use tools provided by MATLAB such as FFT, Spectral
Analysis and more.
Lab1:-Sine wave and Square wave generation
A sine wave or sinusoidal wave is a periodic function that involves the trigonometric sine function
along with other factors such as Amplitude, frequency, and time instant of the wave. The general
form of a sine wave function is:
Syntax:
f(t) = A*sin(w*t + theta)
Where,
A = amplitude
w = angular frequency of the wave, which is 2 *pi * frequency
 t = time variable/ or any variable
Let’s see the plotting of this same function in MATLAB with different examples.


Example 1:
% MATLAB code for sine wave plot
% Frequency
freq = 0.2*pi;
% Angular frequency
w = 2*pi*freq;
% Amplitude
A = 1.25;
% Values of variable argument
t = linspace(0,pi,10000);
% Sin wave function
ft = A * sin(w*t);
% Sine wave plot
plot(t, ft), title("Sine Wave"),
xlabel("Time"), ylabel("Sine wave function")
Output:
Let us create a Sine wave function with phase angle pi/2.
Example 2:
% MATLAB code for sine wave
% Frequency
freq = 0.2*pi;
% Angular frequency
w = 2*pi*freq;
% Amplitude
A = 1.25;
t = linspace(0,pi,10000);
% Values of variable argument
theta = pi/2;
% Phase angle
% Sin wave function
ft = A * sin(w*t + theta);
% Sine wave plot
plot(t, ft), title("Sine Wave with phase pi/2"),
xlabel("Time"), ylabel("Sine wave function")
Output:
Lab 2:
Amplitude modulation (AM) is a method of superimposing the message onto an alternating carrier
waveform.The highest frequency of the modulating signal (Message Signal) is normally < 10 % of the carrier frequency. The
instantaneous amplitude of the modulated wave varies as per the amplitude of the message signal.
MATLAB Code For Amplitude Modulation:
clc;
clear all;
close all;
Ac=2; %carrier amplitude
fc=0.5; %carrier frequency
Am=.5; %message signal amplitude
fm=.05; %message signal frequency
Fs=100; %sampling rate/frequency
ka=1;%Amplitude Sensitivity
t=[0:0.1:50];%defining the time range & disseminating it into samples
ct=Ac*cos(2*pi*fc*t); %defining the carrier signal wave
mt=Am*cos(2*pi*fm*t); %defining the message signal
AM=ct.*(1+ka*mt); %Amplitude Modulated wave, according to the standard definition
subplot(3,1,1);%plotting the message signal wave
plot(mt);
ylabel('Message signal');
subplot(3,1,2); %plotting the carrier signal wave
plot(ct);
ylabel('carrier');
subplot(3,1,3); %plotting the amplitude modulated wave
plot(AM);
ylabel('AM signal');
Screenshot of the output:
MATLAB Code to Simulate / Generate the Amplitide Modulation Signal (AM Signal) [ Amplitude Modulation using MATLAB]
Lab-3
Frequency Modulation
Frequency modulation (FM) is the encoding of information in a carrier wave by varying the instantaneous frequency of the
wave. The amount of frequency variation is proportional to the Modulation index.
A major advantage of FM as compared with AM, is improved Signal-to-noise ratio (SNR). The improvement depends on
modulation level and deviation. For typical voice communications channels, improvements are typically 5-15 dB.
The following MATLAB code for generating/simulating the Frequency Modulation requires 5 inputs, amplitude of both message &
signal, frequency of both message & signal & the modulation index.
clc
clear all
close all
t = 0:0.001:1; %upto 1000 samples
vm = input('Enter Amplitude (Message) = ');
vc = input('Enter Amplitude (Carrier) = ');
fM = input('Enter Message frequency = ');
fc = input('Enter Carrier frequency = ');
m = input('Enter Modulation Index = ');
msg = vm*sin(2*pi*fM*t);
subplot(3,1,1); %plotting message signal
plot(t,msg);
xlabel('Time');
ylabel('Amplitude');
title('Message ');
carrier = vc*sin(2*pi*fc*t);
subplot(3,1,2); %plotting carrier signal
plot(t,carrier);
xlabel('Time');
ylabel('Amplitude');
title('Carrier Signal');
y = vc*sin(2*pi*fc*t+m.*cos(2*pi*fM*t));
subplot(3,1,3);%plotting FM (Frequency Modulated) signal
plot(t,y);
xlabel('Time');
ylabel('Amplitude');
title('FM Signal');
Sample MATLAB Input:
Enter Amplitude (Message) = 5
Enter Amplitude (Carrier) = 5
Enter Message frequency = 8
Enter Carrier frequency = 100
Enter Modulation Index = 10
MATLAB's Output For The Above Input:
Frequency Modilation (FM) Simulation / Generation Using MATLAB Code
Lab-4
Phase Modulation
Program:
clc;
clear all;
t = 0:0.001:1;
vm = input('Enter the amplitude of message signal = ');
vc = input('Enter the amplitude of carrier signal = ');
fm = input('Enter the message frequency = ');
fc = input('Enter the carrier frequency = ');
m = input('Enter modulation index = ');
sm = vm*sin(2*pi*fm*t);
subplot(3,1,1);
plot(t,sm);
xlabel('Time ---->');
ylabel('Amplitude ---->');
title('Message Signal');
grid on;
sc = vc*sin(2*pi*fc*t);
subplot(3,1,2);
plot(t,sc);
xlabel('Time ---->');
ylabel('Amplitude ---->');
title('Carrier Signal');
grid on;
y = vc*sin(2*pi*fc*t+m.*sin(2*pi*fm*t));
subplot(3,1,3);
plot(t,y);
xlabel('Time ---->');
ylabel('Amplitude ---->');
title('PM Wave');
grid on;
Output:
Enter
Enter
Enter
Enter
Enter
the amplitude of message signal = 5
the amplitude of carrier signal = 5
the message frequency = 10
the carrier frequency = 100
modulation index = 4
Output Waveforms:
Lab-6
MATLAB Code FOR ASK (Amplitude Shift Keying) :
clc %for clearing the command window
close all %for closing all the window except command window
clear all %for deleting all the variables from the memory
fc=input('Enter the freq of Sine Wave carrier:');
fp=input('Enter the freq of Periodic Binary pulse (Message):');
amp=input('Enter the amplitude (For Carrier & Binary Pulse Message):');
t=0:0.001:1; % For setting the sampling interval
c=amp.*sin(2*pi*fc*t);% For Generating Carrier Sine wave
subplot(3,1,1) %For Plotting The Carrier wave
plot(t,c)
xlabel('Time')
ylabel('Amplitude')
title('Carrier Wave')
m=amp/2.*square(2*pi*fp*t)+(amp/2);%For Generating Square wave message
subplot(3,1,2) %For Plotting The Square Binary Pulse (Message)
plot(t,m)
xlabel('Time')
ylabel('Amplitude')
title('Binary Message Pulses')
w=c.*m; % The Shift Keyed Wave
subplot(3,1,3) %For Plotting The Amplitude Shift Keyed Wave
plot(t,w)
xlabel('Time')
ylabel('Amplitude')
title('Amplitide Shift Keyed Signal')
NOTE: Use Semicolon ';' in order to suppress the output from coming to the MATLAB's Command Window, whenever declaring a
periodic pulse, as it can display a vary large matrix in the output, so you can miss what you want.
INPUTS GIVEN TO GENERATE ASK MODULATED WAVE:
Enter the freq of Sine Wave carrier:100
Enter the freq of Periodic Binary pulse (Message):10
Enter the amplitude (For Both Carrier & Binary Pulse Message):4
RESULT:
Resultant Graph Of ASK Modulation (Amplitude Shift Keying) In MATLAB
LAB-7
MATLAB Code FOR FSK (Frequency Shift Keying) BFSK in this case:
clc %for clearing the command window
close all %for closing all the window except command window
clear all %for deleting all the variables from the memory
fc1=input('Enter the freq of 1st Sine Wave carrier:');
fc2=input('Enter the freq of 2nd Sine Wave carrier:');
fp=input('Enter the freq of Periodic Binary pulse (Message):');
amp=input('Enter the amplitude (For Both Carrier & Binary Pulse Message):');
amp=amp/2;
t=0:0.001:1; % For setting the sampling interval
c1=amp.*sin(2*pi*fc1*t);% For Generating 1st Carrier Sine wave
c2=amp.*sin(2*pi*fc2*t);% For Generating 2nd Carrier Sine wave
subplot(4,1,1); %For Plotting The Carrier wave
plot(t,c1)
xlabel('Time')
ylabel('Amplitude')
title('Carrier 1 Wave')
subplot(4,1,2) %For Plotting The Carrier wave
plot(t,c2)
xlabel('Time')
ylabel('Amplitude')
title('Carrier 2 Wave')
m=amp.*square(2*pi*fp*t)+amp;%For Generating Square wave message
subplot(4,1,3) %For Plotting The Square Binary Pulse (Message)
plot(t,m)
xlabel('Time')
ylabel('Amplitude')
title('Binary Message Pulses')
for i=0:1000 %here we are generating the modulated wave
if m(i+1)==0
mm(i+1)=c2(i+1);
else
mm(i+1)=c1(i+1);
end
end
subplot(4,1,4) %For Plotting The Modulated wave
plot(t,mm)
xlabel('Time')
ylabel('Amplitude')
title('Modulated Wave')
The following INPUTS GIVEN TO GENERATE FSK MODULATED WAVE:
Enter the freq of 1st Sine Wave carrier:10
Enter the freq of 2nd Sine Wave carrier:30
Enter the freq of Periodic Binary pulse (Message):5
Enter the amplitude (For Both Carrier & Binary Pulse Message):4
Result:
Frequency Shift Keying (FSK) Digital Modulation MATLAB Simulation
LAB-8
PSK (Phase Shift Keying) :
clc %for clearing the command window
close all %for closing all the window except command window
clear all %for deleting all the variables from the memory
t=0:.001:1; % For setting the sampling interval
fc=input('Enter frequency of Carrier Sine wave: ');
fm=input('Enter Message frequency : ');
amp=input('Enter Carrier & Message Amplitude(Assuming Both Equal):');
c=amp.*sin(2*pi*fc*t);% Generating Carrier Sine
subplot(3,1,1) %For Plotting The Carrier wave
plot(t,c)
xlabel('Time')
ylabel('Amplitude')
title('Carrier')
m=square(2*pi*fm*t);% For Plotting Message signal
subplot(3,1,2)
plot(t,m)
xlabel('time')
ylabel('ampmplitude')
title('Message Signal')% Sine wave multiplied with square wave in order to generate PSK
x=c.*m;
subplot(3,1,3) % For Plotting PSK (Phase Shift Keyed) signal
plot(t,x)
xlabel('t')
ylabel('y')
title('PSK')
NOTE: Use Semicolon ';' in order to suppress the output from coming to the MATLAB's Command Window,
whenever declaring a periodic pulse, as it can display a vary large matrix in the output, so you can miss what you
want.
INPUTS GIVEN TO GENERATE ASK MODULATED WAVE:
Enter frequency of Carrier Sine wave: 60
Enter Message frequency : 10
Enter The Carrier & Message Amplitude(Assuming Both Equal): 3
RESULT:
Resultant Graph Of PSK Modulation (Phase Shift Keying) In MATLAB
Experiment-2
Aim: Study of different types of Network cables and Practically implement the cross-wired
cable and straight through cable using clamping tool.
Apparatus (Components): RJ-45 connector, Climping Tool, Twisted pair Cable
Procedure: To do these practical following steps should be done:
1. Start by stripping off about 2 inches of the plastic jacket off the end of the cable. Be very
careful at this point, as to not nick or cut into the wires, which are inside. Doing so could alter
the characteristics of your cable, or even worse render is useless. Check the wires, one more time
for nicks or cuts. If there are any, just whack the whole end off, and start over.
2. Spread the wires apart, but be sure to hold onto the base of the jacket with your other hand.
You do not want the wires to become untwisted down inside the jacket. Category 5 cable must
only have 1/2 of an inch of 'untwisted' wire at the end; otherwise it will be 'out of spec'. At this
point, you obviously have ALOT more than 1/2 of an inch of un-twisted wire.
3. You have 2 end jacks, which must be installed on your cable. If you are using a pre-made
cable, with one of the ends whacked off, you only have one end to install - the crossed over end.
Below are two diagrams, which show how you need to arrange the cables for each type of cable
end. Decide at this point which end you are making and examine the associated picture below.
Diagram shows you how to prepare Cross wired connection
Diagram shows you how to prepare straight through wired connection
Experiment - 3
Aim: Study of following Network Devices in Detail
•
•
•
•
•
•
Repeater
Hub
Switch
Bridge
Router
Gate Way
Apparatus (Software): No software or hardware needed.
Procedure: Following should be done to understand this practical.
1. Repeater:Functioning at Physical Layer.Arepeater is an electronic device that receives a
signal and retransmits it at a higher level and/or higher power, or onto the other side of an
obstruction, so that the signal can cover longer distances. Repeater have two ports ,so cannot be
use to connect for more than two devices
2. Hub: An Ethernet hub, active hub, network hub, repeater hub, hub or concentrator
is a device for connecting multiple twisted pair or fiber optic Ethernet devices together and
making them act as a single network segment. Hubs work at the physical layer (layer 1) of the
OSI model. The device is a form of multiport repeater. Repeater hubs also participate in
collision detection, forwarding a jam signal to all ports if it detects a collision.
3. Switch:Anetwork switch or switching hub is a computer networking device that connects
network segments.The term commonly refers to a network bridge that processes and routes data
at the data link layer (layer 2) of the OSI model. Switches that additionally process data at the
network layer (layer 3 and above) are often referred to as Layer 3 switches or multilayer
switches.
4. Bridge: A network bridge connects multiple network segments at the data link layer (Layer
2) of the OSI model. In Ethernet networks, the term bridge formally means a device that
behaves according to the IEEE 802.1D standard. A bridge and switch are very much alike; a
switch being a bridge with numerous ports. Switch or Layer 2 switch is often used
interchangeably with bridge .Bridges can analyze incoming data packets to determine if the
bridge is able to send the given packet to another segment of the network.
5. Router: A router is an electronic device that interconnects two or more computer networks,
and selectively interchanges packets of data between them. Each data packet contains address
information that a router can use to determine if the source and destination are on the same
network, or if the data packet must be transferred from one network to another. Where multiple
routers are used in a large collection of interconnected networks, the routers exchange
information about target system addresses, so that each rou3ter can build up a table showing the
preferred paths between any two systems on the interconnected networks.
6. Gate Way: In a communications network, a network node equipped for interfacing with
another network that uses different protocols.
•
•
A gateway may contain devices such as protocol translators, impedance matching
devices, rate converters, fault isolators, or signal translators as necessary to provide
system interoperability. It also requires the establishment of mutually acceptable
administrative procedures between both networks.
A protocol translation/mapping gateway interconnects networks with different network
protocol technologies by performing the required protocol conversions.
Experiment - 4
Aim: Study of network IP
•
•
•
Classification of IP address
Sub netting
Super netting
Apparatus (Software): NA
Procedure: Following is required to be study under this practical.
•
Classification of IP address
As show in figure we teach how the ip addresses are classified and when they are used.
Class
Class A
Class B
Class C
Class D
Class E
Address Range
1.0.0.1 to 126.255.255.254
128.1.0.1 to 191.255.255.254
192.0.1.1 to 223.255.254.254
224.0.0.0 to 239.255.255.255
240.0.0.0 to 254.255.255.254
Supports
Supports 16 million hosts on each of 127 networks.
Supports 65,000 hosts on each of 16,000 networks.
Supports 254 hosts on each of 2 million networks.
Reserved for multicast groups.
Reserved.
• Sub netting
Why we Develop sub netting and How to calculate subnet mask and how to identify subnet address.
• Super netting
Why we develop super netting and How to calculate supernet mask and how to identify
supernet address.
Experiment-5
Aim: Connect the computers in Local Area Network.
Procedure: On the host computer
On the host computer, follow these steps to share the Internet connection:
1. Log on to the host computer as Administrator or as Owner.
2. Click Start, and then click Control Panel.
3. Click Network and Internet Connections.
4. Click Network Connections.
5. Right-click the connection that you use to connect to the Internet. For example, if you
connect to the Internet by using a modem, right-click the connection that you want under Dial-up
/ other network available.
6. Click Properties.
7. Click the Advanced tab.
8. Under Internet Connection Sharing, select the Allow other network users to connect
through this computer's Internet connection check box.
9. If you are sharing a dial-up Internet connection, select the Establish a dial-up connection
whenever a computer on my network attempts to access the Internet check box if you
want to permit your computer to automatically connect to the Internet.
10. Click OK. You receive the following message:
When Internet Connection Sharing is enabled, your LAN adapter will be set to use IP address
192.168.0. 1. Your computer may lose connectivity with other computers on your network. If
these other computers have static IP addresses, it is a good idea to set them to obtain their IP
addresses automatically. Are you sure you want to enable Internet Connection Sharing?
11. Click Yes.
The connection to the Internet is shared to other computers on the local area network (LAN).
The network adapter that is connected to the LAN is configured with a static IP address of
192.168.0. 1 and a subnet mask of 255.255.255.0
On the client computer
To connect to the Internet by using the shared connection, you must confirm the LAN adapter
IP configuration, and then configure the client computer. To confirm the LAN adapter IP
configuration, follow these steps:
1. Log on to the client computer as Administrator or as Owner.
2. Click Start, and then click Control Panel.
3. Click Network and Internet Connections.
4. Click Network Connections.
5. Right-click Local Area Connection and then click Properties.
6. Click the General tab, click Internet Protocol (TCP/IP) in the connection uses
the following items list, and then click Properties.
7. In the Internet Protocol (TCP/IP) Properties dialog box, click Obtain an
IP address automatically (if it is not already selected), and then click OK.
Note: You can also assign a unique static IP address in the range of 192.168.0.2 to
254. For example, you can assign the following static IP address, subnet mask, and default gateway:
8. IP Address 192.168.31.202
9. Subnet mask 255.255.255.0
10. Default gateway 192.168.31.1
11. In the Local Area Connection Properties dialog box, click OK.
12. Quit Control Panel.
21 | P a g e
Download