kopia lustrzana https://github.com/miguelvaca/vk3cpu
475 wiersze
22 KiB
HTML
475 wiersze
22 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>VK3CPU Loaded Dipole Antenna Calculator</title>
|
|
<link rel="stylesheet" href="inductor.css">
|
|
</head>
|
|
<body>
|
|
<header><a href="mailto:vk3cpu@gmail.com">VK3CPU</a> - Loaded Dipole Calculator<br></header>
|
|
<section class="gridLayoutClass">
|
|
<div id="inductor-container" class="inductor-container" style="position: relative;">
|
|
<canvas id="inductor2D" class="inductorClass" width="350" height="350">
|
|
</canvas>
|
|
</div>
|
|
<div class="slider_container">
|
|
<div class="sliders">
|
|
<label for="frequency_slider">f(MHz):</label>
|
|
<input type="range" id="frequency_slider" min="0.0" max="5.0" value="1.0" step="0.01">
|
|
</div>
|
|
<div class="sliders">
|
|
<label for="antenna_length_slider">l(%):</label>
|
|
<input type="range" id="antenna_length_slider" min="10" max="100" value="80" step="0.5">
|
|
</div>
|
|
<div class="sliders">
|
|
<label for="inductor_distance_slider">d(%):</label>
|
|
<input type="range" id="inductor_distance_slider" min="10" max="80" value="50" step="0.5">
|
|
</div>
|
|
<div class="sliders">
|
|
<label for="conductor_diameter_slider">AWG:</label>
|
|
<input type="range" id="conductor_diameter_slider" min="10" max="50" value="20" step="1">
|
|
</div>
|
|
</div>
|
|
<div style="text-align:center">
|
|
<a href="./inductor_imp.html">[RF Inductor Calculator]</a>
|
|
</div>
|
|
<div d="notes" class="notes">
|
|
<b><u>Notes:</u></b><br>
|
|
This loaded dipole antenna calculator was developed to quickly estimate the inductance required for a coil-loaded dipole antenna, using
|
|
slider widgets. <br><br>
|
|
<u>Inputs via the slider widgets:</u>
|
|
<ul>
|
|
<li>f : The frequency of operation in MHz. [1.8-57.6 MHz]</li>
|
|
<li>l : Length in percent compared to a half-wave dipole. Defaults to full-length half-wave dipole. [10-100 %]</li>
|
|
<li>d : Distance of the coil/inductor from the feedpoint to the end, in percent. Defaults to midway from feedpoint to the end. [10-80 %]</li>
|
|
<li>AWG : Conductor diameter slider changes wire thickness in AWG until AWG=0, then in mm for larger diameters. Actual diameter displayed in decimal inches and millimeters. [30-0 AWG, up-to 30mm]</li>
|
|
</ul>
|
|
<p>Top left is the length of a single antenna element. (Not including the coil length.) <br>
|
|
Top right is the length of the entire dipole. (Not including the coil length.) </p>
|
|
</div>
|
|
</section>
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjs/7.5.1/math.min.js"></script>
|
|
<script src="inductor.js"></script>
|
|
<script>
|
|
function awgToMm(awg) {
|
|
//
|
|
switch (awg) {
|
|
case 40: return 0.0799;
|
|
case 39: return 0.0897;
|
|
case 38: return 0.101;
|
|
case 37: return 0.113;
|
|
case 36: return 0.127;
|
|
case 35: return 0.143;
|
|
case 34: return 0.160;
|
|
case 33: return 0.180;
|
|
case 32: return 0.202;
|
|
case 31: return 0.227;
|
|
case 30: return 0.255;
|
|
case 29: return 0.286;
|
|
case 28: return 0.321;
|
|
case 27: return 0.361;
|
|
case 26: return 0.405;
|
|
case 25: return 0.455;
|
|
case 24: return 0.511;
|
|
case 23: return 0.573;
|
|
case 22: return 0.644;
|
|
case 21: return 0.723;
|
|
case 20: return 0.812;
|
|
case 19: return 0.912;
|
|
case 18: return 1.024;
|
|
case 17: return 1.150;
|
|
case 16: return 1.291;
|
|
case 15: return 1.450;
|
|
case 14: return 1.628;
|
|
case 13: return 1.828;
|
|
case 12: return 2.053;
|
|
case 11: return 2.305;
|
|
case 10: return 2.588;
|
|
case 9: return 2.906;
|
|
case 8: return 3.264;
|
|
case 7: return 3.665;
|
|
case 6: return 4.115;
|
|
case 5: return 4.621;
|
|
case 4: return 5.189;
|
|
case 3: return 5.827;
|
|
case 2: return 6.544;
|
|
case 1: return 7.348;
|
|
case 0: return 8.251;
|
|
case -1: return 9.0;
|
|
case -2: return 10.0;
|
|
case -3: return 11.0;
|
|
case -4: return 12.0;
|
|
case -5: return 13.0;
|
|
case -6: return 14.0;
|
|
case -7: return 15.0;
|
|
case -8: return 20.0;
|
|
case -9: return 25.0;
|
|
case -10: return 30.0;
|
|
default: return 0.0;
|
|
}
|
|
}
|
|
|
|
// Define global storage for calculated values, so we don't recalculate the same things multiple times:
|
|
var dipole = {
|
|
length_meters : 0.0,
|
|
cond_diameter_meters : 0.0,
|
|
inductor_distance_ratio : 0.0,
|
|
frequency_hz : 0.0,
|
|
|
|
L : 0.0,
|
|
Xl : 0.0,
|
|
};
|
|
|
|
// Solve all the parameters, and re-draw the canvas:
|
|
function recalculate() {
|
|
// Input variables:
|
|
//dipole.length_meters = 0.001 * antenna_length_slider.value * 25.4; // Inches to mm then to m
|
|
dipole.frequency_hz = 1.8e6 * (2.0 ** frequency_slider.value);
|
|
dipole.length_meters = 299792458.0 * 0.0095 * antenna_length_slider.value / (2.0 * dipole.frequency_hz); //
|
|
dipole.length_feet = dipole.length_meters * 3.28084;
|
|
dipole.cond_diameter_meters = 0.001 * awgToMm(40.0 - conductor_diameter_slider.value);
|
|
dipole.cond_diameter_inches = dipole.cond_diameter_meters * 39.37008;
|
|
dipole.inductor_distance_ratio = 0.01 * inductor_distance_slider.value;
|
|
dipole.distance_meters = inductor_distance_slider.value * 0.005 * dipole.length_meters;
|
|
dipole.distance_feet = dipole.distance_meters * 3.28084;
|
|
|
|
// Frequency independent characteristics:
|
|
dipole.Xl = getInductanceFromDimensions(dipole.frequency_hz * 1e-6,
|
|
dipole.length_feet,
|
|
dipole.distance_feet,
|
|
dipole.cond_diameter_inches);
|
|
dipole.L = dipole.Xl / (2 * Math.PI * dipole.frequency_hz * 1e-6);
|
|
}
|
|
|
|
// Specify fonts for changing parameters controlled by the sliders:
|
|
var normal_font = "14px arial";
|
|
//var normal_font = "14px courier";
|
|
var emphasis_font = "bold 14px arial";
|
|
const emphasis_delay = 1200;
|
|
|
|
var antenna_length_timer_handler = 0;
|
|
var antenna_length_font = normal_font;
|
|
|
|
antenna_length_slider.oninput = function() {
|
|
recalculate();
|
|
if(antenna_length_timer_handler == 0) {
|
|
antenna_length_font = emphasis_font;
|
|
antenna_length_timer_handler = setTimeout(function(){
|
|
antenna_length_font = normal_font;
|
|
drawDesign();
|
|
antenna_length_timer_handler = 0;
|
|
}, emphasis_delay);
|
|
} else {
|
|
clearTimeout(antenna_length_timer_handler);
|
|
antenna_length_timer_handler = setTimeout(function(){
|
|
antenna_length_font = normal_font;
|
|
drawDesign();
|
|
antenna_length_timer_handler = 0;
|
|
}, emphasis_delay);
|
|
}
|
|
drawDesign();
|
|
}
|
|
|
|
var cond_dia_timer_handler = 0;
|
|
var cond_dia_font = normal_font;
|
|
|
|
conductor_diameter_slider.oninput = function() {
|
|
recalculate();
|
|
if(cond_dia_timer_handler == 0) {
|
|
cond_dia_font = emphasis_font;
|
|
cond_dia_timer_handler = setTimeout(function(){
|
|
cond_dia_font = normal_font;
|
|
drawDesign();
|
|
cond_dia_timer_handler = 0;
|
|
}, emphasis_delay);
|
|
} else {
|
|
clearTimeout(cond_dia_timer_handler);
|
|
cond_dia_timer_handler = setTimeout(function(){
|
|
cond_dia_font = normal_font;
|
|
drawDesign();
|
|
cond_dia_timer_handler = 0;
|
|
}, emphasis_delay);
|
|
}
|
|
drawDesign();
|
|
}
|
|
|
|
var spacing_timer_handler = 0;
|
|
var spacing_font = normal_font;
|
|
|
|
inductor_distance_slider.oninput = function() {
|
|
recalculate();
|
|
if(spacing_timer_handler == 0) {
|
|
spacing_font = emphasis_font;
|
|
spacing_timer_handler = setTimeout(function(){
|
|
spacing_font = normal_font;
|
|
drawDesign();
|
|
spacing_timer_handler = 0;
|
|
}, emphasis_delay);
|
|
} else {
|
|
clearTimeout(spacing_timer_handler);
|
|
spacing_timer_handler = setTimeout(function(){
|
|
spacing_font = normal_font;
|
|
drawDesign();
|
|
spacing_timer_handler = 0;
|
|
}, emphasis_delay);
|
|
}
|
|
drawDesign();
|
|
}
|
|
|
|
var frequency_timer_handler = 0;
|
|
var frequency_font = normal_font;
|
|
|
|
frequency_slider.oninput = function() {
|
|
recalculate();
|
|
if(frequency_timer_handler == 0) {
|
|
frequency_font = emphasis_font;
|
|
frequency_timer_handler = setTimeout(function(){
|
|
frequency_font = normal_font;
|
|
drawDesign();
|
|
frequency_timer_handler = 0;
|
|
}, emphasis_delay);
|
|
} else {
|
|
clearTimeout(frequency_timer_handler);
|
|
frequency_timer_handler = setTimeout(function(){
|
|
frequency_font = normal_font;
|
|
drawDesign();
|
|
frequency_timer_handler = 0;
|
|
}, emphasis_delay);
|
|
}
|
|
drawDesign();
|
|
}
|
|
|
|
window.onresize = function() {
|
|
recalculate();
|
|
drawDesign();
|
|
}
|
|
|
|
window.onorientationchange = function() {
|
|
recalculate();
|
|
drawDesign();
|
|
}
|
|
|
|
window.onbeforeprint = function() {
|
|
console.log("onbeforeprint");
|
|
drawDesign();
|
|
}
|
|
|
|
function getInductanceFromDimensions(f, A, B, D) {
|
|
// f = frequency in MHz
|
|
// A = total antenna length in feet
|
|
// B = distance from antenna center to loading coil in feet
|
|
// D = diameter of the radiator in inches
|
|
//console.log(f, A, B, D);
|
|
const t1 = Math.log((24*((234/f) - B))/D) - 1;
|
|
const t2 = (1 - (f*B)/234)**2 - 1;
|
|
const t3 = Math.log((24*(A/2 -B))/D) - 1;
|
|
const t4 = ((f*A/2 - f*B)/234)**2 - 1;
|
|
const t5 = 234/f - B;
|
|
const t6 = A/2 - B;
|
|
const k1 = 1e6 / (34*Math.PI*f);
|
|
|
|
var retval = k1 * (t1*t2/t5 - t3*t4/t6);
|
|
return retval;
|
|
}
|
|
|
|
function drawInductor(ctx, x, y, angle) {
|
|
const l1 = 12.0;
|
|
ctx.clearRect(x-l1,y-l1,2*l1,2*l1);
|
|
|
|
// Draw box outline:
|
|
ctx.beginPath();
|
|
ctx.moveTo(x + l1, y - l1);
|
|
ctx.lineTo(x + l1, y + l1);
|
|
ctx.lineTo(x - l1, y + l1);
|
|
ctx.lineTo(x - l1, y - l1);
|
|
ctx.lineTo(x + l1, y - l1);
|
|
ctx.stroke();
|
|
|
|
// Draw the inductor wires:
|
|
const last_width = ctx.lineWidth;
|
|
ctx.lineWidth = 4;
|
|
const last_cap = ctx.lineCap;
|
|
ctx.lineCap = 'round';
|
|
ctx.beginPath();
|
|
ctx.moveTo(x, y - l1 - 2);
|
|
ctx.lineTo(x - l1 - 2, y - 0.875*l1);
|
|
ctx.moveTo(x + l1 + 2, y - 0.625*l1);
|
|
ctx.lineTo(x - l1 - 2, y - 0.375*l1);
|
|
ctx.moveTo(x + l1 + 2, y - 0.125*l1);
|
|
ctx.lineTo(x - l1 - 2, y + 0.125*l1);
|
|
ctx.moveTo(x + l1 + 2, y + 0.375*l1);
|
|
ctx.lineTo(x - l1 - 2, y + 0.625*l1);
|
|
ctx.moveTo(x + l1 + 2, y + 0.875*l1);
|
|
ctx.lineTo(x, y + l1 + 2);
|
|
ctx.stroke();
|
|
ctx.lineWidth = last_width;
|
|
ctx.lineCap = last_cap;
|
|
}
|
|
|
|
function drawArrow(ctx, x, y, angle) {
|
|
const l1 = 15.0;
|
|
const l2 = 20.0;
|
|
ctx.beginPath();
|
|
ctx.moveTo(x , y);
|
|
ctx.lineTo(x + l1*Math.cos(angle+0.33*Math.PI), y + l1*Math.sin(angle+0.33*Math.PI));
|
|
ctx.lineTo(x + l1*Math.cos(angle+0.67*Math.PI), y + l1*Math.sin(angle+0.67*Math.PI));
|
|
ctx.lineTo(x, y);
|
|
ctx.lineTo(x + l2*Math.cos(angle+0.5*Math.PI), y + l2*Math.sin(angle+0.5*Math.PI));
|
|
ctx.stroke();
|
|
}
|
|
|
|
function getFeetAndInchesFromFeet(inFeet) {
|
|
//
|
|
var wholeFeet = Math.trunc(inFeet);
|
|
var inches = (inFeet - wholeFeet) * 12.0;
|
|
return wholeFeet.toString() + "\' " + inches.toFixed(1).toString() + "\"";
|
|
}
|
|
|
|
const afront_canvas = document.getElementById("inductor2D");
|
|
const fctx = afront_canvas.getContext('2d');
|
|
|
|
function drawDesign() {
|
|
const win_width = document.getElementById("inductor-container").clientWidth;
|
|
const win_height = document.getElementById("inductor-container").clientHeight;
|
|
afront_canvas.width = win_width-12;
|
|
afront_canvas.height = win_height-12;
|
|
|
|
fctx.clearRect(0, 0, win_width, win_height);
|
|
const loopx = win_width/2;
|
|
const loopy = win_height/4;
|
|
|
|
const cond_diameter_mm = dipole.cond_diameter_meters * 1000.0;
|
|
const cond_diameter_inches = cond_diameter_mm / 25.4;
|
|
|
|
fctx.font = normal_font;
|
|
|
|
const wire_x = win_width * 0.50;
|
|
const up_wire_top_y = 20;
|
|
const up_wire_bot_y = win_height * 0.5 - 5;
|
|
|
|
const down_wire_top_y = win_height * 0.5 + 5;
|
|
const down_wire_bot_y = win_height - 20;
|
|
|
|
var arrow_size = 10.0;
|
|
|
|
// Draw the top antenna element:
|
|
const last_width = fctx.lineWidth;
|
|
fctx.lineWidth = 3;
|
|
fctx.beginPath();
|
|
fctx.moveTo(wire_x, up_wire_top_y);
|
|
fctx.lineTo(wire_x, up_wire_bot_y);
|
|
fctx.lineTo(wire_x - 15, up_wire_bot_y);
|
|
fctx.stroke();
|
|
|
|
// Draw the bottom antenna element:
|
|
fctx.beginPath();
|
|
fctx.moveTo(wire_x - 15, down_wire_top_y);
|
|
fctx.lineTo(wire_x, down_wire_top_y);
|
|
fctx.lineTo(wire_x, down_wire_bot_y);
|
|
fctx.stroke();
|
|
|
|
fctx.lineWidth = last_width;
|
|
|
|
// Draw relative zero indicator lines:
|
|
if(antenna_length_font == emphasis_font) {
|
|
fctx.beginPath();
|
|
fctx.moveTo(50, up_wire_top_y);
|
|
fctx.lineTo(20, up_wire_top_y);
|
|
fctx.lineTo(20, up_wire_bot_y);
|
|
fctx.lineTo(50, up_wire_bot_y);
|
|
fctx.stroke();
|
|
|
|
fctx.beginPath();
|
|
fctx.moveTo(win_width - 50, up_wire_top_y);
|
|
fctx.lineTo(win_width - 20, up_wire_top_y);
|
|
fctx.lineTo(win_width - 20, down_wire_bot_y);
|
|
fctx.lineTo(win_width - 50, down_wire_bot_y);
|
|
fctx.stroke();
|
|
}
|
|
|
|
const d_pos = up_wire_bot_y - dipole.inductor_distance_ratio * (up_wire_bot_y - up_wire_top_y);
|
|
|
|
fctx.textAlign = "right";
|
|
|
|
// Draw top inductor:
|
|
drawInductor(fctx, wire_x, d_pos, 0.0*Math.PI);
|
|
drawArrow(fctx, wire_x - 30, d_pos, 0.5*Math.PI);
|
|
fctx.font = spacing_font;
|
|
fctx.fillText(dipole.distance_meters.toFixed(2).toString() + " m", wire_x - 60, d_pos + 12 );
|
|
fctx.fillText(dipole.distance_feet.toFixed(2).toString() + " ft", wire_x - 60, d_pos - 4);
|
|
//fctx.fillText(getFeetAndInchesFromFeet(dipole.distance_feet), wire_x - 60, d_pos - 4);
|
|
|
|
// Draw midpoint arrow:
|
|
if((spacing_font == emphasis_font) || (antenna_length_font == emphasis_font)) {
|
|
fctx.font = emphasis_font;
|
|
} else {
|
|
fctx.font = normal_font;
|
|
}
|
|
|
|
drawArrow(fctx, wire_x - 30, up_wire_bot_y, 0.5*Math.PI);
|
|
fctx.fillText("0.00", wire_x - 60, up_wire_bot_y + 5);
|
|
|
|
fctx.font = normal_font;
|
|
|
|
if(spacing_font == emphasis_font) {
|
|
fctx.beginPath();
|
|
fctx.moveTo(50, d_pos);
|
|
fctx.lineTo(20, d_pos);
|
|
fctx.lineTo(20, up_wire_bot_y);
|
|
fctx.lineTo(50, up_wire_bot_y);
|
|
fctx.stroke();
|
|
}
|
|
|
|
// Draw single element length arrow and associated text:
|
|
fctx.font = antenna_length_font;
|
|
drawArrow(fctx, wire_x - 30, up_wire_top_y, 0.5*Math.PI);
|
|
fctx.fillText((dipole.length_feet * 0.5).toFixed(2).toString() + " ft", wire_x - 60, up_wire_top_y - 4);
|
|
//fctx.fillText(getFeetAndInchesFromFeet(dipole.length_feet * 0.5), wire_x - 60, up_wire_top_y - 4);
|
|
fctx.fillText((dipole.length_meters * 0.5).toFixed(2).toString() + " m", wire_x - 60, up_wire_top_y + 12);
|
|
|
|
fctx.textAlign = "left";
|
|
|
|
// Draw antenna length text:
|
|
//fctx.font = antenna_length_font;
|
|
fctx.fillText(dipole.length_feet.toFixed(2).toString() + " ft", wire_x + 60, up_wire_top_y - 4);
|
|
//fctx.fillText(getFeetAndInchesFromFeet(dipole.length_feet), wire_x + 60, up_wire_top_y - 4);
|
|
fctx.fillText(dipole.length_meters.toFixed(2).toString() + " m", wire_x + 60, up_wire_top_y + 12);
|
|
fctx.fillText("0.00", wire_x + 60, down_wire_bot_y + 5);
|
|
|
|
// Display calculated results:
|
|
//fctx.font = emphasis_font;
|
|
fctx.font = normal_font;
|
|
fctx.fillText("L = " + dipole.L.toFixed(1).toString() + " \u00B5H", wire_x + 30, d_pos - 4);
|
|
fctx.fillText("X = " + dipole.Xl.toFixed(1).toString() + " \u03A9", wire_x + 30, d_pos + 12);
|
|
|
|
// Input controls displays:
|
|
const left_spacing = 15;
|
|
fctx.font = frequency_font;
|
|
fctx.fillText("f = " + (dipole.frequency_hz * 1e-6).toFixed(2).toString() + " MHz", left_spacing, down_wire_bot_y - 72);
|
|
fctx.font = antenna_length_font;
|
|
fctx.fillText("l = " + (antenna_length_slider.value * 1.0).toFixed(1).toString() + " %", left_spacing, down_wire_bot_y - 54);
|
|
fctx.font = spacing_font;
|
|
fctx.fillText("d = " + (inductor_distance_slider.value * 1.0).toFixed(1).toString() + " %", left_spacing, down_wire_bot_y - 36);
|
|
fctx.font = cond_dia_font;
|
|
if(conductor_diameter_slider.value <= 40) {
|
|
fctx.fillText("AWG = " + (40-conductor_diameter_slider.value).toString(), left_spacing, down_wire_bot_y - 18);
|
|
} else {
|
|
fctx.fillText("Diameter:", left_spacing, down_wire_bot_y - 18);
|
|
}
|
|
fctx.fillText("\u2300 = " + cond_diameter_inches.toFixed(4).toString() + "\" " +
|
|
"(" + cond_diameter_mm.toFixed(3).toString() + " mm)", left_spacing, down_wire_bot_y);
|
|
fctx.font = normal_font;
|
|
|
|
// Draw bottom inductor:
|
|
drawInductor(fctx, wire_x, down_wire_top_y + dipole.inductor_distance_ratio * (up_wire_bot_y - up_wire_top_y), 0.0*Math.PI);
|
|
|
|
// Draw arrows on the right side of the antenna, to depict full dipole length:
|
|
drawArrow(fctx, wire_x + 30, up_wire_top_y, -0.5*Math.PI);
|
|
drawArrow(fctx, wire_x + 30, down_wire_bot_y, -0.5*Math.PI);
|
|
}
|
|
recalculate();
|
|
drawDesign();
|
|
</script>
|
|
</body>
|
|
</html> |