数字滤波器

数字滤波器

滤波器术语
衰减 – 输出信号幅度相对于输入信号幅度降低。
截止频率 – 滤波器的响应降至额定通带纹波以下时的频率。
通带 – 滤波器频率范围,信号通过该范围的衰减量不超过额定值。
阻带 – 滤波器频率范围,信号通过该范围时会发生额定量的衰减。
阻带衰减 – 阻带中的最小衰减量。
通带纹波 – 通带中的实际输出幅度与期望输出幅度的最大偏差。
采样速率 – 系统对输入信号进行采样的速率。
滤波器系数 – 代表滤波器传递函数的逆傅里叶变换的数值。系数定义滤波器的特性,构成数字滤波器实现的基础。
抽头 – 抽头数等于滤波器针对每个输出点处理的输入采样值数量。抽头数还等于滤波器系数的数量,并且可以用来衡量滤波器延迟时间。

数字滤波器与模拟滤波器的比较

数字滤波器越来越多地应用于调制解调器、雷达、频谱分析仪、语音和图像处理设备等,原因如下:

与模拟滤波器相比,数字设计能够提供更陡的滚降,无需校准,对时间、温度和电源变化的适应能力更强,性能更稳定。简单地改变软件就能实时更改数字滤波器的响应,产生所谓“自适应滤波器”,而要改变模拟滤波器的响应,通常需要更改硬件。然而,数字滤波器并不能令所有应用满意。在滚降要求不超过约24 dB/倍频程的设计中,模拟滤波器通常更具性价比。但是,当滚降要求超过24 - 36 dB/倍频程时,使用数字滤波器更合适。事实上,在要求极陡滚降的应用中,许多设计师发现数字滤波器的开发难度小得多。通过更改软件,可以轻松修改原型。此外,数字滤波器设计的软件仿真可以精确反映滤波器的性能,但模拟滤波器的计算机仿真只能近似反映滤波器的真实性能,因为模拟滤波器的参数对元件值敏感,而初始元件值是不准确的,可能发生相当大的变化。

数字滤波器是对数字信号进行滤波处理以得到期望的响应特性的离散时间系统。作为一种电子滤波器,数字滤波器与完全工作在模拟信号域的模拟滤波器不同。数字滤波器工作在数字信号域,它处理的对象是经由采样器件将模拟信号转换而得到的数位信号。

數字滤波器的工作方式与模拟滤波器也完全不同:后者完全依靠电阻器、电容器、晶体管等电子元件组成的物理网络实现滤波功能;而前者是通过数字运算器件对输入的数字信号进行运算和处理,从而实现设计要求的特性。

數字滤波器理论上可以实现任何可以用数学算法表示的滤波效果。数字滤波器的两个主要限制条件是它们的速度和成本。数字滤波器不可能比滤波器内部的数字电路的运算速度更快。但是随着集成电路成本的不断降低,数字滤波器变得越来越常见并且已经成为了如收音机、蜂窝电话、立体声接收机这样的日常用品的重要组成部分。

数字滤波器一般由寄存器、延时器、加法器和乘法器等基本数字电路实现。随着集成电路技术的发展,其性能不断提高而成本却不断降低,数字滤波器的应用领域也因此越来越广。按照数字滤波器的特性,它可以被分为线性与非线性、因果与非因果、无限脉冲响应(IIR)与有限脉冲响应(FIR)等等。其中,线性时不变的数字滤波器是最基本的类型;而由于数字系统可以对延时器加以利用,因此可以引入一定程度的非因果性,获得比传统的因果滤波器更灵活强大的特性;相对于IIR滤波器,FIR滤波器有着易于实现和系统绝对稳定的优势,因此得到广泛的应用;对于时变系统滤波器的研究则导致了以卡尔曼滤波为代表的自适应滤波理论

数字滤波器具有比模拟滤波器更高的精度,甚至能够实现后者在理论上也无法达到的性能。例如,对于数字滤波器来说很容易就能够做到一个1000Hz的低通滤波器允许999Hz信号通过并且完全阻止1001Hz的信号,模拟滤波器无法区分如此接近的信号。

