/* Program: fkcmn_to_r.c Revision: 21-JULY-2006 ------------ Differential Amplifier Low Pass Filter Calculation Program step #2 This program ask for you to enter five parameters: The cut-off frequency of the filter "freq" in kHz. The pass-band gain "K" The capacitor value "C" in pFd. The value "m" where R2 = R and R3 = mR The value "n" where C1 = C and C2 = nC The program then prints out the full setup for the filter, i.e.: The filter cut-off frequency "freq" in kHz The filter pass-band gain "K" The filter quality "Q" The values of R1, R2, R3 in Ohms The values of C1 and C2 in pfd Recall the basic equations R1 = R/K R2 = R R3 = mR ( recall K = R2/R1 ) C1 = C C2 = nC sqrt(2mn) Q = ------------ 1 + m(K+1) 1 1 Fcut = ------------------ thus R = ---------------------- 2pi RC sqrt(2nm) 2pi Fcut C sqrt(2nm) This program is setup to provide the values for differential Low Pass filters and it assumes that the gain "K" is always positive. Refer to TI sloa_054 documentation about fully differential amplifiers. */ #include #include #define PI 3.1415926 main () { float Fcut ; /* the filter cut-off frequency in kHz */ float K ; /* the pass-band gain of the filter */ float Q ; /* the required Q of the filter pole pair */ float m ; /* the value where R2 = R and R3 = mR */ float n ; /* the value where C1 = C and C2 = nC */ float R ; /* the basic resistor value in Ohms */ float R1, R2, R3 ; /* the resistor values in Ohms */ float C ; /* the basic capacitor value in pFd */ float C1, C2 ; /* the capacitor values in pFd */ float temp_1, temp_2, temp_3, temp_4, temp_5 ; printf(" \n "); printf("Enter the required filter cut-off frequency Fcut in kHz, \n"); printf(" the required pass-band gain of the filter K, \n"); printf(" the desired basic capacitor value C in pFd \n"); printf(" m where m is defined as R2 = R and R3 = mR \n"); printf(" n where n is defined as C1 = C and C2 = mC \n"); printf(" \n "); printf(" Enter the filter cut-off frequency \"Fcut\" in kHz : "); scanf( "%f", &Fcut ) ; printf(" \n ") ; printf(" Enter the filter gain \"K\" : "); scanf( "%f", &K ) ; printf(" \n ") ; printf(" Enter the basic capacitor value \"C\" in pFd : "); scanf( "%f", &C ) ; printf(" \n ") ; printf(" Enter \"m\" where R2 = R and R3 = mR : "); scanf( "%f", &m ) ; printf(" \n ") ; printf(" Enter \"n\" where C1 = C and C2 = nC : "); scanf( "%f", &n ) ; printf(" \n ") ; printf( "\n The filter cut-off frequency is = %7.3f kHz \n", Fcut ) ; printf( "\n The filter gain \"K\" is = %7.3f \n", K ) ; printf( "\n The basic capacitor value \"C\" is = %7.3f pFd \n", C ) ; printf( "\n The R3 to R ratio \"m\" is = %7.3f \n", m ) ; printf( "\n The C2 to C ratio \"n\" is = %7.3f \n", n ) ; /* Calculate the Q of the Filter sqrt(2mn) Q = ------------ 1 + m(K+1) */ temp_1 = sqrt( 2 * m * n ) ; temp_2 = 1 + ( m * ( K + 1.0 ) ) ; Q = temp_1 / temp_2 ; printf( "\n The Q of the filter is = %7.4f \n", Q ) ; /* Calculate the basic Filter resistor 1 R = ---------------------- 2pi Fcut C sqrt(2nm) */ temp_2 = Fcut * 1000.0 ; temp_3 = C * 0.000000000001 ; R = 1 / ( 2 * PI * temp_2 * temp_3 * temp_1 ) ; printf( "\n The basic resistor value \"R\" is = %7.4f Ohm \n", R ) ; /* Calculate the individual resistors and capacitors R1 = R/K R2 = R R3 = mR C1 = C C2 = nC */ R1 = R / K ; R2 = R ; R3 = m * R ; C1 = C ; C2 = n * C ; printf( "\n Resistor R1 is = %7.4f Ohm \n", R1 ) ; printf( "\n Resistor R2 is = %7.4f Ohm \n", R2 ) ; printf( "\n Resistor R3 is = %7.4f Ohm \n", R3 ) ; printf( "\n Capacitor C1 is = %7.4f pFd \n", C1 ) ; printf( "\n Capacitor C2 is = %7.4f pFd \n", C2 ) ; }