Re: IIR filter help
- From: Jerry Avins <jya@xxxxxxxx>
- Date: Fri, 10 Aug 2007 23:40:16 -0400
Zorjak wrote:
I designed two filters using Matlab " filter design and analys tool" .
One 1st and one 2nd order. I tested this filter in matlab. As probe
signal I used signal the same I use with mc (arm lpc2148).
When I am using the filter order 1 I am getting the results almost the
same I am getting when I am using matlab. But, when I try to use
filter order 2 (same input signal) output is "0".
I don't know what is wrong, but I am shure that filter coeficients are
right. I don't know what is wrong.
Thanks for Your try to help, Tim
Zoran
Tim Wescott wrote:Zorjak wrote:Hi,
I have one question regarding implementation of IIR filter. I try to
write C code of IIR filter for ARM microcontroler for real time signal
processing. Filter should be lowpass and second order. I try to do
this in interupt function. This should be part of the code
.
volatile int count, count_on;
char On_ind;
volatile float Sample[3],Filtered[3], Max, Min, Power_curent,
Power_wanted, Scal, FB;;
/* Timer0 interupt funkcija*/
void tc0 (void) __irq
{
IODIR0 = 0x00000001;
Sample[2]=Sample[1];
Sample[1]=Sample[0];
Sample[0]=(float)ADC1_read();
Filtered[2]=Filtered[1];
Filtered[1]=Filtered[0];
Filtered[0]=0.0002478584065*Sample[0]+0.000495716813
*Sample[1]+0.0002478584065*Sample[2]+
1.964326262*Filtered[1]-0.9654386044*Filtered[2]; //ffiltering
But there is a problem this code doesnt work. I try to implement IIR
filter order 1
I replace
Filtered[0]=0.0002478584065*Sample[0]+0.000495716813
*Sample[1]+0.0002478584065*Sample[2]+
1.964326262*Filtered[1]-0.9654386044*Filtered[2]; //ffiltering
with
Filtered[0]= 0.044263*Sample[0]+0.044263*Sample[1]+0.91147*Filtered[1];
and this filter works fine. I am not shure but I don't know what is a
problem when i am trying to implement second order IIR filter.
Could anyone help me, please.
I apreciated any kind of help.
It's lokely that if the output is zero, there's a problem with the code. Try a different input signal and if the output is again zero, "likely" becomes "pretty sure".
...
Jerry
--
Engineering is the art of making what you want from things you can get.
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
.
- References:
- IIR filter help
- From: Zorjak
- Re: IIR filter help
- From: Tim Wescott
- Re: IIR filter help
- From: Zorjak
- IIR filter help
- Prev by Date: time delay device
- Next by Date: Patching Octave
- Previous by thread: Re: IIR filter help
- Next by thread: Re: IIR filter help
- Index(es):
Relevant Pages
|