static const int coeffslp[9] = {
5225, 5175, 7255, 9453, 11595, 13507, 15016, 15983, 16315 };
// Highpass FIR filter coefficients for 17 taps to filter < 2Hz
static const int coeffshp[9] = {
-763, -1267, -1091, -1867, -1969, -2507, -2619, -2911, 29908 };
int filterlp(int sample) // Lowpass FIR filter for EKG
{ static int buflp[32]; // Reserve 32 loactions for circular buffering
static int offsetlp = 0;
long z;
int i;
buflp[offsetlp] = sample;
z = mul16(coeffslp[8], buflp[(offsetlp - 8) & 0x1F]);
for (i = 0; i < 8; i++)
z += mul16(coeffslp, buflp[(offsetlp - i) & 0x1F] + buflp[(offsetlp - 16 + i) & 0x1F]);
offsetlp = (offsetlp + 1) & 0x1F;
return z >> 15; // Return filter output
}// int filterlp
int filterhp(int samplehp) // Highpass FIR filter for hear rate
{ static int bufhp[32]; // Reserve 32 loactions for circular buffering
static int offsethp = 0;
long z;
int i;
bufhp[offsethp] = samplehp;
z = mul16(coeffshp[8], bufhp[(offsethp - 8) & 0x1F]);
for (i = 0; i < 8; i++)
z += mul16(coeffshp, bufhp[(offsethp - i) & 0x1F] + bufhp[(offsethp - 16 + i) & 0x1F]);
offsethp = (offsethp + 1) & 0x1F;
return z >> 15; // Return filter output
}// int filterhp
问题:这是什么原理滤波呢?没看懂。如果我想做一个50hz的陷波器怎么修改?
此帖出自
小平头技术问答
一周热门 更多>