[go: up one dir, main page]

0% found this document useful (0 votes)
72 views19 pages

Advanced Communication Networks Lab Experiments

The document outlines various MATLAB simulations for frequency shift keying, binary phase shift keying, and quadrature phase shift keying, including their generation and detection processes. It also describes interfacing analog and digital sensors with Arduino, detailing the setup for temperature, humidity, and light sensors, along with the necessary hardware and code examples. Additionally, it covers the collection of sensor values from remote nodes using RF transmission for environmental monitoring.

Uploaded by

pavani chinthala
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)
72 views19 pages

Advanced Communication Networks Lab Experiments

The document outlines various MATLAB simulations for frequency shift keying, binary phase shift keying, and quadrature phase shift keying, including their generation and detection processes. It also describes interfacing analog and digital sensors with Arduino, detailing the setup for temperature, humidity, and light sensors, along with the necessary hardware and code examples. Additionally, it covers the collection of sensor values from remote nodes using RF transmission for environmental monitoring.

Uploaded by

pavani chinthala
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/ 19

1

AC LAB

OBSERVATION:-

Output waveform for the bit stream [0 1 0 0 1 1 1 0]

MATLAB SIMULATION WAVEFORMS:-

Dept .of ECE


2
AC LAB
7 (a). FREQUENCY SHIFT KEYING GENERATION & DETECTION
(Using Simulation)

Simulation in MATLAB
Program:
clear;
clc;
b = input('Enter the Bit stream \n '); %b = [0 1 0 1 1 1 0];
n = length(b);
t = 0:.01:n;
x = 1:1:(n+1)*100;
for i = 1:n
if (b(i) == 0)
b_p(i) = -1;
else
b_p(i) = 1;
end
for j = i:.1:i+1 bw(x(i*100:
(i+1)*100)) = b_p(i); end
end
bw = bw(100:end);
wo = 2*(2*pi*t);
W = 1*(2*pi*t);
sinHt = sin(wo+W);
sinLt = sin(wo-W);
st = sin(wo+(bw).*W);
subplot(3,1,1)
plot(t,bw)
grid on ; axis([0 n -2 +2])
subplot(3,1,2)
plot(t,sinHt)
grid on ; axis([0 n -2 +2])
subplot(3,1,3)
plot(t,st)
grid on ; axis([0 n -2 +2])

RESULT:

Dept .of ECE


3
AC LAB

MATLAB SIMULATION WAVEFORMS:-

input signal
1
amplitud

0.5
e

0
0 10 20 30 40 50 60 70 80 90 100
number of samples
carrier signal
1
amplitud

0
e

-1
0 10 20 30 40 50 60 70 80 90 100
number of samples
DPSK Signal
1
amplitud

0
e

-1
0 10 20 30 40 50 60 70 80 90 100
number of
samples
demodulated
Signal
1
amplitud

0.5
e

0
0 10 20 30 40 50 60 70 80 90 100
number of samples

Dept .of ECE


4
AC LAB
7 (b). BINARY PHASE SHIFT KEYING GENERATION & DETECTION

Simulation in MATLAB
Program:

clear;
clc;
b = input('Enter the Bit stream \n '); %b = [0 1 0 1 1 1 0] ;
n = length(b);
t = 0:.01:n;
x = 1:1:(n+1)*100;
for i = 1:n
if (b(i) == 0)
b_p(i) = -1;
else
b_p(i) = 1;
end
for j = i:.1:i+1 bw(x(i*100:
(i+1)*100)) = b_p(i); end
end
bw = bw(100:end);
sint = sin(2*pi*t);
st = bw.*sint;
subplot(3,1,1)
plot(t,bw)
grid on ; axis([0 n -2 +2])
subplot(3,1,2)
plot(t,sint)
grid on ; axis([0 n -2 +2])
subplot(3,1,3)
plot(t,st)
grid on ; axis([0 n -2 +2])

RESULT:

Dept .of ECE


5
AC LAB
MATLAB SIMULATION WAVEFORMS:-]

1 binary data bits carrier signal-1


2

1
b(n

0.5

c1(t
0
)

)
-1
0
-2
1 2 3 4 5 6 7 3 3.2 3.4 3.6 3.8 4 4.2 4.4
8 n----> t--->
carrier signal-2 QPSK signal
2
2
1
1
c2(t

s(t)
0
)

-1
-1
-2
3 3.2 3.4 3.6 3.8 4 4.2 4.4 -2
0 1 2 3 4 5
t--->
t--->
qpsk demodulated bits
1
b(n

0.5
)

0
1 2 3 4 5 6 7 8
n >

Dept .of ECE


6
AC LAB
7(c). QPSK GENERATION & DETECTION

Simulation in MATLAB Program:


