-
Notifications
You must be signed in to change notification settings - Fork 0
/
voltage_divider.html
2882 lines (2521 loc) · 119 KB
/
voltage_divider.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
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<!--
Voltage Divider Calculator v1.12 - Finds voltage dividers nearest a
target ratio using real-world resistor values.
Written in 2018 by Ben Tesch
Distributed at https://github.com/slugrustle/voltage_divider
voltage_divider.html contains the functions download_csv and download_xlsx,
both of which come from a Stack Overflow post https://stackoverflow.com/a/33542499
by user Ludovic Feltz (on 2015-11-5), edited by user Smi (on 2016-08-12).
I retrieved this code on 2018-03-31 and changed it slightly.
Stack Overflow code is distributed under the CC BY-SA 3.0 license:
https://creativecommons.org/licenses/by-sa/3.0/
The remainder of voltage_divider.html is under the
CC0 1.0 Universal Public Domain Dedication, which is reproduced below.
To the extent possible under law, the author has dedicated all copyright
and related and neighboring rights to this software to the public domain
worldwide. This software is distributed without any warranty.
The text of the CC0 Public Domain Dedication should be reproduced below.
If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
Creative Commons Legal Code
CC0 1.0 Universal
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
HEREUNDER.
Statement of Purpose
The laws of most jurisdictions throughout the world automatically confer
exclusive Copyright and Related Rights (defined below) upon the creator
and subsequent owner(s) (each and all, an "owner") of an original work of
authorship and/or a database (each, a "Work").
Certain owners wish to permanently relinquish those rights to a Work for
the purpose of contributing to a commons of creative, cultural and
scientific works ("Commons") that the public can reliably and without fear
of later claims of infringement build upon, modify, incorporate in other
works, reuse and redistribute as freely as possible in any form whatsoever
and for any purposes, including without limitation commercial purposes.
These owners may contribute to the Commons to promote the ideal of a free
culture and the further production of creative, cultural and scientific
works, or to gain reputation or greater distribution for their Work in
part through the use and efforts of others.
For these and/or other purposes and motivations, and without any
expectation of additional consideration or compensation, the person
associating CC0 with a Work (the "Affirmer"), to the extent that he or she
is an owner of Copyright and Related Rights in the Work, voluntarily
elects to apply CC0 to the Work and publicly distribute the Work under its
terms, with knowledge of his or her Copyright and Related Rights in the
Work and the meaning and intended legal effect of CC0 on those rights.
1. Copyright and Related Rights. A Work made available under CC0 may be
protected by copyright and related or neighboring rights ("Copyright and
Related Rights"). Copyright and Related Rights include, but are not
limited to, the following:
i. the right to reproduce, adapt, distribute, perform, display,
communicate, and translate a Work;
ii. moral rights retained by the original author(s) and/or performer(s);
iii. publicity and privacy rights pertaining to a person's image or
likeness depicted in a Work;
iv. rights protecting against unfair competition in regards to a Work,
subject to the limitations in paragraph 4(a), below;
v. rights protecting the extraction, dissemination, use and reuse of data
in a Work;
vi. database rights (such as those arising under Directive 96/9/EC of the
European Parliament and of the Council of 11 March 1996 on the legal
protection of databases, and under any national implementation
thereof, including any amended or successor version of such
directive); and
vii. other similar, equivalent or corresponding rights throughout the
world based on applicable law or treaty, and any national
implementations thereof.
2. Waiver. To the greatest extent permitted by, but not in contravention
of, applicable law, Affirmer hereby overtly, fully, permanently,
irrevocably and unconditionally waives, abandons, and surrenders all of
Affirmer's Copyright and Related Rights and associated claims and causes
of action, whether now known or unknown (including existing as well as
future claims and causes of action), in the Work (i) in all territories
worldwide, (ii) for the maximum duration provided by applicable law or
treaty (including future time extensions), (iii) in any current or future
medium and for any number of copies, and (iv) for any purpose whatsoever,
including without limitation commercial, advertising or promotional
purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
member of the public at large and to the detriment of Affirmer's heirs and
successors, fully intending that such Waiver shall not be subject to
revocation, rescission, cancellation, termination, or any other legal or
equitable action to disrupt the quiet enjoyment of the Work by the public
as contemplated by Affirmer's express Statement of Purpose.
3. Public License Fallback. Should any part of the Waiver for any reason
be judged legally invalid or ineffective under applicable law, then the
Waiver shall be preserved to the maximum extent permitted taking into
account Affirmer's express Statement of Purpose. In addition, to the
extent the Waiver is so judged Affirmer hereby grants to each affected
person a royalty-free, non transferable, non sublicensable, non exclusive,
irrevocable and unconditional license to exercise Affirmer's Copyright and
Related Rights in the Work (i) in all territories worldwide, (ii) for the
maximum duration provided by applicable law or treaty (including future
time extensions), (iii) in any current or future medium and for any number
of copies, and (iv) for any purpose whatsoever, including without
limitation commercial, advertising or promotional purposes (the
"License"). The License shall be deemed effective as of the date CC0 was
applied by Affirmer to the Work. Should any part of the License for any
reason be judged legally invalid or ineffective under applicable law, such
partial invalidity or ineffectiveness shall not invalidate the remainder
of the License, and in such case Affirmer hereby affirms that he or she
will not (i) exercise any of his or her remaining Copyright and Related
Rights in the Work or (ii) assert any associated claims and causes of
action with respect to the Work, in either case contrary to Affirmer's
express Statement of Purpose.
4. Limitations and Disclaimers.
a. No trademark or patent rights held by Affirmer are waived, abandoned,
surrendered, licensed or otherwise affected by this document.
b. Affirmer offers the Work as-is and makes no representations or
warranties of any kind concerning the Work, express, implied,
statutory or otherwise, including without limitation warranties of
title, merchantability, fitness for a particular purpose, non
infringement, or the absence of latent or other defects, accuracy, or
the present or absence of errors, whether or not discoverable, all to
the greatest extent permissible under applicable law.
c. Affirmer disclaims responsibility for clearing rights of other persons
that may apply to the Work or any use thereof, including without
limitation any person's Copyright and Related Rights in the Work.
Further, Affirmer disclaims responsibility for obtaining any necessary
consents, permissions or other rights required for any use of the
Work.
d. Affirmer understands and acknowledges that Creative Commons is not a
party to this document and has no duty or obligation with respect to
this CC0 or use of the Work.
-->
<meta name="Description" content="A solver for optimal voltage dividers using E24 and/or E96 series resistor values."/>
<meta name="viewport" content="width=780px, initial-scale=0.65">
<title>Voltage Divider Calculator</title>
<style>
a:link {
text-decoration: none;
color: blue;
}
a:visited {
text-decoration: none;
color: blue;
}
a:hover {
text-decoration: none;
color: blue;
}
a:active {
text-decoration: none;
color: blue;
}
.titleDiv {
margin-left: 4pt;
margin-top: 16pt;
margin-bottom: 10pt;
font-weight: normal;
}
span.titleSpan {
font-weight: bold;
font-size: 16pt;
}
#inputTable {
border: 1px solid black;
font-size: 12pt;
}
#inputTable th, #inputTable td {
border: none;
padding: 6pt;
}
td.labelCol {
text-align: right;
}
td.buttonCol {
text-align: center;
}
input[type="radio"] {
opacity: 0;
position: absolute;
}
input[type="radio"]:focus+label {
border: 1px solid #4d90fe;
}
input[type="radio"]:checked+label {
background-color: #DDDDDD;
}
.buttonLabel {
user-select: none;
padding-left: 2px;
padding-right: 2px;
}
#eqsDiv {
border: 1px solid black;
padding: 8pt;
}
#resultsTable, #resultsTable th, #resultsTable td {
border: 1px solid black;
border-collapse: collapse;
font-size: 12pt;
}
#resultsTable th, #resultsTable td {
padding-top: 4pt;
padding-bottom: 4pt;
padding-left: 6pt;
padding-right: 6pt;
vertical-align: baseline;
}
tr.normalRow td {
background-color:#ffffff;
}
tr.shadedRow td {
background-color:#e8e8e8;
}
tr.grayRow td {
background-color: #888888;
}
td.diffCol {
padding-left: 10pt;
}
td.groupCol {
text-align: center;
}
td.paramLabel {
text-align: right;
width: 50%;
}
</style>
</head>
<body>
<header class="titleDiv"><span class="titleSpan">Voltage Divider Calculator v1.12 2018-05-07</span></header>
<form action="javascript:void(0)" aria-label="calculator input"><table id="inputTable">
<tr>
<td class="labelCol"><label for="dividerRatio">Target Divider Ratio</label></td>
<td class="buttonCol"><input id="dividerRatio" maxlength="200" autofocus/></td>
<td>>0 and <1</td>
</tr>
<tr>
<td id="ratioTypeLabel" class="labelCol">Ratio Type</td>
<td class="buttonCol" role="radiogroup" aria-labelledby="ratioTypeLabel">
<input type="radio" name="ratioType" id="ratioTypeMin"/><label for="ratioTypeMin" class="buttonLabel">MIN</label> <input type="radio" name="ratioType" id="ratioTypeNom" checked/><label for="ratioTypeNom" class="buttonLabel">NOM</label> <input type="radio" name="ratioType" id="ratioTypeMax"/><label for="ratioTypeMax" class="buttonLabel">MAX</label>
</td>
<td>Over Tolerance</td>
</tr>
<tr>
<td class="labelCol"><label for="resTolerance">Resistor Tolerance</label></td>
<td class="buttonCol"><input id="resTolerance" value="1" maxlength="30"/></td>
<td>%</td>
</tr>
<tr>
<td class="labelCol"><label for="minStringResistance">Min String Resistance</label></td>
<td class="buttonCol"><input id="minStringResistance" value="0" maxlength="30"/></td>
<td>Ω</td>
</tr>
<tr>
<td class="labelCol"><label for="maxStringResistance">Max String Resistance</label></td>
<td class="buttonCol"><input id="maxStringResistance" value="20M" maxlength="30"/></td>
<td>Ω</td>
</tr>
<tr>
<td id="seriesLabel" class="labelCol">Resistor Value Series</td>
<td class="buttonCol" role="radiogroup" aria-labelledby="seriesLabel">
<input type="radio" name="resSeries" id="resSeriesE24"/><label for="resSeriesE24" class="buttonLabel">E24</label> <input type="radio" name="resSeries" id="resSeriesE96"/><label for="resSeriesE96" class="buttonLabel">E96</label> <input type="radio" name="resSeries" id="resSeriesE24E96" checked/><label for="resSeriesE24E96" class="buttonLabel">BOTH</label>
</td>
<td>View <a href="javascript:;" onclick="voltDiv.displayResistorValues('E24');">E24</a>, <a href="javascript:;" onclick="voltDiv.displayResistorValues('E96');">E96</a></td>
</tr>
<tr>
<td class="buttonCol" colspan="3"><button onclick="voltDiv.solveDivider();">Solve</button></td>
</tr>
</table></form>
<section aria-labelledby="eqsTitleSpan">
<h2 class="titleDiv" id="eqsTitle" style="margin-bottom: 0px">
<span id="eqsTitleSpan" class="titleSpan">Equations</span><span style="font-size: 14pt; margin-left: 1em;">( <a href="javascript:;" id="toggleMath" onclick="voltDiv.toggleMath();">show</a> )</span>
</h2>
<div id="eqsDiv" style="display: none;">
<div style="float:left; margin-right: 14pt;">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 221.41 360.341" height="240.228" width="147.606" role="img" aria-label="Voltage Divider Circuit Diagram">
<title>Voltage Divider Circuit Diagram</title>
<desc>Two resistor voltage divider. Upper resistor connects to input and output; lower resistor connects to output and ground.</desc>
<g transform="translate(-144.059 -87.502)">
<circle cx="279.983" cy="132.322" r="5" fill="none" stroke="#000"/>
<text style="line-height:125%" x="140.814" y="222.061" font-weight="400" font-size="37.333" font-family="sans-serif" letter-spacing="0" word-spacing="0"><tspan x="140.814" y="222.061">Upper</tspan></text>
<text style="line-height:125%" x="142.053" y="353.663" font-weight="400" font-size="37.333" font-family="sans-serif" letter-spacing="0" word-spacing="0"><tspan x="142.053" y="353.663">Lower</tspan></text>
<path d="M280 276.103h58.773" fill="none" stroke="#000" stroke-width=".865"/><circle cx="343.912" cy="276.103" r="5" fill="none" stroke="#000"/><circle cx="280" cy="276.393" r="2" stroke="#000"/>
<text style="line-height:125%" x="260.511" y="115.867" font-weight="400" font-size="37.333" font-family="sans-serif" letter-spacing="0" word-spacing="0"><tspan x="260.511" y="115.867">Vi</tspan></text>
<text style="line-height:125%" x="322.065" y="257.984" font-weight="400" font-size="37.333" font-family="sans-serif" letter-spacing="0" word-spacing="0"><tspan x="322.065" y="257.984">Vo</tspan></text>
<path d="M279.995 412.358l.005-17.01m-.005 32.013v-15.003m-20.003 15.003h39.996m-23.998 19.983h8m-16-10h24M280 285.349v25l15 5-30 10 30 10-30 10 30 10-30 10 15 5v25m0-127.99v18m0-128v25l15 5-30 10 30 10-30 10 30 10-30 10 15 5v25m0-109.997v-20" fill="none" stroke="#000"/>
</g>
</svg>
</div>
<div style="display: inline-block; font-size: 12pt;" aria-label="voltage divider equations">
<div style="margin-bottom: 14pt;"><b>String Resistance</b> = Lower + Upper</div>
<div style="margin-bottom: 14pt;"><b>Divider Ratio</b> = Vo <b>/</b> Vi</div>
<div style="margin-bottom: 14pt;"><b>Nom Ratio</b> = Lower <b>/</b> (Lower + Upper)</div>
<div style="margin-bottom: 4pt;"><b>Min Ratio</b> = LowerDim <b>/</b> (LowerDim + UpperAug)</div>
<div style="margin-bottom: 4pt;"><i>LowerDim</i> = (1 − Tolerance<b>/</b>100) • Lower</div>
<div style="margin-bottom: 14pt;"><i>UpperAug</i> = (1 + Tolerance<b>/</b>100) • Upper</div>
<div style="margin-bottom: 4pt;"><b>Max Ratio</b> = LowerAug <b>/</b> (LowerAug + UpperDim)</div>
<div style="margin-bottom: 4pt;"><i>LowerAug</i> = (1 + Tolerance<b>/</b>100) • Lower</div>
<div><i>UpperDim</i> = (1 − Tolerance<b>/</b>100) • Upper</div>
</div>
</div>
</section>
<main aria-labelledby="outTitleSpan">
<h2 class="titleDiv" id="outTitleDiv" style="display: none;">
<span class="titleSpan" id="outTitleSpan" style="margin-right: 0.2em;"></span><span id="downloadSpan" style="margin-left: 1em; font-size: 14pt; display: none;">( <a href="javascript:;" onclick="voltDiv.download_xlsx();">Download .xlsx</a> ) ( <a href="javascript:;" onclick="voltDiv.download_csv();">Download .csv</a> )</span><span id="clearSpan" style="margin-left: 1em; font-size: 14pt; display: none;">( <a href="javascript:;" onclick="voltDiv.clearResults();">clear</a> )</span><span id="ratioSpan" style="margin-left: 1em; font-size: 13pt;"></span>
</h2>
<table id="resultsTable" style="display: none;"></table>
</main>
<section aria-labelledby="errorTitleSpan">
<h2 class="titleDiv" id="errorTitleDiv" style="display: none;">
<span class="titleSpan" id="errorTitleSpan">Input Error</span>
</h2>
<div id="errorDiv" style="max-width: 30em; border: 1px solid black; padding: 8pt; display: none;"></div>
</section>
<footer style="margin-top: 50pt; margin-left: 4pt;" id="licenseBlock">
<div style="float: left; margin-right: 1em;">
<a href="http://creativecommons.org/publicdomain/zero/1.0/" style="text-decoration: none;" target="_blank" rel="noopener noreferrer">
<svg xmlns="http://www.w3.org/2000/svg" width="88" height="31" viewBox="-0.5 -0.101 88 31" role="img" aria-label="CC0 Button">
<title>CC0 Button</title><desc>Creative Commons CC0 1.0 Universal Button Image</desc>
<path fill="#FFF" d="M1.803.482L84.93.631c1.161 0 2.198-.173 2.198 2.333l-.103 27.556H-.295V2.862c0-1.236.118-2.38 2.098-2.38z"/><ellipse fill="#FFF" cx="13.887" cy="15.502" rx="11.101" ry="11.174"/><path d="M23.271 4.061a14.23 14.23 0 0 1 5.755 11.44 14.232 14.232 0 0 1-4.842 10.705h62.853V4.061H23.271z"/>
<path d="M35.739 7.559c.392 0 .728.059 1.002.173.276.116.5.268.674.456.173.189.299.405.379.647a2.437 2.437 0 0 1 0 1.502c-.08.244-.206.462-.379.65a1.874 1.874 0 0 1-.674.456c-.274.114-.61.173-1.002.173h-1.452v2.267h-1.382V7.559h2.834zm-.379 2.976c.158 0 .312-.012.457-.035.147-.023.276-.069.388-.137.112-.068.201-.164.269-.288s.101-.287.101-.487-.033-.362-.101-.487a.725.725 0 0 0-.269-.287 1.058 1.058 0 0 0-.388-.138 2.82 2.82 0 0 0-.457-.036h-1.073v1.896l1.073-.001zm8.391 2.865c-.476.417-1.133.625-1.972.625-.851 0-1.509-.207-1.976-.62-.466-.412-.699-1.052-.699-1.913V7.559h1.381v3.934c0 .171.016.338.045.505.029.165.091.311.185.439.094.126.225.229.392.309.167.081.392.12.673.12.493 0 .833-.11 1.021-.332.188-.222.282-.568.282-1.04V7.559h1.382v3.934c-.001.855-.238 1.49-.714 1.907zm5.319-5.841c.3 0 .572.027.818.081.244.054.457.14.633.261.177.121.312.282.41.482.096.201.146.45.146.745 0 .318-.072.584-.216.796a1.583 1.583 0 0 1-.639.523c.387.112.676.31.865.589.189.281.286.62.286 1.015 0 .319-.062.595-.187.828a1.631 1.631 0 0 1-.496.571 2.165 2.165 0 0 1-.713.327 3.24 3.24 0 0 1-.822.105h-3.047V7.559h2.962zm-.175 2.56c.246 0 .448-.059.607-.178.158-.118.236-.309.236-.576a.737.737 0 0 0-.078-.363.598.598 0 0 0-.211-.221.846.846 0 0 0-.305-.109 1.875 1.875 0 0 0-.355-.032h-1.294v1.48l1.4-.001zm.08 2.685c.135 0 .264-.014.387-.04a.977.977 0 0 0 .326-.133.707.707 0 0 0 .226-.254.86.86 0 0 0 .083-.406c0-.324-.092-.557-.271-.695-.182-.138-.424-.208-.723-.208h-1.505v1.738h1.479v-.002h-.002zm5.168-5.245v5.156h3.062v1.168H52.76V7.559h1.383zm5.605 0v6.324h-1.382V7.559h1.382zm5.703 1.688a1.405 1.405 0 0 0-.309-.349 1.387 1.387 0 0 0-.418-.236 1.399 1.399 0 0 0-.488-.084c-.312 0-.574.062-.793.183-.217.12-.394.283-.525.486a2.182 2.182 0 0 0-.296.695 3.453 3.453 0 0 0 0 1.582c.062.251.16.477.296.678.134.201.312.361.525.483.219.12.481.181.793.181.424 0 .752-.13.99-.389.236-.26.383-.602.437-1.028H67a3.242 3.242 0 0 1-.271 1.072 2.574 2.574 0 0 1-.582.815 2.404 2.404 0 0 1-.845.513 3.06 3.06 0 0 1-1.065.178c-.479 0-.914-.084-1.297-.252a2.763 2.763 0 0 1-.973-.695 3.036 3.036 0 0 1-.607-1.04 3.818 3.818 0 0 1-.211-1.289c0-.473.069-.911.211-1.316a3.19 3.19 0 0 1 .607-1.059 2.77 2.77 0 0 1 .973-.708 3.135 3.135 0 0 1 1.297-.258c.348 0 .676.051.981.15.308.102.583.248.827.44.243.191.443.43.604.712.158.283.259.608.301.975h-1.34a1.121 1.121 0 0 0-.159-.44zm-29.836 7.171c.405 0 .782.062 1.131.192.35.13.651.324.906.585.255.26.455.586.599.975.144.391.216.849.216 1.371 0 .463-.059.888-.176 1.277a2.845 2.845 0 0 1-.532 1.012 2.54 2.54 0 0 1-.89.668c-.354.16-.772.242-1.254.242h-2.71v-6.322h2.71zm-.096 5.154c.199 0 .393-.031.581-.098a1.26 1.26 0 0 0 .502-.323c.146-.151.264-.347.352-.59.088-.241.132-.536.132-.886 0-.317-.031-.606-.093-.863a1.698 1.698 0 0 0-.304-.659 1.347 1.347 0 0 0-.559-.421c-.231-.098-.517-.146-.858-.146h-.984v3.986h1.231zm4.281-3.283c.141-.403.344-.756.606-1.059.265-.303.589-.538.973-.709a3.16 3.16 0 0 1 1.298-.257c.487 0 .921.086 1.303.257.381.171.704.406.969.709.264.303.466.652.605 1.059.143.404.213.845.213 1.316 0 .46-.07.891-.213 1.288a3.168 3.168 0 0 1-.605 1.04 2.843 2.843 0 0 1-.969.695 3.235 3.235 0 0 1-1.303.252c-.481 0-.913-.086-1.298-.252a2.82 2.82 0 0 1-.973-.695 3.122 3.122 0 0 1-.606-1.04 3.854 3.854 0 0 1-.211-1.288c0-.471.07-.911.211-1.316zm1.262 2.09c.062.252.16.479.295.68.135.2.312.359.527.482.218.121.481.183.792.183a1.6 1.6 0 0 0 .792-.183c.218-.121.394-.281.529-.482.134-.2.231-.428.295-.68a3.465 3.465 0 0 0 0-1.58 2.157 2.157 0 0 0-.295-.696 1.522 1.522 0 0 0-.529-.485 1.6 1.6 0 0 0-.792-.184c-.311 0-.574.062-.792.184-.216.12-.393.284-.527.485a2.164 2.164 0 0 0-.295.696 3.446 3.446 0 0 0 0 1.58zm8.03-3.961l1.471 4.348h.02l1.393-4.348h1.942v6.322h-1.294v-4.48h-.02l-1.539 4.48H50l-1.54-4.437h-.019v4.437h-1.293v-6.322h1.944zm9.672 0l2.35 6.322H59.68l-.476-1.408h-2.351l-.492 1.408H54.97l2.377-6.322h1.417zm.08 3.879l-.793-2.322h-.018l-.817 2.322h1.628zm4.703-3.879v6.322h-1.382v-6.322h1.382zm3.057 0l2.623 4.242h.018v-4.242h1.294v6.322h-1.384l-2.611-4.234h-.02v4.234H65.23v-6.322h1.374z" fill="#FFF"/>
<path d="M85.852 0H1.147C.239 0-.5.744-.5 1.658v28.969c0 .207.167.373.372.373h87.256a.372.372 0 0 0 .372-.373V1.658C87.5.744 86.762 0 85.852 0zM1.147.75h84.705c.498 0 .902.406.902.908v28.557H.245V1.658c0-.501.405-.908.902-.908z"/><ellipse fill="#FFF" cx="14.156" cy="15.661" rx="11.004" ry="11.076"/>
<path d="M14.22 8.746c-3.862 0-4.834 3.669-4.834 6.779 0 3.111.971 6.779 4.834 6.779 3.863 0 4.834-3.67 4.834-6.779 0-3.111-.971-6.779-4.834-6.779zm0 2.555c.157 0 .3.024.435.06.278.24.414.573.147 1.038l-2.572 4.76a12.735 12.735 0 0 1-.091-1.634c0-1.37.094-4.224 2.081-4.224zm1.926 2.193c.137.731.155 1.493.155 2.03 0 1.37-.094 4.223-2.08 4.223-.156 0-.301-.017-.435-.049a.537.537 0 0 0-.074-.025c-.04-.012-.084-.024-.122-.041-.442-.188-.721-.531-.319-1.139l2.875-4.999z"/>
<path d="M14.195 3.748c-3.245 0-5.98 1.137-8.21 3.422a11.946 11.946 0 0 0-2.589 3.876 11.708 11.708 0 0 0-.876 4.478c0 1.57.291 3.062.876 4.479s1.434 2.69 2.548 3.826a12.157 12.157 0 0 0 3.802 2.588c1.421.59 2.903.884 4.449.884 1.547 0 3.05-.304 4.499-.907a12.06 12.06 0 0 0 3.883-2.605 10.665 10.665 0 0 0 2.49-3.719c.571-1.415.853-2.932.853-4.544 0-1.598-.281-3.112-.852-4.528a11.292 11.292 0 0 0-2.507-3.801c-2.298-2.302-5.092-3.449-8.366-3.449zm.049 2.119c2.646 0 4.904.944 6.784 2.836a9.432 9.432 0 0 1 2.073 3.119 9.743 9.743 0 0 1 .713 3.703c0 2.707-.92 4.952-2.744 6.746a10.029 10.029 0 0 1-3.196 2.128 9.306 9.306 0 0 1-3.63.732 9.437 9.437 0 0 1-3.638-.717 9.824 9.824 0 0 1-3.113-2.104 10.035 10.035 0 0 1-2.13-3.135 9.465 9.465 0 0 1-.738-3.653 9.41 9.41 0 0 1 .738-3.662 10.247 10.247 0 0 1 2.13-3.175c1.824-1.876 4.077-2.818 6.751-2.818z"/>
</svg>
</a>
</div>
<div style="max-width: 29em; display: inline-block; font-size: 11pt;">
To the extent possible under law, Ben Tesch has waived all copyright and related or neighboring rights to Voltage Divider Calculator. This work is published from: United States.
</div>
</footer>
<script>
(function () {
'use strict';
// Store all globals in this object
window.voltDiv = {};
// E24 contains EIA E24 series resistor values in the 1s decade.
window.voltDiv.E24 = Object.freeze([1.0, 1.1, 1.2, 1.3, 1.5, 1.6, 1.8, 2.0, 2.2, 2.4, 2.7, 3.0, 3.3, 3.6, 3.9, 4.3, 4.7, 5.1, 5.6, 6.2, 6.8, 7.5, 8.2, 9.1]);
// E96 contains EIA E96 series resistor values in the 1s decade.
window.voltDiv.E96 = Object.freeze([1.00, 1.02, 1.05, 1.07, 1.10, 1.13, 1.15, 1.18, 1.21, 1.24, 1.27, 1.30, 1.33, 1.37, 1.40, 1.43, 1.47, 1.50, 1.54, 1.58,
1.62, 1.65, 1.69, 1.74, 1.78, 1.82, 1.87, 1.91, 1.96, 2.00, 2.05, 2.10, 2.15, 2.21, 2.26, 2.32, 2.37, 2.43, 2.49, 2.55, 2.61, 2.67, 2.74, 2.80,
2.87, 2.94, 3.01, 3.09, 3.16, 3.24, 3.32, 3.40, 3.48, 3.57, 3.65, 3.74, 3.83, 3.92, 4.02, 4.12, 4.22, 4.32, 4.42, 4.53, 4.64, 4.75, 4.87, 4.99,
5.11, 5.23, 5.36, 5.49, 5.62, 5.76, 5.90, 6.04, 6.19, 6.34, 6.49, 6.65, 6.81, 6.98, 7.15, 7.32, 7.50, 7.68, 7.87, 8.06, 8.25, 8.45, 8.66, 8.87,
9.09, 9.31, 9.53, 9.76]);
// E24E96 contains the union of E24 and E96.
window.voltDiv.E24E96 = Object.freeze([1.00, 1.02, 1.05, 1.07, 1.10, 1.13, 1.15, 1.18, 1.20, 1.21, 1.24, 1.27, 1.30, 1.33, 1.37, 1.40, 1.43, 1.47, 1.50, 1.54,
1.58, 1.60, 1.62, 1.65, 1.69, 1.74, 1.78, 1.80, 1.82, 1.87, 1.91, 1.96, 2.00, 2.05, 2.10, 2.15, 2.20, 2.21, 2.26, 2.32, 2.37, 2.40, 2.43, 2.49,
2.55, 2.61, 2.67, 2.70, 2.74, 2.80, 2.87, 2.94, 3.00, 3.01, 3.09, 3.16, 3.24, 3.30, 3.32, 3.40, 3.48, 3.57, 3.60, 3.65, 3.74, 3.83, 3.90, 3.92,
4.02, 4.12, 4.22, 4.30, 4.32, 4.42, 4.53, 4.64, 4.70, 4.75, 4.87, 4.99, 5.10, 5.11, 5.23, 5.36, 5.49, 5.60, 5.62, 5.76, 5.90, 6.04, 6.19, 6.20,
6.34, 6.49, 6.65, 6.80, 6.81, 6.98, 7.15, 7.32, 7.50, 7.68, 7.87, 8.06, 8.20, 8.25, 8.45, 8.66, 8.87, 9.09, 9.10, 9.31, 9.53, 9.76]);
// Each value in E24, E96, or E24E96 is multiplied by all scalars
// in multipliers to create the full array of resistance values.
window.voltDiv.multipliers = Object.freeze([1.0, 1.0e1, 1.0e2, 1.0e3, 1.0e4, 1.0e5, 1.0e6]);
// "enum" type containing possible resistor series
window.voltDiv.seriesEnum = Object.freeze({E24:1, E96:2, E24E96:3});
// "enum" type with possible target ratio options
window.voltDiv.ratioEnum = Object.freeze({MIN:1, NOM:2, MAX:3});
// All user input settings stored in this object
window.voltDiv.settings = null;
// Sorted results are stored in this object
window.voltDiv.sortedResults = null;
}) ();
(function () {
'use strict';
// Bring in globals with shorter names.
var seriesEnum = window.voltDiv.seriesEnum;
var ratioEnum = window.voltDiv.ratioEnum;
var settings;
// Fill in form inputs based on sessionStorage
var settingsString;
var dividerRatio_input = document.getElementById('dividerRatio');
var ratioTypeMin_radio = document.getElementById('ratioTypeMin');
var ratioTypeNom_radio = document.getElementById('ratioTypeNom');
var ratioTypeMax_radio = document.getElementById('ratioTypeMax');
var resTolerance_input = document.getElementById('resTolerance');
var minStringRes_input = document.getElementById('minStringResistance');
var maxStringRes_input = document.getElementById('maxStringResistance');
var resSerE24_radio = document.getElementById('resSeriesE24');
var resSerE96_radio = document.getElementById('resSeriesE96');
var resSerE24E96_radio = document.getElementById('resSeriesE24E96');
try {
settingsString = window.sessionStorage.getItem('vdiv_settings');
} catch(err) {
// Ignore exceptions
}
if (settingsString !== null) {
window.voltDiv.settings = JSON.parse(settingsString);
settings = window.voltDiv.settings;
dividerRatio_input.value = settings.ratioExpr;
ratioTypeMin_radio.checked = false;
ratioTypeNom_radio.checked = false;
ratioTypeMax_radio.checked = false;
switch (settings.ratioType) {
case ratioEnum.MIN:
ratioTypeMin_radio.checked = true;
break;
case ratioEnum.NOM:
ratioTypeNom_radio.checked = true;
break;
case ratioEnum.MAX:
ratioTypeMax_radio.checked = true;
break;
}
resTolerance_input.value = settings.resTolExpr;
minStringRes_input.value = settings.minStringExpr;
maxStringRes_input.value = settings.maxStringExpr;
resSerE24_radio.checked = false;
resSerE96_radio.checked = false;
resSerE24E96_radio.checked = false;
switch (settings.resSeries) {
case seriesEnum.E24:
resSerE24_radio.checked = true;
break;
case seriesEnum.E96:
resSerE96_radio.checked = true;
break;
case seriesEnum.E24E96:
resSerE24E96_radio.checked = true;
break;
}
}
}) ();
(function () {
'use strict';
// Decide whether to display equations & schematic based on
// sessionStorage
var displayEqs;
(function() {
// Local scope here to prevent redeclaration of these vars
// in toggleMath().
var eqsDiv;
var eqsTitle;
var toggleAnchor;
try {
displayEqs = window.sessionStorage.getItem('vdiv_displayEqs');
} catch (err) {
// Ignore exceptions
displayEqs = null;
}
if (displayEqs !== 'true' && displayEqs !== 'false') {
displayEqs = 'false';
try {
window.sessionStorage.setItem('vdiv_displayEqs', displayEqs);
} catch (err) {
// Ignore exceptions
}
}
if (displayEqs === 'true') {
eqsDiv = document.getElementById('eqsDiv');
eqsTitle = document.getElementById('eqsTitle');
toggleAnchor = document.getElementById('toggleMath');
toggleAnchor.innerHTML = 'hide';
eqsDiv.style.display = 'inline-block';
eqsTitle.style.marginBottom = '10pt';
}
}) ();
// Toggles display of equations and schematic
window.voltDiv.toggleMath = function() {
var eqsDiv = document.getElementById('eqsDiv');
var eqsTitle = document.getElementById('eqsTitle');
var toggleAnchor = document.getElementById('toggleMath');
if (displayEqs === 'false')
{
toggleAnchor.innerHTML = 'hide';
eqsDiv.style.display = 'inline-block';
eqsTitle.style.marginBottom = '10pt';
displayEqs = 'true';
try {
window.sessionStorage.setItem('vdiv_displayEqs', displayEqs);
} catch (err) {
// Ignore exceptions
}
}
else
{
toggleAnchor.innerHTML = 'show';
eqsDiv.style.display = 'none';
eqsTitle.style.marginBottom = '0px';
displayEqs = 'false';
try {
window.sessionStorage.setItem('vdiv_displayEqs', displayEqs);
} catch (err) {
// Ignore exceptions
}
}
};
}) ();
(function () {
'use strict';
// Clears results from previous run of program, including E24/E96
// display, diagnostic message, download links, error display, etc.
window.voltDiv.clearResults = function () {
var outTitle_div = document.getElementById('outTitleDiv');
var download_span = document.getElementById('downloadSpan');
var clear_span = document.getElementById('clearSpan');
var ratio_span = document.getElementById('ratioSpan');
var results_table = document.getElementById('resultsTable');
var errTitle_div = document.getElementById('errorTitleDiv');
var error_div = document.getElementById('errorDiv');
outTitle_div.style.display = 'none';
download_span.style.display = 'none';
clear_span.style.display = 'none';
ratio_span.style.display = 'none';
results_table.style.display = 'none';
results_table.innerHTML = '';
errTitle_div.style.display = 'none';
error_div.style.display = 'none';
// Set displayType in sessionStorage and remove previous stored
// results.
try {
window.sessionStorage.removeItem('vdiv_displayType');
window.sessionStorage.removeItem('vdiv_sortedResults');
} catch(err) {
// Ignore exceptions
}
};
}) ();
(function () {
'use strict';
// Creates human-readable resistance value strings from
// resistance values in Ohms.
window.voltDiv.resValToString = function(resVal, precision) {
if (resVal >= 1.0e6) {
return (1.0e-6*resVal).toPrecision(precision) + 'M\u03A9';
} else if (resVal >= 1.0e3) {
return (1.0e-3*resVal).toPrecision(precision) + 'k\u03A9';
}
return resVal.toPrecision(precision) + '\u03A9';
};
}) ();
(function () {
'use strict';
// Bring in globals with shorter names.
var E24 = window.voltDiv.E24;
var E96 = window.voltDiv.E96;
var multipliers = window.voltDiv.multipliers;
var resValToString = window.voltDiv.resValToString;
// Displays human-readable resistance values in ohms,
// kilo ohms or megohms, rounded to the nearest digit.
function resistanceString(resistance) {
if (resistance >= 1.0e6) {
return Math.round(1.0e-6*resistance) + 'M\u03A9';
} else if (resistance >= 1.0e3) {
return Math.round(1.0e-3*resistance) + 'k\u03A9';
}
return Math.round(resistance) + '\u03A9';
}
// Display E24 or E96 series resistor values.
// Argument series must be the string 'E24' or 'E96'.
window.voltDiv.displayResistorValues = function(series) {
var tableFragment = document.createDocumentFragment();
var jMult;
var multiplier;
var jVal;
var headerRow;
var decade_td;
var valuesRow;
var values_td;
var title_span;
var title_div;
var clear_span;
var results_table;
// Make sure input is valid before continuing
if (series !== 'E24' && series !== 'E96') {
return;
}
window.voltDiv.clearResults();
for (jMult = 0; jMult < multipliers.length; jMult++) {
multiplier = multipliers[jMult];
headerRow = document.createElement('tr');
headerRow.className = 'shadedRow';
decade_td = document.createElement('td');
decade_td.setAttribute('style', 'text-align:center; font-weight: bold');
decade_td.textContent = resistanceString(multiplier) + ' decade';
headerRow.appendChild(decade_td);
tableFragment.appendChild(headerRow);
valuesRow = document.createElement('tr');
values_td = document.createElement('td');
values_td.style.lineHeight = '1.5';
if (series === 'E24') {
for (jVal = 0; jVal < E24.length-1; jVal++) {
values_td.insertAdjacentText('beforeend', resValToString(multiplier*E24[jVal], 3));
if ((jVal + 1) % 6 === 0) {
values_td.insertAdjacentHTML('beforeend', '<br/>');
} else {
values_td.insertAdjacentText('beforeend', '\u2002');
}
}
values_td.insertAdjacentText('beforeend', resValToString(multiplier*E24[E24.length-1], 3));
} else if (series === 'E96') {
for (jVal = 0; jVal < E96.length-1; jVal++) {
values_td.insertAdjacentText('beforeend', resValToString(multiplier*E96[jVal], 3));
if ((jVal + 1) % 8 === 0) {
values_td.insertAdjacentHTML('beforeend', '<br/>');
} else {
values_td.insertAdjacentText('beforeend', '\u2002');
}
}
values_td.insertAdjacentText('beforeend', resValToString(multiplier*E96[E96.length-1], 3));
}
valuesRow.appendChild(values_td);
tableFragment.appendChild(valuesRow);
}
// Display title
title_span = document.getElementById('outTitleSpan');
title_span.textContent = 'EIA ' + series + ' Series Resistor Values';
title_div = document.getElementById('outTitleDiv');
title_div.style.display = 'block';
// Display clear link
clear_span = document.getElementById('clearSpan');
clear_span.style.display = 'inline';
// Display table of resistor values
results_table = document.getElementById('resultsTable');
results_table.style.display='table';
results_table.appendChild(tableFragment);
// Set displayType in sessionStorage and remove previously stored
// results.
try {
window.sessionStorage.removeItem('vdiv_displayType');
window.sessionStorage.setItem('vdiv_displayType', series);
window.sessionStorage.removeItem('vdiv_sortedResults');
} catch(err) {
// Ignore exceptions
}
};
}) ();
(function(){
'use strict';
// Bring in globals with shorter names.
var seriesEnum = window.voltDiv.seriesEnum;
var ratioEnum = window.voltDiv.ratioEnum;
var resValToString = window.voltDiv.resValToString;
// Diagnostic message that summarizes settings.
// Displayed when no results are found.
window.voltDiv.displayDiagnostics = function() {
// Bring in globals with shorter names.
var settings = window.voltDiv.settings;
var tableFragment = document.createDocumentFragment();
var ratio_tr;
var ratioLabel_td;
var ratioValue_td;
var ratioRange_tr;
var ratioRangeLabel_td;
var ratioRangeValue_td;
var tolerance_tr;
var toleranceLabel_td;
var toleranceValue_td;
var minString_tr;
var minStringLabel_td;
var minStringValue_td;
var maxString_tr;
var maxStringLabel_td;
var maxStringValue_td;
var resSeries_tr;
var resSeries_td;
var title_span;
var title_div;
var results_table;
ratio_tr = document.createElement('tr');
ratioLabel_td = document.createElement('td');
ratioLabel_td.className = 'paramLabel';
switch (settings.ratioType) {
case ratioEnum.MIN:
ratioLabel_td.textContent = 'Target minimum divider ratio';
break;
case ratioEnum.MAX:
ratioLabel_td.textContent = 'Target maximum divider ratio';
break;
default:
ratioLabel_td.textContent = 'Target nominal divider ratio';
break;
}
ratioValue_td = document.createElement('td');
ratioValue_td.textContent = settings.targetRatio.toPrecision(6);
ratio_tr.appendChild(ratioLabel_td);
ratio_tr.appendChild(ratioValue_td);
tableFragment.appendChild(ratio_tr);
ratioRange_tr = document.createElement('tr');
ratioRange_tr.className = 'shadedRow';
ratioRangeLabel_td = document.createElement('td');
ratioRangeLabel_td.className = 'paramLabel';
ratioRangeLabel_td.textContent = 'Ratio search range';
ratioRangeValue_td = document.createElement('td');
ratioRangeValue_td.textContent = '[\u00A0' + settings.ratioThresholdLow.toPrecision(6) + ',\u2002' + settings.ratioThresholdHigh.toPrecision(6) + '\u00A0]';
ratioRange_tr.appendChild(ratioRangeLabel_td);
ratioRange_tr.appendChild(ratioRangeValue_td);
tableFragment.appendChild(ratioRange_tr);
tolerance_tr = document.createElement('tr');
toleranceLabel_td = document.createElement('td');
toleranceLabel_td.className = 'paramLabel';
toleranceLabel_td.textContent = 'Resistor tolerance';
toleranceValue_td = document.createElement('td');
toleranceValue_td.textContent = '\u00B1' + settings.resTolerance.toPrecision(4) + '%';
tolerance_tr.appendChild(toleranceLabel_td);
tolerance_tr.appendChild(toleranceValue_td);
tableFragment.appendChild(tolerance_tr);
minString_tr = document.createElement('tr');
minString_tr.className = 'shadedRow';
minStringLabel_td = document.createElement('td');
minStringLabel_td.className = 'paramLabel';
minStringLabel_td.textContent = 'Minimum string resistance';
minStringValue_td = document.createElement('td');
minStringValue_td.textContent = resValToString(settings.minStringRes, 6);
minString_tr.appendChild(minStringLabel_td);
minString_tr.appendChild(minStringValue_td);
tableFragment.appendChild(minString_tr);
maxString_tr = document.createElement('tr');
maxStringLabel_td = document.createElement('td');
maxStringLabel_td.className = 'paramLabel';
maxStringLabel_td.textContent = 'Maximum string resistance';
maxStringValue_td = document.createElement('td');
maxStringValue_td.textContent = resValToString(settings.maxStringRes, 6);
maxString_tr.appendChild(maxStringLabel_td);
maxString_tr.appendChild(maxStringValue_td);
tableFragment.appendChild(maxString_tr);
resSeries_tr = document.createElement('tr');
resSeries_tr.className = 'shadedRow';
resSeries_td = document.createElement('td');
resSeries_td.className = 'groupCol';
resSeries_td.colSpan = '2';
switch (settings.resSeries) {
case seriesEnum.E24:
resSeries_td.textContent = 'EIA E24 series resistor values';
break;
case seriesEnum.E96:
resSeries_td.textContent = 'EIA E96 series resistor values';
break;
default:
resSeries_td.textContent = 'EIA E24 and E96 series resistor values';
break;
}
resSeries_tr.appendChild(resSeries_td);
tableFragment.appendChild(resSeries_tr);
// Display No Results title
title_span = document.getElementById('outTitleSpan');
title_span.textContent = 'No Results Found';
title_div = document.getElementById('outTitleDiv');
title_div.style.display = 'block';
// Display table with diagnostic message
results_table = document.getElementById('resultsTable');
results_table.appendChild(tableFragment);
results_table.style.display = 'table';
// Set displayType in sessionStorage and remove previously
// stored results.
try {
window.sessionStorage.removeItem('vdiv_displayType');
window.sessionStorage.removeItem('vdiv_storedResults');
} catch(err) {
// Ignore exceptions
}
};
}) ();
(function() {
'use strict';
// Bring in globals with shorter names.
var ratioEnum = window.voltDiv.ratioEnum;
var resValToString = window.voltDiv.resValToString;
// Displays the results in a table on the .html page
// as well as the spreadsheet download links.
window.voltDiv.displayResults = function() {
// Bring in globals with shorter names.
var settings = window.voltDiv.settings;
var tableFragment = document.createDocumentFragment();
var jResult;
var shadeRow;
var thisGroup;
var thisResult;
var grayDiv_tr;
var grayDiv_td;
var result_tr;
var resultGroup_td;
var resultUpper_td;
var resultLower_td;
var resultString_td;
var resultMinRatio_td;
var resultNomRatio_td;
var resultMaxRatio_td;
var resultDiff_td;
var title_span;
var title_div;
var download_span;
var clear_span;
var ratio_span;
var results_table;
var header_tr = document.createElement('tr');
var group_th = document.createElement('th');
var upper_th = document.createElement('th');
var lower_th = document.createElement('th');
var string_th = document.createElement('th');
var minRatio_th = document.createElement('th');
var nomRatio_th = document.createElement('th');
var maxRatio_th = document.createElement('th');
var diffRatio_th = document.createElement('th');
group_th.textContent = 'Group';
upper_th.textContent = 'Upper';
lower_th.textContent = 'Lower';
string_th.textContent = 'String';
minRatio_th.textContent = 'Min\u00A0Ratio';
nomRatio_th.textContent = 'Nom\u00A0Ratio';
maxRatio_th.textContent = 'Max\u00A0Ratio';
switch (settings.ratioType) {
case ratioEnum.MIN:
diffRatio_th.textContent = 'Min\u00A0Ratio\u00A0\u2212\u00A0Target';
break;
case ratioEnum.MAX:
diffRatio_th.textContent = 'Max\u00A0Ratio\u00A0\u2212\u00A0Target';
break;
default:
diffRatio_th.textContent = 'Nom\u00A0Ratio\u00A0\u2212\u00A0Target';
break;
}
header_tr.appendChild(group_th);
header_tr.appendChild(upper_th);
header_tr.appendChild(lower_th);
header_tr.appendChild(string_th);
header_tr.appendChild(minRatio_th);
header_tr.appendChild(nomRatio_th);
header_tr.appendChild(maxRatio_th);
header_tr.appendChild(diffRatio_th);
tableFragment.appendChild(header_tr);
// Display results, putting a gray divider between groups
shadeRow = false;
thisGroup = window.voltDiv.sortedResults[0].groupNum;
for (jResult = 0; jResult < window.voltDiv.sortedResults.length; jResult++) {
thisResult = window.voltDiv.sortedResults[jResult];
if (thisResult.groupNum !== thisGroup) {
// Put a gray divider row between groups.
shadeRow = false;
grayDiv_tr = document.createElement('tr');
grayDiv_td = document.createElement('td');
grayDiv_tr.className = 'grayRow';
grayDiv_td.colSpan = '8';
grayDiv_tr.appendChild(grayDiv_td);
tableFragment.appendChild(grayDiv_tr);
thisGroup = thisResult.groupNum;
}
// Display this result
result_tr = document.createElement('tr');
// Shade every other row within a group
if (shadeRow) {
result_tr.className = 'shadedRow';
shadeRow = false;
} else {
result_tr.className = 'normalRow';
shadeRow = true;
}
resultGroup_td = document.createElement('td');
resultUpper_td = document.createElement('td');
resultLower_td = document.createElement('td');
resultString_td = document.createElement('td');
resultMinRatio_td = document.createElement('td');
resultNomRatio_td = document.createElement('td');
resultMaxRatio_td = document.createElement('td');
resultDiff_td = document.createElement('td');
resultGroup_td.className = 'groupCol';
resultGroup_td.textContent = thisResult.groupNum.toString();
resultUpper_td.textContent = resValToString(thisResult.resUpper, 3);
resultLower_td.textContent = resValToString(thisResult.resLower, 3);
resultString_td.textContent = resValToString(thisResult.stringRes, 6);
resultMinRatio_td.textContent = thisResult.minRatio.toPrecision(6);
resultNomRatio_td.textContent = thisResult.nomRatio.toPrecision(6);
resultMaxRatio_td.textContent = thisResult.maxRatio.toPrecision(6);
resultDiff_td.className = 'diffCol';
resultDiff_td.textContent = thisResult.ratioDiff.toExponential(4);
result_tr.appendChild(resultGroup_td);
result_tr.appendChild(resultUpper_td);
result_tr.appendChild(resultLower_td);