数字滤波器相比模拟滤波器有更高的信噪比。这主要是因为数字滤波器是以数字器件执行运算,从而避免了模拟电路中噪声(如电阻热噪声)的影响。数字滤波器中主要的噪声源是在数字系统之前的模拟电路引入的电路噪声以及在数字系统输入端的模数转换过程中产生的量化噪声。这些噪声在数字系统的运算中可能会被放大,因此在设计数字滤波器时需要采用合适的结构,以降低输入噪声对系统性能的影响。

数字滤波器还具有模拟滤波器不能比拟的可靠性。组成模拟滤波器的电子元件的电路特性会随着时间、温度、电压的变化而漂移,而数字电路就没有这种问题。只要在数字电路的工作环境下,数字滤波器就能够稳定可靠的工作。

由于奈奎斯特采样定理(Nyquist sampling theorem),数字滤波器的处理能力受到系统采样频率的限制。如果输入信号的频率分量包含超过滤波器1/2采样频率的分量时,数字滤波器因为数字系统的“混叠”而不能正常工作。如果超出1/2采样频率的频率分量不占主要地位,通常的解决办法是在模数转换电路之前放置一个低通滤波器(即抗混叠滤波器)将超过的高频成分滤除。否则就必须用模拟滤波器实现要求的功能。

线性移不变的数字滤波器包括无限长脉冲响应滤波器(IIR滤波器)和有限长脉冲响应滤波器(FIR滤波器)两种。

IIR滤波器的优点在于,其设计可以直接利用模拟滤波器设计的成果,因为模拟滤波器本身就是无限长冲激响应的。通常IIR滤波器设计的过程如下:首先根据滤波器参数要求设计对应的模拟滤波器(如巴特沃斯滤波器、切比雪夫滤波器等等),然后通过映射(如脉冲响应不变法、双线性映射等等)将模拟滤波器变换为数字滤波器,从而决定IIR滤波器的参数。IIR滤波器的重大缺点在于,由于存在反馈其稳定性不能得到保证。另外,反馈还使IIR滤波器的数字运算可能溢出。

FIR滤波器最重要的优点就是由于不存在系统极点,FIR滤波器是绝对稳定的系统。FIR滤波器还确保了线性相位,这在信号处理中也非常重要。此外,由于不需要反馈,FIR滤波器的实现也比IIR滤波器简单。FIR滤波器的缺点在于它的性能不如同样阶数的IIR滤波器,不过由于数字计算硬件的飞速发展,这一点已经不成为问题。再加上引入计算机辅助设计,FIR滤波器的设计也得到极大的简化。基于上述原因,FIR滤波器比IIR滤波器的应用更广。

无限脉冲响应滤波器,简称IIR数字滤波器英语:infinite impulse response filter),

是数字滤波器的一种。由于无限脉冲响应滤波器中存在反馈回路,因此对于脉冲输入信号的响应是无限延续的。滤波器的任务是通过一定运算关系,改变输入信号的频谱。数字滤波器是利用计算机程序、专用芯片等软、硬件改变数字信号频谱。如果要处理的是模拟信号可以通过A/D在信号形式上进行转换,在利用数字滤波器处理后经过D/A恢复为模拟信号。

利用选频滤波器的特性可以提取有用的信号频率分量,这类滤波器适用输入信号中有用信号频带与干扰信号频带不同的情况。 选频数字滤波器设计过程一般归纳为以下三个步骤:

  1. 按照实际需求性能要求确定滤波器技术指标。
  2. 用一个因果稳定的系统函数IIR去逼近这个要求。
  3. 用一个有限精度的运算(软、硬件)去实现这个传递函数

无限脉冲响应滤波器(IIR filter)的优点:

  • 较容易设计以及实现。

无限脉冲响应滤波器(IIR filter)的缺点:

  • 脉冲响应(impulse response)为无限长:造成当输入数字信号为有限长的时候,输出数字信号会变成无限长。
  • 比有限脉冲响应滤波器(FIR filter)较不易最佳化(optimize)。
  • 不一定是稳定的(stable):因为Z转换(Z transform)后所有的极点(pole)不一定都在单位圆内。

