-
Notifications
You must be signed in to change notification settings - Fork 3
/
convert.html
456 lines (408 loc) · 16.1 KB
/
convert.html
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
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Convert</title>
<meta name="description" content="Convert one unit to another">
<meta name="author" content="SitePoint">
<meta property="og:title" content="Converter">
<meta property="og:type" content="website">
<meta property="og:url" content=" ">
<meta property="og:description" content="Convert one unit to another">
<meta property="og:image" content="image.png">
<link rel="icon" href="/favicon.ico">
<link rel="apple-touch-icon" sizes="57x57" href="img/apple-icon-57x57.png" />
<link rel="apple-touch-icon" sizes="72x72" href="img/apple-icon-72x72.png" />
<link rel="apple-touch-icon" sizes="114x114" href="img/apple-icon-114x114.png" />
<link rel="apple-touch-icon" sizes="144x144" href="img/apple-icon-144x144.png" />
<link href="css/bootstrap3.min.css" rel="stylesheet" type="text/css" media="all"/>
<script src="js/jquery-3.2.1.min.js"></script>
<script src="js/bootstrap3.min.js"></script>
<style>
body {
margin: 0;
padding: 0;
}
.maxwidth{
max-width: 200px !important;
}
.maxwidthp{
max-width: 120px !important;
}
.jumbotron {
padding-top: 10px !important;
padding-bottom: 10px !important;
}
</style>
</head>
<body>
<div class="jumbotron text-center">
<h3 style="color:red;">Convert</h3>
</div>
<div class="container">
<div class="row">
<div class="col-sm-12">
<h4 style="color:red;">Volts<>Watts<>dBm</h4>
<p></p>
<form class="form-inline">
<div class="form-group form-group-sm">
<label for="volts" style="color:blue;"> Volts(PtP):</label>
<input type="number" class="form-control maxwidth" id="volts">
</div>
<div class="form-group form-group-sm">
<label for="watts" style="color:blue;">Watts:</label>
<input type="number" class="form-control maxwidth" id="watts">
</div>
<div class="form-group form-group-sm">
<label for="dbm" style="color:blue;">dBm:</label>
<input type="number" class="form-control maxwidth" id="dbm">
</div>
<!-- <div class="checkbox">
<label><input type="checkbox"> Remember me</label>
</div> -->
<button type="button" style="color:blue;" onclick="convert()" class="btn btn-default">Convert</button>
<button type="button" style="color:blue;" onclick="clear1()" class="btn btn-default">Clear</button>
</form>
</div>
<div style="margin-top: 40px;" class="col-sm-12">
<h4 style="color:red;">milliVolts<>microTesla (using Beehive Probe)</h4>
<p></p>
<form class="form-inline">
<div class="form-group form-group-sm">
<label for="mvolts" style="color:blue;">milliVolts(PtP):</label>
<input type="number" class="form-control maxwidth" id="mvolts">
</div>
<div class="form-group form-group-sm">
<label for="utesla" style="color:blue;">microTesla:</label>
<input type="number" class="form-control maxwidth" id="utesla">
</div>
<!-- <div class="checkbox">
<label><input type="checkbox"> Remember me</label>
</div> -->
<button type="button" style="color:blue;" onclick="convert1()" class="btn btn-default">Convert</button>
<button type="button" style="color:blue;" onclick="clear2()" class="btn btn-default">Clear</button>
</form>
</div>
<div style="margin-top: 40px;" class="col-sm-12">
<h4 style="color:red;">Path Loss Calculator</h4>
<p></p>
<form class="form-inline">
<div class="form-group form-group-sm">
<label for="txpower" style="min-width:125px;color:blue;">Tx Power(dBm):</label>
<input type="number" class="form-control maxwidthp" id="txpower">
</div>
<div class="form-group form-group-sm">
<label style="min-width:125px; color:blue;" for="txgain" >Tx Ant. Gain (dBi):</label>
<input type="number" class="form-control maxwidthp" id="txgain">
</div>
<div class="form-group form-group-sm">
<label for="txfreq" style="min-width:125px;color:blue;">Frequency(MHz):</label>
<input type="number" class="form-control maxwidthp" id="txfreq">
</div>
<div class="form-group form-group-sm">
<label for="distance" style="min-width:125px; color:blue;">Distance(Meters):</label>
<input type="number" class="form-control maxwidthp" id="distance">
</div>
<div class="form-group form-group-sm">
<label for="rxgain" style="min-width:125px;color:blue;">Rx Ant. Gain (dBi):</label>
<input type="number" class="form-control maxwidthp" id="rxgain">
</div>
</form>
</div>
<div style="margin-top: 0px;" class="col-sm-12">
<form class="form-inline">
<div class="form-group form-group-sm">
<label for="rxpower" style="min-width:125px;color:red;">Rx Power (dBm):</label>
<input type="number" class="form-control maxwidthp" id="rxpower">
</div>
<div class="form-group form-group-sm">
<button type="button" style="color:blue;" onclick="convert2()" class="btn btn-default">Convert</button>
<button type="button" style="color:blue;" onclick="clear3()" class="btn btn-default">Clear</button>
</div>
</form>
</div>
<div style="margin-top: 40px;" class="col-sm-12">
<h4 style="color:red;">Freq<>C<>L</h4>
<p></p>
<form class="form-inline">
<div class="form-group form-group-sm">
<label for="mhz" style="color:blue;"> Frequency(MHz):</label>
<input type="number" class="form-control maxwidth" id="mhz">
</div>
<div class="form-group form-group-sm">
<label for="pf" style="color:blue;">C(pf):</label>
<input type="number" class="form-control maxwidth" id="pf">
</div>
<div class="form-group form-group-sm">
<label for="nh" style="color:blue;">L(nH):</label>
<input type="number" class="form-control maxwidth" id="nh">
</div>
<!-- <div class="checkbox">
<label><input type="checkbox"> Remember me</label>
</div> -->
<button type="button" style="color:blue;" onclick="convert_fcl()" class="btn btn-default">Convert</button>
<button type="button" style="color:blue;" onclick="clear_fcl()" class="btn btn-default">Clear</button>
</form>
</div>
</div>
</div>
<script>
var volts_present=false;
var watts_present=false;
var dbm_present=false;
var mvolts_present=false;
var utesla_present=false;
var mhz_present = false;
var nh_present = false;
var pf_present = false;
$.fn.enterKey = function (fnc) {
return this.each(function () {
$(this).keypress(function (ev) {
var keycode = (ev.keyCode ? ev.keyCode : ev.which);
if (keycode == '13') {
fnc.call(this, ev);
}
})
})
}
$(document).ready(function() {
console.log("ready!");
$("#txpower").val("0");
$("#txgain").val("21");
$("#txfreq").val("5650");
$("#rxgain").val("21");
$("#distance").val("");
$("#rxpower").val("");
$("#mhz").val("");
$("#pf").val("");
$("#nh").val("");
})
function convert(){
console.log("Convert button clicked!");
//$('#dbm').val("00");
if ($('#volts').val().length != 0) {
var volts = $("#volts").val();
if($.isNumeric(volts)) volts_present=true; else volts_present=false;
}else volts_present=false;
if ($('#watts').val().length != 0) {
var watts = $("#watts").val();
if($.isNumeric(watts)) watts_present=true; else watts_present=false;
} else watts_present=false;
if ($('#dbm').val().length != 0) {
var dbm = $("#dbm").val();
if($.isNumeric(dbm)) dbm_present=true; else dbm_present=false;
}else dbm_present=false;
if(volts_present){
var voltspeak = parseFloat($("#volts").val()/2.0);
var voltsrms = parseFloat(voltspeak / Math.sqrt(2));
var watts = parseFloat((voltsrms*voltsrms)/50.0);
var dbw = 10*Math.log10(watts);
var dbm = dbw+30;
watts = Number(watts).toFixed(4);
dbm = Number(dbm).toFixed(2);
$('#dbm').val(dbm);
$('#watts').val(watts);
}
else if(watts_present){
var watts = parseFloat($("#watts").val());
var dbw = 10*Math.log10(watts);
var dbm = dbw+30;
var voltsrms = parseFloat(Math.sqrt(watts*50))
var voltspeak = parseFloat(voltsrms * Math.sqrt(2));
var volts = parseFloat(voltspeak*2);
dbm = Number(dbm).toFixed(2);
volts = Number(volts).toFixed(4);
$('#dbm').val(dbm);
$('#volts').val(volts);
}
else if(dbm_present){
var dbm = parseFloat($("#dbm").val());
var dbw = parseFloat(dbm-30);
var dbw_div10 = parseFloat(dbw/10);
var watts = Math.pow(10,dbw_div10);
var voltsrms = parseFloat(Math.sqrt(watts*50))
var voltspeak = parseFloat(voltsrms * Math.sqrt(2));
var volts = parseFloat(voltspeak*2);
watts = Number(watts).toFixed(4);
volts = Number(volts).toFixed(4);
$('#watts').val(watts);
$('#volts').val(volts);
}
}
function clear1(){
console.log("Clear button clicked!");
$("#volts").val("");
$("#watts").val("");
$("#dbm").val("");
}
$("#volts").enterKey(function () {
console.log('volts entered');
$("#watts").val("");
$("#dbm").val("");
convert();
})
$("#dbm").enterKey(function () {
console.log('dbm entered');
$("#watts").val("");
$("#volts").val("");
convert();
})
$("#watts").enterKey(function () {
console.log('watts entered');
$("#volts").val("");
$("#dbm").val("");
convert();
})
function convert1(){
console.log("Convert1 button clicked!");
if ($('#mvolts').val().length != 0) {
var mvolts = $("#mvolts").val();
if($.isNumeric(mvolts)) mvolts_present=true; else mvolts_present=false;
}else mvolts_present=false;
if ($('#utesla').val().length != 0) {
var utesla = $("#utesla").val();
if($.isNumeric(utesla)) utesla_present=true; else utesla_present=false;
} else utesla_present=false;
// dbM = X + 20Log10(B) + 20log10(F) X = 64.35 F in MHZ B in Tesla
if(mvolts_present){
var mvoltspeak = parseFloat($("#mvolts").val()/2.0);
var voltspeak = parseFloat(mvoltspeak/1000);
var voltsrms = parseFloat(voltspeak / Math.sqrt(2));
var watts = parseFloat((voltsrms*voltsrms)/50.0);
var dbw = parseFloat(10*Math.log10(watts));
var dbm = parseFloat(dbw+30);
var X = parseFloat(64.35);
twentylogTesla = dbm-X-20*Math.log10(27.12);
var tesla = Math.pow(10,(twentylogTesla/20));
var utesla = tesla*1000000;
utesla = Number(utesla).toFixed(4);
$('#utesla').val(utesla);
}
else if(utesla_present){
var X = parseFloat(64.35);
var tesla = parseFloat($("#utesla").val()/1000000);
var dbm = X + 20*Math.log10(tesla)+ 20*Math.log10(27.12);
var dbw = parseFloat(dbm-30);
var dbw_div10 = parseFloat(dbw/10);
var watts = Math.pow(10,dbw_div10);
var voltsrms = parseFloat(Math.sqrt(watts*50))
var voltspeak = parseFloat(voltsrms * Math.sqrt(2));
var voltsp2p = parseFloat(voltspeak*2);
var mvolts = voltsp2p*1000;
mvolts = Number(mvolts).toFixed(4);
$('#mvolts').val(mvolts);
}
}
$("#mvolts").enterKey(function () {
console.log('mvolts entered');
$("#utesla").val("");
convert1();
})
$("#utesla").enterKey(function () {
console.log('utesla entered');
$("#mvolts").val("");
convert1();
})
function clear2(){
console.log("Clear2 button clicked!");
$("#mvolts").val("");
$("#utesla").val("");
}
function convert2(){
console.log("Convert2 button clicked!");
if ($('#txpower').val().length != 0 && $('#txgain').val().length != 0 &&
$('#txfreq').val().length != 0 && $('#rxgain').val().length != 0 &&
$('#distance').val().length != 0){
var txpower = parseFloat($("#txpower").val());
var txgain = parseFloat($("#txgain").val());
var txfreq = parseFloat($("#txfreq").val());
var rxgain = parseFloat($("#rxgain").val());
var distance = parseFloat($("#distance").val());
var lambda = parseFloat(parseFloat(2.99792458*100)/parseFloat(txfreq*1));
var rxpower = parseFloat(txpower+txgain+rxgain+(20*Math.log10(lambda/parseFloat(4*Math.PI*distance))));
rxpower = Number(rxpower).toFixed(2);
$('#rxpower').val(rxpower);
}
}
function clear3(){
console.log("Clear3 button clicked!");
$("#txpower").val("");
$("#txgain").val("");
$("#txfreq").val("");
$("#rxgain").val("");
$("#distance").val("");
$("#rxpower").val("");
}
function clear_fcl(){
console.log("Clear button clicked!");
$("#mhz").val("");
$("#pf").val("");
$("#nh").val("");
}
$("#mhz").enterKey(function () {
console.log('mhz entered');
$("#nh").val("");
$("#pf").val("");
convert_fcl();
})
$("#pf").enterKey(function () {
console.log('pf entered');
$("#mhz").val("");
$("#nh").val("");
convert_fcl();
})
$("#nh").enterKey(function () {
console.log('nh entered');
$("#pf").val("");
$("#mhz").val("");
convert_fcl();
})
function convert_fcl(){
console.log("Convert_fcl button clicked!");
//$('#dbm').val("00");
if ($('#mhz').val().length != 0) {
var mhz = $("#mhz").val();
if($.isNumeric(mhz)) mhz_present=true; else mhz_present=false;
}else mhz_present=false;
if ($('#pf').val().length != 0) {
var pf = $("#pf").val();
if($.isNumeric(pf)) pf_present=true; else pf_present=false;
} else pf_present=false;
if ($('#nh').val().length != 0) {
var nh = $("#nh").val();
if($.isNumeric(nh)) nh_present=true; else nh_present=false;
}else nh_present=false;
if(mhz_present && pf_present){
var hz = parseFloat($("#mhz").val()* Math.pow(10,6));
var f = parseFloat($("#pf").val()* Math.pow(10,-12));
var h = parseFloat(1/(2*Math.PI*hz*Math.sqrt(f)));
h = h*h;
var nh = Number(h * Math.pow(10,9)).toFixed(2);
$('#nh').val(nh);
}
else if(pf_present && nh_present){
var n = parseFloat($("#nh").val()* Math.pow(10,-9));
var f = parseFloat($("#pf").val()* Math.pow(10,-12));
var hz = parseFloat(1/(2*Math.PI*Math.sqrt(n)*Math.sqrt(f)));
hz = Number(hz * Math.pow(10,-6)).toFixed(2);
$('#mhz').val(hz);
}
else if(nh_present && mhz_present){
var hz = parseFloat($("#mhz").val()* Math.pow(10,6));
var h = parseFloat($("#nh").val()* Math.pow(10,-9));
var f = parseFloat(1/(2*Math.PI*hz*Math.sqrt(h)));
f = f*f;
var pf = Number(f * Math.pow(10,12)).toFixed(2);
$('#pf').val(pf);
}
}
</script>
</body>
</html>