Update to v0.3. Build the available sizes on startup.

pull/2/head
miguel 2021-10-16 14:09:17 +11:00
rodzic c180a1c824
commit 273dd00fbd
1 zmienionych plików z 36 dodań i 23 usunięć

Wyświetl plik

@ -7,7 +7,7 @@
<link rel="stylesheet" href="toroid.css">
</head>
<body>
<header>Miguel <a href="mailto:vk3cpu@gmail.com">VK3CPU</a> - RF Toroid Calculator v0.2<br></header>
<header>Miguel <a href="mailto:vk3cpu@gmail.com">VK3CPU</a> - RF Toroid Calculator v0.3<br></header>
<section class="gridLayoutClass">
<div id="chart-container" class="chart-container" style="position: relative;">
<canvas id="chartCanvas" class="chartCanvasClass">
@ -22,16 +22,16 @@
<div>
<select name="functions" id="function-select">
<option value="Inductor">Inductor</option>
<option value="CommonModeChoke">Suppressor</option>
<option value="Transformer">Transformer</option>
<option value="CommonModeChoke" disabled="true">Suppressor</option>
<option value="Transformer" disabled="true">Transformer</option>
</select>
<select name="toroids" id="toroid-select" onchange="setToroid()">
<option value="FT240">FT240</option>
<!--option value="FT240">FT240</option>
<option value="FT140">FT140</option>
<option value="FT114">FT114</option>
<option value="FT82">FT82</option>
<option value="FT50">FT50</option>
<option value="FT37" disabled="true">FT37</option>
<option value="FT37">FT37</option-->
</select>
<select name="materials" id="material-select" onchange="setMaterial()">
<option value="75">75 [5000]</option>
@ -203,6 +203,7 @@
size : {
'FT240' : { PN:'5967003801', A:61.0, B:35.55, C:12.7, W:106.0, CC:9.20, le:14.5, Ae:1.58, Ve:22.8, Al:55.0 },
'FT140' : { PN:'5967002701', A:35.55, B:23.00, C:12.7, W:33.00, CC:11.20, le:8.90, Ae:0.79, Ve:7.00, Al:45.0 },
'FT114+': { PN:'5967001201', A:29.00, B:19.00, C:13.85, W:26.0, CC:10.70, le:7.30, Ae:0.68, Ve:5.0, Al:47.0 },
'FT114' : { PN:'5967001001', A:29.00, B:19.00, C:7.50, W:13.0, CC:19.80, le:7.30, Ae:0.37, Ve:2.70, Al:25.0 },
'FT82' : { PN:'5967000601', A:21.00, B:13.20, C:6.35, W:6.40, CC:21.30, le:5.20, Ae:0.243, Ve:1.26, Al:24.0 },
'FT50' : { PN:'5967000301', A:12.70, B:7.15, C:4.90, W:2.00, CC:22.90, le:2.95, Ae:0.129, Ve:0.38, Al:22 },
@ -227,6 +228,7 @@
size : {
'FT240' : { PN:'5961003801', A:61.0, B:35.55, C:12.7, W:106.0, CC:9.20, le:14.5, Ae:1.58, Ve:22.8, Al:170.0 },
'FT140' : { PN:'5961002701', A:35.55, B:23.00, C:12.7, W:33.00, CC:11.20, le:8.90, Ae:0.79, Ve:7.00, Al:140.0 },
'FT114+': { PN:'5961001201', A:29.00, B:19.00, C:13.85, W:26.0, CC:10.70, le:7.30, Ae:0.68, Ve:5.0, Al:145.0 },
'FT114' : { PN:'5961001001', A:29.00, B:19.00, C:7.50, W:13.0, CC:19.80, le:7.30, Ae:0.37, Ve:2.70, Al:80.0 },
'FT82' : { PN:'5961000601', A:21.00, B:13.20, C:6.35, W:6.40, CC:21.30, le:5.20, Ae:0.243, Ve:1.26, Al:75.0 },
'FT50' : { PN:'5961000301', A:12.70, B:7.15, C:4.90, W:2.00, CC:22.90, le:2.95, Ae:0.129, Ve:0.38, Al:69 },
@ -252,7 +254,8 @@
'FT140' : { PN:'5952020801', A:35.25, B:22.60, C:12.7, W:38.26, CC:11.10, le:8.79, Ae:0.792, Ve:6.959, Al:283.0 },
'FT114' : { PN:'5952020701', A:28.8, B:18.70, C:7.50, W:14.81, CC:19.34, le:7.23, Ae:0.374, Ve:2.702, Al:162.0 },
'FT82' : { PN:'5952020601', A:21.70, B:13.50, C:6.35, W:7.54, CC:20.80, le:5.33, Ae:0.256, Ve:1.368, Al:151.0 },
'FT50' : { PN:'5952020501', A:12.45, B:7.8, C:6.35, W:2.46, CC:21.24, le:3.06, Ae:0.144, Ve:0.442, Al:148.0 },
'FT50+' : { PN:'5952020501', A:12.45, B:7.8, C:6.35, W:2.46, CC:21.24, le:3.06, Ae:0.144, Ve:0.442, Al:148.0 },
'FT50' : { PN:'5952020401', A:12.45, B:7.8, C:4.90, W:2.16, CC:22.31, le:2.90, Ae:0.13, Ve:0.378, Al:141.0 },
'FT37' : { PN:'5952020301', A:9.42, B:4.72, C:3.30, W:0.87, CC:28.66, le:2.06, Ae:0.072, Ve:0.147, Al:110.0 },
},
mat : "NiZn",
@ -532,7 +535,7 @@
const II = math.divide(toroid.Vrms, ZZ).toPolar();
toroid.i_vs_f.push({x:freq, y:(II.r*1e3)});
toroid.P_vs_f.push({x:freq, y:(Z.real * II.r**2)});
toroid.P_vs_f.push({x:freq, y:((Z.real * II.r**2)*1e3)});
toroid.Z_vs_f.push({x:freq, y:(ZZ.toPolar().r)});
const H = ((0.4 * Math.PI * toroid.N * 1.414 * II.r) / toroid.core.le);
@ -562,12 +565,8 @@
myChart.data.datasets[9].data = calculatePowerLoss();
myChart.update();
}
function setMaterial() {
//console.log("setMaterial()")
var materials = document.getElementsByName("materials");
material = materials[0].value;
function rebuildSizeDOM() {
// Remove all toroid sizes in the DOM:
var toroid_sizes = document.getElementById("toroid-select");
while(toroid_sizes.firstChild) {
@ -590,6 +589,15 @@
//console.log(t_size + " NOT exists!");
t_size = Object.keys(cores[material].size)[0];
}
}
function setMaterial() {
//console.log("setMaterial()")
var materials = document.getElementsByName("materials");
material = materials[0].value;
// Rebuild the list of available sizes for this material type:
rebuildSizeDOM();
recalculate()
myChart.options.plugins.title.text = "Fair-Rite " + t_size + "-" + material + " [" + toroid.core.PN + "]";
@ -1010,6 +1018,7 @@
const chartCanvasContext = chartCanvas.getContext('2d');
updateFrequencies();
rebuildSizeDOM();
recalculate();
var myChart = new Chart(chartCanvasContext, {
@ -1068,7 +1077,8 @@
backgroundColor: 'rgb(150,150,255)',
data: calculatePermeability1(),
borderWidth: 1,
yAxisID: 'muID'
yAxisID: 'muID',
hidden: true
},
{
label: '\u03bc\'\'',
@ -1077,7 +1087,8 @@
backgroundColor: 'rgb(255,150,150)',
data: calculatePermeability2(),
borderWidth: 1,
yAxisID: 'muID'
yAxisID: 'muID',
hidden: true
},
{
label: 'H(Oe)',
@ -1086,7 +1097,8 @@
backgroundColor: 'rgb(255,127,0)',
data: calculateH(),
borderWidth: 1,
yAxisID: 'hID'
yAxisID: 'hID',
hidden: true
},
{
label: 'B(G)',
@ -1095,17 +1107,18 @@
backgroundColor: 'rgb(255,255,0)',
data: calculateB(),
borderWidth: 1,
yAxisID: 'bID'
yAxisID: 'bID',
hidden: true
},
{
label: 'P(W)',
label: 'P(mW)',
fill: false,
borderColor: 'rgb(50,50,50)',
backgroundColor: 'rgb(100,100,100)',
data: calculatePowerLoss(),
borderWidth: 1,
yAxisID: 'wattsID',
hidden: true
hidden: false
}]
},
options: {
@ -1167,7 +1180,7 @@
}
},
min: 0.0,
position: 'left',
position: 'right',
},
'muID' : {
type: 'linear',
@ -1195,7 +1208,7 @@
}
},
min: 0.0,
position: 'right',
position: 'left',
},
'bID' : {
type: 'linear',
@ -1209,14 +1222,14 @@
}
},
min: 0.0,
position: 'right',
position: 'left',
},
'wattsID' : {
type: 'linear',
display: 'auto',
title: {
display: true,
text: 'W',
text: 'mW',
color: 'rgb(50,50,50)',
font: {
weight : 'bold'