clc;
clear all;
close all;
%GENERATE QUADRATURE CARRIER SIGNAL Tb=1;t=0:
(Tb/100):Tb;fc=1;
c1=sqrt(2/Tb)*cos(2*pi*fc*t);
c2=sqrt(2/Tb)*sin(2*pi*fc*t);
%generate message signal
N=8;m=rand(1,N);
t1=0;t2=Tb
for i=1:2:(N-1)
t=[t1:(Tb/100):t2]
if m(i)>0.5
m(i)=1;
m_s=ones(1,length(t));
else
m(i)=0;
m_s=-1*ones(1,length(t));
end
%odd bits modulated signal
odd_sig(i,:)=c1.*m_s;
if m(i+1)>0.5
18
m(i+1)=1;
m_s=ones(1,length(t));
else
m(i+1)=0;
m_s=-1*ones(1,length(t));
end
%even bits modulated signal
even_sig(i,:)=c2.*m_s;
%qpsk signal
qpsk=odd_sig+even_sig;
%Plot the QPSK modulated signal
subplot(3,2,4);plot(t,qpsk(i,:));

title ('QPSK signal');xlabel('t----->');


ylabel ('s(t)');
grid on; hold on;
t1=t1+(Tb+.01);
t2=t2+(Tb+.01);

Dept .of ECE


7
AC LAB

end
hold off
%Plot the binary data bits and carrier signal
subplot(3,2,1);
stem(m);
title('binary data bits');
xlabel('n----->');
ylabel('b(n)');
grid on;
subplot(3,2,2);
plot(t,c1);
title('carrier signal-1');
xlabel('t----->');
ylabel('c1(t)');
grid on;
subplot(3,2,3);
plot(t,c2);
title('carrier signal-2');
xlabel('t----->');
ylabel('c2(t)');
grid on;
% QPSK Demodulation
t1=0;t2=Tb
for i=1:N-1 t=[t1:
(Tb/100):t2]
%correlator
x1=sum(c1.*qpsk(i,:));
x2=sum(c2.*qpsk(i,:));
%decision device
if (x1>0&&x2>0)
demod(i)=1;
demod(i+1)=1;
elseif (x1>0&&x2<0)
demod(i)=1;
demod(i+1)=0;
elseif (x1<0&&x2<0)
demod(i)=0;
demod(i+1)=0;
elseif (x1<0&&x2>0)
demod(i)=0;
demod(i+1)=1;
end
t1=t1+(Tb+.01); t2=t2+(Tb+.01);
end

Dept .of ECE


8
AC LAB

subplot(3,2,5);
stem(demod);
title('qpsk demodulated bits');
xlabel('n----->');
ylabel('b(n)');
grid on;

RESULT:

Dept .of ECE


9
AC LAB

8. READING ANALOG AND DIGITAL SENSORS DATA USING UART


USING ICONT SETUP

Reading analog sensors data

The Temperature Humidity sensor provides a pre-calibrated digital output. A


unique capacitive sensor element measures relative humidity and the temperatureis
measured by a negative temperature coefficient (NTC) thermistor. It has excellent
reliability and long-term stability. Please note that this sensor will not work for
temperatures below 0 degree.

Hardware Required:

Component Name Quantity

Arduino UNO 1

Temperature &Humidity sensor 1

USB Cable 1

Base shield 1

Jumper wires 1

Dept .of ECE


10
AC LAB
Connection diagram:

Steps of Working:
1. Connect Grove – Temperature & Humidity Sensor to port A0 of Grove-Base
Shield.

2. Plug Grove-Base Shield into Arduino.

3. Connect Arduino to PC via a USB cable.

4. Open the Serial Monitor of Arduino IDE by click Tool-> Serial Monitor and get
the temperature.

The Sketch:
#include <DHT.h>

// Define DHT11 pin and type


#define DHTPIN A0 // Data pin connected to Digital Pin 2
#define DHTTYPE DHT11 // DHT11 Sensor

// Initialize DHT sensor


DHT dht(DHTPIN, DHTTYPE);

void setup() {
Serial.begin(9600); // Initialize Serial Monitor
dht.begin(); // Start the DHT sensor
Serial.println("DHT11 Sensor Data Monitoring");
}
Dept .of ECE
11
AC LAB

void loop() {
// Wait a few seconds between readings
delay(2000);

// Read temperature as Celsius and Fahrenheit


float temperature = dht.readTemperature();
float humidity = dht.readHumidity();

// Check if any reading failed and exit early


if (isnan(temperature) || isnan(humidity)) {
Serial.println("Failed to read from DHT sensor!");
return;
}

// Print the results to the Serial Monitor


Serial.print("Temperature: ");
Serial.print(temperature);
Serial.print("°C | Humidity: ");
Serial.print(humidity);
Serial.println("%");
}

RESULT:

Dept .of ECE


12
AC LAB

