diff --git a/toroid.css b/toroid.css index 412e143..2f29136 100644 --- a/toroid.css +++ b/toroid.css @@ -26,7 +26,7 @@ section div.slider_container { width: 100%; height: 100%; */ - height: 140px; + /*height: 140px;*/ background: rgb(255, 255, 255); border: 1px solid rgb(0, 0, 0); margin: 0px; @@ -80,7 +80,7 @@ section div.sliders { div label { background:white; display: inline-block; - width: 12%; + width: 40px; font-size: small; text-align: right; } @@ -88,7 +88,7 @@ div label { div input { background:lightsalmon; display: inline-block; - width: 85%; + width:80%; } @media (orientation: portrait) { @@ -99,7 +99,8 @@ div input { grid-template-areas: "chart-container" "inductor-container" - "slider-container"; + "slider-container" + "notes"; justify-items: stretch; } @@ -160,7 +161,7 @@ div input { section.gridLayoutClass { display: grid; grid-template-columns: 1fr; - grid-template-rows: 1fr 0.3fr 0.2fr 5fr; + /*grid-template-rows: 1fr 0.3fr 0.2fr 5fr;*/ grid-template-areas: "chart-container" "inductor-container" diff --git a/transformer.html b/transformer.html index f075749..529fe40 100644 --- a/transformer.html +++ b/transformer.html @@ -51,7 +51,11 @@
- + +
+
+ +
@@ -76,6 +80,7 @@
  • Ns : Number of turns for the secondary Winding. (Defaults to 20 turns.)
  • P : The input power in watts. (Defaults to 100 W)
  • Zl : Load impedance in ohms. (Defaults to 50 ohms.)
  • +
  • Cin : Additional primary capacitance 0 - 200 pF. (Defaults to 0 pF.)
  • Note: Manufacturers recommend keeping the number of turns (N) to a minimum.

    Chart display: @@ -132,29 +137,23 @@
  • P/N : Manufacturer's part number.

  • - Observations:
    - Powdered Iron:
    - Inductance and reactance values correspond well with those predicted by online calculators such as toroids.info. - However, predictions for Q have mixed results when compared to the Micrometals Q-Curve Catalog found HERE. - I suggest using their catalog for accurate Q prediction. It has been previously identified that Q values predicted using Micrometal's curve-fit equations do not reconcile with measured Q as discussed here. -

    Other VK3CPU calculators:
    TODO:

    Change history:
    - [2-May-23] - v0.5
    - * Added 2646102002 which I have called the "FT102B-61"
    + [29-May-23] - v0.1
    + * Under development. Refactoring from toroid.html codebase. Removed Powdered-Iron code.
    @@ -674,10 +673,10 @@ return { real:Rs , imag:Xs }; }; - this.getVSWR = function (Zl) { + this.getVSWR = function (Vrms) { // First calculate the reflection coefficient gamma. Assume Z_load and Z0 are complex numbers: const Z0 = math.complex(this.Z0, 0.0); - //const Zl = math.complex(this.Zl * (this.Np/this.Ns)**2, 0.0); + const Zl = math.complex(this.Zl * (this.Np/this.Ns)**2, 0.0); const gamma = math.divide( math.subtract(Zl, Z0) , math.add(Z0, Zl)); const swr = (1.0 + gamma.toPolar().r) / (1.0 - gamma.toPolar().r); return swr; @@ -690,7 +689,7 @@ } // In Ohms: - this.getWireResistance = function(frequency) { + this.getPrimaryWireResistance = function(frequency) { // Calculate AC wire-resistance, using IEC 60287-1-1: const Ks = 1.0; // Solid core conductor const xs4 = ((8 * Math.PI * frequency * Ks) / (this.Rdc * 1e7))**2; @@ -699,6 +698,16 @@ return Rac; }; + // In Ohms: + this.getSecondaryWireResistance = function(frequency) { + // Calculate AC wire-resistance, using IEC 60287-1-1: + const Ks = 1.0; // Solid core conductor + const xs4 = ((8 * Math.PI * frequency * Ks) / (this.Rdc * 1e7))**2; + const Ys = xs4 / (192.0 + 0.8 * xs4); + const Rac = this.Rdcs * (1 + Ys); + return Rac; + }; + this.getWireResistance2 = function(frequency, r) { // Al-Asadi equation: const mu0 = Math.PI * 4e-7; @@ -721,7 +730,7 @@ // Model the transformer using Fair-Rite lumped equivalent of a loaded transformer as per 17th ed catalogue page 141 Fig 2. // vars: - + /* const R0 = 50.0; const Rc = 0.2; // Conductor losses const Ll1 = 1e-7; // Primary leakage inductance @@ -743,60 +752,50 @@ let V1 = math.complex(this.Vrms, 0); let V2 = math.multiply(V1, math.divide(Zp, math.add(Zp, Zs))); return [math.add(Zp, Zs), V1.toPolar().r, V2.toPolar().r]; - - /* - let Z11 = math.add(1, math.divide(Z0,Zs)); - let Z21 = math.inv(Zs); - let Z12 = math.unaryMinus(math.divide(Z0, Zs)); - let Z22 = math.unaryMinus(math.add(math.inv(Zs), math.inv(Zp))); - let ZZZ = math.matrix([[Z11, Z12], [Z21, Z22]]); - let vvv = math.matrix([[math.complex(this.Vrms, 0.0)], [math.complex(0.0, 0.0)]]); - let inv_ZZZ = math.inv(ZZZ); - let VVV = math.multiply(inv_ZZZ, vvv); - return [this.Vrms, VVV.get([0,0]).toPolar().r, VVV.get([1,0]).toPolar().r]; */ - /* + const Z0 = 50.0; // Source impedance in ohms - const Cp = 1e-10 + (0.9 + (78.1/this.Np**2))*1e-12; // Primary winding parasitic capacitance in F - const R1 = 0.1; // Resistance of primary winding in ohms + const Cp = this.Cin + (0.9 + (78.1/this.Np**2))*1e-12; // Primary winding parasitic capacitance in F + const R1 = this.getPrimaryWireResistance(frequency); //0.1; // Resistance of primary winding in ohms const L1 = 1e-7; // Primary leakage inductance in H const Xp = (Rs**2 + Xs**2) / Xs; // Get parallel equivalent reactance const Rp = (Rs**2 + Xs**2) / Rs; // Get parallel equivalent resistance - const L2 = 1e-7 * (this.Np/this.Ns)**2; // Secondary leakage inductance, reflected into primary side, in H - const R2 = 0.1; // Secondary winding resistance in ohms, reflected at primary side - const Cs = (0.9 + (78.1/this.Ns**2))*1e-12 *(this.Ns/this.Np)**2; // Secondary winding parasitic capacitance in F, reflected at primary side + const L2 = 1e-7 * (this.Np/this.Ns)**2; // Secondary leakage inductance, reflected into primary side, in H + const R2 = this.getSecondaryWireResistance(frequency) * (this.Np/this.Ns)**2; //0.1; // Secondary winding resistance in ohms, reflected at primary side + const Cs = (0.9 + (78.1/this.Ns**2))*1e-12 *(this.Np/this.Ns)**2; // Secondary winding parasitic capacitance in F, reflected at primary side const Zl = this.Zl*(this.Np/this.Ns)**2; // Load impedance reflected to primary side in ohms + const Cc = 1e-12; // Parasitic capacitance between primary and secondary windings const w = 2 * Math.PI * frequency; let Z1 = math.complex(R1, w*L1); let Z2 = math.complex(R2, w*L2); let ZCp = math.complex(0.0, -1.0/(w*Cp)); + let Zp = math.complex(Rp, Xp); //let ZRp = math.complex(Rp, 0.0); //let ZLp = math.complex(0.0, Xp); - let Zp = math.complex(Rp, Xp); //math.divide(math.multiply(ZRp, ZLp), math.add(ZRp, ZLp)); + //let Zp = math.divide(math.multiply(ZRp, ZLp), math.add(ZRp, ZLp)); let ZCs = math.complex(0.0, -1.0/(w*Cs)); let Zlc = math.divide(math.multiply(ZCs,math.complex(Zl,0.0)), math.add(ZCs,math.complex(Zl,0.0))); + let ZCc = math.complex(0.0, -1.0/(w*Cc)); // Setup the 3x3 matrix. Z31 = Z13 = 0 //let Z11 = math.divide(math.add(math.unaryMinus(math.multiply(Zcp,Z1)), math.unaryMinus(math.multiply(Z0,Z1)), math.unaryMinus(math.multiply(Z0,Zcp))), math.multiply(Z0, Zcp, Z1)); const zero = math.complex(0,0); - let Z11 = math.add(math.unaryMinus(math.inv(Z0)), math.unaryMinus(math.inv(ZCp)), math.unaryMinus(math.inv(Z1))); + let Z11 = math.add(math.unaryMinus(math.inv(Z0)), math.unaryMinus(math.inv(ZCp)), math.unaryMinus(math.inv(Z1)), math.unaryMinus(math.inv(ZCc))); let Z21 = math.inv(Z1); - let Z31 = zero; + let Z31 = math.inv(ZCc); let Z12 = Z21; let Z22 = math.add(math.unaryMinus(math.inv(Z1)), math.unaryMinus(math.inv(Zp)), math.unaryMinus(math.inv(Z2))); let Z32 = math.inv(Z2); - let Z13 = zero; + let Z13 = math.inv(ZCc); let Z23 = math.inv(Z2); - let Z33 = math.add(math.unaryMinus(math.inv(Z2)), math.unaryMinus(math.inv(Zlc))); + let Z33 = math.add(math.unaryMinus(math.inv(Z2)), math.unaryMinus(math.inv(Zlc)), math.unaryMinus(math.inv(ZCc))); let ZZZ = math.matrix([[Z11, Z12, Z13], [Z21, Z22, Z23], [Z31, Z32, Z33]]); - let vvv = math.matrix([[this.Vrms/Z0], [zero], [zero]]); + let vvv = math.matrix([[2*this.Vrms/Z0], [zero], [zero]]); let VVV = math.multiply(math.inv(ZZZ), vvv); - return [this.Vrms, this.Vrms, VVV.get([2,0]).toPolar().r]; - */ - //return VVV; + return [VVV.get([0,0]), VVV.get([1,0]), VVV.get([2,0])]; }; this.recalculate = function (frequencies) { @@ -806,6 +805,7 @@ this.Z0 = 50.0; this.Vrms = Math.sqrt(this.Pin * this.Z0); this.Zl = 5.0 * 10.0**load_impedance_slider.value; + this.Cin = 1e-12 * primary_capacitance_slider.value; // Frequency independent characteristics: this.N_max = Math.PI / (Math.atan2(0.5e3 * this.cond_diameter_meters, (0.5 * this.core.B - 0.5e3 * this.cond_diameter_meters))); @@ -818,6 +818,7 @@ this.cond_length_meters_secondary = 2e-3 * Math.sqrt ( (Math.PI * 0.5 * (this.core.A + this.core.B))**2 + (this.Ns * (2*(this.cond_diameter_meters*1e3) + 2*this.core.C + this.core.A - this.core.B))**2 ); this.Rdc = 1.68e-8 * this.cond_length_meters / (Math.PI * ((this.cond_diameter_meters*0.5)**2.0)); + this.Rdcs = 1.68e-8 * this.cond_length_meters_secondary / (Math.PI * ((this.cond_diameter_meters*0.5)**2.0)); //const Cpmult = 12.9*() //this.C = (0.9 + (78.1/this.N**2))*1e-12; // In Farads @@ -868,7 +869,13 @@ const VVV = this.solveTransformer(freq, mu); //const SWR = (math.max(VVV[0]*0.5, VVV[1]) / math.min(VVV[0]*0.5, VVV[1])); - const SWR = this.getVSWR(VVV[0]); + //const SWR = this.getVSWR(VVV[0]); + const Vin = math.complex(this.Vrms, 0.0); + const Z0 = math.complex(this.Z0, 0.0); + const Zl = math.divide(math.multiply(Z0, VVV[0]), math.subtract(VVV[0], Vin)); //math.complex(this.Zl * (this.Np/this.Ns)**2, 0.0); + //console.log(freq, Z0, Zl, VVV[0]); + const gamma = math.divide( math.subtract(Zl, Z0) , math.add(Z0, Zl)); + const SWR = (1.0 + gamma.toPolar().r) / (1.0 - gamma.toPolar().r); //console.log(freq, VVV); //console.log(freq, eff, SWR, VVV); @@ -887,8 +894,8 @@ //const IL = 20.0 * Math.log10(VVV[0]/VVV[3]); //this.IL_vs_f.push({x:freq, y:IL}); - const P0 = (VVV[1]**2 / this.Z0); - const Pl = (VVV[2]**2 / (this.Zl*(this.Np/this.Ns)**2)); + const P0 = this.Vrms**2 / this.Z0; // (VVV[0].toPolar().r**2 / this.Z0); + const Pl = (VVV[2].toPolar().r**2 / (this.Zl*((this.Np/this.Ns)**2))); this.P0_vs_f.push({x:freq, y:P0}); this.Pl_vs_f.push({x:freq, y:Pl}); const IL = 10.0 * Math.log10(P0/Pl); @@ -988,479 +995,7 @@ return this.B_vs_f; }; } - - function PowderedIron() { - // Current selected material type: - this.material = '2'; - - // Current selected ferrite size: - this.size = 'T300'; - - // User-selected variables: - this.cond_diameter_meters = 0.0; - this.coated_cond_diameter_meters = 0.0; - this.Np = 0; - this.Ns = 0; - this.Vrms = 0.0; - - // Calculated frequency-independent variables: - this.cond_length_meters = 0.0; - this.Rdc = 0.0; - this.N_max = 0; - this.L = 0.0; - this.C = 0.0; - this.SRF = 0.0; - - // Calculated and charted frequency-dependent variables: - this.L_vs_f = []; - this.Z_vs_f = []; - this.R_vs_f = []; - this.Rac_vs_f = []; - this.X_vs_f = []; - this.Q_vs_f = []; - this.i_vs_f = []; - this.P_vs_f = []; - this.mu_vs_f = []; - this.H_vs_f = []; - this.B_vs_f = []; - - this.cores = { - '0' : { - size : { - 'T300' : { PN:'T300-0', A:77.22, B:49.02, C:12.70, W:73.5, CC:0.0, le:19.8, Ae:1.68, Ve:33.4, Al:1.5 }, - 'T184' : { PN:'T184-0', A:46.74, B:24.13, C:18.03, W:46.2, CC:0.0, le:11.2, Ae:1.88, Ve:21.0, Al:3.0 }, - 'T157' : { PN:'T157-0', A:39.88, B:24.13, C:14.48, W:23.5, CC:0.0, le:10.1, Ae:1.06, Ve:10.7, Al:1.8 }, - 'T130' : { PN:'T130-0', A:33.02, B:19.81, C:11.10, W:12.7, CC:0.0, le:8.28, Ae:0.698, Ve:5.78, Al:1.5 }, - 'T106' : { PN:'T106-0', A:26.92, B:14.48, C:11.10, W:9.41, CC:0.0, le:6.49, Ae:0.659, Ve:4.28, Al:1.9 }, - 'T94' : { PN:'T94-0', A:23.93, B:14.22, C:7.92, W:4.75, CC:0.0, le:5.97, Ae:0.362, Ve:2.16, Al:1.06 }, - 'T80' : { PN:'T80-0', A:20.19, B:12.57, C:6.35, W:2.62, CC:0.0, le:5.14, Ae:0.231, Ve:1.19, Al:0.85 }, - 'T68' : { PN:'T68-0', A:17.53, B:9.40, C:4.83, W:1.67, CC:0.0, le:4.23, Ae:0.179, Ve:0.759, Al:0.75 }, - 'T50' : { PN:'T50-0', A:12.70, B:7.70, C:4.83, W:0.79, CC:0.0, le:3.19, Ae:0.112, Ve:0.358, Al:0.64 }, - 'T44' : { PN:'T44-0', A:11.18, B:5.82, C:4.04, W:0.59, CC:0.0, le:2.68, Ae:0.099, Ve:0.266, Al:0.65 }, - 'T37' : { PN:'T37-0', A:9.53, B:5.21, C:3.25, W:0.32, CC:0.0, le:2.31, Ae:0.064, Ve:0.147, Al:0.49 }, - 'T30' : { PN:'T30-0', A:7.80, B:3.84, C:3.25, W:0.24, CC:0.0, le:1.84, Ae:0.060, Ve:0.110, Al:0.60 }, - 'T25' : { PN:'T25-0', A:6.48, B:3.05, C:2.44, W:0.12, CC:0.0, le:1.50, Ae:0.037, Ve:0.055, Al:0.45 }, - }, - manufacturer : "Micrometals", - mat : "Phenolic", - mu_i : 1, - Bsat : 14800.0, - Br : 0.0, - Hc : 0.0, - mu_vs_f : { a:1.0e50, b:1.0, c:1.0, d:1.0 }, - mu_vs_B : { a:1.00e2, b:0.0, c:1.0, d:1.0e80, e:1.0, f:1e80 }, - mu_vs_H : { a:1.00e90, b:1.0e90, c:1.0e90, d:1.0e90, e:1.0 }, - CL_vs_f_B : { a:1.0e90, b:1.0e90, c:1.0e90, d:1.0e-90 }, - color : '#EECFA1', // a dark tan - color_code : "Tan", - }, - '2' : { - size : { - 'T300' : { PN:'T300-2', A:77.22, B:49.02, C:12.70, W:167.0, CC:0.0, le:19.8, Ae:1.68, Ve:33.4, Al:11.4 }, - 'T225B': { PN:'T225-2B',A:57.15, B:35.69, C:25.40, W:189.0, CC:0.0, le:14.6, Ae:2.59, Ve:37.8, Al:21.5 }, - 'T225' : { PN:'T225-2', A:57.15, B:35.69, C:13.97, W:103.5, CC:0.0, le:14.6, Ae:1.42, Ve:20.7, Al:12.0 }, - 'T200B': { PN:'T200-2B',A:50.80, B:31.75, C:25.40, W:149.0, CC:0.0, le:13.0, Ae:2.31, Ve:29.8, Al:21.8 }, - 'T200' : { PN:'T200-2', A:50.80, B:31.75, C:13.97, W:82.0, CC:0.0, le:13.0, Ae:1.27, Ve:16.4, Al:12.0 }, - 'T184' : { PN:'T184-2', A:46.74, B:24.13, C:18.03, W:105.0, CC:0.0, le:11.2, Ae:1.88, Ve:21.0, Al:24.0 }, - 'T157' : { PN:'T157-2', A:39.88, B:24.13, C:14.48, W:53.5, CC:0.0, le:10.1, Ae:1.06, Ve:10.7, Al:14.0 }, - 'T130' : { PN:'T130-2', A:33.02, B:19.81, C:11.10, W:28.9, CC:0.0, le:8.28, Ae:0.698, Ve:5.78, Al:11.0 }, - 'T106' : { PN:'T106-2', A:26.92, B:14.48, C:11.10, W:21.4, CC:0.0, le:6.49, Ae:0.659, Ve:4.28, Al:13.5 }, - 'T94' : { PN:'T94-2', A:23.93, B:14.22, C:7.92, W:10.8, CC:0.0, le:5.97, Ae:0.362, Ve:2.16, Al:8.4 }, - 'T80' : { PN:'T80-2', A:20.19, B:12.57, C:6.35, W:5.95, CC:0.0, le:5.14, Ae:0.231, Ve:1.19, Al:5.5 }, - 'T68' : { PN:'T68-2', A:17.53, B:9.40, C:4.83, W:3.795, CC:0.0, le:4.23, Ae:0.179, Ve:0.759, Al:5.7 }, - 'T50' : { PN:'T50-2', A:12.70, B:7.70, C:4.83, W:1.79, CC:0.0, le:3.19, Ae:0.112, Ve:0.358, Al:4.9 }, - 'T44' : { PN:'T44-2', A:11.18, B:5.82, C:4.04, W:1.33, CC:0.0, le:2.68, Ae:0.099, Ve:0.266, Al:5.2 }, - 'T37' : { PN:'T37-2', A:9.53, B:5.21, C:3.25, W:0.735, CC:0.0, le:2.31, Ae:0.064, Ve:0.147, Al:4.0 }, - 'T30' : { PN:'T30-2', A:7.80, B:3.84, C:3.25, W:0.55, CC:0.0, le:1.84, Ae:0.060, Ve:0.110, Al:4.3 }, - 'T25' : { PN:'T25-2', A:6.48, B:3.05, C:2.44, W:0.275, CC:0.0, le:1.50, Ae:0.037, Ve:0.055, Al:3.4 }, - }, - manufacturer : "Micrometals", - mat : "Carbonyl E", - mu_i : 10, - Bsat : 14800.0, - Br : 30.0, - Hc : 3.0, - mu_vs_f : { a:1.11e-1, b:7.01e-11, c:9.00e-1, d:1.0e0 }, - mu_vs_B : { a:1.57e3, b:4.50e-1, c:1.25e0, d:1.16e17, e:-3.70e0, f:1.07e2 }, - mu_vs_H : { a:1.00e-2, b:1.83e-7, c:1.46e0, d:0.0e0 }, - B_vs_H : { a:1.50e-3, b:1.96e0, c:1.97e4, d:9.18e-4, e:1.48e3 }, - CL_vs_f_B : { a:4.0e9, b:3.0e8, c:2.7e6, d:9.6e-16 }, - color : '#CD0000', // a dark red - color_code : "Red/Clear", - }, - '17' : { - size : { - 'T184' : { PN:'T184-17', A:46.74, B:24.13, C:18.03, W:105.0, CC:0.0, le:11.2, Ae:1.88, Ve:21.0, Al:8.7 }, - 'T157' : { PN:'T157-17', A:39.88, B:24.13, C:14.48, W:53.5, CC:0.0, le:10.1, Ae:1.06, Ve:10.7, Al:5.3 }, - 'T130' : { PN:'T130-17', A:33.02, B:19.81, C:11.10, W:28.9, CC:0.0, le:8.28, Ae:0.698, Ve:5.78, Al:4.0 }, - 'T106B': { PN:'T106-17B',A:26.92, B:14.48, C:14.60, W:26.7, CC:0.0, le:6.49, Ae:0.858, Ve:5.57, Al:6.6 }, - 'T106' : { PN:'T106-17', A:26.92, B:14.48, C:11.10, W:21.4, CC:0.0, le:6.49, Ae:0.659, Ve:4.28, Al:5.1 }, - 'T94' : { PN:'T94-17', A:23.93, B:14.22, C:7.92, W:10.8, CC:0.0, le:5.97, Ae:0.362, Ve:2.16, Al:2.9 }, - 'T80' : { PN:'T80-17', A:20.19, B:12.57, C:6.35, W:5.95, CC:0.0, le:5.14, Ae:0.231, Ve:1.19, Al:2.2 }, - 'T68' : { PN:'T68-17', A:17.53, B:9.40, C:4.83, W:3.795, CC:0.0, le:4.23, Ae:0.179, Ve:0.759, Al:2.1 }, - 'T50' : { PN:'T50-17', A:12.70, B:7.70, C:4.83, W:1.79, CC:0.0, le:3.19, Ae:0.112, Ve:0.358, Al:1.8 }, - 'T44' : { PN:'T44-17', A:11.18, B:5.82, C:4.04, W:1.33, CC:0.0, le:2.68, Ae:0.099, Ve:0.266, Al:1.85 }, - 'T37' : { PN:'T37-17', A:9.53, B:5.21, C:3.25, W:0.735, CC:0.0, le:2.31, Ae:0.064, Ve:0.147, Al:1.5 }, - 'T30' : { PN:'T30-17', A:7.80, B:3.84, C:3.25, W:0.55, CC:0.0, le:1.84, Ae:0.060, Ve:0.110, Al:1.6 }, - 'T25' : { PN:'T25-17', A:6.48, B:3.05, C:2.44, W:0.275, CC:0.0, le:1.50, Ae:0.037, Ve:0.055, Al:1.2 }, - }, - manufacturer : "Micrometals", - mat : "Carbonyl", - mu_i : 4, - Bsat : 14400.0, - Br : 30.0, - Hc : 3.0, - mu_vs_f : { a:3.33e-1, b:7.01e-11, c:9.00e-1, d:1.0e0 }, - mu_vs_B : { a:1.57e3, b:4.50e-1, c:1.25e0, d:1.16e17, e:-3.70e0, f:1.07e2 }, - mu_vs_H : { a:1.00e-2, b:1.34e-8, c:1.55, d:0.0 }, - B_vs_H : { a:6.20e-4, b:1.96e0, c:7.71e4, d:9.31e-4, e:3.60e3 }, - CL_vs_f_B : { a:4.0e9, b:3.0e8, c:2.7e6, d:4.40e-16 }, - color : '#007FFF', // azure blue - color_code : "Blue/Yellow", - }, - '6' : { - size : { - 'T300' : { PN:'T300-6', A:77.22, B:49.02, C:12.70, W:167.0, CC:0.0, le:19.8, Ae:1.68, Ve:33.4, Al:9.5 }, - 'T225' : { PN:'T225-6', A:57.15, B:35.69, C:13.97, W:103.5, CC:0.0, le:14.6, Ae:1.42, Ve:20.7, Al:10.4 }, - 'T200' : { PN:'T200-6', A:50.80, B:31.75, C:13.97, W:82.0, CC:0.0, le:13.0, Ae:1.27, Ve:16.4, Al:10.4 }, - 'T184' : { PN:'T184-6', A:46.74, B:24.13, C:18.03, W:105.0, CC:0.0, le:11.2, Ae:1.88, Ve:21.0, Al:19.5 }, - 'T130' : { PN:'T130-6', A:33.02, B:19.81, C:11.10, W:28.9, CC:0.0, le:8.28, Ae:0.698, Ve:5.78, Al:9.6 }, - 'T106' : { PN:'T106-6', A:26.92, B:14.48, C:11.10, W:21.4, CC:0.0, le:6.49, Ae:0.659, Ve:4.28, Al:11.6 }, - 'T94' : { PN:'T94-6', A:23.93, B:14.22, C:7.92, W:10.8, CC:0.0, le:5.97, Ae:0.362, Ve:2.16, Al:7.0 }, - 'T80' : { PN:'T80-6', A:20.19, B:12.57, C:6.35, W:5.95, CC:0.0, le:5.14, Ae:0.231, Ve:1.19, Al:4.5 }, - 'T68' : { PN:'T68-6', A:17.53, B:9.40, C:4.83, W:3.795, CC:0.0, le:4.23, Ae:0.179, Ve:0.759, Al:4.7 }, - 'T50' : { PN:'T50-6', A:12.70, B:7.70, C:4.83, W:1.79, CC:0.0, le:3.19, Ae:0.112, Ve:0.358, Al:4.0 }, - 'T44' : { PN:'T44-6', A:11.18, B:5.82, C:4.04, W:1.33, CC:0.0, le:2.68, Ae:0.099, Ve:0.266, Al:4.2 }, - 'T37' : { PN:'T37-6', A:9.53, B:5.21, C:3.25, W:0.735, CC:0.0, le:2.31, Ae:0.064, Ve:0.147, Al:3.0 }, - 'T30' : { PN:'T30-6', A:7.80, B:3.84, C:3.25, W:0.55, CC:0.0, le:1.84, Ae:0.060, Ve:0.110, Al:3.6 }, - 'T25' : { PN:'T25-6', A:6.48, B:3.05, C:2.44, W:0.275, CC:0.0, le:1.50, Ae:0.037, Ve:0.055, Al:2.7 }, - }, - manufacturer : "Micrometals", - mat : "Carbonyl SF", - mu_i : 8.5, - Bsat : 14800.0, - Br : 26.0, - Hc : 3.0, - mu_vs_f : { a:1.33e-1, b:7.01e-11, c:9.00e-1, d:1.0e0 }, - mu_vs_B : { a:1.57e3, b:4.50e-1, c:1.25e0, d:1.16e17, e:-3.70e0, f:1.07e2 }, - mu_vs_H : { a:1.00e-2, b:4.87e-8, c:1.57e0, d:0.0e0 }, - B_vs_H : { a:1.28e-3, b:1.96e0, c:2.30e4, d:9.19e-4, e:1.74e3 }, - CL_vs_f_B : { a:4.0e9, b:3.0e8, c:2.7e6, d:8.9e-16 }, - color : '#ECD540', // a darker yellow - color_code : "Yellow/Clear", - }, - '10' : { - size : { - 'T184' : { PN:'T184-10', A:46.74, B:24.13, C:18.03, W:102.9, CC:0.0, le:11.2, Ae:1.88, Ve:21.0, Al:13.8 }, - 'T157' : { PN:'T157-10', A:39.88, B:24.13, C:14.48, W:52.43, CC:0.0, le:10.1, Ae:1.06, Ve:10.7, Al:8.2 }, - 'T130' : { PN:'T130-10', A:33.02, B:19.81, C:11.10, W:28.32, CC:0.0, le:8.28, Ae:0.698, Ve:5.78, Al:6.83 }, - 'T94' : { PN:'T94-10', A:23.93, B:14.22, C:7.92, W:10.58, CC:0.0, le:5.97, Ae:0.362, Ve:2.16, Al:5.8 }, - 'T68' : { PN:'T68-10', A:17.53, B:9.40, C:4.83, W:3.72, CC:0.0, le:4.23, Ae:0.179, Ve:0.759, Al:3.2 }, - 'T50' : { PN:'T50-10', A:12.70, B:7.70, C:4.83, W:1.75, CC:0.0, le:3.19, Ae:0.112, Ve:0.358, Al:3.1 }, - 'T44' : { PN:'T44-10', A:11.18, B:5.82, C:4.04, W:1.30, CC:0.0, le:2.68, Ae:0.099, Ve:0.266, Al:3.3 }, - 'T37' : { PN:'T37-10', A:9.53, B:5.21, C:3.25, W:0.72, CC:0.0, le:2.31, Ae:0.064, Ve:0.147, Al:2.5 }, - }, - manufacturer : "Micrometals", - mat : "Carbonyl W", - mu_i : 6, - Bsat : 14600.0, - Br : 18.0, - Hc : 3.0, - mu_vs_f : { a:2.00e-1, b:7.01e-11, c:9.00e-1, d:1.0e0 }, - mu_vs_B : { a:1.57e3, b:4.50e-1, c:1.25e0, d:1.16e17, e:-3.70e0, f:1.07e2 }, - mu_vs_H : { a:1.00e-2, b:5.54e-9, c:1.69e0, d:0.0e0 }, - B_vs_H : { a:9.13e-4, b:1.96e0, c:3.83e4, d:9.23e-4, e:2.43e3 }, - CL_vs_f_B : { a:4.0e9, b:3.0e8, c:2.7e6, d:8.0e-16 }, - color : '#4F4F4F', - color_code : "Black/Clear", - }, - }; - - this.mat = this.cores[this.material]; - this.core = this.mat.size[this.size]; - - this.getMaterialDataStrings = function () { - retval = []; - retval.push(["Size", this.size]); - retval.push(["Material", this.material.toString()]); - retval.push(["Type", this.mat.mat]); - retval.push(["\u03bci", this.mat.mu_i.toString()]); - retval.push(["Color", this.mat.color_code]); - retval.push(["Bsat", this.mat.Bsat.toString() + " G"]); - retval.push(["Mass", this.core.W.toString() + " g"]); - retval.push(["P/N", this.core.PN]); - return retval; - }; - - this.setMaterial = function (material) { - this.material = material; - this.mat = this.cores[this.material]; - this.core = this.mat.size[this.size]; - }; - - this.setSize = function (size) { - this.size = size; - this.core = this.mat.size[this.size]; - }; - - this.setTurns = function (turns) { - this.N = turns; - }; - - this.getMaterialTypes = function () { - return ["2", "6", "10", '17', '0']; - }; - - this.getSizesForMaterial = function (material) { - return Object.keys(this.cores[material].size); - }; - - this.getMuFromFreq = function (f) { - return 1/(this.mat.mu_vs_f.a + this.mat.mu_vs_f.b * f**this.mat.mu_vs_f.c) + this.mat.mu_vs_f.d; - }; - - this.getMuFromBpk = function (B) { - // return ((this.mat.mu_vs_B.a + this.mat.mu_vs_B.c * B + this.mat.mu_vs_B.e * B**2) / (1.0 + this.mat.mu_vs_B.b * B + this.mat.mu_vs_B.d * B**2))**0.5; - return (1 / ((1/(this.mat.mu_vs_B.a + this.mat.mu_vs_B.b * B ** this.mat.mu_vs_B.c)) + (1/(this.mat.mu_vs_B.d * B ** this.mat.mu_vs_B.e)) + (1/this.mat.mu_vs_B.f))); // ((this.mat.mu_vs_B.a + this.mat.mu_vs_B.c * B + this.mat.mu_vs_B.e * B**2) / (1.0 + this.mat.mu_vs_B.b * B + this.mat.mu_vs_B.d * B**2))**0.5; - }; - - this.getBpkFromH = function (H, f) { - return this.getMuFromFreq(f) / ((1/(H + this.mat.B_vs_H.a * H ** this.mat.B_vs_H.b)) + (1/(this.mat.B_vs_H.c * H ** this.mat.B_vs_H.d)) + (1/this.mat.B_vs_H.e)); - }; - - this.getMuFromH = function (H, f) { - //return this.getMuFromFreq(f) / ((1/(H + this.mat.mu_vs_H.a * H ** this.mat.mu_vs_H.b)) + (1/(this.mat.mu_vs_H.c * H ** this.mat.mu_vs_H.d)) + (1/this.mat.mu_vs_H.e)); - return 1/(this.mat.mu_vs_H.a + this.mat.mu_vs_H.b * H**this.mat.mu_vs_H.c) + this.mat.mu_vs_H.d; - }; - - // Return power loss in Watts: - this.getPdFromfB = function (f, B) { - return this.core.Ve * 1e-3 * (f / (this.mat.CL_vs_f_B.a / B**3.0 + this.mat.CL_vs_f_B.b / B**2.3 + this.mat.CL_vs_f_B.c / B**1.65) + this.mat.CL_vs_f_B.d * B**2 * f**2); - }; - - this.getInductanceOld = function (frequency) { - const mu = this.getMuFromFreq(frequency); - //const L = mu * 4.0 * Math.PI * this.N**2 * 1e-9 / this.core.CC; - const CC = this.core.le / this.core.Ae; - const L = mu * 4.0 * Math.PI * this.N**2 * 1e-9 / CC; - return L; - }; - this.getInductance = function (frequency, Bpk) { - // const L = this.core.Al * this.N**2 * 1e-9; - // New method because using Ae and le did not match Al with N^2. - const L = this.getMuFromFreq(frequency) * this.getMuFromBpk(Bpk) * 1e-2 * (this.core.Al / this.mat.mu_i) * this.N**2 * 1e-9; - - return L; - }; - - this.getReactance = function (frequency, Bpk) { - const Xs = 2.0 * Math.PI * frequency * this.getInductance(frequency, Bpk); - return Xs; - }; - /* - this.getWireResistance = function(frequency) { - // Calculate AC wire-resistance, using IEC 60287-1-1: - this seemed really hopeless for high-frequencies: - const Ks = 1.0; // Solid core conductor - const xs4 = ((8 * Math.PI * frequency * Ks) / (this.Rdc * 1e7))**2; - const Ys = xs4 / (192.0 + 0.8 * xs4); - const Rac = this.Rdc * (1 + Ys); - return Rac; - }; - */ - this.getWireResistance = function(frequency, wire_radius_meter) { - // Al-Asadi equation for AC resistance in Ohms/meter: - const mu0 = Math.PI * 4e-7; - const cu_sigma = 58e6; - const delta = 1/Math.sqrt(Math.PI * frequency * this.mat.mu_i * mu0 * cu_sigma); - const k = delta * (1-Math.E**(-wire_radius_meter/delta)); - const Rac = 1/(Math.PI * cu_sigma * k * (2*wire_radius_meter - k)); - return Rac; - }; - - this.I_inductor = function (frequency, voltage) { - const K1 = 4.44 * frequency * this.N * this.core.Ae * 1e-8; - const K2 = 0.4 * Math.PI * this.N / this.core.le; - const B = voltage * 1e8 / (4.44 * frequency * this.N * this.core.Ae); - var mu = this.getMuFromFreq(frequency); - mu *= this.getMuFromBpk(B); - mu *= 1e-2; - return voltage / (mu * K1 * K2 * 1.414); - } - - this.I_wire = function (frequency, voltage) { - const Rac = this.getWireResistance(frequency, this.cond_diameter_meters * 0.5); - return (voltage / Rac); - } - - this.solve_V_inductor = function (frequency, voltage) { - // Initially assume voltage is divided between wire resistance and inductor core-loss resistance equivalently: - var voltage_upper = voltage; - var voltage_lower = 0.0; - var voltage_fraction = 0.5 * voltage; - var i_inductor = 0.0; - var i_wire = 0.0; - var count = 0; - while(true) { - count++; - i_inductor = this.I_inductor(frequency, (voltage - voltage_fraction)); - i_wire = this.I_wire(frequency, voltage_fraction); - - if(count > 60) { - console.log("ERROR!", count); - break; - } - - if(i_inductor > (i_wire * 1.001)) { - voltage_lower = voltage_fraction; - voltage_fraction = 0.5 * (voltage_lower + voltage_upper); - continue; - } - - if(i_wire > (i_inductor * 1.001)) { - voltage_upper = voltage_fraction; - voltage_fraction = 0.5 * (voltage_lower + voltage_upper); - continue; - } - - // Current's match within 1% of each other, which is good-enough for now. - break; - } - //console.log(count, frequency, i_inductor, i_wire); - const Rac = this.cond_length_meters * this.getWireResistance(frequency, this.cond_diameter_meters*0.5); - const V = (voltage - voltage_fraction); // Across the inductor. - const B = V * 1.0e8 / (4.44 * frequency * this.N * this.core.Ae); - const Pd = this.getPdFromfB(frequency, B); - const Pw = (i_wire**2 * Rac); - const X = this.getReactance(frequency, B); - const Xc = 1/(2*Math.PI*frequency*this.C); - const H = 0.4 * Math.PI * this.N * i_inductor / this.core.le; - const Ri = Pd / i_inductor**2; - const Q = X / (Ri + Rac); - const mu = this.getMuFromFreq(frequency) * this.getMuFromBpk(B) * 1e-2; - const L = this.getInductance(frequency, B); - return { - V : V, // Voltage across inductor in the L-R model. - I : i_wire, - Pd : Pd, - Pw : Pw, - L : L, - X : X, - B : B, - H : H, - Ri : Ri, - Rac: Rac, - R : (Ri+Rac), - u : mu, - Q : Q, - Z : (X**2 + (Ri+Rac)**2)**0.5, - } - } - - // frequencies = [] of frequencies in Hz - this.recalculate = function (awg, turns_density, voltage, frequencies) { - // Input variables: - // awg = 40.0 - conductor_diameter_slider.value; - this.cond_diameter_meters = 0.001 * awgToMm(awg)[0]; - this.coated_cond_diameter_meters = 0.001 * awgToMm(awg)[1]; - this.Vrms = 10.0 ** voltage; - - // Frequency independent characteristics: - this.N_max = Math.PI / (Math.atan2(0.5e3 * this.cond_diameter_meters, (0.5 * this.core.B - 0.5e3 * this.cond_diameter_meters))); - this.N = 1 + Math.round(turns_density * (this.N_max - 1)); - - //this.cond_length_meters = this.N * (2*this.core.C + this.core.A - this.core.B) * 1e-3; - //this.cond_length_meters = 2e-3 * Math.sqrt ( (Math.PI * 0.5 * (this.core.A + this.core.B))**2 + (this.N * (2*this.core.C + this.core.A - this.core.B))**2 ); - this.cond_length_meters = 1e-3 * Math.sqrt ( (Math.PI * 0.5 * (this.core.A + this.core.B))**2 + (this.N * (4*(this.cond_diameter_meters*1e3) + 2*this.core.C + this.core.A - this.core.B))**2 ); - - this.Rdc = 1.68e-8 * this.cond_length_meters / (Math.PI * ((this.cond_diameter_meters*0.5)**2.0)); - - this.L = (this.N**2) * this.core.Al * 1.0e-9; // In Henries - - // Based on David Knight's equation: - this.C = (0.9 + (78.1/this.N**2))*1e-12; // In Farads - //this.C = this.getEquivalentCapacitance(); - this.SRF = 1.0/(2.0*Math.PI* Math.sqrt(this.L*this.C)); - - // Clear the frequency dependent characteristics before appending new data: - this.L_vs_f = []; - this.Z_vs_f = []; - this.R_vs_f = []; - this.Rac_vs_f = []; - this.X_vs_f = []; - this.Q_vs_f = []; - this.i_vs_f = []; - this.P_vs_f = []; - this.mu_vs_f = []; - this.H_vs_f = []; - this.B_vs_f = []; - - frequencies.forEach(freq => { - const ind = this.solve_V_inductor(freq, this.Vrms); - - freq *= 1e-3; - - this.mu_vs_f.push({x:freq, y:ind.u}); - this.L_vs_f.push({x:freq, y:ind.L*1e6}); - this.R_vs_f.push({x:freq, y:ind.Ri}); - this.Rac_vs_f.push({x:freq, y:ind.Rac}); - this.X_vs_f.push({x:freq, y:ind.X}); - this.Q_vs_f.push({x:freq, y:ind.Q}); - this.i_vs_f.push({x:freq, y:(ind.I*1e3)}); // in mA - this.P_vs_f.push({x:freq, y:((ind.Pd + ind.Pw)*1e3)}); // in mW - this.Z_vs_f.push({x:freq, y:ind.Z}); - this.H_vs_f.push({x:freq, y:ind.H}); - this.B_vs_f.push({x:freq, y:ind.B}); - }); - }; - - // - this.calculateInductance = function () { - return this.L_vs_f; - }; - - this.calculateImpedance = function () { - return this.Z_vs_f; - }; - - this.calculatePermeability = function () { - return this.mu_vs_f; - }; - - this.calculateResistance = function () { - return this.R_vs_f; - }; - - this.calculateWireResistance = function () { - return this.Rac_vs_f; - }; - - this.calculateReactance = function () { - return this.X_vs_f; - }; - - this.calculateQualityFactor = function () { - return this.Q_vs_f; - }; - - this.calculateCurrent = function () { - return this.i_vs_f; - }; - - this.calculatePowerLoss = function () { - return this.P_vs_f; - }; - - this.calculateH = function () { - return this.H_vs_f; - }; - - this.calculateB = function () { - return this.B_vs_f; - }; - - }; - function Controller() { // Define global storage for calculated values, so we don't recalculate the same things multiple times: @@ -1472,7 +1007,7 @@ // Create a ferrite and powdered-iron object: this.ferrite = new Ferrite(); - this.powdered_iron = new PowderedIron(); + // this.powdered_iron = new PowderedIron(); this.toroid = this.ferrite; @@ -1652,123 +1187,6 @@ hidden: false }*/] }; - } else - if(material in this.powdered_iron.cores) { - this.toroid = this.powdered_iron; - this.toroid.setMaterial(material); - this.t_material = material; - this.t_type = 'powdered_iron'; - - // Now re-configure the chart axes options: - this.myChart.data = { - datasets: [ - { - label: 'L (\u03bcH)', - fill: false, - borderColor: 'orange', - backgroundColor: 'orange', - data: this.toroid.calculateInductance(), - borderWidth: 1, - yAxisID: 'lID' - }, - { - label: '|Z| (\u03A9)', - fill: false, - borderColor: 'black', - backgroundColor: 'black', - data: this.toroid.calculateImpedance(), - borderWidth: 1, - yAxisID: 'ohmsID' - }, - { - label: 'X (j\u03A9)', - fill: false, - borderColor: 'blue', - backgroundColor: 'blue', - data: this.toroid.calculateReactance(), - borderWidth: 1, - yAxisID: 'ohmsID' - }, - { - label: 'Rc (\u03A9)', - fill: false, - borderColor: 'red', - backgroundColor: 'red', - data: this.toroid.calculateResistance(), - borderWidth: 1, - yAxisID: 'ohmsID' - }, - { - label: 'Rw (\u03A9)', - fill: false, - borderColor: '#F78FA7', - backgroundColor: '#FFC0CB', - //borderColor: 'pink', - //backgroundColor: 'pink', - data: this.toroid.calculateWireResistance(), - borderWidth: 1, - yAxisID: 'ohmsID' - }, - { - label: 'Q', - fill: false, - borderColor: '#69359C', - backgroundColor: '#9A4EAE', - data: this.toroid.calculateQualityFactor(), - borderWidth: 1, - yAxisID: 'qID' - }, - { - label: 'I (mA)', - fill: false, - borderColor: 'rgb(0,128,128)', - backgroundColor: 'rgb(0,118,118)', - data: this.toroid.calculateCurrent(), - borderWidth: 1, - yAxisID: 'ccID' - }, - { - label: '\u03bc', - fill: false, - borderColor: '#0070FF', - backgroundColor: '#1974D2', - data: this.toroid.calculatePermeability(), - borderWidth: 1, - yAxisID: 'muID', - hidden: true - }, - { - label: 'H(Oe)', - fill: false, - borderColor: '#654321', - backgroundColor: '#986960', - data: this.toroid.calculateH(), - borderWidth: 1, - yAxisID: 'hID', - hidden: true - }, - { - label: 'B(G)', - fill: false, - borderColor: '#FFD300', - backgroundColor: '#F0E130', - data: this.toroid.calculateB(), - borderWidth: 1, - yAxisID: 'bID', - hidden: true - }, - { - label: 'Pd(mW)', - fill: false, - borderColor: 'rgb(50,50,50)', - backgroundColor: 'rgb(100,100,100)', - data: this.toroid.calculatePowerLoss(), - borderWidth: 1, - yAxisID: 'wattsID', - hidden: false - }] - } - } else { console.log("Unrecognised material selected =", material); } @@ -1784,43 +1202,25 @@ } this.updateChart = function () { - if(this.t_type == 'ferrite') { - this.myChart.options.plugins.title.text - = this.ferrite.mat.manufacturer + " " + this.t_size + "-" + this.t_material + " [" + this.ferrite.core.PN + "] " - + this.toroid.Np + ":" + this.toroid.Ns + ' #' + (40.0 - conductor_diameter_slider.value) + ' AWG'; - this.myChart.data.datasets[0].data = this.ferrite.calculateImpedance(); - this.myChart.data.datasets[1].data = this.ferrite.calculateSWR(); - this.myChart.data.datasets[2].data = this.ferrite.calculateEfficiency(); - this.myChart.data.datasets[3].data = this.ferrite.calculateInsertionLoss(); - this.myChart.data.datasets[4].data = this.ferrite.calculateP0(); - this.myChart.data.datasets[5].data = this.ferrite.calculatePl(); - /* - this.myChart.data.datasets[4].data = this.ferrite.calculateQualityFactor(); - this.myChart.data.datasets[5].data = this.ferrite.calculateCurrent(); - this.myChart.data.datasets[6].data = this.ferrite.calculatePermeability1(); - this.myChart.data.datasets[7].data = this.ferrite.calculatePermeability2(); - this.myChart.data.datasets[8].data = this.ferrite.calculateH(); - this.myChart.data.datasets[9].data = this.ferrite.calculateB(); - this.myChart.data.datasets[10].data = this.ferrite.calculatePowerLoss(); - */ - this.myChart.update(); - } else { - this.myChart.options.plugins.title.text - = this.powdered_iron.mat.manufacturer + " " + this.t_size + "-" + this.t_material + " [" + this.powdered_iron.core.PN + "]" - + " : " + this.toroid.N + 't #' + (40.0 - conductor_diameter_slider.value) + ' AWG'; - this.myChart.data.datasets[0].data = this.powdered_iron.calculateInductance(); - this.myChart.data.datasets[1].data = this.powdered_iron.calculateImpedance(); - this.myChart.data.datasets[2].data = this.powdered_iron.calculateReactance(); - this.myChart.data.datasets[3].data = this.powdered_iron.calculateResistance(); - this.myChart.data.datasets[4].data = this.powdered_iron.calculateWireResistance(); - this.myChart.data.datasets[5].data = this.powdered_iron.calculateQualityFactor(); - this.myChart.data.datasets[6].data = this.powdered_iron.calculateCurrent(); - this.myChart.data.datasets[7].data = this.powdered_iron.calculatePermeability(); - this.myChart.data.datasets[8].data = this.powdered_iron.calculateH(); - this.myChart.data.datasets[9].data = this.powdered_iron.calculateB(); - this.myChart.data.datasets[10].data = this.powdered_iron.calculatePowerLoss(); - this.myChart.update(); - } + this.myChart.options.plugins.title.text + = this.ferrite.mat.manufacturer + " " + this.t_size + "-" + this.t_material + " [" + this.ferrite.core.PN + "] " + + this.toroid.Np + ":" + this.toroid.Ns + ' #' + (40.0 - conductor_diameter_slider.value) + ' AWG'; + this.myChart.data.datasets[0].data = this.ferrite.calculateImpedance(); + this.myChart.data.datasets[1].data = this.ferrite.calculateSWR(); + this.myChart.data.datasets[2].data = this.ferrite.calculateEfficiency(); + this.myChart.data.datasets[3].data = this.ferrite.calculateInsertionLoss(); + this.myChart.data.datasets[4].data = this.ferrite.calculateP0(); + this.myChart.data.datasets[5].data = this.ferrite.calculatePl(); + /* + this.myChart.data.datasets[4].data = this.ferrite.calculateQualityFactor(); + this.myChart.data.datasets[5].data = this.ferrite.calculateCurrent(); + this.myChart.data.datasets[6].data = this.ferrite.calculatePermeability1(); + this.myChart.data.datasets[7].data = this.ferrite.calculatePermeability2(); + this.myChart.data.datasets[8].data = this.ferrite.calculateH(); + this.myChart.data.datasets[9].data = this.ferrite.calculateB(); + this.myChart.data.datasets[10].data = this.ferrite.calculatePowerLoss(); + */ + this.myChart.update(); }; this.recalculate = function () { @@ -2023,7 +1423,7 @@ } }, min: 0.0, - max: 10.0, + max: 5.0, position: 'right', }, 'effID' : { @@ -2295,7 +1695,7 @@ l_inductors = { sort_order : { "Ferrites" : ["75", "78", "77", "79", "43", "43_old", "80", "52", "61", "67"], - "Powdered Iron" : ["2", "6", "10", "17", "0"] + //"Powdered Iron" : ["2", "6", "10", "17", "0"] }, "75":"75 [\u03bci=5000]", "78":"78 [\u03bci=2300]", @@ -2482,6 +1882,20 @@ }, emphasis_delay); } + var primary_capacitance_handler = 0; + primary_capacitance_slider.oninput = function() { + controller.recalculate(); + + if(primary_capacitance_handler != 0) { + clearTimeout(primary_capacitance_handler); + } + + primary_capacitance_handler = setTimeout(function(){ + controller.updateChart(); + primary_capacitance_handler = 0; + }, emphasis_delay); + } + window.onresize = function() { controller.recalculate(); controller.updateChart(); @@ -2520,170 +1934,6 @@ const afront_canvas = document.getElementById("inductor2D"); const fctx = afront_canvas.getContext('2d'); - function drawInductor(fctx, originX, originY, outerRadius, innerRadius, wireRadius, turns, width, toroid_colour) { - let theta = Math.PI/(turns); - - var front_originX = originX - 0.5*(1*outerRadius + 20 + width) - 10; - originY -= 12; - - var x1 = 0; - var y1 = 0; - var x2 = 0; - var y2 = 0; - // Draw entry and exit wires: - if(turns > 1) { - x1 = front_originX + (outerRadius + 20) * Math.cos(0.5 * Math.PI + 0.5 * theta); - y1 = originY + (outerRadius + 20) * Math.sin(0.5 * Math.PI + 0.5 * theta); - x2 = front_originX + (innerRadius - wireRadius) * Math.cos(0.5 * Math.PI + theta); - y2 = originY + (innerRadius - wireRadius) * Math.sin(0.5 * Math.PI + theta); - } else { - x1 = front_originX + (outerRadius + 20) * Math.cos(0.5 * Math.PI + 0.1 * theta); - y1 = originY + (outerRadius + 20) * Math.sin(0.5 * Math.PI + 0.1 * theta); - x2 = front_originX; - y2 = originY + (innerRadius - wireRadius); - } - var angle = math.atan2(y1 - y2, x1 - x2) - Math.PI * 0.5; - fctx.beginPath(); - fctx.arc(x1, y1, wireRadius, angle, Math.PI+angle); - fctx.arc(x2, y2, wireRadius, Math.PI+angle, angle); - fctx.fillStyle = "black"; - fctx.fill(); - - // Draw front profile of toroid former: - fctx.lineWidth = outerRadius - innerRadius; - //fctx.strokeStyle = "#7F7F7F"; // rgb(100, 100, 100); - fctx.strokeStyle = toroid_colour; // rgb(100, 100, 100); - fctx.beginPath(); - fctx.arc(front_originX, originY, 0.5 * (outerRadius + innerRadius), 0.0, 2.0 * Math.PI, false); - fctx.stroke(); - fctx.lineWidth = 1.0; - - // Draw side profile of toroid: - var side_originX = front_originX + outerRadius + 20; - fctx.fillStyle = "#7F7F7F"; // rgb(100, 100, 100); - fctx.fillRect(side_originX, originY - outerRadius, width, (outerRadius - innerRadius)); - fctx.fillRect(side_originX, originY + innerRadius, width, (outerRadius - innerRadius)); - //fctx.fillStyle = 'lightgrey'; - fctx.fillStyle = toroid_colour; // rgb(100, 100, 100); - fctx.fillRect(side_originX, originY - innerRadius, width, (2 * innerRadius)); - - // Write width of cross-section of toroid (not including winding wire thickness): - fctx.font = "12px arial"; - fctx.fillStyle = "black"; - fctx.textAlign = "center"; - fctx.fillText((controller.toroid.core.C).toFixed(1) + " mm", side_originX + 0.5*width, originY + outerRadius + 20); - fctx.fillText("(" + (controller.toroid.core.C*0.03937).toFixed(3) + "\")", side_originX + 0.5*width, originY + outerRadius + 34); - - // Draw wire winding around top cross-section view: - fctx.strokeStyle = "black"; - fctx.beginPath(); - fctx.lineWidth = 2.0 * wireRadius; - fctx.moveTo(side_originX + 0.5*width, originY - outerRadius - wireRadius); - fctx.arcTo(side_originX + width + wireRadius, originY - outerRadius - wireRadius, side_originX + width + wireRadius, originY - outerRadius + 0.5*innerRadius, wireRadius); - fctx.arcTo(side_originX + width + wireRadius, originY - innerRadius + wireRadius, side_originX + 0.5*width, originY - innerRadius + wireRadius, wireRadius); - fctx.arcTo(side_originX - wireRadius, originY - innerRadius + wireRadius, side_originX - wireRadius, originY - outerRadius + 0.5*innerRadius, wireRadius); - fctx.arcTo(side_originX - wireRadius, originY - outerRadius - wireRadius, side_originX + 0.5*width, originY - outerRadius - wireRadius, wireRadius); - fctx.lineTo(side_originX + 0.5*width, originY - outerRadius - wireRadius); - fctx.stroke(); - - // Draw wire winding around bottom cross-section view: - fctx.beginPath(); - fctx.lineWidth = 2.0 * wireRadius; - fctx.moveTo(side_originX + 0.5*width, originY + outerRadius + wireRadius); - fctx.arcTo(side_originX + width + wireRadius, originY + outerRadius + wireRadius, side_originX + width + wireRadius, originY + outerRadius - 0.5*innerRadius, wireRadius); - fctx.arcTo(side_originX + width + wireRadius, originY + innerRadius - wireRadius, side_originX + 0.5*width, originY + innerRadius - wireRadius, wireRadius); - fctx.arcTo(side_originX - wireRadius, originY + innerRadius - wireRadius, side_originX - wireRadius, originY + outerRadius - 0.5*innerRadius, wireRadius); - fctx.arcTo(side_originX - wireRadius, originY + outerRadius + wireRadius, side_originX + 0.5*width, originY + outerRadius + wireRadius, wireRadius); - fctx.lineTo(side_originX + 0.5*width, originY + outerRadius + wireRadius); - fctx.stroke(); - - // Draw horizontal wires across mid of cross-section view: - fctx.lineWidth = 1.0; - for(let i = 0; i < Math.floor(turns/2); i++) { - x1 = (side_originX - wireRadius); - y1 = originY + (innerRadius-wireRadius) * Math.sin((i/turns)* (2.0 * Math.PI) + 0.5*Math.PI + (1/turns) * Math.PI); - x2 = (side_originX + width + wireRadius); - y2 = y1; - angle = 0.5 * Math.PI; - - fctx.beginPath(); - fctx.arc(x1, y1, wireRadius, angle, Math.PI+angle); - fctx.arc(x2, y2, wireRadius, Math.PI+angle, angle); - fctx.fillStyle = "black"; - fctx.fill(); - } - - // Draw the lead-in wires: - if(turns > 1) { - x1 = front_originX + (outerRadius + 20) * Math.cos(0.5 * Math.PI - 0.5 * theta); - y1 = originY + (outerRadius + 20) * Math.sin(0.5 * Math.PI - 0.5 * theta); - x2 = front_originX + (innerRadius - wireRadius) * Math.cos(0.5 * Math.PI - theta); - y2 = originY + (innerRadius - wireRadius) * Math.sin(0.5 * Math.PI - theta); - } else { - x1 = front_originX + (outerRadius + 20) * Math.cos(0.5 * Math.PI - 0.1 * theta); - y1 = originY + (outerRadius + 20) * Math.sin(0.5 * Math.PI - 0.1 * theta); - x2 = front_originX; - y2 = originY + (innerRadius - wireRadius); - } - angle = math.atan2(y1 - y2, x1 - x2) - Math.PI * 0.5; - fctx.beginPath(); - fctx.arc(x1, y1, wireRadius, angle, Math.PI+angle); - fctx.arc(x2, y2, wireRadius, Math.PI+angle, angle); - fctx.fillStyle = "black"; - fctx.fill(); - - // Now draw the rest of the wires: - for(let i = 0; i < (turns - 1); i++) { - x1 = front_originX + (outerRadius + wireRadius) * Math.cos((i/turns)* (2.0 * Math.PI) + 0.5*Math.PI + (1/turns) * Math.PI + Math.PI/turns); - y1 = originY + (outerRadius + wireRadius) * Math.sin((i/turns)* (2.0 * Math.PI) + 0.5*Math.PI + (1/turns) * Math.PI + Math.PI/turns); - x2 = front_originX + (innerRadius - wireRadius) * Math.cos((i/turns)* (2.0 * Math.PI) + 0.5*Math.PI + (1/turns) * Math.PI); - y2 = originY + (innerRadius - wireRadius) * Math.sin((i/turns)* (2.0 * Math.PI) + 0.5*Math.PI + (1/turns) * Math.PI); - angle = math.atan2(y1 - y2, x1 - x2) - Math.PI * 0.5; - - fctx.beginPath(); - fctx.arc(x1, y1, wireRadius, angle, Math.PI+angle); - fctx.arc(x2, y2, wireRadius, Math.PI+angle, angle); - fctx.fillStyle = "black"; - fctx.fill(); - } - - // Draw the Dimensions: - var localx = front_originX - outerRadius - 10; - fctx.beginPath(); - fctx.moveTo(localx + 10, originY - outerRadius); - fctx.lineTo(localx, originY - outerRadius); - fctx.moveTo(localx + 10, originY + outerRadius); - fctx.lineTo(localx, originY + outerRadius); - fctx.lineTo(localx, originY - outerRadius); - fctx.stroke(); - - fctx.font = "12px arial"; - - fctx.save(); - fctx.translate(localx, originY); - fctx.rotate(-Math.PI * 0.5); - fctx.textAlign = "center"; - fctx.fillText((controller.toroid.core.A).toFixed(1) + " mm", 0, -20); - fctx.fillText("(" + (controller.toroid.core.A*0.03937).toFixed(3) + "\")", 0, -6); - fctx.restore(); - - localx = front_originX + outerRadius + 20 + width + 15; - fctx.beginPath(); - fctx.moveTo(localx - 5, originY - innerRadius); - fctx.lineTo(localx, originY - innerRadius); - fctx.lineTo(localx, originY + innerRadius); - fctx.lineTo(localx - 5, originY + innerRadius); - fctx.stroke(); - - fctx.save(); - fctx.translate(localx, originY); - fctx.rotate(-Math.PI * 0.5); - fctx.textAlign = "center"; - fctx.fillText((controller.toroid.core.B).toFixed(1) + " mm", 0, 12); - fctx.fillText("(" + (controller.toroid.core.B*0.03937).toFixed(3) + "\")", 0, 26); - fctx.restore(); - } - function drawWire(ctx, x1, y1, x2, y2, wireRadius, fillColor) { var angle = math.atan2(y1 - y2, x1 - x2) - Math.PI * 0.5; ctx.beginPath(); @@ -2815,7 +2065,7 @@ fctx.textAlign = "left"; var num = getMetricPrefix(controller.toroid.Zl); fctx.fillText(num.val.toPrecision(3).toString() + ' ' + num.pfx + "\u03A9", side_originX + 95, originY); - + // Draw the Dimensions: fctx.strokeStyle = "black"; fctx.lineWidth = 1;