-
Notifications
You must be signed in to change notification settings - Fork 7
/
marshall.htm
344 lines (306 loc) · 15.6 KB
/
marshall.htm
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
<!DOCTYPE html>
<HTML>
<HEAD>
<TITLE>TSC in the web</TITLE>
<LINK href="nouislider.css" rel="stylesheet"/>
<SCRIPT type="text/javascript" src="nouislider.min.js"></SCRIPT>
<LINK href="dygraph.css" rel="stylesheet"/>
<LINK href="tsc.css" rel="stylesheet"/>
<LINK href="https://fonts.googleapis.com/css?family=Barlow+Condensed|Raleway" rel="stylesheet">
<SCRIPT type="text/javascript" src="dygraph.min.js"></SCRIPT>
<SCRIPT type="text/javascript" src="rlc.js"></SCRIPT>
<SCRIPT type="text/javascript" src="tsc_common.js"></SCRIPT>
</HEAD>
<BODY>
<FORM name="frm">
<TABLE class="tonestack-layout">
<TR>
<TD colspan="3" class="navbar">
<DIV id="linkDiv" class="navbar-stack"></DIV>
<DIV id="infoDiv" class="navbar-info"><a href="info.htm" class="navbar-menu-item">INFO</a></DIV>
</TD>
</TR>
<TR>
<TD class="tonestack-image">
<IMG src="marshall2_pic.png"></IMG>
</TD>
<TD class="tonestack-values">
<table class="tonestack-values-table">
<thead>
<tr>
<th class="tonestack-value-th-part">Part</th>
<th class="tonestack-value-th-value">Value</th>
<th class="tonestack-value-th-unit"></th>
</tr>
</thead>
<tbody>
<tr>
<td class="tonestack-value-label"><label for="id_RIN">RIN</label></td>
<td class="tonestack-value-value"><INPUT type="text" name="RIN" id="id_RIN" size="7" readonly="readonly" class="tonestack-value-input resistance"></td>
<td class="tonestack-value-unit">Ω</td>
</tr>
<tr>
<td class="tonestack-value-label"><label for="id_R1">R1</label></td>
<td class="tonestack-value-value"><INPUT type="text" name="R1" id="id_R1" size="7" readonly="readonly" class="tonestack-value-input resistance"></td>
<td class="tonestack-value-unit">Ω</td>
</tr>
<tr>
<td class="tonestack-value-label"><label for="id_RT">RT</label></td>
<td class="tonestack-value-value"><INPUT type="text" name="RT" id="id_RT" size="7" readonly="readonly" class="tonestack-value-input resistance"></td>
<td class="tonestack-value-unit">Ω</td>
</tr>
<tr>
<td class="tonestack-value-label"><label for="id_RB">RB</label></td>
<td class="tonestack-value-value"><INPUT type="text" name="RB" id="id_RB" size="7" readonly="readonly" class="tonestack-value-input resistance"></td>
<td class="tonestack-value-unit">Ω</td>
</tr>
<tr>
<td class="tonestack-value-label"><label for="id_RM">RM</label></td>
<td class="tonestack-value-value"><INPUT type="text" name="RM" id="id_RM" size="7" readonly="readonly" class="tonestack-value-input resistance"></td>
<td class="tonestack-value-unit">Ω</td>
</tr>
<tr>
<td class="tonestack-value-label"><label for="id_RL">RL</label></td>
<td class="tonestack-value-value"><INPUT type="text" name="RL" id="id_RL" size="7" readonly="readonly" class="tonestack-value-input resistance"></td>
<td class="tonestack-value-unit">Ω</td>
</tr>
<tr>
<td class="tonestack-value-label"><label for="id_C1">C1</label></td>
<td class="tonestack-value-value"><INPUT type="text" name="C1" id="id_C1" size="7" readonly="readonly" class="tonestack-value-input capacitance"></td>
<td class="tonestack-value-unit">F</td>
</tr>
<tr>
<td class="tonestack-value-label"><label for="id_C2">C2</label></td>
<td class="tonestack-value-value"><INPUT type="text" name="C2" id="id_C2" size="7" readonly="readonly" class="tonestack-value-input capacitance"></td>
<td class="tonestack-value-unit">F</td>
</tr>
<tr>
<td class="tonestack-value-label"><label for="id_C3">C3</label></td>
<td class="tonestack-value-value"><INPUT type="text" name="C3" id="id_C3" size="7" readonly="readonly" class="tonestack-value-input capacitance"></td>
<td class="tonestack-value-unit">F</td>
</tr>
</tbody>
</table>
<CENTER>
<INPUT type="button" name="edit" value="Edit" title="Edit values" id="id_edit" class="tonestack-values-button">
<INPUT type="submit" name="apply" value="Apply" title="Apply values" id="id_apply" class="tonestack-values-button">
<INPUT type="button" name="defaults" value="Default" title="Set default values" id="id_defaults" class="tonestack-values-button">
</CENTER>
</TD>
<TD rowspan="2" class="tonestack-graph-panel">
<div class="tonestack-bar">
<div class="tonestack-graph-toggle">
Amplitude<input type="checkbox" name="graphToggle" class="toggle">Phase
</div>
<input type="button" name="Clear" value="Clear snapshots" id="id_clear" class="tonestack-values-button tonestack-graph-button">
<input type="button" name="Snapshot" value="Take snapshot" id="id_snapshot" class="tonestack-values-button tonestack-graph-button">
<input type="button" name="Sweep" value="Sweep" id="id_sweep" class="tonestack-values-button tonestack-graph-button">
</div>
<div id="graphContainer" class="tonestack-graph-container">
<div id="graph" class="tonestack-graph"></div>
<div id="graph2" class="tonestack-graph hidden"></div>
<div id="legendDiv" class="tonestack-graph-value"></div>
</div>
</TD>
</TR>
<TR>
<TD colspan="2" class="tonestack-sliders">
<BR>
<SPAN id="label_RB" class="tonestack-slider-label">RB
<select id="id_RB_pot" name="RB_pot" class="tonestack-select-pot">
<option value="Linear">Linear</option>
<option value="LogA">LogA</option>
<option value="LogB" selected="selected">LogB</option>
</select>
</SPAN>
<DIV id="range_RB" class="tonestack-slider-input"></DIV>
<SPAN id="value_RB" class="tonestack-slider-value"></SPAN><BR><BR><BR><BR>
<SPAN id="label_RM" class="tonestack-slider-label">RM
<select id="id_RM_pot" name="RM_pot" class="tonestack-select-pot">
<option value="Linear" selected="selected">Linear</option>
<option value="LogA">LogA</option>
<option value="LogB">LogB</option>
</select>
</SPAN>
<DIV id="range_RM" class="tonestack-slider-input"></DIV>
<SPAN id="value_RM" class="tonestack-slider-value"></SPAN><BR><BR><BR><BR>
<SPAN id="label_RT" class="tonestack-slider-label">RT
<select id="id_RT_pot" name="RT_pot" class="tonestack-select-pot">
<option value="Linear" selected="selected">Linear</option>
<option value="LogA">LogA</option>
<option value="LogB">LogB</option>
</select>
</SPAN>
<DIV id="range_RT" class="tonestack-slider-input"></DIV>
<SPAN id="value_RT" class="tonestack-slider-value"></SPAN><BR><BR><BR><BR>
</TD>
</TR>
</TABLE>
<SCRIPT>
// create links to all the tone stack pages to the top of the page
createLinks("linkDiv","Marshall");
// component variables for calculation
var RTreble;
var RBass;
var RMid
var RIN;
var RL;
var R1;
var C1;
var C2;
var C3;
// create sliders and save the div-element of the slider
var range_RB = createSlider('range_RB','value_RB');
var range_RM = createSlider('range_RM','value_RM');
var range_RT = createSlider('range_RT','value_RT');
// Graph objects
var X = createFrequencies(90,10,100000,1);
var graph1 = new tscGraph(X, "frequency [Hz]", "amplitude [dB]", "Marshall");
var graph2 = new tscGraph(X, "frequency [Hz]", "phase", "Marshall", 0, "graph2");
currentGraph = graph1;
initializeForm();
// Set default part values, plus any customizations
setDefaultValues();
setCustomValues();
// Apply part values and display settings
applyValues();
if (document.frm.graphToggle.checked) {
swapGraphs();
}
// this function is called when the Apply-button is clicked
function applyValues() {
const f = document.frm;
RIN = tscResistance.parseElement(f.RIN);
R1 = tscResistance.parseElement(f.R1);
RBass = tscResistance.parseElement(f.RB);
RMid = tscResistance.parseElement(f.RM);
RTreble = tscResistance.parseElement(f.RT);
RL = tscResistance.parseElement(f.RL);
C1 = tscCapacitance.parseElement(f.C1);
C2 = tscCapacitance.parseElement(f.C2);
C3 = tscCapacitance.parseElement(f.C3);
// set the input fields to readonly mode
var inputElements = f.getElementsByTagName('input');
for (var i in inputElements) {
if (inputElements[i].type == "text") {
inputElements[i].setAttribute('readonly', 'readonly');
}
}
updateURL();
doCalc();
}
// this function is called when the Edit-button is clicked
function editValues() {
var inputElements = document.frm.getElementsByTagName('input');
for (var i in inputElements) {
if (inputElements[i].type == "text") {
inputElements[i].removeAttribute('readonly');
}
}
}
// This function resets form fields to their default values
function setDefaultValues() {
const f = document.frm;
// Pair form element names to default values
const defaultValues = {
RIN : "1300",
R1 : "33k",
RT : "220k",
RB : "1M",
RM : "25k",
RL : "517k",
C1 : "470p",
C2 : "22n",
C3 : "22n",
RB_pot : "LogB",
RM_pot : "Linear",
RT_pot : "Linear",
}
// Set default values and clear any custom form validation errors
for (var key in defaultValues) {
f[key].value = defaultValues[key];
f[key].setCustomValidity("");
}
}
function sweepValues() {
range_RB.noUiSlider.set(5);
range_RM.noUiSlider.set(5);
range_RT.noUiSlider.set(5);
addSeries();
for (p = 0; p <= 10; p += 10) {
range_RB.noUiSlider.set(p);
for (q = 0; q <=10; q += 10) {
range_RM.noUiSlider.set(q);
for (r = 0; r <=10; r += 10) {
range_RT.noUiSlider.set(r);
addSeries();
}
}
}
}
// This function is called with every change of the slider.
// It does the hard math and evaluates the filter transfer function
// for the given frequency range and updates values to the graph.
function doCalc() {
// pot rotation 0 - 10 from the slider component
var RotTreble = getRotationForPotType(range_RT.noUiSlider.get(), document.frm.RT_pot.value);
var RotMid = getRotationForPotType(range_RM.noUiSlider.get(), document.frm.RM_pot.value);
var RotBass = getRotationForPotType(range_RB.noUiSlider.get(), document.frm.RB_pot.value);
// Calculated part values
var RT2 = Math.round( RTreble*(1.0*RotTreble/10.0) );
var RT1 = Math.round( RTreble*(1.0 - 1.0*RotTreble/10.0) );
var RB = Math.round( RBass*(1.0*RotBass/10.0) );
var RM2 = Math.round( RMid*(1.0*RotMid/10.0) );
var RM1 = Math.round( RMid*(1.0 - 1.0*RotMid/10.0) );
// Transfer function denominator coefficients
var DEN_AIm = RM1*RM2*RT1*RT2*C1*C2*C3 + RB*RM2*RT1*RT2*C1*C2*C3 + RIN*RM1*RT1*RT2*C1*C2*C3 + R1*RM1*RT1*RT2*C1*C2*C3
+ RB*RIN*RT1*RT2*C1*C2*C3 + R1*RB*RT1*RT2*C1*C2*C3 + RL*RM1*RM2*RT2*C1*C2*C3 + RIN*RM1*RM2*RT2*C1*C2*C3
+ RB*RL*RM2*RT2*C1*C2*C3 + RB*RIN*RM2*RT2*C1*C2*C3 + RIN*RL*RM1*RT2*C1*C2*C3 + R1*RL*RM1*RT2*C1*C2*C3
+ R1*RIN*RM1*RT2*C1*C2*C3 + RB*RIN*RL*RT2*C1*C2*C3 + R1*RB*RL*RT2*C1*C2*C3 + R1*RB*RIN*RT2*C1*C2*C3
+ RL*RM1*RM2*RT1*C1*C2*C3 + RIN*RM1*RM2*RT1*C1*C2*C3 + R1*RM1*RM2*RT1*C1*C2*C3 + RB*RL*RM2*RT1*C1*C2*C3
+ RB*RIN*RM2*RT1*C1*C2*C3 + R1*RB*RM2*RT1*C1*C2*C3 + RIN*RL*RM1*RT1*C1*C2*C3 + R1*RL*RM1*RT1*C1*C2*C3
+ RB*RIN*RL*RT1*C1*C2*C3 + R1*RB*RL*RT1*C1*C2*C3 + R1*RL*RM1*RM2*C1*C2*C3 + R1*RIN*RM1*RM2*C1*C2*C3
+ R1*RB*RL*RM2*C1*C2*C3 + R1*RB*RIN*RM2*C1*C2*C3 + R1*RIN*RL*RM1*C1*C2*C3 + R1*RB*RIN*RL*C1*C2*C3;
var DEN_BRe = RM2*RT1*RT2*C1*C2 + RM1*RT1*RT2*C1*C2 + RIN*RT1*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RM2*RT1*C1*C3
+ R1*RM2*RT1*C1*C3 + RIN*RM1*RT1*C1*C3 + R1*RM1*RT1*C1*C3 + RIN*RL*RT1*C1*C3 + R1*RL*RT1*C1*C3 + RB*RIN*RT1*C1*C3
+ R1*RB*RT1*C1*C3 + RL*RM1*RM2*C1*C3 + RIN*RM1*RM2*C1*C3 + RB*RL*RM2*C1*C3 + R1*RL*RM2*C1*C3 + RB*RIN*RM2*C1*C3
+ R1*RIN*RM2*C1*C3 + RIN*RL*RM1*C1*C3 + R1*RL*RM1*C1*C3 + R1*RIN*RM1*C1*C3 + RB*RIN*RL*C1*C3 + R1*RIN*RL*C1*C3
+ R1*RB*RL*C1*C3 + R1*RB*RIN*C1*C3;
var DEN_CIm = RM2*RT2*C2 + RM1*RT2*C2 + RIN*RT2*C2 + RB*RT2*C2 + R1*RT2*C2 + RL*RM2*C2 + RIN*RM2*C2
+ R1*RM2*C2 + RL*RM1*C2 + RIN*RM1*C2 + R1*RM1*C2 + RIN*RL*C2 + RB*RL*C2 + R1*RL*C2 + RB*RIN*C2 + R1*RB*C2 + RT1*RT2*C1 + RL*RT2*C1 + RIN*RT2*C1
+ RM2*RT1*C1 + RM1*RT1*C1 + RL*RT1*C1 + RB*RT1*C1 + RL*RM2*C1 + RIN*RM2*C1 + RL*RM1*C1 + RIN*RM1*C1 + RIN*RL*C1 + RB*RL*C1 + RB*RIN*C1
+ RM2*RT2*C3 + RIN*RT2*C3 + R1*RT2*C3 + RM1*RM2*C3 + RL*RM2*C3 + RIN*RM2*C3 + RB*RM2*C3 + R1*RM2*C3 + RIN*RM1*C3 + R1*RM1*C3
+ RIN*RL*C3 + R1*RL*C3 + RB*RIN*C3 + R1*RB*C3;
var DEN_DRe = RT2 + RM2 + RM1 + RL + RB;
// Transfer function numerator coefficients
var NOM_AIm = C1*C2*C3*RL*RM1*RM2*RT2 + C1*C2*C3*RB*RL*RM2*RT2
+ C1*C2*C3*R1*RL*RM1*RT2 + C1*C2*C3*R1*RB*RL*RT2 + C1*C2*C3*RL*RM1*RM2*RT1
+ C1*C2*C3*RB*RL*RM2*RT1 + C1*C2*C3*R1*RL*RM1*RM2 + C1*C2*C3*R1*RB*RL*RM2
var NOM_BRe = C1*C3*RL*RM2*RT2 + C1*C2*RL*RM2*RT2 + C1*C2*RL*RM1*RT2
+ C1*C2*RB*RL*RT2 + C1*C3*R1*RL*RT2 + C1*C2*R1*RL*RT2 + C1*C3*RL*RM2*RT1
+ C1*C2*RL*RM2*RT1 + C1*C2*RL*RM1*RT1 + C1*C2*RB*RL*RT1 + C2*C3*RL*RM1*RM2
+ C1*C3*RL*RM1*RM2 + C2*C3*RB*RL*RM2 + C1*C3*RB*RL*RM2 + C1*C3*R1*RL*RM2
+ C1*C2*R1*RL*RM2 + C1*C3*R1*RL*RM1 + C1*C2*R1*RL*RM1 + C1*C3*R1*RB*RL
+ C1*C2*R1*RB*RL;
var NOM_CIm = C1*RL*RT2 + C3*RL*RM2 + C2*RL*RM2 + C1*RL*RM2 + C2*RL*RM1 + C1*RL*RM1 + C2*RB*RL + C1*RB*RL;
var NOM_DRe = 0;
// Calculate magnitude and phase at each frequency
doCalcBode(
[ NOM_DRe, NOM_CIm, NOM_BRe, NOM_AIm ],
[ DEN_DRe, DEN_CIm, DEN_BRe, DEN_AIm ]
);
currentGraph.update();
}
</SCRIPT>
</FORM>
</BODY>
</HTML>