Porównaj commity

...

4 Commity

Autor SHA1 Wiadomość Data
miguel 1aee9e1284 Update transformer.html 2023-05-23 23:55:17 +10:00
miguel 047f4647ad Play around with SWR calculation 2023-05-23 23:39:18 +10:00
miguel 6a05fd6493 Update SWR 2023-05-23 23:33:34 +10:00
miguel 9213ac561f Added better graphics. 2023-05-23 23:09:35 +10:00
1 zmienionych plików z 72 dodań i 25 usunięć

Wyświetl plik

@ -7,7 +7,7 @@
<link rel="stylesheet" href="toroid.css"> <link rel="stylesheet" href="toroid.css">
</head> </head>
<body> <body>
<header>Miguel <a href="mailto:vk3cpu@gmail.com">VK3CPU</a> - RF Transformer Calculator v0.5a<br></header> <header>Miguel <a href="mailto:vk3cpu@gmail.com">VK3CPU</a> - RF Transformer Calc v0.1<br></header>
<section class="gridLayoutClass"> <section class="gridLayoutClass">
<div id="chart-container" class="chart-container"> <div id="chart-container" class="chart-container">
<canvas id="chartCanvas" class="chartCanvasClass"> <canvas id="chartCanvas" class="chartCanvasClass">
@ -675,10 +675,10 @@
return { real:Rs , imag:Xs }; return { real:Rs , imag:Xs };
}; };
this.getVSWR = function (frequency, mu) { this.getVSWR = function (Zl) {
// First calculate the reflection coefficient gamma. Assume Z_load and Z0 are complex numbers: // First calculate the reflection coefficient gamma. Assume Z_load and Z0 are complex numbers:
const Z0 = math.complex(this.Z0, 0.0); 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 gamma = math.divide( math.subtract(Zl, Z0) , math.add(Z0, Zl));
const swr = (1.0 + gamma.toPolar().r) / (1.0 - gamma.toPolar().r); const swr = (1.0 + gamma.toPolar().r) / (1.0 - gamma.toPolar().r);
return swr; return swr;
@ -712,7 +712,6 @@
this.solveTransformer = function(frequency, mu) { this.solveTransformer = function(frequency, mu) {
// Solve the voltages, currents and losses: // Solve the voltages, currents and losses:
const Zc = this.getImpedance(frequency, mu); const Zc = this.getImpedance(frequency, mu);
const Rs = Zc.real; const Rs = Zc.real;
const Xs = Zc.imag; const Xs = Zc.imag;
@ -730,7 +729,7 @@
//const Ls = mu[0] * 4.0 * Math.PI * this.Np**2 / this.core.CC; //const Ls = mu[0] * 4.0 * Math.PI * this.Np**2 / this.core.CC;
const Xp = (Rs**2 + Xs**2) / Xs; // Get parallel equivalent reactance const Xp = (Rs**2 + Xs**2) / Xs; // Get parallel equivalent reactance
const Rp = (Rs**2 + Xs**2) / Rs; // Get parallel equivalent resistance const Rp = (Rs**2 + Xs**2) / Rs; // Get parallel equivalent resistance
const Cd = 1e-12; const Cd = 1e-10 + (0.9 + (78.1/this.Np**2))*1e-12;
const Rl = this.Zl*(this.Np/this.Ns)**2; // Load impedance reflected to primary side in ohms const Rl = this.Zl*(this.Np/this.Ns)**2; // Load impedance reflected to primary side in ohms
const w = 2 * Math.PI * frequency; const w = 2 * Math.PI * frequency;
@ -744,9 +743,8 @@
let V1 = math.complex(this.Vrms, 0); let V1 = math.complex(this.Vrms, 0);
let V2 = math.multiply(V1, math.divide(Zp, math.add(Zp, Zs))); let V2 = math.multiply(V1, math.divide(Zp, math.add(Zp, Zs)));
return [this.Vrms, V1.toPolar().r, V2.toPolar().r]; return [math.add(Zp, Zs), V1.toPolar().r, V2.toPolar().r];
/* /*
let Z11 = math.add(1, math.divide(Z0,Zs)); let Z11 = math.add(1, math.divide(Z0,Zs));
let Z21 = math.inv(Zs); let Z21 = math.inv(Zs);
@ -761,14 +759,14 @@
/* /*
const Z0 = 50.0; // Source impedance in ohms const Z0 = 50.0; // Source impedance in ohms
const Cp = 1e-12; //(0.9 + (78.1/this.Np**2))*1e-12; // Primary winding parasitic capacitance in F 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 R1 = 0.1; // Resistance of primary winding in ohms
const L1 = 1e-8; // Primary leakage inductance in H const L1 = 1e-7; // Primary leakage inductance in H
const Xp = (Rs**2 + Xs**2) / Xs; // Get parallel equivalent reactance const Xp = (Rs**2 + Xs**2) / Xs; // Get parallel equivalent reactance
const Rp = (Rs**2 + Xs**2) / Rs; // Get parallel equivalent resistance const Rp = (Rs**2 + Xs**2) / Rs; // Get parallel equivalent resistance
const L2 = 1e-8; // Secondary leakage inductance, reflected into primary side, in H 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 R2 = 0.1; // Secondary winding resistance in ohms, reflected at primary side
const Cs = 1e-12; //(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 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 Zl = this.Zl*(this.Np/this.Ns)**2; // Load impedance reflected to primary side in ohms const Zl = this.Zl*(this.Np/this.Ns)**2; // Load impedance reflected to primary side in ohms
const w = 2 * Math.PI * frequency; const w = 2 * Math.PI * frequency;
@ -826,13 +824,13 @@
//this.C = (0.9 + (78.1/this.N**2))*1e-12; // In Farads //this.C = (0.9 + (78.1/this.N**2))*1e-12; // In Farads
// Low frequency mean primary inductance based on Al: // Low frequency mean primary inductance based on Al:
this.L = (this.Np**2) * this.core.Al * 1.0e-9; // In Henries this.L = (this.Np**2) * this.core.Al * 1.0e-9; // In Henries
// Mutual inductance (based on initial permeability): // Mutual inductance (based on initial permeability):
this.M = this.Np * this.Ns * this.core.Al * 1.0e-9; // In Henries this.M = this.Np * this.Ns * this.core.Al * 1.0e-9; // In Henries
// Based on David Knight's equation: // Based on David Knight's equation:
this.C = (0.9 + (78.1/this.Np**2))*1e-12; // In Farads this.C = (0.9 + (78.1/this.Np**2))*1e-12; // In Farads
this.SRF = 1.0/(2.0*Math.PI* Math.sqrt(this.L*this.C)); this.SRF = 1.0/(2.0*Math.PI* Math.sqrt(this.L*this.C));
//console.log(this.Rdc, this.L, this.C); //console.log(this.Rdc, this.L, this.C);
@ -871,7 +869,7 @@
const VVV = this.solveTransformer(freq, mu); 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 = (math.max(VVV[0]*0.5, VVV[1]) / math.min(VVV[0]*0.5, VVV[1]));
const SWR = this.getVSWR(freq, mu); const SWR = this.getVSWR(VVV[0]);
//console.log(freq, VVV); //console.log(freq, VVV);
//console.log(freq, eff, SWR, VVV); //console.log(freq, eff, SWR, VVV);
@ -1531,7 +1529,7 @@
yAxisID: 'ilID' yAxisID: 'ilID'
}, },
{ {
label: 'Pin (mW)', label: 'Pin (W)',
fill: false, fill: false,
borderColor: '#69359C', borderColor: '#69359C',
backgroundColor: '#9A4EAE', backgroundColor: '#9A4EAE',
@ -1541,7 +1539,7 @@
hidden: false hidden: false
}, },
{ {
label: 'Pout (mW)', label: 'Pout (W)',
fill: false, fill: false,
borderColor: 'rgb(0,128,128)', borderColor: 'rgb(0,128,128)',
backgroundColor: 'rgb(0,118,118)', backgroundColor: 'rgb(0,118,118)',
@ -1781,7 +1779,7 @@
// In Hz: // In Hz:
this.frequencies = []; this.frequencies = [];
//var f = 1.0 * slider_value; //var f = 1.0 * slider_value;
for(var i = Math.floor(5.00); i <= 8.00; i+=0.01) { for(var i = Math.floor(6.00); i <= 8.00; i+=0.01) {
this.frequencies.push(10.0**i); this.frequencies.push(10.0**i);
} }
} }
@ -2734,11 +2732,12 @@
// Primary winding: // Primary winding:
fctx.beginPath(); fctx.beginPath();
fctx.moveTo(x1, y1); fctx.moveTo(x1, y1);
fctx.lineTo(x2, y2); //fctx.lineTo(x2, y2);
// This is the lead-in line coming from the bottom: // This is the lead-in line coming from the bottom:
var angle = (-1 * theta) + (Math.PI - ((pturns>>1) * 2 * theta)); var angle = (-1 * theta) + (Math.PI - ((pturns>>1) * 2 * theta));
x2 = front_originX + (outerRadius + wireRadius) * Math.cos(angle); x2 = front_originX + (outerRadius + wireRadius) * Math.cos(angle);
fctx.lineTo(x2-5, y2);
y2 = originY + (outerRadius + wireRadius) * Math.sin(angle); y2 = originY + (outerRadius + wireRadius) * Math.sin(angle);
fctx.lineTo(x2, y2); fctx.lineTo(x2, y2);
@ -2756,7 +2755,7 @@
// Then to the primary exit out the top: // Then to the primary exit out the top:
x1 = front_originX - 2*outerRadius; x1 = front_originX - 2*outerRadius;
y1 = originY - outerRadius - 10; y1 = originY - outerRadius - 10;
x2 = front_originX - outerRadius; x2 -= 5;
y2 = originY - outerRadius - 10; y2 = originY - outerRadius - 10;
fctx.lineTo(x2, y2); fctx.lineTo(x2, y2);
fctx.lineTo(x1, y1); fctx.lineTo(x1, y1);
@ -2777,16 +2776,64 @@
} }
// Right-hand exit wires: // Right-hand exit wires:
x1 = side_originX + outerRadius; x1 = side_originX + outerRadius;
//x1 += 5;
y1 = originY - outerRadius - 10; y1 = originY - outerRadius - 10;
x2 = front_originX + outerRadius; x2 += 5;
y2 = originY - outerRadius - 10; y2 = originY - outerRadius - 10;
fctx.moveTo(x2, y2); //fctx.moveTo(x2, y2);
fctx.lineTo(x2, y2);
fctx.lineTo(x1, y1); fctx.lineTo(x1, y1);
y1 = originY + outerRadius + 10;
var angle1 = (Math.PI - ((sturns>>1) * 2 * theta));
x2 = front_originX + (outerRadius + wireRadius) * Math.cos(angle1);
y2 = originY + (outerRadius + wireRadius) * Math.sin(angle1);
fctx.moveTo(x2, y2);
x2 += 5; //front_originX + outerRadius;
y2 = originY + outerRadius + 10; y2 = originY + outerRadius + 10;
fctx.moveTo(x2, y2); fctx.lineTo(x2, y2);
fctx.lineTo(x1, y1); fctx.lineTo(x1, y2);
fctx.stroke(); fctx.stroke();
// Draw the primary-side capacitor:
// Draw the Dimensions:
fctx.strokeStyle = "black";
fctx.lineWidth = 1;
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 drawBalun(fctx, originX, originY, outerRadius, innerRadius, wireRadius, turns) { function drawBalun(fctx, originX, originY, outerRadius, innerRadius, wireRadius, turns) {