Hello,
Would anyone here know how to create a digital lowpass filter? I wanted to use one for audio processing on a Pic12f
Thanks
-K
Digital Low Pass Filter
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Digital Low Pass Filter
Hello
Could you not just use a Pf or Nf ceramic cap to provide your low pass filter effect.
Could you not just use a Pf or Nf ceramic cap to provide your low pass filter effect.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: Digital Low Pass Filter
Hey,
You could use an IIR-filter. IIR ask a litle CPU from the chip.
At the site: http://www-users.cs.york.ac.uk/~fisher/ ... /trad.html you can design your filter.
Here is a little guide to use the site:
1) For audio you choose the "Butterworth" filter (this has a flat passband). The you choose the type of filter.
2) leave this empty.
3) In order you choose the selectivity of the filer. Per oder you'll make the filter more selective with 20dB/dec.
4) sample rate. How fast dou you sample the audio?
5) Enter the frequency's. Read the text there.
6) Leave this empty
7) Leave this empty
Leave this empty
9) Select query verzenden.
Then you come at a new page. This are the results.
What you need is from the results: Recurrence relation.
Example: With a High pass filter at 2000 Hz the eduqaution is:
y[n] = ( 1 * x[n- 2])+( -2 * x[n- 1])+( 1 * x[n- 0])+( -0.6683689946 * y[n- 2])+( 1.6010923942 * y[n- 1])
Were x[n] is the input and y[n] is the output.
Here you'll need a buffer 3 times the input and 3 times the input.
There is also a C example code.
If you can't make it work I will help you further.
Greetings
You could use an IIR-filter. IIR ask a litle CPU from the chip.
At the site: http://www-users.cs.york.ac.uk/~fisher/ ... /trad.html you can design your filter.
Here is a little guide to use the site:
1) For audio you choose the "Butterworth" filter (this has a flat passband). The you choose the type of filter.
2) leave this empty.
3) In order you choose the selectivity of the filer. Per oder you'll make the filter more selective with 20dB/dec.
4) sample rate. How fast dou you sample the audio?
5) Enter the frequency's. Read the text there.
6) Leave this empty
7) Leave this empty
Leave this empty
9) Select query verzenden.
Then you come at a new page. This are the results.
What you need is from the results: Recurrence relation.
Example: With a High pass filter at 2000 Hz the eduqaution is:
y[n] = ( 1 * x[n- 2])+( -2 * x[n- 1])+( 1 * x[n- 0])+( -0.6683689946 * y[n- 2])+( 1.6010923942 * y[n- 1])
Were x[n] is the input and y[n] is the output.
Here you'll need a buffer 3 times the input and 3 times the input.
There is also a C example code.
If you can't make it work I will help you further.
Greetings
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Digital Low Pass Filter
This sound's very interesting,
If you give it a go I would like to know how you get on.
I have one or two doubts such as can you run these sort of calculations on a PIC fast enough for the filter to work effectivly? There is a lot of floating point maths calculations there.
I can see this being a very handy little equasion for an AVR or ARM device.
If you give it a go I would like to know how you get on.
I have one or two doubts such as can you run these sort of calculations on a PIC fast enough for the filter to work effectivly? There is a lot of floating point maths calculations there.
I can see this being a very handy little equasion for an AVR or ARM device.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: Digital Low Pass Filter
Of the Speed I Have absolutly no idea. You can lower the order of the filter to decrease the number of calculations.
Re: Digital Low Pass Filter
Jasper,
thanks for the link, and for making sense of the calculations also... I was planning to use this for a pic 12f685 running @ 8MHZ (it will do this exclusively) I'll load it up and see if I can't get away with it.
-K
thanks for the link, and for making sense of the calculations also... I was planning to use this for a pic 12f685 running @ 8MHZ (it will do this exclusively) I'll load it up and see if I can't get away with it.
-K
Re: Digital Low Pass Filter
Hi guys.
I want to convert below C code to FC8 charts but dont know how to do it. Can someone help.
This is butterworth filter generated by Win Filter software.
Many thanks.
#define NCoef 4
float iir(float NewSample) {
float ACoef[NCoef+1] = {
0.01020853419306819500,
0.04083413677227278000,
0.06125120515840917100,
0.04083413677227278000,
0.01020853419306819500
};
float BCoef[NCoef+1] = {
1.00000000000000000000,
-1.96842778693851760000,
1.73586070920888560000,
-0.72447082950736208000,
0.12038959989624438000
};
static float y[NCoef+1]; //output samples
static float x[NCoef+1]; //input samples
int n;
//shift the old samples
for(n=NCoef; n>0; n--) {
x[n] = x[n-1];
y[n] = y[n-1];
}
//Calculate the new output
x[0] = NewSample;
y[0] = ACoef[0] * x[0];
for(n=1; n<=NCoef; n++)
y[0] += ACoef[n] * x[n] - BCoef[n] * y[n];
return y[0];
}
I want to convert below C code to FC8 charts but dont know how to do it. Can someone help.
This is butterworth filter generated by Win Filter software.
Many thanks.
#define NCoef 4
float iir(float NewSample) {
float ACoef[NCoef+1] = {
0.01020853419306819500,
0.04083413677227278000,
0.06125120515840917100,
0.04083413677227278000,
0.01020853419306819500
};
float BCoef[NCoef+1] = {
1.00000000000000000000,
-1.96842778693851760000,
1.73586070920888560000,
-0.72447082950736208000,
0.12038959989624438000
};
static float y[NCoef+1]; //output samples
static float x[NCoef+1]; //input samples
int n;
//shift the old samples
for(n=NCoef; n>0; n--) {
x[n] = x[n-1];
y[n] = y[n-1];
}
//Calculate the new output
x[0] = NewSample;
y[0] = ACoef[0] * x[0];
for(n=1; n<=NCoef; n++)
y[0] += ACoef[n] * x[n] - BCoef[n] * y[n];
return y[0];
}