kopia lustrzana https://github.com/miguelvaca/vk3cpu
Big updates to original. Cleaned up
rodzic
64e82f3c02
commit
d20a8f561c
116
inductor.html
116
inductor.html
|
@ -78,12 +78,17 @@
|
|||
<script>
|
||||
// Define global storage for calculated values, so we don't recalculate the same things multiple times:
|
||||
var inductor = {
|
||||
loop_diameter_meters : 0.0,
|
||||
cond_diameter_meters : 0.0,
|
||||
spacing_ratio : 0.0,
|
||||
loop_turns : 0.0,
|
||||
frequency_hz : 0.0,
|
||||
|
||||
L : 0.0,
|
||||
C : 0.0,
|
||||
Rdc : 0.0,
|
||||
SRF : 0.0,
|
||||
|
||||
f : 0.0,
|
||||
Xl : 0.0,
|
||||
Xc : 0.0,
|
||||
Z : 0.0,
|
||||
|
@ -95,22 +100,21 @@
|
|||
// Solve all the parameters, and re-draw the canvas:
|
||||
function recalculate() {
|
||||
// Input variables:
|
||||
const loop_diameter_meters = 0.001 * loop_diameter_slider.value;
|
||||
const cond_diameter_meters = 0.001 * conductor_diameter_slider.value;
|
||||
const spacing_ratio = 1.0 * loop_spacing_slider.value;
|
||||
const loop_turns = 1.0 * loop_turns_slider.value;
|
||||
const frequency_hz = 1e6 * frequency_slider.value;
|
||||
inductor.loop_diameter_meters = 0.001 * loop_diameter_slider.value; // Inches to mm then to m
|
||||
inductor.cond_diameter_meters = 0.001 * conductor_diameter_slider.value;
|
||||
inductor.spacing_ratio = 1.0 * loop_spacing_slider.value;
|
||||
inductor.loop_turns = 1.0 * loop_turns_slider.value;
|
||||
inductor.frequency_hz = 1e6 * frequency_slider.value;
|
||||
// Frequency independent characteristics:
|
||||
inductor.L = getInductance(loop_diameter_meters, cond_diameter_meters, spacing_ratio, loop_turns);
|
||||
inductor.C = multiloopCapacitance(loop_diameter_meters, cond_diameter_meters, spacing_ratio, loop_turns);
|
||||
inductor.Rdc = dcResistance(loop_diameter_meters, cond_diameter_meters, spacing_ratio, loop_turns);
|
||||
inductor.L = getInductance(inductor.loop_diameter_meters, inductor.cond_diameter_meters, inductor.spacing_ratio, inductor.loop_turns);
|
||||
inductor.C = multiloopCapacitance(inductor.loop_diameter_meters, inductor.cond_diameter_meters, inductor.spacing_ratio, inductor.loop_turns);
|
||||
inductor.Rdc = dcResistance(inductor.loop_diameter_meters, inductor.cond_diameter_meters, inductor.spacing_ratio, inductor.loop_turns);
|
||||
inductor.SRF = selfResonantFrequency(inductor.L, inductor.C);
|
||||
// Frequency dependent characteristics:
|
||||
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.Xl = inductiveReactance(inductor.frequency_hz, inductor.L);
|
||||
inductor.Xc = capacitiveReactance(inductor.frequency_hz, inductor.C);
|
||||
inductor.skin_depth = skinDepth(inductor.frequency_hz);
|
||||
inductor.Rac = acResistance(inductor.loop_diameter_meters, inductor.cond_diameter_meters, inductor.spacing_ratio, inductor.loop_turns, inductor.frequency_hz);
|
||||
inductor.Q = qualityFactor(inductor.Xl, inductor.Rac);
|
||||
// Calculate impedance:
|
||||
var Zl = math.complex(inductor.Rac, inductor.Xl);
|
||||
|
@ -164,10 +168,14 @@
|
|||
|
||||
fctx.clearRect(0, 0, win_width, win_height);
|
||||
const loop_radius = 0.11 * win_height; // 100; // loop_diameter_slider.value * 80;
|
||||
var cond_radius = loop_radius * conductor_diameter_slider.value / loop_diameter_slider.value;
|
||||
var cond_radius = loop_radius * (inductor.cond_diameter_meters / inductor.loop_diameter_meters);
|
||||
//var cond_radius = loop_radius * conductor_diameter_slider.value / loop_diameter_slider.value;
|
||||
const loopx = win_width/2;
|
||||
const loopy = win_height/4;
|
||||
|
||||
const loop_diameter_mm = inductor.loop_diameter_meters * 1000.0;
|
||||
const cond_diameter_mm = inductor.cond_diameter_meters * 1000.0;
|
||||
|
||||
fctx.font = "bold 14px arial";
|
||||
fctx.textAlign = "center";
|
||||
fctx.fillText("Wire - Metric", win_width*0.5, 18);
|
||||
|
@ -214,14 +222,14 @@
|
|||
|
||||
// Write conductor diameter symbol:
|
||||
fctx.font = "12px arial";
|
||||
const cond_dia = 1.0 * conductor_diameter_slider.value;
|
||||
//const cond_dia = 1.0 * conductor_diameter_slider.value;
|
||||
fctx.textAlign = "right";
|
||||
fctx.fillText("\u2300a = " + cond_dia.toFixed(2).toString() + "mm", loopx - loop_radius - 2.0*arrow_size, loopy - 6);
|
||||
fctx.fillText("(" + (cond_dia**2).toFixed(2).toString() + " mm\u00B2) ", loopx - loop_radius - 3.0*arrow_size, loopy + 6);
|
||||
fctx.fillText("\u2300a = " + cond_diameter_mm.toFixed(2).toString() + "mm", loopx - loop_radius - 2.0*arrow_size, loopy - 6);
|
||||
fctx.fillText("(" + (cond_diameter_mm**2).toFixed(2).toString() + " mm\u00B2) ", loopx - loop_radius - 3.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.toFixed(2).toString() + "mm", loopx - loop_radius - 2.0*arrow_size, y_offset - 2);
|
||||
//const loop_dia = 1.0 * loop_diameter_slider.value; // Convert from mm to inches
|
||||
fctx.fillText("\u2300b = " + loop_diameter_mm.toFixed(2).toString() + "mm", 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;
|
||||
|
@ -243,7 +251,7 @@
|
|||
fctx.lineTo(loopx + loop_radius + 3.0*arrow_size, inner_dia_y);
|
||||
fctx.stroke();
|
||||
fctx.textAlign = "left";
|
||||
fctx.fillText("\u2300i = " + (loop_dia-0.5*conductor_diameter_slider.value).toFixed(2).toString() + "mm", loopx + loop_radius + 2.0*arrow_size, inner_dia_y - 2);
|
||||
fctx.fillText("\u2300i = " + (loop_diameter_mm - 0.5*cond_diameter_mm).toFixed(2).toString() + "mm", loopx + loop_radius + 2.0*arrow_size, inner_dia_y - 2);
|
||||
|
||||
// Draw outer-diameter arrows: (for using a winding former)
|
||||
const outer_dia_y = loopy + loop_radius + 0;
|
||||
|
@ -264,7 +272,7 @@
|
|||
fctx.lineTo(loopx + loop_radius + cond_radius, outer_dia_y);
|
||||
fctx.lineTo(loopx + loop_radius + 3.0*arrow_size, outer_dia_y);
|
||||
fctx.stroke();
|
||||
fctx.fillText("\u2300o = " + (loop_dia+0.5*conductor_diameter_slider.value).toFixed(2).toString() + "mm", loopx + loop_radius + 2.0*arrow_size, outer_dia_y - 2);
|
||||
fctx.fillText("\u2300o = " + (loop_diameter_mm+0.5*cond_diameter_mm).toFixed(2).toString() + "mm", loopx + loop_radius + 2.0*arrow_size, outer_dia_y - 2);
|
||||
|
||||
// Write loop inductance:
|
||||
fctx.font = "12px arial";
|
||||
|
@ -294,7 +302,7 @@
|
|||
|
||||
var awg = "";
|
||||
var swg = "";
|
||||
switch(cond_dia) {
|
||||
switch(cond_diameter_mm) {
|
||||
case 0.100 :
|
||||
awg = "~38 AWG";
|
||||
break;
|
||||
|
@ -407,30 +415,26 @@
|
|||
fctx.fillText(swg, loopx, loopy + 12);
|
||||
fctx.font = "12px arial";
|
||||
|
||||
|
||||
var cond_spacing = 2.0 * cond_radius * loop_spacing_slider.value;
|
||||
if((cond_spacing * loop_turns_slider.value) > (0.8 * win_width)) {
|
||||
cond_radius = ((0.8 * win_width) / (loop_turns_slider.value * 2.0*loop_spacing_slider.value));
|
||||
cond_spacing = 2.0 * cond_radius * loop_spacing_slider.value;
|
||||
var cond_spacing = 2.0 * cond_radius * inductor.spacing_ratio;
|
||||
if((cond_spacing * inductor.loop_turns) > (0.8 * win_width)) {
|
||||
cond_radius = ((0.8 * win_width) / (inductor.loop_turns * 2.0*inductor.spacing_ratio));
|
||||
cond_spacing = 2.0 * cond_radius * inductor.spacing_ratio;
|
||||
}
|
||||
var start_x = win_width/2.0 - loop_turns_slider.value * cond_spacing * 0.5;
|
||||
var start_x = win_width/2.0 - inductor.loop_turns * cond_spacing * 0.5;
|
||||
var top_y = win_height * 0.56;
|
||||
var bot_y = top_y + 2.0 * cond_radius * (loop_diameter_slider.value / conductor_diameter_slider.value);
|
||||
|
||||
for (let i = 0; i < loop_turns_slider.value; i++) {
|
||||
var bot_y = top_y + 2.0 * cond_radius * (inductor.loop_diameter_meters / inductor.cond_diameter_meters);
|
||||
var angle = math.atan2((cond_spacing * 0.5), (bot_y - top_y));
|
||||
|
||||
for (let i = 0; i < inductor.loop_turns; i++) {
|
||||
fctx.beginPath();
|
||||
fctx.moveTo(start_x + ((0.5 + i) * cond_spacing) + cond_radius, top_y);
|
||||
fctx.lineTo(start_x + (i+1) * cond_spacing + cond_radius, bot_y);
|
||||
fctx.arc(start_x + (i+1) * cond_spacing, bot_y, cond_radius, 0, Math.PI, false);
|
||||
fctx.lineTo(start_x + ((0.5 + i) * cond_spacing) - cond_radius, top_y);
|
||||
fctx.arc(start_x + (i+0.5) * cond_spacing, top_y, cond_radius, Math.PI-angle, -angle, false);
|
||||
fctx.arc(start_x + (i+1) * cond_spacing, bot_y, cond_radius, -angle, Math.PI-angle, false);
|
||||
fctx.fillStyle = "grey";
|
||||
fctx.fill();
|
||||
|
||||
fctx.beginPath();
|
||||
fctx.arc(start_x + (i * cond_spacing), bot_y, cond_radius, 0, Math.PI);
|
||||
fctx.arc(start_x + (cond_spacing * 0.5) + i * cond_spacing, top_y, cond_radius, Math.PI, 0);
|
||||
fctx.lineTo(start_x + (i * cond_spacing) + cond_radius, bot_y);
|
||||
fctx.closePath();
|
||||
fctx.arc(start_x + (i * cond_spacing), bot_y, cond_radius, angle, Math.PI+angle);
|
||||
fctx.arc(start_x + (cond_spacing * 0.5) + i * cond_spacing, top_y, cond_radius, Math.PI+angle, angle);
|
||||
fctx.fillStyle = "black";
|
||||
fctx.fill();
|
||||
}
|
||||
|
@ -438,7 +442,7 @@
|
|||
// Draw the wire ends:
|
||||
fctx.fillRect(start_x - cond_radius, bot_y, 2.0 * cond_radius, 30);
|
||||
fctx.fillStyle = "grey";
|
||||
fctx.fillRect(start_x + loop_turns_slider.value*cond_spacing - cond_radius, bot_y, 2.0 * cond_radius, 30);
|
||||
fctx.fillRect(start_x + inductor.loop_turns * cond_spacing - cond_radius, bot_y, 2.0 * cond_radius, 30);
|
||||
fctx.fillStyle = "black";
|
||||
|
||||
// Draw left spacing arrow:
|
||||
|
@ -466,13 +470,13 @@
|
|||
|
||||
// Draw right length arrow:
|
||||
fctx.beginPath();
|
||||
fctx.moveTo(start_x + loop_turns_slider.value*cond_spacing + 20, dim_y);
|
||||
fctx.lineTo(start_x + loop_turns_slider.value*cond_spacing, dim_y);
|
||||
fctx.lineTo(start_x + loop_turns_slider.value*cond_spacing + 7, dim_y + 7)
|
||||
fctx.lineTo(start_x + loop_turns_slider.value*cond_spacing + 7, dim_y - 7)
|
||||
fctx.lineTo(start_x + loop_turns_slider.value*cond_spacing, dim_y);
|
||||
fctx.moveTo(start_x + loop_turns_slider.value*cond_spacing, dim_y - 7);
|
||||
fctx.lineTo(start_x + loop_turns_slider.value*cond_spacing, dim_y + 7);
|
||||
fctx.moveTo(start_x + inductor.loop_turns * cond_spacing + 20, dim_y);
|
||||
fctx.lineTo(start_x + inductor.loop_turns * cond_spacing, dim_y);
|
||||
fctx.lineTo(start_x + inductor.loop_turns * cond_spacing + 7, dim_y + 7)
|
||||
fctx.lineTo(start_x + inductor.loop_turns * cond_spacing + 7, dim_y - 7)
|
||||
fctx.lineTo(start_x + inductor.loop_turns * cond_spacing, dim_y);
|
||||
fctx.moveTo(start_x + inductor.loop_turns * cond_spacing, dim_y - 7);
|
||||
fctx.lineTo(start_x + inductor.loop_turns * cond_spacing, dim_y + 7);
|
||||
fctx.stroke();
|
||||
|
||||
// Extended lines:
|
||||
|
@ -482,14 +486,14 @@
|
|||
fctx.lineTo(start_x, dim_y - 12);
|
||||
fctx.moveTo(start_x + cond_spacing, bot_y + 15);
|
||||
fctx.lineTo(start_x + cond_spacing, dim_y - 12);
|
||||
fctx.moveTo(start_x + loop_turns_slider.value*cond_spacing, bot_y + 35);
|
||||
fctx.lineTo(start_x + loop_turns_slider.value*cond_spacing, dim_y - 12);
|
||||
fctx.moveTo(start_x + inductor.loop_turns * cond_spacing, bot_y + 35);
|
||||
fctx.lineTo(start_x + inductor.loop_turns * cond_spacing, dim_y - 12);
|
||||
fctx.stroke();
|
||||
fctx.strokeStyle = "black";
|
||||
|
||||
fctx.font = "12px arial";
|
||||
fctx.textAlign = "right";
|
||||
var freq = 1.0 * frequency_slider.value;
|
||||
var freq = 1e-6 * inductor.frequency_hz;
|
||||
fctx.fillText("f = " + freq.toFixed(1) + " MHz", win_width-18, 18);
|
||||
fctx.fillText("X\u2097 = " + inductor.Xl.toFixed(1) + " \u03A9", win_width-18, 32);
|
||||
fctx.fillText("|Z| = " + inductor.Z.r.toFixed(1) + " \u03A9", win_width-18, 46);
|
||||
|
@ -498,17 +502,17 @@
|
|||
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);
|
||||
fctx.fillText("N = " + inductor.loop_turns.toString(), win_width/2, win_height * 0.52);
|
||||
|
||||
// Draw spacing text: (gap is to avoid collision of spacing and length texts)
|
||||
fctx.textAlign = "right";
|
||||
var gap = ((loop_turns_slider.value*cond_spacing - cond_spacing) < 60) ? (60 - (loop_turns_slider.value*cond_spacing - cond_spacing)) : 0;
|
||||
const spc = loop_spacing_slider.value * conductor_diameter_slider.value;
|
||||
var gap = ((inductor.loop_turns * cond_spacing - cond_spacing) < 60) ? (60 - (inductor.loop_turns * cond_spacing - cond_spacing)) : 0;
|
||||
const spc = inductor.loop_turns * cond_diameter_mm;
|
||||
fctx.fillText("c = " + spc.toFixed(1).toString() + "mm", start_x + cond_spacing + 20 - gap, dim_y + 20);
|
||||
|
||||
// Draw length text:
|
||||
const sol_len = loop_turns_slider.value*spc;
|
||||
fctx.fillText("\u2113 = " + sol_len.toFixed(1).toString() + "mm", start_x + loop_turns_slider.value*cond_spacing + 20, dim_y + 20);
|
||||
const sol_len = inductor.loop_turns * spc;
|
||||
fctx.fillText("\u2113 = " + sol_len.toFixed(1).toString() + "mm", start_x + inductor.loop_turns * cond_spacing + 20, dim_y + 20);
|
||||
}
|
||||
recalculate();
|
||||
</script>
|
||||
|
|
|
@ -346,7 +346,7 @@
|
|||
|
||||
fctx.textAlign = "center";
|
||||
fctx.font = "14px courier";
|
||||
fctx.fillText(conductor_diameter_slider.value.toString() + " AWG", loopx, loopy - 6);
|
||||
fctx.fillText(conductor_diameter_slider.value.toString() + "AWG", loopx, loopy - 6);
|
||||
fctx.font = "12px arial";
|
||||
|
||||
var cond_spacing = 2.0 * cond_radius * inductor.spacing_ratio;
|
||||
|
@ -357,21 +357,18 @@
|
|||
var start_x = win_width/2.0 - inductor.loop_turns * cond_spacing * 0.5;
|
||||
var top_y = win_height * 0.56;
|
||||
var bot_y = top_y + 2.0 * cond_radius * (inductor.loop_diameter_meters / inductor.cond_diameter_meters);
|
||||
var angle = math.atan2((cond_spacing * 0.5), (bot_y - top_y));
|
||||
|
||||
for (let i = 0; i < inductor.loop_turns; i++) {
|
||||
fctx.beginPath();
|
||||
fctx.moveTo(start_x + ((0.5 + i) * cond_spacing) + cond_radius, top_y);
|
||||
fctx.lineTo(start_x + (i+1) * cond_spacing + cond_radius, bot_y);
|
||||
fctx.arc(start_x + (i+1) * cond_spacing, bot_y, cond_radius, 0, Math.PI, false);
|
||||
fctx.lineTo(start_x + ((0.5 + i) * cond_spacing) - cond_radius, top_y);
|
||||
fctx.arc(start_x + (i+0.5) * cond_spacing, top_y, cond_radius, Math.PI-angle, -angle, false);
|
||||
fctx.arc(start_x + (i+1) * cond_spacing, bot_y, cond_radius, -angle, Math.PI-angle, false);
|
||||
fctx.fillStyle = "grey";
|
||||
fctx.fill();
|
||||
|
||||
fctx.beginPath();
|
||||
fctx.arc(start_x + (i * cond_spacing), bot_y, cond_radius, 0, Math.PI);
|
||||
fctx.arc(start_x + (cond_spacing * 0.5) + i * cond_spacing, top_y, cond_radius, Math.PI, 0);
|
||||
fctx.lineTo(start_x + (i * cond_spacing) + cond_radius, bot_y);
|
||||
fctx.closePath();
|
||||
fctx.arc(start_x + (i * cond_spacing), bot_y, cond_radius, angle, Math.PI+angle);
|
||||
fctx.arc(start_x + (cond_spacing * 0.5) + i * cond_spacing, top_y, cond_radius, Math.PI+angle, angle);
|
||||
fctx.fillStyle = "black";
|
||||
fctx.fill();
|
||||
}
|
||||
|
|
|
@ -356,7 +356,7 @@
|
|||
|
||||
fctx.textAlign = "center";
|
||||
fctx.font = "14px courier";
|
||||
fctx.fillText(conductor_diameter_slider.value.toString() + " SWG", loopx, loopy - 6);
|
||||
fctx.fillText(conductor_diameter_slider.value.toString() + "SWG", loopx, loopy - 6);
|
||||
fctx.font = "12px arial";
|
||||
|
||||
var cond_spacing = 2.0 * cond_radius * inductor.spacing_ratio;
|
||||
|
|
Ładowanie…
Reference in New Issue