IIR数字滤波器设计有以下几种基本方法:

  • 零、极点累试法:由于频率响应在靠近集点频处会出现峰值,在靠近零点频率处会出现谷值,并且零、极点越靠近单位圆峰谷越明显。所以在设计时通过不断调整零、极点位置,达到设计标准,对要求不高的简单滤波器,可以用此方法设计。
  • 最优化设计:这种设计方法一般事先确定最好的推测,找出最好推测下误差最小的系统函数H(z)。在得到最佳结果之前,因为设计需要大量反复计算,所以必须用到CAD技术,而此类设计随着技术发展,应用也越来越多。
  • 用模拟滤波器理论设计数字滤波器:利用模拟滤波器理论先设计模拟滤波器,得到其系统函数Ha(s)。然后经过一定的变换,得到满足要求的数字滤波器系统函数H(z)。这样设计的优点是模拟滤波器设计理论成熟,有许多现成的公式、曲线、表格可以直接使用。并且在许多场合下就是用数字滤波器代替模拟滤波器。这种由模拟滤波器设计数字滤波器的方法,其实就是从s平面到z平面的映射变换,对这个变换基本要求是:
    • 数字滤波器的频率响应要保持模拟滤波器的频率响应,所以s平面的虚轴jΩ应当映射到z平面的单位圆ejw上。
    • 模拟滤波器的因果稳定性经映射数字滤波器仍应保持,所以s平面的左半平面应当映射到z平面的单位圆内。

有限脉冲响应(Finite impulse response,缩写 FIR)滤波器是数字滤波器的一种,简称FIR数字滤波器

这类滤波器对于脉冲输入信号的响应最终趋向于0,因此是有限的,而得名。它是相对于无限脉冲响应滤波器(IIR)而言。由于无限脉冲响应滤波器中存在反馈回路,因此对于脉冲输入信号的响应是无限延续的。

有限脉冲响应滤波器(FIR filter)的优点:

  • 脉冲响应(impulse response)为有限长:造成当输入数字信号为有限长的时候,输出数字信号也为有限长。
  • 比无限脉冲响应滤波器(IIR filter)较容易最佳化(optimize)。
  • 线性相位(linear phase):造成h(n)\,是偶对称(even)或奇对称(odd)且有限长。
  • 一定是稳定的(stable):因为Z转换(Z transform)后所有的极点(pole)都在单位圆内。

有限脉冲响应滤波器(FIR filter)的缺点:

  • 设计方式较无限脉冲响应滤波器(IIR filter)不容易。

以下尝试以滤波器设计方法、设计方法的限制、以及所设计滤波器的效果三方面,来比较最小化平均误差(Least MSE)、最小化最大误差(Minimax)与频率取样(Frequency sampling)三种设计方法的差异。

1.以设计方法而论

  1. Least MSE:使用到内积以及反矩阵的运算。
  2. Minimax:使用recursive的方式,所以相对而言较为复杂。
  3. Frequency sampling:利用到inverse fourier transform,就想法而言是最简单的。

2.以方法的限制而论

  1. Least MSE:使用上的限制较少。
  2. Minimax:所设计滤波器必须要是偶对称或是奇对称才可以,且必须要有转换频带(transition band)
  3. Frequency sampling:无法使用权重函数(weighting function),且转换频带的加入也很难做到最佳化。

3.以效果而论

  1. Least MSE:平均误差最小,一般而言系统稳定性较好。
  2. Minimax:最大误差最小,一般而言表现较好,且可以保证系统的运作在一定的误差内。
  3. Frequency sampling:很难做到最佳化,且容易有aliasing effect、Gibb’s phenomenon等等缺点,所以是较不普及的设计方法。

