From e5d1bc148485208261d7533fda425bb7716d72f8 Mon Sep 17 00:00:00 2001 From: LightningStalker Date: Fri, 14 May 2021 19:57:13 -0400 Subject: [PATCH] Initial commit --- elcut.c | 24 ++++++++++++++++++++++ iloc.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ tankfreq.c | 24 ++++++++++++++++++++++ 3 files changed, 106 insertions(+) create mode 100644 elcut.c create mode 100644 iloc.c create mode 100644 tankfreq.c diff --git a/elcut.c b/elcut.c new file mode 100644 index 0000000..2905075 --- /dev/null +++ b/elcut.c @@ -0,0 +1,24 @@ +/* Compile with gcc -Wall -o elcut elcut.c */ + +#include +#include + +int main (int argc, char **argv) +{ + if (argc == 4) + { + printf ("%f\n", (atof(argv[1]) - atof(argv[2])) / atof(argv[1]) * atof(argv[3])); + return (0); + } + else + { + puts ("elcut is a resonant antenna tuning aid."); + puts ("elcut finds the length to cut based on the current and desired frequency."); + puts ("output is the length of an ideal cutoff"); + puts ("remember the output is theoretical and subtract from it to avoid mistuning.\n"); + puts ("Usage: elcut freq_desired freq_current length_current"); + puts ("Example: elcut 28.33 25.55 2516"); + puts ("Output should be: 246.893046"); + return (1); + } +} diff --git a/iloc.c b/iloc.c new file mode 100644 index 0000000..d339dd0 --- /dev/null +++ b/iloc.c @@ -0,0 +1,58 @@ +/* + * iloc.c -- Air-core coil design program + * + * compile with: cc -Wall -o iloc iloc.c -lm + * + * Copyright (c) 2000, Eddie Kovelan and Sam Goldwasser + * Dvoracek (c)2021 + */ + +#include +#include +#include + +#define u 1.2566370621219E-6 // permeability of free space + +int main() +{ + /* + * L = inductance in microhenries, + * DIA = diameter of coil. + * NOT = Number Of Turns + * A = area of cross section + * TS = turn spacing + * imed = intermediate temp variable + */ + + long double L, DIA, A, length, TS, NOT, imed; + + printf("\n \ + **********************************************************\n \ + * This program finds the required number of turns and *\n \ + * length for an air-core inductor with specified *\n \ + * inductance (uH), radius (mm), and turn spacing (mm). *\n \ + * Valid for coils where diameter = length or longer. *\n \ + **********************************************************\n"); + + printf("\nEnter inductance (uH): "); + scanf("%Lf", &L); + printf("Enter diameter of coil (mm): "); + scanf("%Lf", &DIA); + printf("Enter turn spacing (mm per turn): "); + scanf("%Lf", &TS); + + /* calculation of NOT (Number Of Turns) */ + // first some unit conversion + L = L / 1000000; // H --> µH + DIA = DIA / 1000; // m --> mm + TS = TS / 1000; // m --> mm + + // Meet the meat + A = M_PI * powl(DIA / 2, 2); + imed = L * (1 / u) / A; + NOT = imed * TS; + length = NOT * TS * 1000; + + //The coil shall be 2.138090 in length (inches) and have 4.209364 turns. + printf("\nThe coil shall be %.1Lf mm in length and have %.1Lf turns.\n\n", length, NOT); +} diff --git a/tankfreq.c b/tankfreq.c new file mode 100644 index 0000000..42eec9a --- /dev/null +++ b/tankfreq.c @@ -0,0 +1,24 @@ +/* Compile with gcc -Wall -o tankfreq tankfreq.c -lm */ + +#include +#include +#include + +int main (int argc, char **argv) +{ + if (argc == 3) + { + printf ("%f\n", 1 / (3.14159265358979324 * 2 * sqrt (atof(argv[1]) / + 1000000 * atof(argv[2]) / 1000000))); + return (0); + } + else + { + puts ("tankfreq is an LC tank resonance frequency calculator."); + puts ("output is frequency in Hz\n"); + puts ("Usage: tankfreq microfarads microhenries"); + puts ("Example: tankfreq 3.3 .86207"); + puts ("Output should be: 94360.861167"); + return (1); + } +}