ГОСТ Р ИСО/МЭК 10373-6—2015
acoettIСI—1;
tor(mdex-’5;index<-2*butter_order;index-*4>
deoetf[ir.dex)-0 ;
£ree(vec_t;;
tree(vec_r>;
return(acoeff>;
i
// Calculates the Butterworth filter coefficients
void butterworth_eoe££s{double freql, double Ireq
2
, double *dfiltercoefi,
double *cfilteieoeft)
I
I f
n filter order
// freql, treq2 lower/uppercutott trequencies
double з
C ;
double *dcoeft;
f t
scaling tactor
f l
n coelftcients
double cotan-0;
I f
cotangent of theta
/* calculate the d coefficients
* f
dcoett-butter_d_i.-oet£s(treql,£req2>;
/* a coefficients tor 4th oraer butterworth */
dliltercoetf|0]-dcoe£f[Cl; //Always 1
dfUtercoett[1]-acoeff|1);
dfiltercoett|2)-dcoetf(21;
dliltercoeff[3J-acoeff [1];
dfiltercoett[4)-dcoet £(41;
/* stalling Гас-tor tor the c filter coetticients (Butterworth 4th order ♦/
cotan-1.0/tan
(M_PI*
(£req2-treqlj/2.0>;
st- (1.0/(((cotan-isqrt(2»/2»•(cotan*sqrt (2}
/ 2 )
>•l/2>>;
/* c coefficients tor 4th oraer butterworth*/
diltercoeft|0]-l*s£;
cflltercoett[l)-0*sf;
cfiltercoetf[21--2*efг
cllltercoett|3J-0»s£;
dil tercoetf141-1♦sf;
free(dcoe£C>;
i
// Checks it the data Lnput ts adequate to our algorithms
in».da».acheck(lrit posval, Lrit negval, Lrit samplesp, double clast,FILE *pointfile)
l
double dittr-0.0;
char timestrl[2Ъ1;
char tiniestr2[2i;l;
char voltstr|2b];
aouble txmestrfl-0;
double timestr£2-0;
aouble cut_sample-0;
double delta_t-0;
double val_t-0;
mt loop-0;
double linf-Q;
lnt lind-0;
66