频域电子滤波器设计必须首先考虑任务所需滤波器的类型。首先必须确定滤波器的基本功能,如低通滤波器、高通滤波器、带通滤波器、全通滤波器或者是更为复杂的功能。

  • 低通滤波器用于阻止不需要的高频信号。
  • 高通滤波器允许高频信号通过,阻止不需要的低频信号成分通过。
  • 带通滤波器只允许有限频率范围的信号通过。
  • 带阻滤波器允许低于和高于特定频率范围的信号通过,对于这个范围内的频率阻止通过。这种滤波器较少见。

滤波器的一个重要参数是所要求的频率响应。尤其是频率响应曲线的陡峭性和复杂性是滤波器阶数和可行性的一个决定性因素。

一阶滤波器只有一个依赖于频率的成分,这就意味着频率响应slope就局限在每倍频6 dB。对于许多应用来说,这是不够的,为了实现更陡的斜率,必须使用更高阶的滤波器。

无限脉冲响应是与模拟滤波器对应数字实现。无限脉冲响应使用了反馈过程,所以通常要比同样性能的有限脉冲响应滤波器所耗费的资源要少。同样是由于反馈的因素,高阶的无限脉冲响应滤波器可能会有不稳定和运算溢出的问题,因此需要细心设计以避免出现类似问题。另外,它们有内在的依赖于频率的相移,在很多情况下这可能成为问题。二阶无限脉冲响应滤波器经常叫作'biquads',更高阶的滤波器就是biquads的层叠。一个有用的计算biquad系数的参考文献是RBJ Audio EQ Cookbook。

有限脉冲响应滤波器不使用反馈,本身是稳定的。有限脉冲响应滤波器系数通常是对称的,这样很自然地相移就被抵消。并且也很容易避免运算溢出。它的主要缺点是要比灵巧设计的无限脉冲响应变量的计算要花费多得多的处理和内存资源。有限脉冲响应设计比较简单:Remez exchange算法就是一个能够半自动设计相当高质量滤波器的方法。

IIR vs FIR Filters

IIR filters are difficult to control and have no particular phase, whereas FIR filters make a linear phase always possible.

IIR can be unstable, whereas FIR is always stable.

IIR, when compared to FIR, can have limited cycles, but FIR has no limited cycles.

IIR is derived from analog, whereas FIR has no analog history.

IIR filters make polyphase implementation possible, whereas FIR can always be made casual.

FIR filters are helpful to achieve fractional constant delays.

#MAD stands for a number of multiplications and additions, and is used as a criterion for an IIR and FIR filter comparison. IIR filters require more

#MAD when compared to FIR, because FIR is of a higher order in comparison to IIR, which is of lower order, and uses polyphase structures.

FIR filters are dependent upon linear-phase characteristics, whereas IIR filters are used for applications which are not linear.

FIR’s delay characteristics is much better, but they require more memory.

On the other hand, IIR filters are dependent on both i/p and o/p, but FIR is dependent upon i/p only.

IIR filters consist of zeros and poles, and require less memory than FIR filters, whereas FIR only consists of zeros.

IIR filters can become difficult to implement, and also delay and distort adjustments can alter the poles & zeroes, which make the filters unstable,

whereas FIR filters remain stable. FIR filters are used for tapping of a higher-order, a

nd IIR filters are better for tapping of lower-orders, since IIR filters may become unstable with tapping higher-orders.

FIR stands for Finite IR filters, whereas IIR stands for Infinite IR filters.

IIR and FIR filters are utilized for filtration in digital systems.

FIR filters are more widely in use, because they differ in response.

FIR filters have only numerators when compared to IIR filters, which have both numerators and denominators.

Where the system response is infinite, we use IIR filters, and where the system response is zero, we use FIR filters.

FIR filters are also preferred over IIR filters because they have a linear phase response and are non recursive,

whereas IIR filters are recursive, and feedback is also involved.

FIR cannot simulate analog filter responses, but IIR is designed to do that accurately.

IIR’s impulse response when compared to FIR is infinite.

The high computational efficiency of IIR filters, with short delays, often make the IIR popular as an alternative.

FIR filters have become too long in digital feedback systems, as well as in other applications, and cause problems. 

