H
hbaocr
Guest
hier de Low Pass Filter code met NUM en DEN ontworpen door Matlab (sptool) dat fsample = 1kHz; Fc = 40Hz; Butterworth IIR filter
# define pi acos (-1)
dubbele Teller [] = (0.00018321602337,0.000732864093479,0.001099296140218,0.000732864093479,0.00018321602337);
dubbele Noemer [] = (1, -3.344067837711875,4.238863950884069, -2.409342856586321,0.517478199788041);
Code:
void CVedothiDlg:: Low_pass_filter (double * NUM, DEN double *, double * monster, dubbel data_update, double * output, unsigned int length_output_data)
(unsigned char i;monster [4] = monster [3];
monster [3] = monster [2];
monster [2] = monster [1];
monster [1] = monster [0];
monster [0] = data_update;
/ / output buffer
for (i = length_output_data, i> 0; i -)
(
output = output [i-1];
)/ / update output data
output [0] = NUM [0] * monster [0] NUM [1] * monster [1] NUM [2] * monster [2] NUM [3] * monster [3] NUM [4] * monster [4]-DEN [1] * output [1]-DEN [2] * output [2]-DEN [3] * output [3]-DEN [4] * output [4]
# define pi acos (-1)
dubbele Teller [] = (0.00018321602337,0.000732864093479,0.001099296140218,0.000732864093479,0.00018321602337);
dubbele Noemer [] = (1, -3.344067837711875,4.238863950884069, -2.409342856586321,0.517478199788041);
Code:
void CVedothiDlg:: Low_pass_filter (double * NUM, DEN double *, double * monster, dubbel data_update, double * output, unsigned int length_output_data)
(unsigned char i;monster [4] = monster [3];
monster [3] = monster [2];
monster [2] = monster [1];
monster [1] = monster [0];
monster [0] = data_update;
/ / output buffer
for (i = length_output_data, i> 0; i -)
(
output = output [i-1];
)/ / update output data
output [0] = NUM [0] * monster [0] NUM [1] * monster [1] NUM [2] * monster [2] NUM [3] * monster [3] NUM [4] * monster [4]-DEN [1] * output [1]-DEN [2] * output [2]-DEN [3] * output [3]-DEN [4] * output [4]