-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy path12_pathloss_interference.html
More file actions
309 lines (249 loc) · 13.1 KB
/
Copy path12_pathloss_interference.html
File metadata and controls
309 lines (249 loc) · 13.1 KB
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
<!DOCTYPE html>
<!--
To Do: Update spectrum plot to use Lance's framework; Add path loss model menu
with 2-3 models; Replace text-based status display with bar graph that includes
text labels, and numeric values
-->
<html lang="en-US" style="display: flex;">
<head>
<title>12 - Path Loss</title>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width"/>
<link rel="stylesheet" type="text/css" media="all" href="base.css">
<link rel=stylesheet type=text/css href=sidebar.css />
</head>
<body style="margin:0;">
<!-- <h2>Exercise 12 - Path Loss with Interference</h2>
<p><a href="index.html">[exercises]</a></p> -->
<section class="banner" style="position: fixed; z-index: 11; background: rgba(0,0,0,0.85)">
<label for="menu-control" class="hamburger">
<i class="hamburger__icon"></i>
<i class="hamburger__icon"></i>
<i class="hamburger__icon"></i>
</label>
<input type="checkbox" id="menu-control" class="menu-control">
<aside class="sidebar" style="z-index: 10;">
<nav class="sidebar__menu">
<a href="01_bw.html"><b>1</b> Bandwidth</a>
<a href="02_freq.html"><b>2</b> Frequency</a>
<a href="03_gn.html"><b>3</b> Gain</a>
<a href="04_freq_bw_gn.html"><b>4</b> Frequency, Bandwidth, and Gain</a>
<a href="05_capacity.html"><b>5</b> Information Capacity</a>
<a href="06_interference.html"><b>6</b> Interference and Information Capacity</a>
<a href="07_capacity.html"><b>7</b> Information Capacity</a>
<a href="08_capacity.html"><b>8</b> Information Capacity</a>
<a href="09_capacity.html"><b>9</b> Information Capacity</a>
<a href="10_capacity.html"><b>10</b> Information Capacity</a>
<a href="11_pathloss.html"><b>11</b> Path Loss</a>
<a href="12_pathloss_interference.html" class="selected"><b>12</b> Path Loss with Interference</a>
<a href="13_manual_avoidance.html"><b>13</b> Manual Interferer Avoidance</a>
<a href="" onclick="alert('Exercise 14: reserved for future use')"><b>14</b> SAS (Spectrum Access System)</a>
<a href="15_rule_based_avoidance.html"><b>15</b> Rule Based Interferer Avoidance</a>
<a href="16_programmable_avoidance.html"><b>16</b> Programmable Interferer Avoidance</a>
<a href="17_machine_learning_avoidance.html"><b>17</b> Machine Learning Interferer Avoidance</a>
<a href="18_machine_learning_time_based_avoidance.html"><b>18</b> Machine Learning With Periodic Interferer Avoidance</a>
<a href="19_rf_front_end_spectrum_sharing.html"><b>19</b> RF Front End Spectrum Sharing</a>
<a href="20_rf_front_end_spectrum_sharing.html"><b>20</b> Programmable RF Front End Spectrum Sharing</a>
<a href="21_rf_front_end_spectrum_sharing_with_interferer.html"><b>21</b> RF Front End Spectrum Sharing with Interferer</a>
<a href="22_rf_front_end_spectrum_sharing_with_interferer.html"><b>22</b> Programmable Spectrum Sharing with Interferer</a>
<a href="23_rf_front_end_spectrum_sharing_sliders_programmable.html"><b>23</b> RFFE Spectrum Sharing - Manual and Programmable</a>
<a href="25_rf_front_end_spectrum_sharing_menu.html"><b>25</b> RFFE Spectrum Sharing - Calculate SINR options menu</a>
<a href="26_rf_front_end_spectrum_sharing_ programmable.html"><b>26</b> RFFE Spectrum Sharing -- SINR Calculations Programmable</a>
</nav>
<label for="menu-control" class="sidebar__close"></label>
</aside>
<div style="margin-left: 6%; font-size: 1.3rem; margin-top: 0.3%; font-family: sans-serif; order: 1; width: inherit;"><span style="color: #ddd;">Exercise 12</span> Path Loss with Interference</div>
<div style="order: 2; margin-left: auto; margin-right: 2%; display: flex;">
<span style="font-size: 250%; font-family: monospace; letter-spacing: 2px; margin-left: auto; margin-right: 5px; color: #e6d9ba;"></span>
<div style="width: 20%;">
<img style="width: 100%;" src="images/wireless-logo.png">
</div>
</div>
</section>
<div class="content-section" id="slider_1_parent" style="margin-left: 1%; margin-top:8%;">
<p style="color: #62B9E4"><label>Distance = </label><output id="d0"></output>, <label>Path Loss = </label><output id="L0"></output> - User</p>
<p style="color: #EAB6B6"><label>Distance = </label><output id="d1"></output>, <label>Path Loss = </label><output id="L1"></output> - Interferer</p>
<p>
<label for="signal_to_int_noise_ratio">Signal to Interference & Noise Ratio: SINR = </label>
<output for="signal_to_int_noise_ratio" id="sinr"></output>
</p>
<p>
<label for="information_capacity">Information Capacity: C = </label>
<output for="information_capacity" id="cap"></output>
</p>
<p>
<label style="color: #62B9E4" for="frequency">Frequency</label>
<input class="width-4" type="range" min="-0.3" max="0.3" value="0.0" id="frequency" step="0.001"
oninput="update_display(parseFloat(value))">
<output for="frequency" id="fc"></output>
</p>
</div>
</body>
<!-- Load in the javascript libraries -->
<script src="d3.v5.min.js"></script>
<script src="fft.js"></script>
<script src="support.js"></script>
<script src="signal.js"></script>
<script src="iqPlot.js"></script>
<script>
// 2. Use the margin convention practice
var margin = {top: 10, right: 50, bottom: 50, left: 50}
, width = 720 - margin.left - margin.right // Use the window's width
, height = 320 - margin.top - margin.bottom; // Use the window's height
// options
var fs=40e6, f0=1800e6; // sample rate, center frequency
var bw = 0.3912234, fc = 0.0, gn = 20; // user values
var bw_int = 0.086, fc_int = -0.033, gn_int = 20; // interference values
var n0 = -80, sinr = 0, cap = 10;
var xrange=1200, yrange=200; // range in meters
var xmax =1150, ymax =180; // maximum values
var dmin = 10; // minimum distance between nodes for path loss calculation
var nfft = 2048, generator = new siggen(nfft);
generator.m = 80; // set filter semi-length
generator.beta = 2;
var lambda = 299.792458e6 / (fc*fs + f0); // wavelength in meters
// create a signal object
var sig = Signal(JSON.parse(JSON.stringify(conf.signal_multi)), '', {
gn_init: gn, // dB
bw_int: bw,
fc_int: fc,
mcs_init: 2, // array index int
});
// create IQ plot plot variable
const plot = {
width: 620, // total svg width in px
height: 260, // total svg height in px
margin: { top: 10, right: 30, bottom: 40, left: 60 }
};
// scale
var xScale = d3.scaleLinear().domain([-xrange, xrange]).range([0, width]);
var yScale = d3.scaleLinear().domain([-yrange, yrange]).range([height, 0]);
// inverted scale
var xInvScale = d3.scaleLinear().range([-xrange, xrange]).domain([0, width]);
var yInvScale = d3.scaleLinear().range([-yrange, yrange]).domain([height, 0]);
// determine time and frequency scale/units
var [scale_freq,units_freq] = scale_units(f0+fs/2,0.1); // freq scale
var fScale = d3.scaleLinear().domain([(f0-0.5*fs)*scale_freq, (f0+0.5*fs)*scale_freq]).range([0, width]);
var pScale = d3.scaleLinear().domain([-90, -20]).range([height, 0]);
// create SVG objects (map and frequency plot)
var svgm = svg_create(margin, width, height, xScale, yScale);
var svgf = svg_create(margin, width, height, fScale, pScale);
// add labels
svg_add_labels(svgm, margin, width, height, "Horizonal Position (m)", "Vertical Position (m)");
svg_add_labels(svgf, margin, width, height, "Frequency ("+units_freq+"Hz)", "Power Spectra Density (dB)");
// clip paths
svgf.append("clipPath").attr("id","clipf").append("rect").attr("width",width).attr("height",height);
// add pointer definition
var pointer = svgm.append("defs").append("g")
.attr("id","pointer")
.attr("transform","scale(0.8)");
pointer.append("path").attr("d","M0-1c-14.5-25.6-14.5-25.7-14.5-33.8c0-8.1,6.5-14.6,14.5-14.6s14.5,6.6,14.5,14.6C14.5-26.7,14.5-26.6,0-1z");
pointer.append("path").attr("d","M0-49c7.7,0,14,6.3,14,14.1c0,8,0,8.1-14,32.8c-14-24.7-14-24.9-14-32.8C-14-42.7-7.7-49,0-49 M0-50c-8.3,0-15,6.8-15,15.1 S-15-26.5,0,0c15-26.5,15-26.5,15-34.9S8.3-50,0-50L0-50z");
// create markers with default positions
var markers = [
{x:xScale(-xmax), y:yScale( ymax), c:"#039be5", b:"#004080"},
{x:xScale( 0), y:yScale( 0), c:"#03e539", b:"#008040"},
{x:xScale( 0), y:yScale(-ymax), c:"#9d7d7d", b:"#400000"},];
// spectrum data
var dataf = d3.range(0,nfft-1).map(function(f) { return {"y": 0 } })
// d3's line generator
var line = d3.line()
.x(function(d) { return d.x; })
.y(function(d) { return d.y; });
var linef = d3.line()
.x(function(d, i) { return fScale((f0+(i/nfft-0.5)*fs)*scale_freq); }) // map frequency
.y(function(d) { return pScale(d.y); }); // map PSD
// Append the path, bind the data, and call the line generator
var path = svgm.append("path")
.datum(markers)
.attr("class", "stroke-light no-fill dashed stroke-gray-0")
.attr("d", line);
var pathf = svgf.append("path")
.attr("clip-path","url(#clipf)")
.datum(dataf)
.attr("class", "stroke-med no-fill stroke-yellow")
.attr("d", linef);
// add markers with associated data
svgm.selectAll("use")
.data(markers)
.enter()
.append("use")
.attr("href","#pointer")
.attr("x", function(d) { return (d.x) })
.attr("y", function(d) { return (d.y) })
.attr("fill", function(d) { return (d.c) })
.attr("stroke", function(d) { return (d.b) })
.attr("class","pin");
var dragHandler = d3.drag()
.on("drag", function(d) {
d3.select(this)
.attr("x", d.x = Math.max(Math.min(d3.event.x,xScale(xmax)),xScale(-xmax)))
.attr("y", d.y = Math.min(Math.max(d3.event.y,yScale(ymax)),yScale(-ymax))); // min/max flipped for y-axis
update_display();
});
dragHandler(svgm.selectAll("use"));
// run initial update
update_display();
// generate power spectral density
function compute_pathloss(marker_a, marker_b)
{
let dx = xInvScale(marker_a.x) - xInvScale(marker_b.x);
let dy = yInvScale(marker_a.y) - yInvScale(marker_b.y);
let d = Math.max(dmin,Math.sqrt(dx**2 + dy**2));
return [d, 20*Math.log10(4*Math.PI*d/lambda)];
}
function update_display(freq) {
if(freq!=null) { fc = freq; }
function update_freq() {
document.querySelector('#fc').value = d3.format(".2f")((f0+fc*fs)*scale_freq) + " " + units_freq + "Hz";
document.querySelector('#frequency').value = fc;
}
update_freq();
// compute loss between appropriate nodes and update generator
let [d0, L0] = compute_pathloss(markers[0], markers[1]);
let [d1, L1] = compute_pathloss(markers[2], markers[1]);
// update generator, compensating for bandwidth
generator.clear();
generator.add_signal(fc, bw, gn -L0+10*Math.log10(bw) ); // user signal
generator.add_signal(fc_int,bw_int,gn_int-L1+10*Math.log10(bw_int)); // interference
generator.generate(n0); // generate with specific noise floor
dataf = d3.range(0,nfft-1).map(function(i) { return {"y": generator.psd[i] } })
pathf.datum(dataf).attr("d", linef);
// draw line between markers
path.datum(markers).attr("d", line);
// update ouput values
document.querySelector('#d0').value = d3.format(".3f")(d0) + " m";
document.querySelector('#L0').value = d3.format(".1f")(L0) + " dB";
document.querySelector('#d1').value = d3.format(".3f")(d1) + " m";
document.querySelector('#L1').value = d3.format(".1f")(L1) + " dB";
// compute and display SINR
let S = Math.pow(10.,(gn -L0)/10); // received signal power (linear)
let I = Math.pow(10.,(gn_int-L1)/10); // received interference power (linear)
let N = bw * Math.pow(10.,n0/10.); // noise power (linear)
// overlap will be the fraction of the interferer that overlaps.
let overlap;
let int_lower = fc_int - bw_int/2.0;
let int_upper = fc_int + bw_int/2.0;
let sig_lower = fc - bw/2.0;
let sig_upper = fc + bw/2.0;
if(int_lower > sig_upper || int_upper < sig_lower)
overlap = 0.0;
else {
// they overlap at least some.
if(int_lower < sig_lower)
int_lower = sig_lower;
if(int_upper > sig_upper)
int_upper = sig_upper;
overlap = (int_upper - int_lower)/bw;
}
//console.log("S = " + 10*Math.log10(S) + ", I = " + 10*Math.log10(I) + ", N = " + 10*Math.log10(N));
let SINRdB= 10*Math.log10(S/(N+ overlap * I));
document.querySelector('#sinr').value = d3.format(".2f")(SINRdB) + " dB";
// compute and display capacity
let C = fs * bw * Math.log2(1+Math.pow(10.,SINRdB/10.));
var [scale_cap,units_cap] = scale_units(C,0.1);
document.querySelector('#cap').value = d3.format(".1f")(C*scale_cap) + " " + units_cap + "bps";
}
// IQPlot(sig);
</script>
</html>