Update inductor_imp.html

Added impedance. Re-arranged display.
pull/2/head
miguel 2020-11-25 17:12:26 +11:00
rodzic 06b399c5b5
commit ed492a33d5
1 zmienionych plików z 125 dodań i 43 usunięć

Wyświetl plik

@ -16,11 +16,11 @@
<div class="slider_container">
<div class="sliders">
<label for="conductor_diameter_slider">&#8960a:</label>
<input type="range" id="conductor_diameter_slider" min="0.010" max="0.204" value="0.032" step="0.001">
<input type="range" id="conductor_diameter_slider" min="0.005" max="0.204" value="0.032" step="0.001">
</div>
<div class="sliders">
<label for="loop_diameter_slider">&#8960b:</label>
<input type="range" id="loop_diameter_slider" min="0.25" max="2.0" value="0.50" step="0.01">
<input type="range" id="loop_diameter_slider" min="0.25" max="2.0" value="1.00" step="0.01">
</div>
<div class="sliders">
<label for="loop_spacing_slider">c/a:</label>
@ -72,8 +72,7 @@
</ul>
</div>
</section>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.3/Chart.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/chartjs-plugin-crosshair@1.1.2"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjs/7.5.1/math.min.js"></script>
<script src="inductor.js"></script>
<script>
// Define global storage for calculated values, so we don't recalculate the same things multiple times:
@ -83,7 +82,10 @@
Rdc : 0.0,
SRF : 0.0,
X : 0.0,
f : 0.0,
Xl : 0.0,
Xc : 0.0,
Z : 0.0,
skin_depth : 0.0,
Rac : 0.0,
Q : 0.0
@ -103,10 +105,17 @@
inductor.Rdc = dcResistance(loop_diameter_meters, cond_diameter_meters, spacing_ratio, loop_turns);
inductor.SRF = selfResonantFrequency(inductor.L, inductor.C);
// Frequency dependent characteristics:
inductor.X = inductiveReactance(frequency_hz, inductor.L);
inductor.f = frequency_hz;
inductor.Xl = inductiveReactance(frequency_hz, inductor.L);
inductor.Xc = capacitiveReactance(frequency_hz, inductor.C);
inductor.skin_depth = skinDepth(frequency_hz);
inductor.Rac = acResistance(loop_diameter_meters, cond_diameter_meters, spacing_ratio, loop_turns, frequency_hz);
inductor.Q = qualityFactor(inductor.X, inductor.Rac);
inductor.Q = qualityFactor(inductor.Xl, inductor.Rac);
// Calculate impedance:
var Zl = math.complex(inductor.Rac, inductor.Xl);
var Zc = math.complex(0, inductor.Xc);
inductor.Z = math.divide(math.multiply(Zl, Zc), math.add(Zl, Zc)).toPolar();
// Redraw the canvas:
drawDesign();
}
@ -203,11 +212,15 @@
fctx.lineTo(loopx + loop_radius + 3.0*arrow_size, y_offset);
fctx.stroke();
// Write loop diameter symbol:
// Write conductor diameter symbol:
fctx.font = "12px arial";
const cond_dia = 1.0 * conductor_diameter_slider.value;
fctx.textAlign = "right";
fctx.fillText("\u2300a = " + cond_dia.toFixed(3).toString() + "\"", loopx - loop_radius - 2.0*arrow_size, loopy - 6);
// Write loop diameter symbol:
const loop_dia = 1.0 * loop_diameter_slider.value; // Convert from mm to inches
fctx.fillText("\u2300b = " + loop_dia.toPrecision(3).toString() + "\"", loopx - loop_radius - 2.0*arrow_size, y_offset - 2);
fctx.fillText("\u2300b = " + loop_dia.toFixed(2).toString() + "\"", loopx - loop_radius - 2.0*arrow_size, y_offset - 2);
// Draw inner-diameter arrows: (for using a winding former)
const inner_dia_y = loopy + loop_radius + 40;
@ -263,92 +276,160 @@
// Draw conductor diameter arrow:
fctx.beginPath();
fctx.moveTo(loopx + loop_radius - cond_radius, loopy);
fctx.lineTo(loopx + loop_radius - cond_radius - arrow_size, loopy - arrow_size);
fctx.lineTo(loopx + loop_radius - cond_radius - arrow_size, loopy + arrow_size);
fctx.lineTo(loopx + loop_radius - cond_radius, loopy);
fctx.lineTo(loopx - 0.6*loop_radius, loopy);
fctx.moveTo(loopx - loop_radius - cond_radius, loopy);
fctx.lineTo(loopx - loop_radius - cond_radius - arrow_size, loopy - arrow_size);
fctx.lineTo(loopx - loop_radius - cond_radius - arrow_size, loopy + arrow_size);
fctx.lineTo(loopx - loop_radius - cond_radius, loopy);
fctx.lineTo(loopx - loop_radius - 3.0*arrow_size, loopy);
fctx.stroke();
fctx.beginPath();
fctx.moveTo(loopx + loop_radius + cond_radius, loopy);
fctx.lineTo(loopx + loop_radius + cond_radius + arrow_size, loopy - arrow_size);
fctx.lineTo(loopx + loop_radius + cond_radius + arrow_size, loopy + arrow_size);
fctx.lineTo(loopx + loop_radius + cond_radius, loopy);
fctx.lineTo(loopx + loop_radius + cond_radius + 2.0*arrow_size, loopy);
fctx.moveTo(loopx - loop_radius + cond_radius, loopy);
fctx.lineTo(loopx - loop_radius + cond_radius + arrow_size, loopy - arrow_size);
fctx.lineTo(loopx - loop_radius + cond_radius + arrow_size, loopy + arrow_size);
fctx.lineTo(loopx - loop_radius + cond_radius, loopy);
fctx.lineTo(loopx - loop_radius + cond_radius + 2.0*arrow_size, loopy);
fctx.stroke();
//fctx.textAlign = "right";
const cond_dia = 1.0 * conductor_diameter_slider.value;
fctx.textAlign = "center";
fctx.fillText("\u2300a = " + cond_dia.toPrecision(2).toString() + "\"", loopx, loopy - 6);
var awg = "";
var swg = "";
switch(cond_dia) {
case 0.004 :
awg = "38 AWG";
awg = " 38 AWG";
break;
case 0.005 :
awg = "36 AWG";
awg = " 36 AWG";
swg = "39-40 SWG";
break;
case 0.006 :
swg = " 38 SWG";
break;
case 0.007 :
swg = "~37 SWG";
break;
case 0.008 :
awg = "32 AWG";
awg = " 32 AWG";
swg = "35-36 SWG";
break;
case 0.009 :
swg = "~34 SWG";
break;
case 0.010 :
awg = "30 AWG";
awg = " 30 AWG";
swg = " 33 SWG";
break;
case 0.011 :
swg = "~32 SWG";
break;
case 0.012 :
swg = "30-31 SWG";
break;
case 0.013 :
awg = "~28 AWG";
break;
case 0.015 :
swg = "~28 SWG";
break;
case 0.016 :
awg = "26 AWG";
awg = " 26 AWG";
break;
case 0.018 :
awg = "25 AWG";
awg = " 25 AWG";
swg = " 26 SWG";
break;
case 0.020 :
awg = "24 AWG";
awg = " 24 AWG";
swg = " 25 SWG";
break;
case 0.022 :
swg = " 24 SWG";
break;
case 0.024 :
swg = " 23 SWG";
break;
case 0.025 :
awg = "~22 AWG";
break;
case 0.028 :
swg = " 22 SWG";
break;
case 0.032 :
awg = "20 AWG";
awg = " 20 AWG";
swg = " 21 SWG";
break;
case 0.036 :
swg = " 20 SWG";
break;
case 0.040 :
awg = "~18 AWG";
break;
case 0.048 :
swg = " 18 SWG";
break;
case 0.051 :
awg = "~16 AWG";
break;
case 0.056 :
swg = " 17 SWG";
break;
case 0.064 :
awg = "~14 AWG";
swg = " 16 SWG";
break;
case 0.072 :
swg = " 15 SWG";
break;
case 0.080 :
swg = " 14 SWG";
break;
case 0.081 :
awg = "~12 AWG";
break;
case 0.102 :
awg = "10 AWG";
awg = " 10 AWG";
break;
case 0.104 :
swg = " 12 SWG";
break;
case 0.114 :
awg = "~9 AWG";
awg = "~ 9 AWG";
break;
case 0.116 :
swg = " 11 SWG";
break;
case 0.128 :
awg = "~8 AWG";
awg = "~ 8 AWG";
swg = " 10 SWG";
break;
case 0.144 :
awg = "~7 AWG";
awg = "~ 7 AWG";
swg = " 9 SWG";
break;
case 0.160 :
swg = " 8 SWG";
break;
case 0.162 :
awg = "6 AWG";
awg = " 6 AWG";
break;
case 0.182 :
awg = "5 AWG";
awg = " 5 AWG";
break;
case 0.192 :
swg = " 6 SWG";
break;
case 0.204 :
awg = "~4 AWG";
awg = "~ 4 AWG";
break;
case 0.232 :
swg = " 4 SWG";
break;
}
fctx.textAlign = "left";
fctx.fillText(awg, loopx + loop_radius + cond_radius + 2.0*arrow_size, loopy - 6);
fctx.textAlign = "center";
fctx.font = "14px courier";
fctx.fillText(awg, loopx, loopy - 6);
fctx.fillText(swg, loopx, loopy + 12);
fctx.font = "12px arial";
@ -435,10 +516,11 @@
fctx.textAlign = "right";
var freq = 1.0 * frequency_slider.value;
fctx.fillText("f = " + freq.toFixed(1) + " MHz", win_width-18, 18);
fctx.fillText("Xl = " + inductor.X.toFixed(1) + " \u03A9", win_width-18, 32);
fctx.fillText("\u03B4 = " + (inductor.skin_depth * 1e6).toFixed(1) + " \u03BCm", win_width-18, 46);
fctx.fillText("Rac = " + inductor.Rac.toFixed(2) + " \u03A9", win_width-18, 60);
fctx.fillText("Q = " + inductor.Q.toFixed(1), win_width-18, 74);
fctx.fillText("Xl = " + inductor.Xl.toFixed(1) + " \u03A9", win_width-18, 32);
fctx.fillText("|Z| = " + inductor.Z.r.toFixed(1) + " \u03A9", win_width-18, 46);
fctx.fillText("\u03B4 = " + (inductor.skin_depth * 1e6).toFixed(1) + " \u03BCm", win_width-18, 60);
fctx.fillText("Rac = " + inductor.Rac.toFixed(2) + " \u03A9", win_width-18, 74);
fctx.fillText("Q = " + inductor.Q.toFixed(1), win_width-18, 88);
fctx.textAlign = "center";
fctx.fillText("N = " + loop_turns_slider.value.toString(), win_width/2, win_height * 0.52);