You are on page 1of 6

DESIGN OF DIGITAL IIR FILTERS USING STANDARD GENETIC ALGORITHM

PĜemysl Žiška *, Miloš Laipert *

*
Department of Circuit Theory, CTU Prague, Technicka 2,
166 27 Prague, Czech Republic
e-mail: premysl.ziska@seznam.cz, laipert@feld.cvut.cz

Abstract: A simple method of the IIR filter design using the standard genetic algorithm is
described in the paper. This genetic algorithm was programmed in the Matlab
environment. Using this method, it can be proposed even filter with lower order of the
transfer function, which satisfies requirements for magnitude frequency response, than is
order of the transfer function which was proposed using the standard approximation
methods. Genetic algorithm is able to find a solution of the task successfully. For
realization in a digital signal processor with fixed point number representation, a filter
coefficients quantization process must be included to the design procedure. This novel
technique is presented on application examples of digital IIR filters design, which were
simulated in DSP TMS320C54x software simulator. The magnitude frequency response
of the proposed IIR filter is shown in the enclosed graphical output of the simulation in
the Matlab environment and the simulation in DSP TMS320C54x software simulator.
Copyright © 2004 IFAC

Keywords: standard genetic algorithms, digital IIR filter, digital signal processors,
magnitude frequency response

1. INTRODUCTION transfer function represents a difficult mathematical


problem. The present design methods, which are
The evolutionary algorithms are currently used for based on usage of numerical methods for solving
solving of transfer function approximation problem nonlinear equation system, need to estimate an initial
in many cases of design analog or digital filters. For approximation well to ensure convergence of the
example, in a recent paper Storn (1995) has proposed used numerical method. Therefore, a simple method
a method for the design of a digital IIR filter with of the digital IIR filter design based on standard
concurrent requirements for magnitude and group genetic algorithm is presented in this contribution.
delay frequency response by using the Differential
Evolutionary (DE) algorithm. Similarly, in papers This design method does not require the estimation
Martinek and Vondras (2001, 2002) presented results of initial condition to ensure convergence of the
where an approximation of the analog filter transfer computation. Genetic algorithms are powerful global
function with concurrent requirements for magnitude minimization algorithms which simulate an
and group delay frequency response was solved. evolutional process in the nature, see (Michalewicz,
Here, a simple method for IIR filter design using 1996). It stores a number of representations of
standard genetic algorithm will be presented. The solutions to a problem in the so called a ‘population’
method will be compared with standard matrix. The genetic algorithms can minimize not
approximation method, the Cauer approximation in only a standard function, but also highly nonlinear
particular. In general, an approximation of the filter and partly non-differentiable functions which have
many local minima. The disadvantage of genetic where x,y are different members of the
algorithms is the stochastic nature; it means that we population, r is random number with uniform
cannot predict the rate of convergence exactly, but probability distribution in the range (0..1) and
some experiments show that the process convergence x’,y’ are new offspring. Members x,y are chosen
at the correct initial condition setting is relatively with uniform probability Pc. The advantage of
quick. this operator is that it does not need to check
exceeding of the range of the found variables if
there is solved the task with the limited
2. GENETIC ALGORITHM FOR FUNCTION variables.
MINIMIZATION 4. Mutation operator. This operator is defined as
follows: elements of the offspring are chosen
The standard genetic algorithm, which uses with uniform probability Pm and then each of
floating-point number representation to find them is substituted by a number with uniform
continuous parameters, was proposed and probability in the form:
programmed in the Matlab environment. The
function of the algorithm can be described in the x (i )  min  r  (max  min) (4)
following block diagram in Fig. 1.
where i is the position in the matrix NP x D and
range of the variables is (min..max).

Sometimes the best offspring dies from the previous


generation as the result of operation: selection,
crossovering and mutation. Therefore, proposed
algorithm uses the elite strategy. This strategy saves
the best offspring, which is always inserted into the
new population.

