-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
211 lines (184 loc) · 6.37 KB
/
index.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
<!DOCTYPE html>
<html>
<head>
<title>Spice diode model</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width" />
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="0">
<link rel="shortcut icon" href="icon.png" type="image/png" />
<script type="text/javascript" src="canvas.js?version=191"></script>
<script type="text/javascript" src="chart_xyxy.js?version=191"></script>
<script type="text/javascript" src="engineering.js?version=191"></script>
<script type="text/javascript" src="models.js?version=191"></script>
<script type="text/javascript" src="optimize.js?version=191"></script>
<script type="text/javascript" src="csv/all.js?version=191"></script>
<script type="text/javascript" src="index.js?version=191"></script>
<style>
body {
font-family: sans-serif;
}
h3 {
margin: 0;
padding: 0;
}
label {
display: inline-block;
min-width: 4em;
}
input[type=number] {
max-width: 18ex;
min-width: 18ex;
}
table, tr, td, th {
border: 1px solid black;
border-collapse: collapse;
}
td {
min-width: 3ex;
text-align: right;
max-width: 3em;
overflow: hidden;
}
#chart1 {
width: 100%;
height: 80vw;
}
@media only screen and (min-width: 800px) {
#chart {
display: inline-block;
}
#chart table {
max-widthg: 50vw;
}
#chart1 {
width: 45vw;
height: 45vw;
}
main {
max-width: 50vw;
position: fixed;
left: 50vw;
top: 1ex;
}
}
</style>
</head>
<body>
<div id="chart" style="outline: 0px solid red;">
<div style="position: relative;">
<div id="zoom_to_fit" style="position: absolute; top: 0ex; left: 0ex; cursor: pointer;" title="Zoom to fit curves into chart">🔎</div>
</div>
<canvas id="chart1" style=""></canvas>
<div style="display: flex; align-items: center;">
<label style="user-select: none;"><input id="logy" type="checkbox">Logarithmic</label>
<div style="flex: 1;"></div>
<div>
<span style="color: red;">—</span> real diode,
<span style="color: green;">—</span> model
</div>
</div>
<br>
Difference: <span id="diff_total">0</span>
<table id="diff" style="font-size: small;">
<tr id="diff_u">
<th>U/mV</th>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
</tr>
<tr id="diff_i_real">
<th>I<sub>real</sub>/mA</th>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
</tr>
<tr id="diff_i_model">
<th>I<sub>model</sub>/mA</th>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
</tr>
<tr id="diff_percent">
<th>Δ/%</th>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
</tr>
</table>
<br>
Optimize model
<label title="Optimize model to have lowest average difference"><input id="optimize_for_avg" name="optimize_for" type="radio" checked>average</label>
<label title="Optimize model to have lowest maximal difference"><input id="optimize_for_max" name="optimize_for" type="radio">max</label>
<button id="start_monte_carlo">Start</button>
<button id="stop_monte_carlo" disabled>Stop</button>
</div>
<main>
<h3>Settings</h3>
<p>
<label>Temperature</label>
<input id="temperature" type="number" value="25" min="-273" max="150" step="1" dataWheelStep="1"/>°C
</p>
<h3 style="color: red;">Real diode</h3>
<p>
Paste CSV file with forward voltage in volts and forward current in amps (e.g. 2.7mA is 0.0027 or 2.7e-3), comma separated values, each measurement on new line.
You can also use one of these real measured diodes:
<select id="preset_real"></select>
<a href="how_to_measure_diode.png">How to measure diode</a>.
You can publish your measurements on <a href="https://github.com/dvhx/spice-diode-model-js">github</a>.
<br>
<br>
<textarea id="measured_values" spellcheck="false" style="width: 18em; height: 22em; display: block;" placeholder="Paste CSV file here"></textarea>
</p>
<h3 style="color: green;">Diode model</h3>
<p>
<label>IS</label>
<input title="" id="IS" type="number" value="1.46464e-9" min="0" max="10" step="0.000000000001" dataWheelStep="0.05"/>A - Reverse saturation current
<br>
<label>N</label>
<input title="" id="N" type="number" value="1.71972" min="0" max="10" step="0.01" dataWheelStep="0.005"/> Emission coefficient
<br>
<label>RS</label>
<input title="" id="RS" type="number" value="0.355592" min="0" max="1000" step="0.01" dataWheelStep="0.1"/>Ω - Ohmic (series) resistance
<br>
<label>Preset</label>
<select id="preset_model">
<option selected></option>
</select>
</p>
<p style="font-size: small;">
<b>Spice code:</b> <span id="spice"></span><br><br>
<b>JS code:</b> <span id="js_code"></span> <span id="js_diff"></span><br>
</p>
</main>
</body>
</html>