-
Notifications
You must be signed in to change notification settings - Fork 1
/
abeeway_battery_standalone.html
736 lines (592 loc) · 32.4 KB
/
abeeway_battery_standalone.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
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
<!DOCTYPE html>
<html>
<head>
<title>Abeeway battery life-time calculator</title>
<meta>
<link rel=icon href=https://www.abeeway.com/wp-content/uploads/2020/01/favicon.png sizes=32x32>
<link rel=icon href=https://www.abeeway.com/wp-content/uploads/2020/01/favicon.png sizes=192x192>
<link rel=apple-touch-icon href=https://www.abeeway.com/wp-content/uploads/2020/01/favicon.png>
</meta>
<style>
html {
margin: 10px;
font-family: sans-serif, Arial, Helvetica;
font-size: 90%;
}
h1 {
color: #008293;
}
legend {
color: #008293;
font-weight: bold;
font-size: 100%;
}
.flexcontainer {
display: flex;
flex-flow: row wrap;
justify-content: flex-start;
align-items: stretch;
align-content: flex-start
}
.flexitem {
flex-flow: 1 1 1;
padding: 4px;
box-sizing: border-box;
min-width: 200px;
}
.flexitem1 {
flex-flow: 1 1 1;
padding: 4px;
box-sizing: border-box;
min-width: 196px;
}
input[type="text"], input[type="number"], select, button, textarea {
width: 100%;
padding: 2px 3px 2px 3px;
margin-bottom: 10px;
box-sizing: border-box;
}
textarea {
width: 392px;
height: 150px;
padding: 2px 3px 2px 3px;
margin-bottom: 10px;
box-sizing: border-box;
}
.radiogroup {
margin-bottom: 10px;
}
</style>
</head>
<body>
<img src="https://www.abeeway.com/wp-content/uploads/2019/06/Abeeway_LOGO_blue-small.png" alt="Abeeway Logo" height=40px>
<h1>Abeeway battery life-time calculator</h1>
<p>
The results as an output of this tool can vary from the field due to impact of environment and other ambient factors.</br>
The values that should be entered should be typical average usage of the tracker and NOT worst case scenario.</br>
<i>For example do not enter the maximum convergence time of the GNSS, but the average convergence time that you observe for the given target EHPE.</i>
</p>
<div class="flexcontainer">
<fieldset class='flexcontainer flexitem'>
<legend>General config params:</legend>
<div class='flexitem1'>
<label for="product">Product:</label><br />
<select id="product" name="product">
<option value="industrial">Industrial Tracker</option>
<option value="compact">Compact Tracker</option>
<option value="micro">Microtracker</option>
<option value="smart_badge" selected>Smart Badge</option>
</select><br />
<label for="tx_power">Tx power:</label><br />
<select id="tx_power" name="tx_power">
<option value="_14dBm_">14dBm</option>
<option value="_17dBm_">17dBm</option>
<option value="_19dBm_">19dBm</option>
</select><br />
<label for="sf">Spreading Factor:</label><br />
<select id="sf" name="sf">
<option value="7">SF7</option>
<option value="8">SF8</option>
<option value="9">SF9</option>
<option value="10" selected>SF10</option>
<option value="11">SF11</option>
<option value="12">SF12</option>
</select><br />
</div>
<div class='flexitem1'>
<label for="nof_msg_repetition">N. of times every msg sent:</label><br />
<select id="nof_msg_repetition" name="nof_msg_repetition">
<option value=1 selected>1</option>
<option value=2>2</option>
<option value=3>3</option>
<option value=4>4</option>
</select><br />
<label for="accelerometer_on">Accelerometer On:</label>
<input type="checkbox" id="accelerometer_on" name="accelerometer_on" checked><br />
</div>
</fieldset>
<fieldset class='flexitem'>
<legend>Custom messages:</legend>
<label for="custom_msg_nof_msg_per_day">Num. of msg/day:</label><br />
<input type="number" min="0" id="custom_msg_nof_msg_per_day" name="custom_msg_nof_msg_per_day" value="0"><br />
<label for="custom_msg_payl_len">Payload length [byte]:</label><br />
<input type="number" min="0" id="custom_msg_payl_len" name="custom_msg_payl_len" value="17">
</fieldset>
<fieldset class='flexitem'>
<legend>Heartbeat messages:</legend>
<label for="heartbeat_nof_msg_per_day">Num. of msg/day:</label><br />
<input type="number" min="0" id="heartbeat_nof_msg_per_day" name="heartbeat_nof_msg_per_day" value="0"><br />
</fieldset>
<fieldset class='flexitem'>
<legend>GPS location updates:</legend>
<label for="gps_nof_msg_per_day">Num. of update/day:</label><br />
<input type="number" min="0" id="gps_nof_msg_per_day" name="gps_nof_msg_per_day" value="0"><br />
<label for="gps_ttff">Time to first fix [s]:</label><br />
<input type="number" min="0" id="gps_ttff" name="gps_ttff" value="49"><br />
<label for="gps_conv_time">GPS convergence time [s]:</label><br />
<input type="number" min="0" id="gps_conv_time" name="gps_conv_time" value="90"><br />
</fieldset>
<fieldset class='flexitem'>
<legend>AGPS location updates:</legend>
<label for="agps_nof_msg_per_day">Num. of update/day:</label><br />
<input type="number" min="0" id="agps_nof_msg_per_day" name="agps_nof_msg_per_day" value="0"><br />
<label for="agps_on_time">AGPS on time [s]:</label><br />
<input type="number" min="0" id="agps_on_time" name="agps_on_time" value="8"><br />
<label for="agps_nof_satellites">Num. of satellites:</label><br />
<select id="agps_nof_satellites" name="agps_nof_satellites">
<option value=1>1</option>
<option value=2>2</option>
<option value=3>3</option>
<option value=4>4</option>
<option value=5 selected>5</option>
</select>
</fieldset>
<fieldset class='flexitem'>
<legend>WiFi location updates:</legend>
<label for="wifi_nof_msg_per_day">Num. of update/day:</label><br />
<input type="number" min="0" id="wifi_nof_msg_per_day" name="wifi_nof_msg_per_day" value="0"><br />
<label for="wifi_nof_bssid">Num. of BSSID/msg:</label><br />
<select id="wifi_nof_bssid" name="wifi_nof_bssid">
<option value=1>1</option>
<option value=2>2</option>
<option value=3>3</option>
<option value=4 selected>4</option>
</select>
</fieldset>
<fieldset class='flexitem'>
<legend>BLE location updates:</legend>
<label for="ble_nof_msg_per_day">Num. of update/day:</label><br />
<input type="number" min="0" id="ble_nof_msg_per_day" name="ble_nof_msg_per_day" value="0"><br />
<label for="ble_nof_beaconid">Num. of beacon ID/msg:</label><br />
<select id="ble_nof_beaconid" name="ble_nof_beaconid">
<option value=1>1</option>
<option value=2>2</option>
<option value=3>3</option>
<option value=4 selected>4</option>
</select><br />
</fieldset>
<fieldset class='flexitem'>
<legend>Custom BLE usage:</legend>
<label for="custom_ble_usage_time_per_day">Usage per day [hour]:</label><br />
<input type="number" min="0" id="custom_ble_usage_time_per_day" name="custom_ble_usage_time_per_day" value="0"><br />
<label for="custom_ble_operation">BLE operation:</label><br />
<select id="custom_ble_operation" name="custom_ble_operation">
<option value="fast_adv">Fast advertisement (2s)</option>
<option value="slow_adv">Slow advertisement (10s)</option>
<option value="connected">Connected (2s)</option>
<option value="slow_scan">Slow BLE scan (30sec)</option>
<option value="fast_scan">Fast BLE scan (8sec)</option>
</select><br />
</fieldset>
<fieldset class='flexcontainer flexitem'>
<legend>Scan collection reports:</legend>
<div class='flexitem1'>
<label for="scancoll_nof_msg_per_day">Num. of report/day:</label><br />
<input type="number" min="0" id="scancoll_nof_msg_per_day" name="scancoll_nof_msg_per_day" value="0"><br />
<div id="scancoll_tech_radiogroup" class="radiogroup">
Applied technology:<br />
<input
type="radio" id="scancoll_tech_ble" name="scancoll_tech" value="BLE" checked
onchange = "javascript:document.getElementById('scancoll_idtype_radiogroup').style.display='block'"
>
<label for="male">BLE</label>
<input
type="radio" id="scancoll_tech_wifi" name="scancoll_tech" value="WiFi"
onchange = "javascript:document.getElementById('scancoll_idtype_radiogroup').style.display='none'">
<label for="female">WiFi</label><br>
</div>
<div id="scancoll_idtype_radiogroup" class="radiogroup">
BLE ID Type:<br />
<input type="radio" id="scancoll_idtype_mac" name="scancoll_idtype" value="MAC" checked>
<label for="male">MAC Addr (6 bytes)</label><br />
<input type="radio" id="scancoll_idtype_id" name="scancoll_idtype" value="ID">
<label for="female">Beacon ID (2 bytes)</label><br>
</div>
</div>
<div class='flexitem1'>
<label for="scancoll_max_payl_len">Max. payload len. [byte]:</label><br />
<select id="scancoll_max_payl_len" name="scancoll_max_payl_len">
<option value=36>36 (SF12..SF10)</option>
<option value=92>92 (SF9..SF7)</option>
</select><br />
<label for="scancoll_nof_id">Num. of ID/msg:</label><br />
<select id="scancoll_nof_id" name="scancoll_nof_id">
<option value=1>1</option>
<option value=2>2</option>
<option value=3>3</option>
<option value=4>4</option>
<option value=5>5</option>
<option value=6>6</option>
<option value=7>7</option>
<option value=8 selected>8</option>
<option value=9>9</option>
<option value=10>10</option>
<option value=11>11</option>
<option value=12>12</option>
<option value=13>13</option>
<option value=14>14</option>
<option value=15>15</option>
<option value=16>16</option>
<option value=17>17</option>
<option value=18>18</option>
<option value=19>19</option>
<option value=20>20</option>
</select><br />
</div>
</fieldset>
<!-- Will be implemented soon!!! -->
<!--
<fieldset class='flexitem'>
<legend>Proximity detection:</legend>
<label for="proximity_usage_time_per_day">Usage per day [hour]:</label><br />
<input type="number" min="0" id="proximity_usage_time_per_day" name="proximity_usage_time_per_day" value="0"><br />
<label for="proximity_alarms_per_day">Num. of alarms per day :</label><br />
<input type="number" min="0" id="proximity_alarms_per_day" name="proximity_alarms_per_day" value="10"><br />
<label for="proximity_warnings_per_day">Num. of warnings per day :</label><br />
<input type="number" min="0" id="proximity_warnings_per_day" name="proximity_warnings_per_day" value="20"><br />
</fieldset>
-->
<fieldset class='flexitem'>
<legend>Calculation:</legend>
<button onClick = "calculate()">Calculate</button><br />
<label for="result">Result:</label><br />
<textarea id="result"></textarea>
</fieldset>
</div>
</body>
<script>
/*********************************************************************/
/***** GUI SCRIPTS *****/
/*********************************************************************/
function calculate() {
let input = {
product: document.getElementById('product').value, // industrial|compact|micro|smart_badge
tx_power: document.getElementById('tx_power').value, // _14dBm_|_17dBm_|_19dBm
sf: parseInt(document.getElementById('sf').value), // 7|8|9|10|11|12
nof_msg_repetition: parseInt(document.getElementById('nof_msg_repetition').value),
accelerometer_on: document.getElementById('accelerometer_on').checked,
custom_msg: {
nof_msg_per_day: parseInt(document.getElementById('custom_msg_nof_msg_per_day').value),
payl_len: parseInt(document.getElementById('custom_msg_payl_len').value), // [bytes]
},
heartbeat: {
nof_msg_per_day: parseInt(document.getElementById('heartbeat_nof_msg_per_day').value),
},
gps: {
nof_msg_per_day: parseInt(document.getElementById('gps_nof_msg_per_day').value),
ttff: parseFloat(document.getElementById('gps_ttff').value), // [s]
conv_time: parseFloat(document.getElementById('gps_conv_time').value), // [s]
},
agps: {
nof_msg_per_day: parseInt(document.getElementById('agps_nof_msg_per_day').value),
on_time: parseFloat(document.getElementById('agps_on_time').value), // [s]
nof_satellites: parseInt(document.getElementById('agps_nof_satellites').value),
},
wifi: {
nof_msg_per_day: parseInt(document.getElementById('wifi_nof_msg_per_day').value),
nof_bssid: parseInt(document.getElementById('wifi_nof_bssid').value),
},
ble: {
nof_msg_per_day: parseInt(document.getElementById('ble_nof_msg_per_day').value),
nof_beaconid: parseInt(document.getElementById('ble_nof_beaconid').value),
},
custom_ble: {
usage_time_per_day: parseFloat(document.getElementById('custom_ble_usage_time_per_day').value),
operation: document.getElementById('custom_ble_operation').value, // fast_adv|slow_adv|connected|fast_scan|slow_scan
},
scan_collection: {
nof_msg_per_day: parseInt(document.getElementById('scancoll_nof_msg_per_day').value),
tech: document.getElementById('scancoll_tech_ble').checked ? "BLE" : "WiFi",
idtype: document.getElementById('scancoll_tech_ble').checked && document.getElementById('scancoll_idtype_id').checked ? "ID" : "MAC",
max_payl_len: parseInt(document.getElementById('scancoll_max_payl_len').value),
nof_id: parseInt(document.getElementById('scancoll_nof_id').value),
},
// The following parameters will be implemented soon!!!
/*
proximity: {
usage_time_per_day: document.getElementById('proximity_usage_time_per_day').value,
alarms_per_day: document.getElementById('proximity_alarms_per_day').value,
warnings_per_day: document.getElementById('proximity_warnings_per_day').value,
}
*/
};
let result = calculate_battery_life_time(input);
// document.getElementById('result').value = JSON.stringify(result, null, 2);
let result_text = "Battery life time: " + result.battery_life_time + " days (" + (result.battery_life_time/365).toFixed(2) + " years)\n";
result_text += "Energy distribution:\n";
if (result.current_distribution.custom_msg > 0) {
result_text += " Custom msg: " + result.current_distribution.custom_msg + " %\n";
}
if (result.current_distribution.heartbeat > 0) {
result_text += " Heartbeat: " + result.current_distribution.heartbeat + " %\n";
}
if (result.current_distribution.gps > 0) {
result_text += " GPS: " + result.current_distribution.gps + " %\n";
}
if (result.current_distribution.agps > 0) {
result_text += " AGPS: " + result.current_distribution.agps + " %\n";
}
if (result.current_distribution.wifi > 0) {
result_text += " WiFi: " + result.current_distribution.wifi + " %\n";
}
if (result.current_distribution.ble > 0) {
result_text += " BLE: " + result.current_distribution.ble + " %\n";
}
if (result.current_distribution.custom_ble > 0) {
result_text += " Custom BLE: " + result.current_distribution.custom_ble + " %\n";
}
if (result.current_distribution.scan_collection > 0) {
result_text += " Scan Collection: " + result.current_distribution.scan_collection + " %\n";
}
if (result.current_distribution.accelerometer > 0) {
result_text += " Accelerometer: " + result.current_distribution.accelerometer + " %\n";
}
if (result.current_distribution.quiesent_and_battery_leakage > 0) {
result_text += " Quiesent and Battery leakage: " + result.current_distribution.quiesent_and_battery_leakage + " %\n";
}
document.getElementById('result').value = result_text;
}
</script>
<script>
/*********************************************************************/
/***** BATTERY LIFE CALCULATION SCRIPTS *****/
/*********************************************************************/
/* GLOBAL CONSTANTS */
const SPREADING_FACTORS = [7, 8, 9, 10, 11, 12]
const BATTERY_TYPES = {
primary: {
descr: 'Primary (LTC)',
leakage_per_month: 0.003, // =0.3%
practical_capacity_multiplier: 0.80 // =80%
},
rechargeable: {
descr: 'Rechargeable (Li-Po)',
leakage_per_month: 0.05, // =5%
practical_capacity_multiplier: 0.90 // =90%
},
};
const PRODUCTS = {
industrial: {
descr: 'Industrial Tracker',
battery: {
nominal_capacity: 19000, // [mAh]
practical_capacity: 19000 * BATTERY_TYPES.primary.practical_capacity_multiplier, // [mAh]
leakage_per_month: BATTERY_TYPES.primary.leakage_per_month, // ratio
}
},
compact: {
descr: 'Compact Tracker',
battery: {
nominal_capacity: 8000, // [mAh]
practical_capacity: 8000 * BATTERY_TYPES.primary.practical_capacity_multiplier, // [mAh]
leakage_per_month: BATTERY_TYPES.primary.leakage_per_month, // ratio
}
},
micro: {
descr: 'Microtracker',
battery: {
nominal_capacity: 450, // [mAh]
practical_capacity: 450 * BATTERY_TYPES.rechargeable.practical_capacity_multiplier, // [mAh]
leakage_per_month: BATTERY_TYPES.rechargeable.leakage_per_month, // ratio
}
},
smart_badge: {
descr: 'Smart Badge',
battery: {
nominal_capacity: 1300, // [mAh]
practical_capacity: 1300 * BATTERY_TYPES.rechargeable.practical_capacity_multiplier, // [mAh]
leakage_per_month: BATTERY_TYPES.rechargeable.leakage_per_month, // ratio
}
},
}
const BLE_OPERATIONS = {
fast_adv: { descr: 'Fast advertisement (2s)', time: 2, current: 10 }, // [s], [mA]
slow_adv: { descr: 'Slow advertisement (10s)', time: 10, current: 3.5 }, // [s], [mA]
connected: { descr: 'Connected (2s)', time: 2, current: 3.6 }, // [s], [mA]
fast_scan: { descr: 'Fast BLE scan (8sec)', time: 8, current: 2 }, // [s], [mA]
slow_scan: { descr: 'Slow BLE scan (30sec)', time: 30, current: 0.5 }, // [s], [mA]
};
const TX_POWERS = {
_14dBm_: { descr: '14 dBm', current: 45 }, // SX1262 TX [mA]
_17dBm_: { descr: '17 dBm', current: 75 }, // SX1262 TX [mA]
_19dBm_: { descr: '19 dBm', current: 85 }, // SX1262 TX [mA]
}
const SUPPLY_VOLTAGE = 3.6; // Supply voltage [V]
const MCU_CURRENT = 0.3; // Current MCU in active mode [mA]
const RX_CURRENT = 10; // Current SX1262 RX [mA]
const GPS_CURRENT = 22; // Current GPS [mA]
const GPS_STANDBY_CURRENT = 0.05; // Current GPS Stand-by [mA]
const WIFI_CURRENT = 60; // Current WiFi [mA]
const WIFI_ON_TIME = 3; // WIFI ON time [s]
const BLE_CURRENT = 10; // Current BLT [mA]
const BLE_ON_TIME = 3; // WIFI ON time [s]
// The following parameters will be implemented soon !!!
const PROXIMITY_DET_CURRENT = 10; // [mA] // TODO: TO BE DEFINED BY STEPHANE!!!
const BUZZER_CURRENT = 100; // [mA] // TODO: TO BE DEFINED BY STEPHANE!!!
const BUZZER_TIME = 0.5; // [s] // TODO: TO BE DEFINED BY STEPHANE!!!
const ACCELEROMETER_CURRENT = 0.0065; // Accelerometer [mA] (=6.5 uA)
const QUIESENT_CURRENT = 0.0010; // [mA] (=10 uA)
const HEARTBEAT_PAYL_LEN = 12; // [bytes]
const GPS_PAYL_LEN = 16; // [bytes]
const AGPS_MIN_PAYL_LEN = 6; // [bytes]
const AGPS_ADDITIONAL_SAT_PAYL_LEN = 5; // [bytes]
const WIFI_MIN_PAYL_LEN = 6; // [bytes]
const WIFI_ADDITIONAL_BSSID_PAYL_LEN = 7; // [bytes]
const BLE_MIN_PAYL_LEN = 6; // [bytes]
const BLE_ADDITIONAL_BSSID_PAYL_LEN = 7; // [bytes]
const SCANCOLL_MIN_PAYL_LEN = 8; // [bytes]
const SCANCOLL_ADDITIONAL_MACADDR_PAYL_LEN = 7; // [bytes]
const SCANCOLL_ADDITIONAL_BEACONID_PAYL_LEN = 4; // [bytes]
/* CALCULATION FUNCTIONS */
function calculate_lora_current(sf, tx_power, payl_len, nof_msg_per_day) {
const SYMBOL_TIME = (2**sf)/125; // [ms]
const PREAMBLE_TIME = 12.25 * SYMBOL_TIME; // [ms]
let time_on_air; // [ms]
if (sf >= 11) {
time_on_air = SYMBOL_TIME*(8+Math.ceil(((payl_len+12)*8-4*(sf-7)+16)/(4*sf-8))*5);
} else {
time_on_air = SYMBOL_TIME*(8+Math.ceil(((payl_len+12)*8-4*(sf-7)+16)/(4*sf-0))*5);
}
const total_time_on_air = time_on_air + PREAMBLE_TIME;
// all following energy values are in [mJ]
const tx_energy = total_time_on_air * SUPPLY_VOLTAGE * TX_POWERS[tx_power].current / 1000;
const rx_energy = 2 * 8*SYMBOL_TIME * SUPPLY_VOLTAGE * RX_CURRENT / 1000; // 2 RX windows are open after every tx
const mcu_energy = (total_time_on_air + 2000) * SUPPLY_VOLTAGE * MCU_CURRENT / 1000; // The MCU cannot sleep until the 2 RX windows are opened
const total_energy_per_transmission = tx_energy + rx_energy + mcu_energy;
const average_current = (total_energy_per_transmission / SUPPLY_VOLTAGE) * ( nof_msg_per_day / (24*3600)) // [mA]
return average_current // in [mA]
}
function calculate_gps_current(gps_ttff, gps_conv_time, nof_msg_per_day) {
const gps_usage_time_of_cold_start = Math.min(gps_ttff + gps_conv_time, 300);
const average_current_with_cold_starts_only = gps_usage_time_of_cold_start * GPS_CURRENT * nof_msg_per_day / (24 *3600);
const average_current_with_hot_starts = ( // we assume that there is only one cold start per day
gps_usage_time_of_cold_start * GPS_CURRENT + // 1st time there is a cold start
(nof_msg_per_day - 1) * gps_conv_time * GPS_CURRENT + // all the rest of the gps updates are with hot start
(24 * 3600 - gps_conv_time * nof_msg_per_day) * GPS_STANDBY_CURRENT // the gps board is in standby status in between
) / (24 * 3600)
const average_current = Math.min(average_current_with_cold_starts_only, average_current_with_hot_starts); // [mA]
return average_current; // in [mA]
}
function calculate_agps_current(agps_on_time, nof_msg_per_day) {
const average_current = agps_on_time * GPS_CURRENT * nof_msg_per_day / (24*3600); // [mA]
return average_current; // in [mA]
}
function calculate_wifi_current(nof_msg_per_day) {
const average_current = WIFI_ON_TIME * WIFI_CURRENT * nof_msg_per_day / (24*3600); // [mA]
return average_current; // in [mA]
}
function calculate_ble_current(nof_msg_per_day) {
const average_current = BLE_ON_TIME * BLE_CURRENT * nof_msg_per_day / (24*3600); // [mA]
return average_current; // in [mA]
}
function calculate_scancollection_current(sf, nof_msg_per_day, tech, idtype, nof_id) {
let average_current = 0;
if (tech == "WiFi") {
average_current = calculate_wifi_current(nof_msg_per_day)
}
if (tech == "BLE") {
average_current = calculate_ble_current(nof_msg_per_day)
}
return average_current; // in [mA]
}
function calculate_custom_ble_usage_current(operation, usage_time_per_day) {
const average_current = BLE_OPERATIONS[operation].current * usage_time_per_day / ( 24 ); // [mA]
return average_current; // [mA]
}
function calculate_accelerometer_current(accelerometer_on) {
if (accelerometer_on) {
return ACCELEROMETER_CURRENT;
} else {
return 0;
}
}
function calculate_battery_leakage_current(product) {
const battery_capacity = PRODUCTS[product].battery.nominal_capacity; // [mAh]
const battery_leakage_per_month = PRODUCTS[product].battery.leakage_per_month; // ratio
const average_current = (battery_capacity / 2) * ( battery_leakage_per_month /(30*24) ) // [mA]
return average_current // [mA]
}
function calculate_battery_life_time(input) {
const custom_msg_lora_current = input.nof_msg_repetition * calculate_lora_current(input.sf, input.tx_power, input.custom_msg.payl_len, input.custom_msg.nof_msg_per_day);
const heartbeat_lora_current = input.nof_msg_repetition * calculate_lora_current(input.sf, input.tx_power, HEARTBEAT_PAYL_LEN, input.heartbeat.nof_msg_per_day);
const gps_lora_current = input.nof_msg_repetition * calculate_lora_current(input.sf, input.tx_power, GPS_PAYL_LEN, input.gps.nof_msg_per_day);
const agps_lora_current = input.nof_msg_repetition * calculate_lora_current(
input.sf, input.tx_power,
AGPS_MIN_PAYL_LEN + (input.agps.nof_satellites * AGPS_ADDITIONAL_SAT_PAYL_LEN),
input.agps.nof_msg_per_day
);
const wifi_lora_current = input.nof_msg_repetition * calculate_lora_current(
input.sf, input.tx_power,
WIFI_MIN_PAYL_LEN + (input.wifi.nof_bssid * WIFI_ADDITIONAL_BSSID_PAYL_LEN),
input.wifi.nof_msg_per_day
);
const ble_lora_current = input.nof_msg_repetition * calculate_lora_current(
input.sf, input.tx_power,
BLE_MIN_PAYL_LEN + (input.ble.nof_beaconid * BLE_ADDITIONAL_BSSID_PAYL_LEN),
input.ble.nof_msg_per_day
);
let scancoll_additional_payl_len;
if ((input.scan_collection.tech == "BLE") && (input.scan_collection.idtype == "ID")) {
scancoll_additional_payl_len = SCANCOLL_ADDITIONAL_BEACONID_PAYL_LEN;
} else {
scancoll_additional_payl_len = SCANCOLL_ADDITIONAL_MACADDR_PAYL_LEN;
}
let nof_id_in_full_msg = Math.floor((input.scan_collection.max_payl_len - SCANCOLL_MIN_PAYL_LEN) / scancoll_additional_payl_len);
let nof_id_last_msg = input.scan_collection.nof_id % nof_id_in_full_msg
let nof_full_fragments = Math.floor(input.scan_collection.nof_id / nof_id_in_full_msg);
let scan_collection_lora_current = calculate_lora_current(
input.sf, input.tx_power,
( SCANCOLL_MIN_PAYL_LEN + (nof_id_in_full_msg * scancoll_additional_payl_len) ),
nof_full_fragments * input.scan_collection.nof_msg_per_day
);
scan_collection_lora_current += calculate_lora_current(
input.sf, input.tx_power,
( SCANCOLL_MIN_PAYL_LEN + (nof_id_last_msg * scancoll_additional_payl_len) ),
input.scan_collection.nof_msg_per_day
);
scan_collection_lora_current *= input.nof_msg_repetition;
const gps_geoloc_current = calculate_gps_current(input.gps.ttff, input.gps.conv_time, input.gps.nof_msg_per_day);
const agps_geoloc_current = calculate_agps_current(input.agps.on_time, input.agps.nof_msg_per_day);
const wifi_geoloc_current = calculate_wifi_current(input.wifi.nof_msg_per_day);
const ble_geoloc_current = calculate_ble_current(input.ble.nof_msg_per_day);
const custom_ble_usage_current = calculate_custom_ble_usage_current(input.custom_ble.operation, input.custom_ble.usage_time_per_day);
const scan_collection_current = calculate_scancollection_current(
input.sf, input.scan_collection.nof_msg_per_day, input.scan_collection.tech,
input.scan_collection.idtype, input.scan_collection.nof_id
);
const accelerometer_current = calculate_accelerometer_current(input.accelerometer_on);
const average_battery_leakage = calculate_battery_leakage_current(input.product);
const total_lora_current = custom_msg_lora_current + heartbeat_lora_current + gps_lora_current + agps_lora_current + wifi_lora_current + ble_lora_current + scan_collection_lora_current;
const total_fix_current = QUIESENT_CURRENT + average_battery_leakage;
const total_current = (
total_lora_current +
ble_geoloc_current + gps_geoloc_current + agps_geoloc_current + wifi_geoloc_current +
custom_ble_usage_current +
scan_collection_current +
accelerometer_current +
total_fix_current
); // [mA]
const battery_life_time = Math.round(
10 * (PRODUCTS[input.product].battery.practical_capacity / total_current ) / 24
) / 10 // [day]
const current_distribution = {
custom_msg: Math.round( 1000 * custom_msg_lora_current / total_current ) / 10,
heartbeat: Math.round( 1000 * heartbeat_lora_current / total_current ) / 10,
gps: Math.round( 1000 * (gps_lora_current + gps_geoloc_current) / total_current ) / 10,
agps: Math.round( 1000 * (agps_lora_current + agps_geoloc_current) / total_current ) / 10,
wifi: Math.round( 1000 * (wifi_lora_current + wifi_geoloc_current) / total_current ) / 10,
ble: Math.round( 1000 * (ble_lora_current + ble_geoloc_current) / total_current ) / 10,
custom_ble: Math.round( 1000 * custom_ble_usage_current / total_current ) / 10,
scan_collection: Math.round( 1000 * (scan_collection_lora_current + scan_collection_current) / total_current ) / 10,
accelerometer: Math.round( 1000 * accelerometer_current / total_current ) / 10,
quiesent_and_battery_leakage: Math.round( 1000 * total_fix_current / total_current ) / 10,
}
let result = {
battery_life_time: battery_life_time,
current_distribution: current_distribution,
}
return result;
// return JSON.stringify(result, null, 2);
};
</script>
</html>