Fig. 1. Block diagram of the genetic algorithm This process is repeated until an acceptable solution
has been found or a preselect number of generations
1. Generation of the initial population. This has been performed.
population is generated as NP x D matrix, where
NP is number of members of the population and
D is number of unknown variables in the solved 3. APPLICATION TASK
task. Each element of the matrix is generated as
a random number with uniform probability The ability of this method to the digital IIR filter
distribution in the form: design will be presented on the solution of the two
following examples. It is required to propose the
(1) digital IIR filter with requirements on magnitude
xi , j  min  r  (max  min)
frequency response specification defined in tolerance
band and to implement the proposed filters on digital
where i = 1...NP, j =1...D and range of the signal processor. A cascade structure is an optimum
variables is (min..max). technique to implement practical applications on the
2. The selection mechanism. This algorithm uses a digital signal processor, because coefficients of the
tournament selection. Two members of the filter must be quantized, see (Davídek, et al., 2000).
population are chosen randomly and their values This structure has low sensitivity of the IIR filter
of the objective function are compared. A magnitude frequency response relatively to the
member which has lower value of the objective quantization of coefficients. Moreover, it is usually
function is chosen. The selected member is requested to implement the cascade structure
inserted into the new population. The selection applying minimal memory and computing time
mechanism runs till the necessary number of requirements. Therefore, a certain structure is usually
members for creating the new population is not used which is defined as a product of the second
found. order transfer functions so called “biquadratic”
3. Crossovering. For this algorithm an arithmetical sections in the form:
crossover operator was used, which can be
defined in the form: N N
b0i  b1i  z 1  b2i  z 2
x   r  x  1  r   y (2)
H ( z)  
i
H i ( z)   1 a
i 1 1i  z 1  a 2i  z 2
(5)

y   1  r   x  r  y (3) The ”biquadratic“ section can be realized by the


following block diagram, which is shown in Fig. 2.
Then, the transfer function of the cascade structure of
the proposed IIR filter with the quantized coefficients
is defined in the form:

b0i  b1i  z 1  b2i  z 2


2
H ( z)   1 a
i 1 1i  z 1  a 2i  z  2
(7)

Hence, the cascade filter coefficients must be


calculated at first and then these coefficients ak,i, bk,i
Fig. 2. Block diagram of the “biquadratic” section must be modified by the terms:
For the IIR filters realization, the family of
TMS320C54x digital signal processors was chosen. a k ,i 

round a k ,i  2 k 1  bk ,i 

round bk ,i  2 k 1 
k 1 k 1 (8)
This processor uses an advanced, modified Harvard- 2 2
type architecture with common address space for the
program memory and data memory. These C54x’
processors are 16-bit fixed point. Therefore, 3.2 The digital filter approximation principle
coefficient value must be converted to a fraction
format of the number. If the number is expressed in Fundamental of the presented procedure is
twos complement form then maximum positive value computation of the complex poles of the transfer
is 1-2k, where k is number of the used bits and function of the bandstop filter with the magnitude
minimum negative value is -1. frequency response, which satisfies the preassigned
tolerance band. The mathematical formulation of the
objective function is
3.1 First example: a bandstop filter definition
F ( x)  H 1  H 2  H 3 (9)
The input requirement is design of a digital bandstop
IIR filter with specification of magnitude frequency where vector x = [x1 ,..,x9 ] is mapped:
response defined in tolerance band shown in Fig. 3.
x1 = r11 x5 = 11
x2 = r12 x6 = 12
x3 = r21 x7 = 21 (10)
x4 = r22 x8 = 22
x9 = K

The functions H1, H2, H3 are defined (for solved


example, the whole magnitude frequency response is
sampled at 128 equidistant points) as:

 a  
38
 a p  H dB ˆ k   0
Fig. 3. The magnitude frequency response 2
H1  p  H dB ˆ k if
specification (11)
0 otherwise
k 0
76

 H    H dB ˆ k   a s  0
The magnitude frequency response specification can  2
H2  dB ˆ k  a s if
(12)
be satisfied using digital IIR filter with 6th order 0 otherwise
k 51
transfer function proposed by applying the Cauer
 a  
128
 a p  H dB ˆ k   0
2
approximation. However, for presentation of method H3  p  H dB ˆ k if
(13)
ability, here will be proposed digital IIR filter with k 90
0 otherwise
4th order transfer function. Its transfer function is
defined in the form:
where ap is loss in passband and as is loss in stopband
and the magnitude frequency response is calculated
 1  z  
2
K 1
 r1i  e j1i  1  z 1  r1i  e  j1i by the term:
i 1 (6)
H ( z) 
H dB ˆ   20  log10 H z  z e j ˆ (14)
 1  z  
2
1
 r2i  e j2i  1  z 1  r2i  e  j 2i
