Skip to content

Commit 41faefd

Browse files
committed
added whole code for paper implementation
1 parent a8705d4 commit 41faefd

22 files changed

+581
-2
lines changed

Design.md

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
## Data Communications (CO250): Mini-Project
2+
3+
:: Design File
4+
5+
Tool: Matlab
6+
7+
**Design Aspects**
8+
9+
* Matlab code for NRZ-I encoding scheme will be implemented.
10+
11+
* Matlab code for MNRZ-I encoding scheme will be implemented.
12+
13+
* Then graph for NRZ-I and MNRZ-I will be plotted to show the differnce in between the two encoding.
14+
15+
* Then graph for comparision of average DC component between NRZ-I and MNRZ-I will be plotted to show the result of the reseach paper.

Graph_1.png

207 KB
Loading

Graph_2.png

202 KB
Loading

Graph_3.png

206 KB
Loading

Graph_4.png

207 KB
Loading

Graph_5.png

208 KB
Loading

Introduction.md

+122
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
## Data Communications (CO250): Mini-Project :: Introduction file
2+
3+
* According to the World Health Organisation (WHO) , cardiovascular disease causes 30 percent of all deaths
4+
in the world.
5+
6+
* Wireless Body Area Network (WBAN) monitors human
7+
physiological signs at home, in hospital and even when
8+
moving and transmits sick vital signs to medical
9+
database.
10+
11+
* In data transmission process most of the energy is spent on commnuication. So, improvement in the data transmission method has great importance.
12+
13+
* So finding the new methods in communication and
14+
transmission can be a valuable step in quickly to wrap
15+
up this technology.
16+
17+
**Wireless Body Area Network (WBAN)**
18+
19+
* WBAN is a set of independent nodes such as sensors
20+
and actuators that are situated deeply in tissues, under
21+
the skin, on the body or in the clothes .
22+
23+
* WBAN emerged as a new technology for E-healthcare ,communicated using short-range wireless communication techniques and allows the data and parameters of a patient's vital body move to be collected in medical database
24+
25+
![alt text](diagram_1.png)
26+
27+
* As shown, sensors detect vital signs which are in analog
28+
form. Next convert them to digital.
29+
30+
* Then CPU processes the data (Compression and
31+
Encryption for decrease in Bandwidth consumption and
32+
increase data security for data transmission).
33+
34+
* The data send to receiver by digital to digital encoding
35+
NRZ-I.
36+
37+
* The receiver does this step vice versa to achieve main
38+
data.
39+
40+
**WBAN Total Architecture**
41+
42+
**1) First Level**
43+
The first level is a set of intelligent sensors and actuator or
44+
nodes.
45+
46+
**2) Second Level**
47+
The second level is the personal server (personal digital
48+
assistant, cell-phone or PC).Here collects patient vital data
49+
from nodes.
50+
51+
52+
**3) Third Level**
53+
The third level encompasses remote servers that manage
54+
patient medical information.
55+
56+
57+
![alt text](diagram_2.png)
58+
59+
**Bio Signal**
60+
61+
* Bio signal is a short term for type of signal that can
62+
measure and control live creature's vital signs
63+
continuously.
64+
65+
* In fact, the sensors located in/on any organ for
66+
measure electrical current and electrical resistance
67+
changes and report gained values.
68+
69+
* Incompatibility of values with standard values, means
70+
disorder in organ. If this happens, PDA warns
71+
disruptions to person.
72+
73+
**NRZ-I DIGITAL TO DIGITAL ENCODING**
74+
75+
* “I” i.e. inverse. “Z” i.e. zero that shows zero voltage
76+
level. “1” shows if in start of bit interval signal polarity
77+
would be inverse, the bit equals “1”.
78+
79+
* If in start of bit interval hasn't change level, the bit
80+
equals “0”.
81+
82+
* NRZ-I is a differential method that less affected by the
83+
noise.
84+
85+
![alt text](diagram_3.png)
86+
87+
**WBAN’S CERITERIA**
88+
89+
The most important WBAN bio signal transmission
90+
criteria are as follows:
91+
92+
* High bit rate
93+
* Sync problem (Long string of one or zero will be lost in
94+
time)
95+
* Reducing or eliminating the DC (Direct Current)
96+
component
97+
* Less influence from noise
98+
99+
![alt text](diagram_4.png)
100+
101+
**MODIFIED NRZ-I (MNRZ-I)**
102+
103+
For solving the synchronization problem (Clock loses)
104+
between transmitter and receiver also for inappropriate
105+
DC component in NRZ-I encoding, we do as follows
106+
107+
A. Synchronization
108+
109+
Every bits clock send with its signal, but for bandwidth
110+
loss prevention instead in all of bits send with its clock,
111+
after every two zero bits, only third zero bit send with its
112+
clock. With this process, receiver will able to detect
113+
repeated more than two zero bits similar to each other and
114+
prevents from asynchronous between transmitter and
115+
receiver.
116+
117+
B. DC Component
118+
119+
With the change made is clear that area under the diagram
120+
is close to zero. It's an improvement on DC component.
121+
122+
![alt text](diagram_5.png)

