/* Calculate a Coil's Inductance for Various Number of Turns Revision: 5-JULY-1995 This routine calculates the inductance of a single layer air core coil using the simplified formula: a^2 * n^2 L(uH) = ------------- 9a + 10b where: a = the coil radius in inches b = the coil length in inches n = the number of turns This formula gives a good approximation of a coils ture inductance for coils having a length (b) that is equal to or greater than 0.8 times their radius (a). Recall also that; Inductive Reactance = 2 pi f L and that; Resonant Frequency = 1 / 2 pi sqrt(LC) */ #include /* I/O definitions */ #define MAXLINE 80 #define PI 3.1415926 main() { float radius, turn_width, inductance, aspect, reactance; float frequency, capacitance; int turns, min_turns, max_turns; char filename[MAXLINE]; FILE *fpout; /* Get the various parameters that will be used for this run */ printf("Enter the RADIUS of the coil in inches: "); scanf("%f", &radius); printf("Enter the coil length per turn (pitch) in inches: "); scanf("%f", &turn_width); printf("Enter the Frequency (MHz) for this coil's operation: "); scanf("%f", &frequency); printf("Enter the MINimum number of turns that should be considered: "); scanf("%d", &min_turns); printf("Enter the MAXimum number of turns that should be considered: "); scanf("%d", &max_turns); /* Get the filename of the output file */ printf("Enter the filename of the output text file: "); scanf("%s", filename); if ((fpout = fopen(filename, "w", "rat=cr", "rfm=var")) == NULL) { printf("\nERROR: Can't open output file %s\n", filename); exit (2); } /* Now that we have all of the parameters and the output filename we can start the actual work */ /* In the reactance calculation the inductance in uH will be balanced by having the frequency in and Mhz. */ /* In the capacitance calculation the frequency in MHz squard and inductance in uH both in the denominator is balanced by the 10^6 in the numerator to give capacitance in pF */ fprintf(fpout, "\n Coil Radius is: %6.3f inches \n", radius ); fprintf(fpout, " The Coil's pitch is: %6.3f inches \n", turn_width ); fprintf(fpout, " Coil's Operating frequency is: %6.3f MHz \n", frequency ); fprintf(fpout, "\n Inductive " ); fprintf(fpout, "\n Reactance Capacitor for" ); fprintf(fpout, "\n Ratio of the at Resonance at" ); fprintf(fpout, "\n Coil Inductance Coil's %7.3f MHz %7.3f MHz ", frequency, frequency); fprintf(fpout, "\n Turns (uH) Length/Radius (Ohms) (pF) " ); fprintf(fpout, "\n ----- ---------- ------------- --------- ------------- " ); for (turns = min_turns; turns <= max_turns; ++turns) { inductance = (radius * radius * turns * turns) / ((9.0 * radius) + (10.0 * turns * turn_width)); aspect = (turns * turn_width) / radius; reactance = 2 * PI * frequency * inductance; capacitance = 1000000.0 / (4 * PI * PI * frequency * frequency * inductance); fprintf(fpout, "\n %4d %6.2f %5.2f %7.2f %6.1f", turns, inductance, aspect, reactance, capacitance); } }