-
Notifications
You must be signed in to change notification settings - Fork 0
/
ZigBee_Device.m
executable file
·84 lines (63 loc) · 2.02 KB
/
ZigBee_Device.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
%%
% A ZigBee device operates at a frequency and rate of:
f_o = 2400 % MHz - INPUT
data_rate = 40 % Kbps - INPUT
%%
% BPSK modulation is used. The output power of the transmitter is in the range
% of 0 to 20dBm. The gain of the receiver and transmitter antennas are:
G_dBi = 2 % dBi - INPUT
%%
% At a distance of:
distance = 10 % m - INPUT
%%
% from the receiver, the probability of error is:
P_err = 0.1 % - INPUT
%%
% if the power level is:
P_tr_dBm = 10 % dBm - INPUT
%%
% a) Calculate noise power in the receiver
% Convert Power from dBm to Watts
P_tr_lin = 10^(P_tr_dBm / 10) * 1e-3 % Watts
% Convert Antenna Gain from dBi to linear gain
G_tr = 10^(G_dBi / 10)
G_rx = G_tr
% Calculate wavelength of antenna
wavelength = 3e8 / (f_o * 1e6)
% Calculate Power of receiver
P_rx_lin = P_tr_lin * G_rx * G_tr * (wavelength / (4*pi*distance))^2
% Calculate SNR from P_err = Q(sqrt(2*SNR))
SNR_lin = (qfuncinv(P_err))^2 / 2
% Calculate noise power SNR_lin = P_rx_lin / P_noise
P_noise = P_rx_lin / SNR_lin % - OUTPUT ----------------------------->
%%
% b) What is the maximum distance of operation if the probability of error is
% no more than:
P_err_max = 0.15 % - INPUT
%%
% Answer:
% Calculate SNR from P_err_max = Q(sqrt(2*SNR))
SNR_lin = qfuncinv(P_err_max)^2 / 2
% Calculate receiver power from noise power and SNR
P_rx = SNR_lin * P_noise
% At mininmum transmitter power (0 dBm)
P_tr_min = 10^(0/10) * 1e-3
% Rearrange P_rx = P_tr*G*G*(wave/4pi*distance)^2
max_distance = wavelength / ...
(4 * pi * sqrt(P_rx / (P_tr_min * G_rx * G_tr))) % - OUTPUT ---------->
%%
% c) What is the probability of error at the following distance and power level:
distance = 15 % m - INPUT
P_tr_dBm = 15 % dBm - INPUT
%%
% Answer:
% Convert Power from dBm to Watts
P_tr_lin = 10^(P_tr_dBm / 10) * 1e-3
% Calculate Power of receiver
P_rx_lin = P_tr_lin * G_rx * G_tr * (wavelength / (4*pi*distance))^2
% Calculate linear SNR
SNR_lin = P_rx_lin / P_noise
% Calculate error probability
P_err = qfunc(sqrt(2 * SNR_lin)) % - OUTPUT ------------->
%%
%