patan.gova
Full Member level 3
- Joined
- Dec 19, 2011
- Messages
- 172
- Helped
- 4
- Reputation
- 8
- Reaction score
- 0
- Trophy points
- 1,296
- Activity points
- 2,776
Hello,
I want to know how to build an IIR filter function if the filter coefficients got form matlab are available.
The lowpass IIR filter designed in matlab is shown below with fc=4Hz,sample frequency=100Hz
I used the below filter function to filter my ADC sample with filter coefficients(32) generated from Matlab
coeff[32]=[ ...........];
int FIR_filter(int ADC_sample)
{
long z=0;
for (k=0;k<30;k++)
{
Buf[k+1]=Buf[k];
}
Buf[0]=ADC_sample;
for (i = 0; i < 31; i++)
z += mul16(coeffs, Buf);
check=coeffs;
return z >> 15;
}
can someone please explain me how to build the IIR filter function for generated IIR filter coefficients to filter the ADC samplementioned above.
Thanks.
I want to know how to build an IIR filter function if the filter coefficients got form matlab are available.
The lowpass IIR filter designed in matlab is shown below with fc=4Hz,sample frequency=100Hz
Code:
[b,a] = cheby1(2,0.5,4/50,'low');
filter_output=filtfilt(b,a,signal);
I used the below filter function to filter my ADC sample with filter coefficients(32) generated from Matlab
coeff[32]=[ ...........];
int FIR_filter(int ADC_sample)
{
long z=0;
for (k=0;k<30;k++)
{
Buf[k+1]=Buf[k];
}
Buf[0]=ADC_sample;
for (i = 0; i < 31; i++)
z += mul16(coeffs, Buf);
check=coeffs;
return z >> 15;
}
can someone please explain me how to build the IIR filter function for generated IIR filter coefficients to filter the ADC samplementioned above.
Thanks.