MAIN_FILE.m

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
%Data Communication Paper Implementation
2+
%Title :A Modified Digital To Digital Encoding Method to Improve the
3+
% Wireless Body Area Network (WBAN) Transmission.
4+
% This is a main code for this paper implementation. It contains NRZI & MNRZI codes combined together.
5+
6+
%Input stream of bits to plot NRZ-I and MNRZ-I
7+
bitSequence = input('Enter the stream of bits :');
8+
9+
%Default bitrate is 5
10+
bitrate = 5;
11+
12+
%-------------- Plot of Non Return to Zero - Inverted -----------------
13+
14+
[t,x] = NRZI(bitSequence,bitrate);
15+
16+
subplot(1,2,1);
17+
plot(t,x);
18+
ylabel('Amplitude','fontweight','bold','fontsize',14);
19+
xlabel('time(sec)','fontweight','bold','fontsize',14);
20+
axis([0 t(end) -4 4]);
21+
grid on;
22+
title(['NRZ-I: [' num2str(bitSequence) ']']);
23+
24+
25+
%-------------- Plot of Modern Non Return to Zero - Inverted -----------------
26+
27+
28+
[t,x] = MNRZI(bitSequence,bitrate);
29+
30+
subplot(1,2,2);
31+
plot(t,x);
32+
ylabel('Amplitude','fontweight','bold','fontsize',14);
33+
xlabel('time(sec)','fontweight','bold','fontsize',14);
34+
axis([0 t(end) -4 4]);
35+
grid on;
36+
title(['MNRZ-I: [' num2str(bitSequence) ']']);
37+
38+
%------------------------- End Of Code ----------------------------------------

MAIN_PLOT.m

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
% This file contains code for main Plot which integrates both NRZIPLOT.m & MNRZIPLOT.m files and will plot the graph.
2+
% The graph obtaned here will be in a new window & it will contain 2 plots .
3+
% Left plot will be NRZI DC Component Average plot
4+
% Right plot will be MNRZI DC Component Average plot
5+
6+
% Variable for holding bitrate
7+
bitRate = 5;
8+
9+
% Calling function NRZIPLOT For plotting where i is X axis scale & plot1 is Y axis scale
10+
[i,plot1] = NRZIPLOT(bitRate);
11+
12+
% Variable for storing the Final Average DC component for NRZI
13+
finalAvgComponent = 0;
14+
15+
% finding Average DC Component for NRZI
16+
for k=1:2000
17+
finalAvgComponent = finalAvgComponent + plot1(k);
18+
end
19+
20+
finalAvgComponent = finalAvgComponent/2000;
21+
22+
% Plotting graph as a subplot containing 2 plots in one row for NRZI
23+
subplot(1,2,1);
24+
plot(i,plot1,'r');
25+
axis([0 2000 -40 40]); % defining axis
26+
title([ 'NRZI DC Component Average :' num2str(finalAvgComponent) ]); % defining title of graph
27+
28+
29+
% Calling function MNRZIPLOT For plotting where i is X axis scale & plot1 is Y axis scale
30+
[j,plot2] = MNRZIPLOT(bitRate);
31+
32+
% Variable for storing the Final Average DC component for MNRZI
33+
finalAvgComponent = 0;
34+
35+
% finding Average DC Component for MNRZI
36+
for i=1:2000
37+
finalAvgComponent = finalAvgComponent + plot2(i);
38+
end
39+
40+
finalAvgComponent = finalAvgComponent/2000;
41+
42+
% Plotting graph as a subplot containing 2 plots in one row for MNRZI
43+
subplot(1,2,2);
44+
plot(j,plot2,'b');
45+
axis([0 2000 -50 50]); % defining axis
46+
title([ 'MNRZI DC Component Average :' num2str(finalAvgComponent)]); % defining title of graph

MNRZI.m

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
% This file contains a code for MNRZI digital to digital encoding method
2+
3+
%-------------- Function to plot Modern Non Return to Zero - Inverted -----------------
4+
5+
function [t,x] = MNRZI(bitSequence,bitrate)
6+
7+
T = length(bitSequence)/bitrate; %Full Time of bit sequence
8+
n = 200; %For making signal as a straight line
9+
N = n*length(bitSequence); %total values to plot(To get perfect DC signal)
10+
dt = T/N; %Small time dt
11+
t = 0:dt:T; %Increment in small intervals
12+
x = zeros(1,length(t)); %Output Signal
13+
valueToAssign = 1; %Current signal level to assign
14+
prevTwoZeroCount=0; %Variable to maintain the previous zero count
15+
previous = 1;
16+
17+
%------- Code to plot the Modern Non Return To Zero inverted -------
18+
19+
%Traversing full length of bit sequence
20+
for i = 0:length(bitSequence)-1
21+
22+
%If previous Two and current bits is zero, make the third
23+
%bit synchronous and continue from the next bit.
24+
if prevTwoZeroCount == 2 && bitSequence(i+1) == 0
25+
x(i*n+1:(i+0.5)*n) = valueToAssign;
26+
valueToAssign = -1 * valueToAssign;
27+
x((i+0.5)*n+1:(i+1)*n) = valueToAssign;
28+
prevTwoZeroCount = 0;
29+
continue;
30+
end
31+
32+
%If the current bit is zero then increment the prevTwoZeroCount by 1
33+
%The level of the signal remain same
34+
if bitSequence(i+1) == 0
35+
prevTwoZeroCount = prevTwoZeroCount + 1;
36+
end
37+
38+
%If the current bit is one then make the prevTwoZeroCount 0.
39+
%As the current bit is one the level of the signal is inverted.
40+
if bitSequence(i+1) == 1
41+
prevTwoZeroCount=0;
42+
valueToAssign = -1*valueToAssign;
43+
end
44+
45+
%Assign the value got as per the bit sequence.
46+
x(i*n+1:(i+1)*n) = valueToAssign;
47+
end
48+
49+
50+
%----------------------------- End Of Code -----------------------------

