/* Program: David.c Revision: 18-AUG-1995 This program ask for you to enter three parameters: Frequency in Mhz Inductance in uH Capacitance in pF Enter the majic value of "0" for one of these parameters. This program will then calculate the value of that parameter and display it. The unknow value is calculated by the high Q parallel resonant frequency (by one definition) equation: 1 or solve 1 F = ------------------ for C C = ---------------- 2 pi sqrt( LC ) and it is 4 pi^2 F^2 L and recall that the inductive reactance is: Inductive Reactance = 2 pi f L */ #include #include #define PI 3.1415926 main () { float freq, cap, induct ; float two_pi, four_pi_sqrd ; float reactance ; two_pi = 2.0 * PI ; four_pi_sqrd = two_pi * two_pi ; printf(" \n "); printf("Enter the resonant frequency, the inductance, and the \n " ); printf("capacitance. Enter 0 for the unknow value of the three. \n"); printf(" \n "); printf("Enter the resonant frequency (MHz) : "); scanf( "%f", &freq ) ; printf(" \n ") ; printf(" Enter the inductance (uH): "); scanf( "%f", &induct ) ; printf(" \n ") ; printf(" Enter the capacitance (pF): "); scanf( "%f", &cap ) ; printf(" \n ") ; if ( freq == 0 ) { freq = 1000.0 / ( 2.0 * PI * sqrt( induct * cap )) ; printf( "\n This parallel LC resonant freq. is = %9.3f MHz \n", freq ) ; reactance = two_pi * freq * induct ; printf( "\n The reactance of either L or C is = %7.2f Ohms \n", reactance ) ; } else if ( induct == 0 ) { induct = 1000000.0 / (four_pi_sqrd * (freq * freq) * cap) ; printf( "\n The inductance from Freq and cap is = %7.2f uH \n", induct ) ; reactance = two_pi * freq * induct ; printf( "\n The reactance of either L or C is = %7.2f Ohms \n", reactance ) ; } else if ( cap == 0 ) { cap = 1000000.0 / (four_pi_sqrd * (freq * freq) * induct ) ; printf( "\n The capacitance from Freq and L is = %7.2f pF \n", cap ) ; reactance = two_pi * freq * induct ; printf( "\n The reactance of either L or C is = %7.2f Ohms \n", reactance ) ; } }