Summary:

  • 1. IIR is infinite and used for applications where linear characteristics are not of concern.
  • 2. FIR filters are Finite IR filters which are required for linear-phase characteristics.
  • 3. IIR is better for lower-order tapping, whereas the FIR filter is used for higher-order tapping.
  • 4. FIR filters are preferred over IIR because they are more stable, and feedback is not involved.
  • 5. IIR filters are recursive and used as an alternate, whereas FIR filters have become too long and cause problems in various applications.

1,对于IIR和FIR的比较,有些书上有论述。我引用陈怀琛的“数字信号处理教程--MATLAB释义与实现”: 

从性能上来说,IIR滤波器传递函数包括零点和极点两组可调因素,对极点的惟一限制是在单位圆内。因此可用较低的阶数获得高的选择性,所用的存储单元少,计算量小,效率高。但是这个高效率是以相位的非线性为代价的。选择性越好,则相位非线性越严重。FIR滤波器传递函数的极点固定在原点,是不能动的,它只能靠改变零点位置来改变它的性能。所以要达到高的选择性,必须用较高的阶数;对于同样的滤波器设计指标,FIR滤波器所要求的阶数可能比IIR滤波器高5-10倍,结果,成本较高,信号延时也较大;如果按线性相位要求来说,则IIR滤波器就必须加全通网络进行相位校正,同样要大大增加滤波器的阶数和复杂性。而FIR滤波器却可以得到严格的线性相位。 

从结构上看,IIR滤波器必须采用递归结构来配置极点,并保证极点位置在单位圆内。由于有限字长效应,运算过程中将对系数进行舍入处理,引起极点的偏移。这种情况有时会造成稳定性问题,甚至产生寄生振荡。相反,FIR滤波器只要采用非递归结构,不论在理论上还是在实际的有限精度运算中都不存在稳定性问题,因此造成的频率特性误差也较小。此外FIR滤波器可以采用快速傅里叶变换算法,在相同阶数的条件下,运算速度可以快得多。 

另外,也应看到,IIR滤波器虽然设计简单,但主要是用于设计具有分段常数特性的滤波器,如低通、高通、带通及带阻等,往往脱离不了模拟滤波器的格局。而FIR滤波器则要灵活得多,尤其是他易于适应某些特殊应用,如构成数字微分器或希尔波特变换器等,因而有更大的适应性和广阔的应用领域。 
从上面的简单比较可以看到IIR与FIR滤波器各有所长,所以在实际应用时应该从多方面考虑来加以选择。从使用要求上来看,在对相位要求不敏感的场合,如语言通信等,选用IIR较为合适,这样可以充分发挥其经济高效的特点;对于图像信号处理,数据传输等以波形携带信息的系统,则对线性相位要求较高。如果有条件,采用FIR滤波器较好。当然,在实际应用中可能还要考虑更多方面的因素。 

2,不论IIR和FIR,阶数越高,信号延迟越大;同时在IIR滤波器中,阶数越高,系数的精度要求越高,否则很容易造成有限字长的误差使极点移到单位园外。因此在阶数选择上是综合考虑的。

 

 

To answer that question you have to know what "Impulse" and "Response" mean...

An "Impulse" is a simple pulse.

Digitally it would be a sample with a maximum value, while all of the other samples before and after it would be zero.
If you listened to this, you would hear something like a pop or firecracker.

The "Response" is the output of a filter (or something else) is given the impulse.

For example, you can listen to the "impulse response of a room" by going into the room, doing a simple hand clap, and listening to the echo.
It would take some practice to get the hand clap to be as "sharp" as possible.
Getting the impulse response of a filter is the same way but instead of a hand clap you use a simple pulse and instead of a room you have a filter.

If you look at the impulse response of a filter, or a room, you will see the output wiggle for a time after the impulse (and sometimes it wiggles before, too).
In the room you heard this wiggle as the echo. In a filter this wiggling is directly related to the frequency and phase response of the filter.
In a room, the amount of time you hear the echo is called the "reverb time"-- there is no corresponding term for a filter, but it is part of the impulse response.