i 1
where the variable ̂ means normalized frequency:
At this point, the quantization of the filter
coefficients must be taken into account during the ̂    T (15)
design process.
where T is the sampling interval.
The vector xopt, for which the objective function F(x) software simulator by the procedure described above,
= 0, is the wanted solution of the digital IIR filter in this figure.
design problem.

3.3 Results

The optimization task stated above was solved using


the initial settings: NP=500, Pc=0.8, Pm=0.1, range of
the variables was: x1, x2, x3, x4, x9  (0..1), x5, x6, x7,
x8  (0..ʌ). The algorithm found the following values
after 63243 generations:

x1 = r11 = 0.99043051376 x5 = 11 = 1.80140683482


x2 = r12 = 0.97210679031 x6 = 12 = 1.32294988541
x3 = r21 = 0.90833303169 x7 = 21 = 2.35141020891
x4 = r22 = 0.96319422342 x8 = 22 = 0.77755423337
x9 = K = 0.52807674793

The transfer function of the proposed filter is in the Fig. 4. Resultant magnitude frequency response of
form: the proposed filter
4
From the figure is seen, that real magnitude
b  z i
i
frequency response fully corresponds with ideal
H ( z)  i 0 (16) magnitude frequency response.
4
1 a  z
i 1
i
i

3.4 Second example: a bandpass filter definition


where The input requirement is design of a digital bandpass
IIR filter with specification of magnitude frequency
a1= -0.09439086914 b0 = 0.52807046473 response defined in tolerance band shown in Fig.5.
a2= -0.00219968706 b1 = -0.01277375221
a3= 0.05336382985 b2 = 0.90301252435
a4= 0.76544880867 b3 = -0.02113552857
b4 = 0.48952569998

The output response was computed by the following


procedure. The filter was simulated in the C54x’
signal processor software simulator where the filter
was programmed in an assembly language. An input
signal to the simulator was the unit pulse. Hence, the
output signal corresponds with the impulse
characteristic h(n). Afterwards, a frequency response
Fig. 5. The magnitude frequency response
H(j ̂ ) can be calculated in the discrete frequencies
specification
2·k/N using the Fast Fourier Transform (FFT) of the
output signal by the term: The magnitude frequency response specification can
be satisfied using digital IIR filter with 6th order
N 1
transfer function proposed by applying the Cauer
H  j  ˆ  ˆ  2k / N   hn e
n0
 j 2 nk / N
(17) approximation. However, for presentation of method
ability, here will be proposed digital IIR filter with
4th order transfer function. Its transfer function is
where k = 0, 1, …, N-1. Then, the magnitude defined in the form:
frequency response is calculated by the term 14. The
magnitude frequency response of the proposed filter
 1  z  
2
is shown in Fig. 4. K 1
 r1i  e j 1i  1  z 1  r1i  e  j 1i
i 1 (18)
H (z) 

 1  z  1  z 
2
There can be seen an ideal magnitude frequency 1 j  2 i 1  j  2 i
 r2i  e  r2i  e
response, which was achieved as a result of the IIR
i 1
filter simulation in the Matlab environment and a real
magnitude frequency response, which was achieved
from simulation in the C54x’ signal processor
However, here the quantization of the filter 3.6 Results
coefficients must be taken into account during the
design process. The optimization task stated above was solved using
the initial settings: NP=500, Pc=0.8, Pm=0.1, range of
Then, the transfer function of the cascade structure of the variables was: x1, x2, x3, x4, x9  (0..1), x5, x6, x7,
the proposed IIR filter with the quantized coefficients x8  (0..ʌ). The algorithm found the following values
is defined in the form: after 2303 generations:

2
b0i  b1i  z 1  b2i  z 2 x1 = r11 = 0.86677813070 x5 = 11 = 1.74421558660
H ( z)   1 a z 1
 a 2i  z 2
(19) x2 = r12 = 0.94835726973
x3 = r21 = 0.99631710757
x6 = 12 = 3.13608290789
i 1 1i x7 = 21 = 2.29294972241
x4 = r22 = 0.99730014573 x8 = 22 = 2.40250807160
x9 = K = 0.076597625551
Hence, the cascade filter coefficients must be
calculated at first and then these coefficients ak,i, bk,i
must be modified by the terms: The transfer function of the proposed filter has form:

a k ,i 

round a k ,i  2 k 1  bk ,i 

round bk ,i  2 k 1  4

