-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbclod.c
More file actions
61 lines (51 loc) · 1.81 KB
/
bclod.c
File metadata and controls
61 lines (51 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/* Compile with gcc -Wall -o bclod bclod.c -lm
Base loaded antenna loading coil calculator
a very small program by The Lightning Stalker April 14, 2022CE
Formula sourced ARRL Handbook 2020 Edition Vol. 4. page 21.42 */
#define PROGNAME "bclod"
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#if defined (__WATCOMC__)
#ifndef M_PI
#define M_PI 3.14159265358979323846 /* pi */
#endif
#endif
#if defined (__DOS__)
#define MUSYM "\xe6"
#else
#define MUSYM "µ" /* differences of the codepage */
#endif
int main (int argc, char **argv)
{
if (argc == 4)
{ // This is where it happens.
float f = atof(argv[1]); // frequency
float h = atof(argv[2]); // conductor height without coil
float r = atof(argv[3]) / 2000; // conductor radius in meters
#if defined (__WATCOMC__)
float den1 = log(h / r) - 1; // Japanese intermediate variables?
#else
float den1 = logl(h / r) - 1; // Japanese intermediate variables?
#endif
float den2 = 1 - pow(f * h / 75, 2);
float C = 55.78 * h / (den1 * den2); // capacitance of a small antenna
float w = 2 * M_PI * f; // angular frequency
float L = 1 / (C * 1e-6 * w) / w; // capacitance to inductance
printf ("%.3f"MUSYM"H\n", L);
return (0);
}
else
{
puts ( \
"\n"
" "PROGNAME" is a base loaded antenna loading coil calculator.\n"
" output is coil inductance in microhenries\n"
"\n"
" Usage: "PROGNAME" frequency(MHz) whip_length(m) whip_diameter(mm)\n"
" Example: "PROGNAME" 10.000 1.7 10.0\n"
" Output should be: 12.237"MUSYM"H\n"
);
return (1);
}
}