1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
|
#include<stdlib.h>
#include<stdio.h>
#include<math.h>
int get_capacitance(int);
int get_inductance(int);
int frequency_gen(int[]);
int capacitive_reactance(int,int[],int[]);
int inductive_reactance(int,int[],int[]);
int attenuation_ratio(int,int,int[]);
int attenuation_db(int[]);
int main(int argc, char*argv[])
{
int cap,ind;
int frequencies[18];
int cap_reactance[18];
int ind_reactance[18];
int att_ratio[18];
int att_db[18];
get_capacitance(cap);
get_inductance(ind);
frequency_gen(frequencies);
capacitive_reactance(cap_reactance);
inductive_reactance(ind_reactance);
attenuation_ratio(att_ratio);
attenuation_db(att_db);
getchar();
return 0;
}
int get_capacitance(int cap);
{
printf("Enter Capacitor value in uF\n");
scanf("%i",cap);
return cap;
}
int get_inductance(int ind);
{
printf("Enter Inductor value in mH\n";
scanf("%i",ind);
return ind;
}
int frequency_gen(int frequencies[18]);
{
int inc[2] = { 100, 1000 }; //Generates array of two increments//
int freq = 100;
int n;
for( n = 0; n < 18; n++ )
{
frequencies[n] = freq; //Assigns value of freq to start of array//
freq += (n < 9) ? inc[0] : inc[1]; //If n<9 the first value of array inc is used(100), n>9 second value is used//
}
return frequencies;
}
int capacitive_reactance(int cap,int frequencies[18],int cap_reactance[18]);
{
int n;
for (n=0; n<18; n++)
{
cap_reactance[n]=1/(2*3.14*frequencies[18]*(cap*pow(10,-6)));
return cap_reactance;
}
}
int inductive_reactance (int ind, int frequencies[18], int ind_reactance);
{
int n;
for (n=0; n<18; n++)
{
ind_reactance[n] = 2*3.14*frequencies[18]*(ind*pow(10,-3));
return ind_reactance;
}
}
int attenuation_ratio (int cap,int ind, int frequencies[18]);
{
int n;
for (n=0; n<18; n++)
{
int omega;
omega = 2*3.14*frequencies[18];
att_ratio[n] = (pow(omega,2)*cap*ind)/((pow(omega,2)*cap*ind)-1);
return att_ratio;
}
}
int attenuation_db(int att_ratio[18]);
{
int n;
for (n=0; n<18; n++)
{
att_db[n] = 20*log10(att_ratio[18]);
return att_db;
}
}
|