Now, a FIR filter (Finite Impulse Response) is finite because the impulse response time is limited by the math.
It's mathematically impossible for the impulse response time to extend beyond the number of taps in the filter-- therefore it is finite.

An IIR filter, on the other hand, does not have this mathematical limitation in the impulse response time.
If given an infinite mathematical precision, an IIR filter can wiggle the outputs forever.
Of course, in a practical sense it never goes on forever since at some point the wiggle gets smaller than the precision of the math used and so goes away.

The impulse response is the filter's signature. In the case of a FIR filter the impulse response gives you a direct image of the filter's coefficients. The impulse is a single sample with maximum amplitude, all samples before and after are zero. (This is the digital equivalent of a Dirac pulse.)
At the time of the pulse its value is multiply by b0 (see bottom diagram). The other samples are zero, so the output y equals b0 (I'm presuming a maximum value for the pulse of 1). One sample later the pulse has moved one z1 block and is multiplied by b1. Again, all other values are zero, so the output is b1. And so on. While the pulse shifts through the filter you get the successive values for bi at the output. After N samples the pulse is shifted out of the filter, and the output becomes zero again.
For an IIR filter it's not so obvious to derive the filter coefficients from the impulse response.

IIR
In an IIR filter (part of) the processed signal is fed back to the input.

That means that there will always be some residue of the signal looping around.
Most of the time however this part of the signal will be ever smaller and end up being zero, but in theory it never disappears completely.
The block diagram below shows a biquad filter, an often used implementation of an IIR filter.
The left branch takes (delayed) input values, the right branch works with (delayed) output values.
(A z1 block represents a 1 sample delay. Biquads are often cascaded.

FIR
FIR filters on the other hand have a linear path from input to output.

After N samples the input signal (like a Dirac pulse) will have been shifted out and that's the end of it.

FIR filters are inherently stable, while IIR filters aren't necessarily.

There are two broad classes of digital filters, infinite impluse response (IIR) and finite impulse response (FIR).
Again broadly, IIR filters are equation-based and FIR filters table-based.

IIR filters are more like real world analog filters.
For example, consider a simple exponential decay like you would get from a R-C analog low pass filter.
The output response to a step input is a exponential that gets ever closer to the input.
Note that this exponential never actually gets to the output, only close enough so that we don't care or can't measure the error.
In that sense, such a filter is inifinite. A IIR filter has the same characteristics.

The very common single pole low pass IIR filter can be expressed as:

FILT <-- FILT + FF(NEW - FILT)

This means that each iteration the output if moved a fixed fraction (FF, the "filter fraction") of the distance to the input.
This is easy to visualize when FF = 1/2. If everything is 0 and the input suddenly goes to 1 and stays there (a unit step), then the output will be 1/2, 3/4, 7/8, 15/16, etc.
This is a infinite series. Eventually the value will get so close to 1 that it is expressed as 1 since the digital values in the computer don't have infinite precision.

FIR filters work on a totally different principle.
A finite recent snippet of the input signal is saved, and each of the saved values is multiplied by a different coefficient,
then all the results added to make the filter output for that iteration.

The next iteration the oldest saved value is discard, the others are shifted one slot older, and the new input is put in the vacated slot.
The new saved snippet is then multiplied by the coeficients, etc.

This process is known as a "convolution", and the table of coefficients often referred to as the filter kernel.

Some fancy and useful things can be done with this kind of filter by getting creative with the coefficients.
That's a whole topic onto itself that I won't go into now.
However, since a finite snippet of the input is stored in memory, any part of the input signal can only effect the output for a finite time.
Once a input sample is shifted out the end of the stored snippet it's gone and no longer has any effect on the output.

There are whole books written on this stuff and you can spend several semesters of college courses devling into this deeper.
Hopefully my 30 second overview demystifies this enough to answer your question.

 

posted @ 2015-09-29 09:22  IAmAProgrammer  阅读(4493)  评论(0编辑  收藏  举报