vk3cpu/magloop.html

653 wiersze
30 KiB
HTML
Czysty Zwykły widok Historia

2020-10-17 04:04:13 +00:00
<!DOCTYPE html>
2020-10-08 07:21:58 +00:00
<html lang="en">
2020-10-17 04:04:13 +00:00
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>VK3CPU Magloop Solver</title>
<link rel="stylesheet" href="magloop.css">
</head>
<body>
<header>Miguel VK3CPU - Small Loop Antenna Calculator</header>
2020-10-19 10:01:28 +00:00
<canvas id="3Dantenna" width="800" height="200">
2020-10-17 04:04:13 +00:00
3D Antenna Radiation Pattern Canvas
</canvas>
2020-10-19 10:01:28 +00:00
<!--
2020-10-17 13:03:20 +00:00
<svg >
<circle cx="25%" cy="50%" r="40" stroke="black" stroke-width="2" fill="white"/>
<circle cx="25%" cy="50%" r="35" stroke="black" stroke-width="2" fill="white"/>
<text x="08%" y="50%" style="fill:black;">&#8960 1</text>
<line x1="40" y1="50%" x2="80" y2="50%" style="stroke:rgb(0,0,0);stroke-width:2" />
2020-10-17 13:00:08 +00:00
</svg>
2020-10-18 11:59:01 +00:00
-->
2020-10-17 13:03:20 +00:00
<canvas id="chartCanvas">
2020-10-17 04:04:13 +00:00
2D Chart Canvas
</canvas>
<section class="controls">
<div>
2020-10-19 10:01:28 +00:00
<label for="loop_diameter_slider">&#8960a:</label>
2020-10-18 11:59:01 +00:00
<input type="range" id="loop_diameter_slider" min="0.5" max="3.0" value="1.0" step="0.05">
2020-10-17 04:04:13 +00:00
<span id="loop_diameter_value"></span> (m)
</div>
<div>
2020-10-19 10:01:28 +00:00
<label for="conductor_diameter_slider">&#8960b:</label>
2020-10-17 04:04:13 +00:00
<input type="range" id="conductor_diameter_slider" min="5" max="30" value="19" step="1">
<span id="conductor_diameter_value"></span> (mm)
</div>
<div>
<label for="loop_turns_slider">Loop turns:</label>
<input type="range" id="loop_turns_slider" min="1" max="8" value="1.0" step="1.0">
<span id="loop_turns_value"></span>
</div>
<div>
<label for="loop_spacing_slider">Loop spacing ratio:</label>
<input type="range" id="loop_spacing_slider" min="1.1" max="4.0" value="2.0" step="0.05">
<span id="loop_spacing_value"></span>
</div>
2020-10-17 04:04:13 +00:00
<div>
<label for="transmit_power_slider">Transmit Power:</label>
<input type="range" id="transmit_power_slider" min="25" max="1500" value="400" step="25">
<span id="transmit_power_value"></span> (W)
</div>
<!--
2020-10-17 04:04:13 +00:00
<div>
<label for="heightAboveGround_slider">Height above ground:</label>
<input type="range" id="heightAboveGround_slider" min="0.0" max="10.0" value="1.0" step="0.1">
<span id="heightAboveGround_value"></span> (m)
</div>
-->
2020-10-17 04:04:13 +00:00
</section>
</body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.3/Chart.min.js"></script>
<script>
2020-10-18 23:42:27 +00:00
var frequencies = [];
2020-10-18 12:27:18 +00:00
2020-10-17 04:04:13 +00:00
var loop_diameter_slider = document.getElementById("loop_diameter_slider");
var loop_diameter_value = document.getElementById("loop_diameter_value");
loop_diameter_value.innerHTML = loop_diameter_slider.value;
var conductor_diameter_slider = document.getElementById("conductor_diameter_slider");
var conductor_diameter_value = document.getElementById("conductor_diameter_value");
conductor_diameter_value.innerHTML = conductor_diameter_slider.value;
var loop_turns_slider = document.getElementById("loop_turns_slider");
var loop_turns_value = document.getElementById("loop_turns_value");
loop_turns_value.innerHTML = loop_turns_slider.value;
var loop_spacing_slider = document.getElementById("loop_spacing_slider");
var loop_spacing_value = document.getElementById("loop_spacing_value");
loop_spacing_value.innerHTML = loop_spacing_slider.value;
2020-10-17 04:04:13 +00:00
var transmit_power_slider = document.getElementById("transmit_power_slider");
var transmit_power_value = document.getElementById("transmit_power_value");
transmit_power_value.innerHTML = transmit_power_slider.value;
/*
2020-10-17 04:04:13 +00:00
var heightAboveGround_slider = document.getElementById("heightAboveGround_slider");
var heightAboveGround_value = document.getElementById("heightAboveGround_value");
heightAboveGround_value.innerHTML = heightAboveGround_slider.value;
*/
2020-10-18 12:27:18 +00:00
function updateFrequencies() {
const hamFrequencies = [
2020-10-19 05:47:06 +00:00
//1.6, 2.0, 4.0, 6.0, 8.0
2020-10-18 12:27:18 +00:00
1.8, 3.5, 5.0, 7.0, 10.1, 14.0, 18.068, 21.0, 24.89, 28.0
2020-10-18 23:42:27 +00:00
//1.8, 2.2, 2.8, 3.5, 5.0, 6.0, 7.0, 8.0, 9.0, 10.1, 12.0, 14.0, 16.0, 18.068, 21.0, 24.89, 28.0
2020-10-19 05:47:06 +00:00
//1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
2020-10-18 12:27:18 +00:00
];
frequencies = [];
hamFrequencies.forEach(freq => {
const wavelength = 3e8 / (freq * 1e6);
const l = (Math.PI * loop_diameter_slider.value) / wavelength;
if (l <= 0.20) {
frequencies.push(freq);
}
});
}
// Update the frequencies, now that we have the sliders available:
updateFrequencies();
2020-10-17 04:04:13 +00:00
function getInductance() {
const a_coil_radius = loop_diameter_slider.value * 0.5;
const b_conductor_radius = conductor_diameter_slider.value * 0.0005;
const n_turns = loop_turns_slider.value;
const mu0 = 4.0 * Math.PI * 1e-7;
var retval = (n_turns ** 2.0) * mu0 * a_coil_radius * (Math.log(8.0 * a_coil_radius / b_conductor_radius) - 2.0);
return retval;
}
2020-10-18 11:41:31 +00:00
function radiationResistance(frequency) {
2020-10-17 04:04:13 +00:00
const n_turns = loop_turns_slider.value;
const k = 20.0 * (Math.PI ** 2.0);
2020-10-18 11:41:31 +00:00
const wavelength = 3e8 / (frequency * 1e6);
const l = (Math.PI * loop_diameter_slider.value) / wavelength;
const rr = (n_turns ** 2.0) * k * (l ** 4.0);
return rr;
}
2020-10-19 05:47:06 +00:00
2020-10-18 11:41:31 +00:00
function calculateRadiationResistance() {
var retval = [];
2020-10-17 04:04:13 +00:00
frequencies.forEach(freq => {
2020-10-18 12:27:18 +00:00
const rr = radiationResistance(freq);
retval.push({x:freq, y:rr});
2020-10-17 04:04:13 +00:00
});
return retval;
}
2020-10-18 11:41:31 +00:00
function inductiveReactance(frequency) {
const inductance = getInductance();
const wavelength = 3e8 / (frequency * 1e6);
const l = (Math.PI * loop_diameter_slider.value) / wavelength;
const reactance = 2.0 * Math.PI * (frequency * 1e6) * inductance;
return reactance;
}
2020-10-17 04:04:13 +00:00
function calculateInductiveReactance() {
var retval = [];
frequencies.forEach(freq => {
2020-10-18 11:41:31 +00:00
const reactance = inductiveReactance(freq);
retval.push({x:freq, y:reactance});
2020-10-17 04:04:13 +00:00
});
return retval;
}
2020-10-18 11:41:31 +00:00
function tuningCapacitance(frequency) {
const inductance = getInductance();
const wavelength = 3e8 / (frequency * 1e6);
const l = (Math.PI * loop_diameter_slider.value) / wavelength;
const reactance = 2.0 * Math.PI * frequency * 1e6 * inductance;
const capacitance = 1e12 / (2.0 * Math.PI * frequency * 1e6 * reactance);
return capacitance;
}
2020-10-17 04:04:13 +00:00
function calculateTuningCapacitor() {
var retval = [];
frequencies.forEach(freq => {
2020-10-18 12:27:18 +00:00
const capacitor = tuningCapacitance(freq);
retval.push({x:freq, y:capacitor});
2020-10-17 04:04:13 +00:00
});
return retval;
}
const proximityResistance = {
// From G. S. Smith, "Radiation Efficiency of Electrically Small Multiturn Loop Antennas", IEEE Trans Antennas Propagation, September 1972
2020-10-19 05:47:06 +00:00
// 0 - this is the corresponding x-axis value. 1 - single loop adds zero to proximity resistance. Others measured empirically.
0:[ 1.1, 1.15, 1.20, 1.25, 1.30, 1.40, 1.50, 1.60, 1.70, 1.80, 1.90, 2.00, 2.20, 2.40, 2.50, 2.60, 2.80, 3.00, 3.50, 4.00],
1:[0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000],
2:[0.299, 0.284, 0.268, 0.254, 0.240, 0.214, 0.191, 0.173, 0.155, 0.141, 0.128, 0.116, 0.098, 0.032, 0.077, 0.071, 0.061, 0.054, 0.040, 0.031],
3:[0.643, 0.580, 0.531, 0.491, 0.455, 0.395, 0.346, 0.305, 0.270, 0.241, 0.216, 0.195, 0.161, 0.135, 0.124, 0.114, 0.098, 0.085, 0.062, 0.048],
4:[0.996, 0.868, 0.777, 0.704, 0.644, 0.564, 0.470, 0.408, 0.353, 0.316, 0.281, 0.252, 0.205, 0.170, 0.156, 0.144, 0.123, 0.106, 0.077, 0.058],
5:[1.347, 1.142, 1.002, 0.896, 0.809, 0.674, 0.572, 0.492, 0.428, 0.375, 0.332, 0.295, 0.239, 0.197, 0.180, 0.165, 0.141, 0.121, 0.087, 0.066],
6:[1.689, 1.400, 1.210, 1.068, 0.956, 0.784, 0.658, 0.561, 0.485, 0.423, 0.372, 0.330, 0.265, 0.217, 0.198, 0.182, 0.154, 0.133, 0.095, 0.072],
7:[2.020, 1.693, 1.401, 1.224, 1.086, 0.880, 0.732, 0.620, 0.532, 0.462, 0.405, 0.358, 0.286, 0.234, 0.213, 0.195, 0.165, 0.142, 0.101, 0.076],
8:[2.340, 1.872, 1.577, 1.365, 1.203, 0.965, 0.796, 0.670, 0.573, 0.495, 0.433, 0.392, 0.304, 0.247, 0.225, 0.206, 0.174, 0.150, 0.106, 0.080]
};
function getProximityResFromSpacing(spacing_ratio) {
2020-10-18 11:41:31 +00:00
// Use the proximityResistance look-up table and interpolate values depending on the spacing ratio and the number of turns.
2020-10-17 13:00:08 +00:00
var retval = 0.0;
const n_turns = loop_turns_slider.value;
var i = 0;
for (i = 0; i < (proximityResistance[0].length-1); i++) {
if(spacing_ratio <= proximityResistance[0][i+1]) {
// Linear interpolation between empirical proximity resistance values:
retval = (((spacing_ratio - proximityResistance[0][i]) / (proximityResistance[0][i+1] - proximityResistance[0][i]) * (proximityResistance[n_turns][i+1] - proximityResistance[n_turns][i])) + proximityResistance[n_turns][i]);
break;
}
2020-10-17 13:00:08 +00:00
}
return retval;
2020-10-17 13:00:08 +00:00
}
2020-10-18 11:41:31 +00:00
function lossResistance(frequency) {
2020-10-17 04:04:13 +00:00
const a_coil_radius = loop_diameter_slider.value * 0.5;
const b_conductor_radius = conductor_diameter_slider.value * 0.0005;
const n_turns = loop_turns_slider.value;
const loop_spacing_ratio = loop_spacing_slider.value;
2020-10-17 04:04:13 +00:00
const mu0 = 4.0 * Math.PI * 1e-7;
const k = (n_turns * a_coil_radius / b_conductor_radius);
2020-10-18 11:41:31 +00:00
const cu_sigma = 58e6; // Copper conductance value
const Rp = getProximityResFromSpacing(loop_spacing_ratio);
2020-10-18 11:41:31 +00:00
const Rs = Math.sqrt(Math.PI * frequency * 1e6 * mu0 / cu_sigma);
const R0 = (n_turns * Rs) / (2.0 * Math.PI * b_conductor_radius);
const R_ohmic = k * Rs * (Rp / R0 + 1.0);
return R_ohmic;
}
function calculateLossResistance() {
var retval = [];
2020-10-17 04:04:13 +00:00
frequencies.forEach(freq => {
2020-10-18 11:41:31 +00:00
const R_ohmic = lossResistance(freq);
retval.push({x:freq, y:R_ohmic});
2020-10-17 04:04:13 +00:00
});
return retval;
}
function calculateEfficiencyFactor() {
var retval = [];
2020-10-18 11:41:31 +00:00
frequencies.forEach(freq => {
const R_ohmic = lossResistance(freq);
const R_rad = radiationResistance(freq);
const efficiency = 100.0 / (1.0 + (R_ohmic / R_rad));
2020-10-19 05:47:06 +00:00
//const efficiency = 10.0 * Math.log10(1.0 / (1.0 + (R_ohmic / R_rad))); // for Efficiency in dB
2020-10-18 11:41:31 +00:00
retval.push({x:freq, y:efficiency});
});
return retval;
}
2020-10-18 11:41:31 +00:00
function qualityFactor(frequency) {
const Xl = inductiveReactance(frequency);
const Rl = lossResistance(frequency);
const Rr = radiationResistance(frequency);
const Q = Xl / (Rl + Rr);
return Q;
}
2020-10-17 04:04:13 +00:00
function calculateQualityFactor() {
var retval = [];
2020-10-18 11:41:31 +00:00
frequencies.forEach(freq => {
const Q = qualityFactor(freq);
retval.push({x:freq, y:Q});
});
return retval;
}
function bandwidth(frequency) {
const Q = qualityFactor(frequency);
const bw = frequency * 1e3 / Q; // in kiloHertz, remember that frequency comes in as MHz. Conversion between MHz and kHz is why the 1e3 exists.
return bw;
}
function calculateBandwidth() {
var retval = [];
frequencies.forEach(freq => {
const bw = bandwidth(freq);
retval.push({x:freq, y:bw});
});
2020-10-17 04:04:13 +00:00
return retval;
}
2020-10-18 13:15:40 +00:00
function capacitorVoltage(frequency) {
const Vcap = Math.sqrt(transmit_power_slider.value * inductiveReactance(frequency) * qualityFactor(frequency));
return Vcap;
}
function calculateCapacitorVoltage() {
var retval = [];
frequencies.forEach(freq => {
2020-10-18 23:42:27 +00:00
const Vcap = 0.001 * capacitorVoltage(freq);
2020-10-18 13:15:40 +00:00
retval.push({x:freq, y:Vcap});
});
return retval;
}
2020-10-17 04:04:13 +00:00
loop_diameter_slider.oninput = function() {
loop_diameter_value.innerHTML = this.value;
2020-10-19 10:01:28 +00:00
drawDesign();
2020-10-18 12:27:18 +00:00
updateFrequencies();
2020-10-18 13:15:40 +00:00
myChart.data.datasets[0].data = calculateTuningCapacitor();
myChart.data.datasets[1].data = calculateBandwidth();
myChart.data.datasets[2].data = calculateEfficiencyFactor();
myChart.data.datasets[3].data = calculateRadiationResistance();
myChart.data.datasets[4].data = calculateInductiveReactance();
myChart.data.datasets[5].data = calculateLossResistance();
myChart.data.datasets[6].data = calculateQualityFactor();
myChart.data.datasets[7].data = calculateCapacitorVoltage();
2020-10-17 04:04:13 +00:00
myChart.update();
}
conductor_diameter_slider.oninput = function() {
conductor_diameter_value.innerHTML = this.value;
2020-10-19 10:01:28 +00:00
drawDesign();
2020-10-18 13:15:40 +00:00
myChart.data.datasets[0].data = calculateTuningCapacitor();
myChart.data.datasets[1].data = calculateBandwidth();
myChart.data.datasets[2].data = calculateEfficiencyFactor();
myChart.data.datasets[3].data = calculateRadiationResistance();
myChart.data.datasets[4].data = calculateInductiveReactance();
myChart.data.datasets[5].data = calculateLossResistance();
myChart.data.datasets[6].data = calculateQualityFactor();
myChart.data.datasets[7].data = calculateCapacitorVoltage();
2020-10-17 04:04:13 +00:00
myChart.update();
}
loop_turns_slider.oninput = function() {
loop_turns_value.innerHTML = this.value;
drawDesign();
2020-10-18 13:15:40 +00:00
myChart.data.datasets[0].data = calculateTuningCapacitor();
myChart.data.datasets[1].data = calculateBandwidth();
myChart.data.datasets[2].data = calculateEfficiencyFactor();
myChart.data.datasets[3].data = calculateRadiationResistance();
myChart.data.datasets[4].data = calculateInductiveReactance();
myChart.data.datasets[5].data = calculateLossResistance();
myChart.data.datasets[6].data = calculateQualityFactor();
myChart.data.datasets[7].data = calculateCapacitorVoltage();
myChart.update();
}
loop_spacing_slider.oninput = function() {
loop_spacing_value.innerHTML = loop_spacing_slider.value;
drawDesign();
2020-10-18 13:15:40 +00:00
myChart.data.datasets[0].data = calculateTuningCapacitor();
myChart.data.datasets[1].data = calculateBandwidth();
myChart.data.datasets[2].data = calculateEfficiencyFactor();
myChart.data.datasets[3].data = calculateRadiationResistance();
myChart.data.datasets[4].data = calculateInductiveReactance();
myChart.data.datasets[5].data = calculateLossResistance();
myChart.data.datasets[6].data = calculateQualityFactor();
myChart.data.datasets[7].data = calculateCapacitorVoltage();
2020-10-17 04:04:13 +00:00
myChart.update();
}
transmit_power_slider.oninput = function() {
transmit_power_value.innerHTML = this.value;
2020-10-18 13:15:40 +00:00
myChart.data.datasets[7].data = calculateCapacitorVoltage();
myChart.update();
2020-10-17 04:04:13 +00:00
}
/*
2020-10-17 04:04:13 +00:00
heightAboveGround_slider.oninput = function() {
heightAboveGround_value.innerHTML = this.value;
}
*/
2020-10-17 04:04:13 +00:00
2020-10-19 10:01:28 +00:00
const plan_canvas = document.getElementById("3Dantenna");
const ctx = plan_canvas.getContext('2d');
function drawDesign() {
const win_width = plan_canvas.width;
const win_height = plan_canvas.height;
ctx.clearRect(0, 0, win_width, win_height);
const loop_radius = 75; // loop_diameter_slider.value * 80;
const cond_radius = conductor_diameter_slider.value / 4;
// Draw loop:
ctx.beginPath();
ctx.arc(win_width/4, win_height/2, loop_radius + cond_radius, 0.5 * Math.PI + 0.02, 0.5 * Math.PI - 0.02, false);
//ctx.stroke();
//ctx.beginPath();
ctx.arc(win_width/4, win_height/2, loop_radius - cond_radius, 0.5 * Math.PI - 0.025, 0.5 * Math.PI + 0.025, true);
ctx.closePath();
ctx.fill();
2020-10-19 10:01:28 +00:00
// Draw cap:
ctx.beginPath();
2020-10-19 10:01:28 +00:00
ctx.moveTo(win_width/4 - 3, win_height/2 + loop_radius - 3*cond_radius);
ctx.lineTo(win_width/4 - 3, win_height/2 + loop_radius + 3*cond_radius);
ctx.moveTo(win_width/4 + 3, win_height/2 + loop_radius - 3*cond_radius);
ctx.lineTo(win_width/4 + 3, win_height/2 + loop_radius + 3*cond_radius);
ctx.stroke();
// Draw loop diameter arrow:
ctx.beginPath();
2020-10-19 10:01:28 +00:00
ctx.moveTo(win_width/4 - loop_radius, win_height/2);
ctx.lineTo(win_width/4 - loop_radius + 2*cond_radius, win_height/2 - 2*cond_radius);
ctx.lineTo(win_width/4 - loop_radius + 2*cond_radius, win_height/2 + 2*cond_radius);
ctx.lineTo(win_width/4 - loop_radius, win_height/2);
ctx.lineTo(win_width/4 + loop_radius, win_height/2);
ctx.lineTo(win_width/4 + loop_radius - 2*cond_radius, win_height/2 + 2*cond_radius);
ctx.lineTo(win_width/4 + loop_radius - 2*cond_radius, win_height/2 - 2*cond_radius);
ctx.lineTo(win_width/4 + loop_radius, win_height/2);
ctx.stroke();
2020-10-19 10:01:28 +00:00
// Write loop diameter symbol:
ctx.font = "14px arial";
ctx.textAlign = "center";
ctx.fillText("\u2300a = " + loop_diameter_slider.value.toString() + "m", win_width/4, win_height/2 - 5);
2020-10-19 10:01:28 +00:00
// Draw conductor diameter arrow:
ctx.beginPath();
2020-10-19 10:01:28 +00:00
var p1x = win_width/4 + 0.4 * (loop_radius - cond_radius);
var p1y = win_height/2 + 0.4 * (loop_radius - cond_radius);
var p2x = win_width/4 + 0.707 * (loop_radius - cond_radius);
var p2y = win_height/2 + 0.707 * (loop_radius - cond_radius);
var p3x = win_width/4 + 0.707 * (loop_radius - cond_radius) - 3*cond_radius;
var p3y = win_height/2 + 0.707 * (loop_radius - cond_radius);
var p4x = win_width/4 + 0.707 * (loop_radius - cond_radius);
var p4y = win_height/2 + 0.707 * (loop_radius - cond_radius) - 3*cond_radius;
ctx.moveTo(p1x, p1y);
ctx.lineTo(p2x, p2y);
ctx.lineTo(p3x, p3y);
ctx.lineTo(p4x, p4y);
ctx.lineTo(p2x, p2y);
//ctx.stroke();
2020-10-19 10:01:28 +00:00
var p1x = win_width/4 + 1.0 * (loop_radius + cond_radius);
var p1y = win_height/2 + 1.0 * (loop_radius + cond_radius);
var p2x = win_width/4 + 0.707 * (loop_radius + cond_radius);
var p2y = win_height/2 + 0.707 * (loop_radius + cond_radius);
var p3x = win_width/4 + 0.707 * (loop_radius + cond_radius) + 3*cond_radius;
var p3y = win_height/2 + 0.707 * (loop_radius + cond_radius);
var p4x = win_width/4 + 0.707 * (loop_radius + cond_radius);
var p4y = win_height/2 + 0.707 * (loop_radius + cond_radius) + 3*cond_radius;
ctx.moveTo(p1x, p1y);
ctx.lineTo(p2x, p2y);
ctx.lineTo(p3x, p3y);
ctx.lineTo(p4x, p4y);
ctx.lineTo(p2x, p2y);
ctx.stroke();
var p1x = win_width/4 + 0.4 * (loop_radius - cond_radius);
var p1y = win_height/2 + 0.4 * (loop_radius - cond_radius) - 5;
ctx.fillText("\u2300b = " + conductor_diameter_slider.value.toString() + "mm", p1x, p1y);
const start_x = win_width/2;
const top_y = win_height * 0.2;
const bot_y = win_height * 0.8;
//const cond_radius = conductor_diameter_slider.value;
const cond_spacing = 2 * cond_radius * loop_spacing_slider.value;
for (let i = 0; i < loop_turns_slider.value; i++) {
ctx.beginPath();
//ctx.moveTo(start_x + i * cond_spacing + cond_radius, bot_y);
ctx.arc(start_x + i * cond_spacing, bot_y, cond_radius, 0, Math.PI);
//ctx.moveTo(start_x + i * cond_spacing - cond_radius, bot_y);
//ctx.lineTo(start_x + cond_spacing * 0.5 + i * cond_spacing - cond_radius, top_y);
//ctx.stroke();
ctx.arc(start_x + cond_spacing * 0.5 + i * cond_spacing, top_y, cond_radius, Math.PI, 0);
ctx.lineTo(start_x + i * cond_spacing + cond_radius, bot_y);
ctx.fill();
//ctx.stroke();
ctx.beginPath();
ctx.moveTo(start_x + cond_spacing * 0.5 + i * cond_spacing + cond_radius, top_y);
ctx.lineTo(start_x + (i+1) * cond_spacing + cond_radius, bot_y);
ctx.arc(start_x + (i+1) * cond_spacing, bot_y, cond_radius, 0, Math.PI, false);
ctx.lineTo(start_x + cond_spacing * 0.5 + i * cond_spacing - cond_radius, top_y);
ctx.stroke();
}
// Draw left spacing arrow:
const dim_y = win_height * 0.9;
ctx.beginPath();
ctx.moveTo(start_x - 30, dim_y);
ctx.lineTo(start_x, dim_y);
ctx.lineTo(start_x - 10, dim_y + 10)
ctx.lineTo(start_x - 10, dim_y - 10)
ctx.lineTo(start_x, dim_y);
ctx.moveTo(start_x, dim_y - 10);
ctx.lineTo(start_x, dim_y + 10);
ctx.stroke();
// Draw right spacing arrow:
ctx.beginPath();
ctx.moveTo(start_x + cond_spacing + 30, dim_y);
ctx.lineTo(start_x + cond_spacing, dim_y);
ctx.lineTo(start_x + cond_spacing + 10, dim_y + 10)
ctx.lineTo(start_x + cond_spacing + 10, dim_y - 10)
ctx.lineTo(start_x + cond_spacing, dim_y);
ctx.moveTo(start_x + cond_spacing, dim_y - 10);
ctx.lineTo(start_x + cond_spacing, dim_y + 10);
ctx.stroke();
// Draw spacing text:
ctx.textAlign = "left";
const spc = loop_spacing_slider.value * conductor_diameter_slider.value;
ctx.fillText(spc.toPrecision(2).toString() + "mm", start_x + cond_spacing + 35, dim_y + 5);
2020-10-19 10:01:28 +00:00
}
drawDesign();
2020-10-17 04:04:13 +00:00
const chartCanvasContext = document.getElementById("chartCanvas").getContext('2d');
var myChart = new Chart(chartCanvasContext, {
type: 'line',
data: {
datasets: [
2020-10-18 12:27:18 +00:00
{
2020-10-18 23:42:27 +00:00
label: 'Tuning Capacitor (pF)',
2020-10-18 12:27:18 +00:00
fill: false,
borderColor: 'green',
backgroundColor: 'green',
data: calculateTuningCapacitor(),
borderWidth: 1,
yAxisID: 'pfID'
},
{
2020-10-18 23:42:27 +00:00
label: 'BW (kHz)',
2020-10-18 12:27:18 +00:00
fill: false,
borderColor: 'brown',
backgroundColor: 'brown',
data: calculateBandwidth(),
borderWidth: 1,
yAxisID: 'bwID'
},
{
2020-10-18 23:42:27 +00:00
label: 'Efficiency (%)',
2020-10-18 12:27:18 +00:00
fill: false,
borderColor: 'black',
backgroundColor: 'black',
data: calculateEfficiencyFactor(),
borderWidth: 1,
yAxisID: 'effID'
},
{
2020-10-18 23:42:27 +00:00
label: 'Radiation Resistance (\u03A9)',
2020-10-17 04:04:13 +00:00
fill: false,
borderColor: 'red',
backgroundColor: 'red',
data: calculateRadiationResistance(),
borderWidth: 1,
yAxisID: 'mohmsID'
},
{
2020-10-18 23:42:27 +00:00
label: 'Reactance (j\u03A9)',
2020-10-17 04:04:13 +00:00
fill: false,
borderColor: 'blue',
backgroundColor: 'blue',
data: calculateInductiveReactance(),
borderWidth: 1,
yAxisID: 'ohmsID'
},
{
2020-10-18 23:42:27 +00:00
label: 'Loss Resistance (\u03A9)',
fill: false,
borderColor: 'orange',
backgroundColor: 'orange',
data: calculateLossResistance(),
borderWidth: 1,
yAxisID: 'mohmsID'
},
{
2020-10-18 12:27:18 +00:00
label: 'Q',
2020-10-18 06:16:51 +00:00
fill: false,
borderColor: 'purple',
backgroundColor: 'purple',
data: calculateQualityFactor(),
borderWidth: 1,
yAxisID: 'qID'
2020-10-18 13:15:40 +00:00
},
{
2020-10-18 23:42:27 +00:00
label: 'V cap (kV)',
2020-10-18 13:15:40 +00:00
fill: false,
borderColor: 'rgb(150, 150, 0)',
backgroundColor: 'rgb(150, 150, 0)',
data: calculateCapacitorVoltage(),
borderWidth: 1,
yAxisID: 'vID'
2020-10-17 04:04:13 +00:00
}]
},
options: {
scales: {
xAxes: [{
type: 'linear',
position: 'bottom',
display: true,
scaleLabel: {
display: true,
labelString: 'Frequency (MHz)'
}
}],
yAxes: [{
type: 'linear',
display: 'auto',
2020-10-17 04:04:13 +00:00
scaleLabel: {
display: true,
2020-10-18 12:27:18 +00:00
labelString: 'Efficiency %',
fontColor: 'black',
2020-10-17 04:04:13 +00:00
fontStyle: 'bold'
},
position: 'left',
2020-10-18 12:27:18 +00:00
id: 'effID'
},{
2020-10-17 04:04:13 +00:00
type: 'linear',
display: 'auto',
2020-10-17 04:04:13 +00:00
scaleLabel: {
display: true,
2020-10-18 12:27:18 +00:00
labelString: 'BW kHz',
fontColor: 'brown',
2020-10-17 04:04:13 +00:00
fontStyle: 'bold'
},
position: 'left',
2020-10-18 12:27:18 +00:00
id: 'bwID'
2020-10-17 04:04:13 +00:00
},{
type: 'linear',
display: 'auto',
2020-10-17 04:04:13 +00:00
scaleLabel: {
display: true,
2020-10-18 12:27:18 +00:00
labelString: '\u03A9',
fontColor: 'red',
2020-10-17 04:04:13 +00:00
fontStyle: 'bold'
},
position: 'right',
2020-10-18 12:27:18 +00:00
id: 'mohmsID',
},{
type: 'linear',
display: 'auto',
scaleLabel: {
display: true,
2020-10-18 12:27:18 +00:00
labelString: 'pF',
fontColor: 'green',
fontStyle: 'bold'
},
2020-10-18 12:27:18 +00:00
position: 'left',
id: 'pfID'
2020-10-18 06:16:51 +00:00
},{
type: 'linear',
display: 'auto',
2020-10-18 06:16:51 +00:00
scaleLabel: {
display: true,
2020-10-18 12:27:18 +00:00
labelString: 'j\u03A9',
fontColor: 'blue',
2020-10-18 06:16:51 +00:00
fontStyle: 'bold'
},
position: 'right',
2020-10-18 12:27:18 +00:00
id: 'ohmsID'
2020-10-18 11:41:31 +00:00
},{
type: 'linear',
display: 'auto',
2020-10-18 11:41:31 +00:00
scaleLabel: {
display: true,
2020-10-18 12:27:18 +00:00
labelString: 'Q',
fontColor: 'purple',
2020-10-18 11:41:31 +00:00
fontStyle: 'bold'
},
2020-10-18 12:27:18 +00:00
position: 'right',
id: 'qID'
2020-10-18 13:15:40 +00:00
},{
type: 'linear',
display: 'auto',
2020-10-18 13:15:40 +00:00
scaleLabel: {
display: true,
2020-10-18 23:42:27 +00:00
labelString: 'kV',
2020-10-18 13:15:40 +00:00
fontColor: 'rgb(150, 150, 0)',
fontStyle: 'bold'
},
position: 'right',
id: 'vID'
2020-10-17 04:04:13 +00:00
}]
},
showLines: true
}
});
</script>
2020-10-08 07:21:58 +00:00
</html>