Re: IIR filter help



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.
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
.



Relevant Pages

  • Re: Phaeless filtering
    ... > 1) Filter a block of data using an IIR filter. ... > 2) Filter the resulting output in reverse direction through the same IIR ... > filter that has a truncated version of the IIR filter. ... > reversed version of the FIR filter EXCEPT in the first case the output is ...
    (comp.dsp)
  • Re: Frequency filtering from non stable IIR.
    ... I want to filter a real infinite signal xby block convolution. ... your IIR filter is under-specified. ... unit circle, the impulse response becomes unstable, as you have ... for the IIR filter and use one of the usual methods to design an IIR ...
    (comp.dsp)
  • Re: Generating 1/f^2 and 1/f^3 noise
    ... an exact IIR filter can be designed analytically. ... is a magnitude-only filter-design problem, ... Do you have a reference for this filter design method? ...
    (comp.dsp)
  • Re: Nearest IIR System to FIR?
    ... Greg Berchin wrote: ... Prony's Method fits an IIR filter to a desired ... Since the coefficients of an FIR filter are its ... your method is a fully linear alternative to Steiglitz- ...
    (comp.dsp)
  • Re: designing hp at 2Hz, Fs = 100kHz
    ... The sample frecuency is ... Won't this be a fairly high-order filter?? ... better than 32 bits to locate the poles properly, and the data widths will ... So your IIR filter will either need to use esoteric methods to keep the ...
    (comp.dsp)