MNRZIPLOT.m

+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
2+
function [i,arrToPlot] = MNRZIPLOT(bitRate)
3+
4+
%Time required For the one bit
5+
timePerBit = 1/bitRate;
6+
7+
%Matrix A with 2000 bit string Each of which will contain 100 bits.
8+
A = zeros(2000,100);
9+
10+
%Generating Random Bits for all the 2000 bit string with random function in matlab.
11+
%rand function gives a value between 0 to 1
12+
%which is then multiplied with 100 and after that taking
13+
%modulus by 2 to get the desired binary bits.
14+
for i=1:2000
15+
for j=1:100
16+
A(i,j) = mod((ceil(rand *100)),2) ;
17+
end
18+
end
19+
20+
%------------------------Integration Part---------------------------------
21+
22+
%calculation of average DC component value of every bit string.
23+
24+
%Matrix B to strore the current level of the signal whether it is +1 or -1.
25+
B = zeros(2000,100);
26+
27+
%Values +1 , 0 and -1 assigned which represent the current level of signal.
28+
for i=1:2000
29+
%Value to be assigned for current level.
30+
currentZeroCount=0;
31+
valueToAssign = 1;
32+
for j=1:100
33+
%if current bit is zero then the currentZeroBit count will be
34+
%incremented.
35+
if A(i,j) == 0
36+
currentZeroCount = currentZeroCount + 1;
37+
end
38+
39+
%if the current bit is third consecutive zero then the Intergration
40+
%of this part will be zero as it is a transition in the middle of
41+
%the bit.
42+
if currentZeroCount == 3
43+
B(i,j) = 0;
44+
valueToAssign = valueToAssign * -1;
45+
currentZeroCount = 0;
46+
continue;
47+
end
48+
%if current bit is 1, change the level.
49+
if A(i,j) == 1
50+
valueToAssign = valueToAssign * -1;
51+
currentZeroCount = 0;
52+
end
53+
%Assigning the value to Martix B
54+
B(i,j) = valueToAssign;
55+
end
56+
end
57+
58+
%Array for Average DC Component of Each bit string(Total 2000).
59+
arrToPlot = [1:1:2000];
60+
61+
%Integration is Nothing but the area under the graph with time axis.
62+
%Below is the code for the Intergration(Area with time axis).
63+
for i=1:2000
64+
areaUnderTheCurve = 0;
65+
66+
for j=1:100
67+
if B(i,j) == 1
68+
areaUnderTheCurve = areaUnderTheCurve + timePerBit;
69+
elseif B(i,j) == -1
70+
areaUnderTheCurve = areaUnderTheCurve - timePerBit;
71+
end
72+
end
73+
74+
arrToPlot(i) = (areaUnderTheCurve / 20)*100;
75+
end
76+
77+
%---------------------Integration Part Ended-------------------------------
78+
79+
%Total Number of bit string
80+
i = 1:1:2000;
81+
82+
%----------------------------End Of Code-----------------------------------

NRZI.m

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
%This file contains a code for NRZI digital to digital encoding method
2+
%-------------- Plot of Non Return to Zero - Inverted -----------------
3+
4+
5+
function [t,x] = NRZI(bitSequence,bitrate)
6+
7+
T = length(bitSequence)/bitrate; %Full Time of bit sequence
8+
n = 200; %For making signal as a straight line
9+
N = n*length(bitSequence); %total values to plot(To get perfect DC signal)
10+
dt = T/N; %Small time dt
11+
t = 0:dt:T; %Increment in small intervals
12+
x = zeros(1,length(t)); %Output Signal
13+
valueToAssign = 1; %Current signal level to assign
14+
var = 1;
15+
16+
%------- Code to plot the Non Return To Zero inverted -------
17+
for i = 0:length(bitSequence)-1
18+
19+
%If the current bit is one, the level of the signal is inverted
20+
%else the level of signal remains same
21+
if bitSequence(i+1) == 1
22+
valueToAssign = -1*valueToAssign;
23+
end
24+
25+
%Assign the value got as per the bit sequence.
26+
x(i*n+1:(i+1)*n) = valueToAssign;
27+
end
28+
29+
%----------------------------- End Of Code -----------------------------

0 commit comments

Comments
 (0)