Смекни!
smekni.com

Давачі наближення (стр. 3 из 3)

{

r -= step * sign;

c -= step * sign;

break;

}

minDelta = fabs( res - r * c );

}

}

void main( )

{

double inpVolt;

double iImp;

double tImp;

double T;

double tZv;

char choose;

do

{

printf( "Enter input voltage: ");

scanf( "%lf", &inpVolt );

printf( "Enter impulse amplitude: ");

scanf( "%lf", &iImp );

printf( "Enter generated impulses length: ");

scanf( "%lf", &tImp );

printf( "Enter impulses period: ");

scanf( "%lf", &T );

printf( "Enter output impulse length: ");

scanf( "%lf", &tZv );

double r5 = ( inpVolt - 3.5 ) / iImp;

printf( "R5 = %.3lf Ohm\n", r5 );

double r3 = 10 * pow( 10, 3 );

double c2 = 1000 * pow( 10, -12 );

findRC( r3, c2, tImp / 0.7 );

printf( "R3 = %.2e Ohm, C2 = %.2e Farad\n", r3, c2 );

double r2 = 300 * pow( 10, 6 );

double c1 = 0.047 * pow( 10, -6 );

findRC( r2, c1, T / 1.4 );

printf( "R2 = %.2e Ohm, C1 = %.2e Farad\n", r2, c1 );

double r8 = 300 * pow( 10, 6 );

double c7 = 0.047 * pow( 10, -6 );

findRC( r8, c7, tZv / 0.7 );

printf( "R8 = %.2e Ohm, C7 = %.2e Farad\n", r8, c7 );

printf( "\n TESTING:\n" );

printf( "Iimp = (V - 3.5) / R5 = ( %.2e - 3.5 ) / %.2e = %.2e\n", inpVolt, r5, ( inpVolt - 3.5 ) / r5 );

printf( "timp = 0.7*R3*C2 = 0.7 * %.2e * %.2e = %.2e\n", r3, c2, 0.7 * r3 * c2 );

printf( "T = 1.4*R2*C1 = 0.7 * %.2e * %.2e = %.2e\n", r2, c1, 1.4 * r2 * c1 );

printf( "Tzv = 0.7*R8*C7 = 0.7 * %.2e * %.2e = %.2e\n", r8, c7, 0.7 * r8 * c7 );

while( kbhit( ) )

{

getche( );

}

printf( "\nDo you want to repeat calculation (y/n)? " );

choose = getche( );

printf( "\n\n" );

} while( choose != 'n' );

}


Додаток Е – Результати роботи програми розрахунку давача наближення

Enter input voltage: 6

Enter impulse amplitude: 0.25

Enter generated impulses length: 0.0000105

Enter impulses period: 0.16

Enter output impulse length: 0.08

R5 = 10.000 Ohm

R3 = 1.00e+004 Ohm, C2 = 1.50e-009 Farad

R2 = 3.00e+008 Ohm, C1 = 3.80e-010 Farad

R8 = 3.00e+008 Ohm, C7 = 3.80e-010 Farad

TESTING:

Iimp = (V - 3.5) / R5 = ( 6.00e+000 - 3.5 ) / 1.00e+001 = 2.50e-001

timp = 0.7*R3*C2 = 0.7 * 1.00e+004 * 1.50e-009 = 1.05e-005

T = 1.4*R2*C1 = 0.7 * 3.00e+008 * 3.80e-010 = 1.60e-001

Tzv = 0.7*R8*C7 = 0.7 * 3.00e+008 * 3.80e-010 = 7.98e-002

Do you want to repeat calculation (y/n)? n