I have a 100kHz sampling frequency ADC hooked up to an FPGA (CycloneII) and would like to use a FIR filter to lowpass this signal down to about
50Hz -3dB cutoff frequency. The Quartus FIR builder attenuates DC when I put 100kHz input and 50Hz output in it, is there a better way to do this perhaps decimate the input signal or use nested FIR filters? I would like to get an average of this 100kHz sampled data basically with about a 5Hz to 50Hz update rate.
That is an IIR filter. If you put a spike into it, it basically never returns to the zero point. If the OP can get away with IIR, it isn't such a bad thing but it isn't exactly what the OP wanted to do.
Doing it as:
filtered =3D filtered + sample - filtered/A
is often easier to do. The add and subtract can be the same hardware. The two operations happen at different times. Both "sample" and "filtered/A" are less bits than "filtered". This means that less than full adder hardware can be used in the upper bits.
You don't really need a multiply if you can accept a power of two for the alpha.
This depends on alpha and the resolution. E.g. if you use 8 bit words, even for low alpha values like 0.1, after a pulse of 255 the filtered variable will be down to 0 after 19 steps, but I think this is ok for a spike. A FIR lowpass filter with 19 taps can show the same behavior.
It depends on the application. The main disadvantage of IIR filters are different phase delay times for different frequencies, so it is nothing you want to use for audio filtering, but it is much faster to calculate than FIR filters and good for doing some noise filtering for sensor measurement.
Frank Buss, email@example.com
Not if the competing product doesn't do that and their marketing department is clever enough to make it seem like a major issue.
No, with 19 taps after the 19th tap is passed, the output is exactly zero.
You can implement the same "linear phase" character as an analog filter.
For audio work it doesn't matter. Real physical things that reduce the high frequencies have the same sort of phase effects as IIRs and unless you do something very foolish you won't make enough phase shift to matter. People can only hear massively abrupt phase shifts. There are those who claim you can't hear any but they just lack the imagination needed to see how abrupt a phase shift can be.
Note: The only difference between a sound and that same sound played backwards is the phase relationships.
I use both FIR and IRR filters. In some sensor applications the long tail of an IIR is a major problem.
A single pole IIR doesn't have a limit cycle oscillation unless you do something massively dumb. A 2 pole IIR or a single pole combined with some other feedback path will do it. If you use an IIR as part of a servo system, you can easily end up with a limit cycle problem.
I have a problem with these kind of statements. When you make a definitive statement, you shouldn't qualify it with "unless you do something stupid." For example, "the earth is round, unless you do something stupid" doesn't fly. Basically, you should state the condition as part of the statement.
Thus under what condition does a single pole IIR filter never have limit cycles. Now I agree a single pole IIR won't ring. I just don't know why it will never have a limit cycle. Is there a theorem behind this?
Think of the IIR filter as a feedback system. There is no gain condition that leads to oscillation. This includes the theoretical infinite gain case. Limit cycle oscillation is caused by the gain effectively becoming infinite at the zero vs one decision.
That is the same as my suggestion of the round up on the divide by
Unfortunately, it makes for a nonlinear response. A better method involves remembering the error remainder from each step and biasing the next step with that. It makes the filter really a 2 pole with the second pole at a high frequency but it is very linear.
You had to assume a single sample pulse to get 19 steps.
Single pole IIR filters do have limit cycles--but since it's first order, the limit cycle is a constant nonzero value. A single-pole, integer-value IIR with a time constant of N cycles will stop decaying when its output value gets to N-1 (truncating arithmetic) or N/2-1 (rounding arithmetic), because the decrement will go to zero.
You can't usefully analyze IIR limit cycles with linear systems theory because they're entirely due to roundoff error, which is about as far from linear as anything.
I explained this point earlier. I don't call the settling to a constant offset a "limit cycle" because it doesn't cycle. It is one of those cases where our natural language doesn't work so well. We don't usually call a DC voltage a "zero Hz AC voltage" for the same sort of reason. Although calling it zero Hz is technically correct, it leads to extra confusion as is best avoided.
Yes but the point about the gain going infinite at the zero / one boundary is correct. Obviously this is one way to describe a very nonlinear situation.