Interfacing of light Sensor with Arduino

Introduction:

The Grove - Light sensor integrates a photo-resistor (light dependent resistor) to


detect the intensity of light. The resistance of photo-resistor decreases when the
intensity of light increases. A dual Op Amp chip LM358 on board produces voltage
corresponding to intensity of light (i.e. based on resistance value). The output
signal is analog value, the brighter the light is, the larger the value.

Hardware Required:

Component Name Quantity

Arduino UNO 1

Base Shield 1

USB Cable 1

Grove Light Sensor 1

Connecting wires 1

Dept .of ECE


13
AC LAB
Connection Diagram:

Steps of working:

1) Connect Grove-Light Sensor to port A0 of Grove-Base Shield.

2) Plug Grove-Base Shield into Arduino.

3) Connect Arduino to PC through a USB cable.

4) Observe the light intensity readings on the serial monitor.

The Sketch:
This sketch works by setting pin A0 as for the Light sensor.

#include <math.h>

#defineLIGHT_SENSORA0 //Grove-Light Sensor is connected to A0 of


Arduino

const int ledPin=12; //Connect theLEDGrovemoduletoPin12, Digital12

const int threshold value=10;

Dept .of ECE


14
AC LAB
float Rsensor;

void setup()

Serial.begin(9600); //Start the Serial connection

pinMode(ledPin,OUTPUT); //SettheLEDonDigital12asanOUTPUT

Void loop()

int sensor Value = analog Read(LIGHT_SENSOR);

Rsensor=(float)(1023-sensorValue)*10/sensorValue;

Serial.println("the analog read data is ");

Serial.println(sensorValue);

Serial.println("thesensorresistanceis");

Serial.println (Rsensor,DEC);//showthelightintensityontheserialmonitor;}

RESULT:

Dept .of ECE


15
AC LAB

Collecting sensor values of remote nodes


The multiple sensors used are digital humidity and temperature sensor, light-
dependent resistor (LDR) that senses ambient light, and soil moisture sensor
that senses soil moisture content. The project also makes use of Arduino
Nano as microcontroller (MCU) and 433MHz ASK RF transmitter module.
There can be many such sensor nodes but only two such nodes are used
here.
The receiver includes 433MHz ASK RF receiver module, real-time clock (RTC)
module, and Arduino Nano. Both sensor nodes transmit data of sensed values
of temperature, humidity, ambient light, and soil moisture content. The
receiver receives the values from both sensors (total eight values) and gives
them to computer, which displays these values and stores for future use.

Dept .of ECE


16
AC LAB

#include
<VirtualWi
re.h>
#include
"DHT.h"
#define
DHTPIN 10
#define DHTTYPE
DHT11 #define
LDR_pin A0
#define
soil_moist_sensor_p
in A1 DHT
dht(DHTPIN,
DHTTYPE);

const int
led_pin = 12;
const int
transmit_pin =
11;
char
str1[2],str2[4],str3[6],str
4[8]; char node[3] =
"01", trnsmit_str[10];
void setup()
{
vw_set_tx_pin(transmit_pin);
vw_set_ptt_inverted(true); //
Required for DR3100

Dept .of ECE


17
AC LAB
vw_setup(2000); // Bits per sec
Serial.begin(9600);
dht.begin();
pinMode(led_p
in, OUTPUT);
}
void loop()
{
int h =
dht.readHumidit
y(); int t =
dht.readTemper
ature(); int l,m;
l=analogRead(LD
R_pin);
m=analogRead(soil_moist_sensor_pi
n); l=map(l,0,1023,0,99);
m=map(m,0,1023,0,99);
Serial .println("
Node 1"); Serial
.print("Tempera
ture: ");
Serial .print(t);
Serial .print("
deg C\t");
Serial .print("
Humidity: ");
Serial .print(h
);
Serial .print(" %\t ");
Serial .print("light

Dept .of ECE


18
AC LAB
intensity: ");
Serial .print(l);
Serial .print(" %\t");
Serial .print("soil
moisture: ");
Serial .print(m);
Serial .println(" %");
Digital Write(led_pin, HIGH); // Flash a light to show
transmitting itoa(t,str1,10);
itoa(h,str2,10);
itoa(l,str3,10);
itoa(m,str4,1
0);
strcat(str2,str
1);
strcat(str3,str
2);
strcat(str4,str
3);
strcpy(trnsmi
t_str,node);
strcat(trnsmit
_str,str4);
Serial .print("transmitte
d string: ");
Serial .println(trnsmit_s
tr); vw_send((uint8_t
*)trnsmit_str, 10);
vw_wait_tx(); // Wait until the whole
message is gone digital Write(led_pin,
LOW);

Dept .of ECE


19
AC LAB
delay(5000);
}

RESULT:

Dept .of ECE

You might also like