b  z i
i
k 1 k 1 (20)
2 2 H ( z)  i 0 (26)
4
1 a  z
i 1
i
i

3.5 An approximation principle for bandpass


digital filter
where
Fundamental of the presented procedure is
computation of the complex poles of the transfer a1= 2.79132080078 b0 = 0.07659826520
function of the bandpass filter with the magnitude a2= 3.92894594371 b1 = 0.16819691844
frequency response, which satisfies the preassigned a3= 2.77336390875 b2 = 0.16990047227
tolerance band. The mathematical formulation of the a4= 0.98728337977 b3 = 0.12976568378
objective function is b4 = 0.051758237183

F ( x)  H 1  H 2  H 3 (21) There the output response was computed by the


following procedure which differs from the previous
case. This filter was also simulated in the C54x’
where vector x = [x1 ,..,x9 ] is mapped:
signal processor software simulator where the filter
was programmed in an assembly language. But, input
x1 = r11 x5 = 11 signals to simulator were discrete signals in the form:
x2 = r12 x6 = 12
x7 = 21 (22)
x3 = r21 U 1k n   A1  cos̂ k  n  (27)
x4 = r22 x8 = 22
x9 = K
Hence, the output signals are in the form:
The functions H1, H2, H3 are defined (for solved
example, the whole magnitude frequency response is U 2 k n   A2 k  cos̂ k  n  (28)
sampled at 128 equidistant points) as:
Then, the magnitude frequency response in k-th
76 frequency point is calculated by the term:
 H    H dB ˆ k   as  0
 2
H1  dB ˆ k  as if
(23)
0 otherwise
k 0 A2 k
H dB ˆ k   20  log10 (29)
 
102
 a  H ˆ  2 if a p  H dB ˆ k   0 A1
H2   p dB k
(24)
 0 otherwise
k 90
128 Then, the magnitude frequency response can be
H ˆ   a 2 H dB ˆ k   a s  0
H3  
k 115
 dB k
 0
s if
otherwise
(25) compounded of this point. This way is obtained the
magnitude frequency response of the proposed filter
shown in Fig. 6.
where ap is loss in passband and as is loss in
stopband. There can be seen an ideal magnitude frequency
response, which was achieved as a result of the IIR
The vector xopt, for which the objective function F(x) filter simulation in the Matlab environment and a real
= 0, is the wanted solution of the digital IIR filter magnitude frequency response, which was achieved
design problem. from simulation in the C54x’ signal processor
software simulator by the procedure described above, for Function Minimization. In: ICCSC'02 1st
in this figure. IEEE International Conference on Circuits and
Systems for Communications - Proceedings. vol.
1, pp. 106-109. Saint-Petersburg State Technical
University. St. Petersburg.
Michalewicz, Z. (1996). Genetic Algorithms + Data
Structures = Evolution Programs, 3rd ed..
Springer-Verlag, Berlin Heidelberg New York
Storn, R. (1995). “Differential Evolution Design of
an IIR-Filter with Requirements for Magnitude
and Group Delay”, Technical Report TR-95-026,
ICSI.

Fig. 6. Resultant magnitude frequency response of


the proposed filter

From the figure is seen, that real magnitude


frequency response almost fully corresponds with
ideal magnitude frequency response.

4. ACKNOWLEDGEMENT

The work reported in the paper was supported by the


grant GAýR No. 102/02/1067.

5. CONCLUSION

Usage of the genetic algorithm is unconventional


design method of the digital IIR filter. Both, the
bandstop and bandpass digital filter transfer functions
were proposed successfully. Resultant magnitude
frequency responses fully satisfy the preassigned
tolerance band.

This method is able to solve this class of the tasks


effectively even if using of other numerical methods
can lead to convergency problems. The method has
not been already published in such form like in this
paper.

REFERENCES
Davídek, V., Laipert, M. and M. Vlþek (2000).
Analog and digital filters (in Czech: Analogové
a þíslicové filtry), ýVUT, Praha.
Martinek, P. and J. Vondras (2001). New Approach
to Filters and Group Delay Equaliser Transfer
Function Design. In: ICECS 2001 - The 8th
IEEE International Conference on Electronics,
Circuits and Systems. vol. 1, pp. 70. ICECS
2001. St. Julian’s.
Martinek, P. and J. Vondras (2002). Multi-criterion
Filter Design via Differential Evolution Method

You might also like