ST AN2182 Application note

AN2182
Application note
Filters using the ST10 DSP library
Introduction
The ST10F2xx family provides a 16-bit multiply and accumulate unit (MAC) allowing control-oriented signal processing and filtering widely used in digital applications.
The first chapter of this application note describes a theoretical digital implementation of four different filters:
Low-pass filter
High-pass filter
Passband filter
Cut-band filter
The method adopted for each filter is th e approximation of the ideal filter model by a FIR filter . This th eory aims to compute the FIR’s coefficients by truncating the real signal with a known window.
The second chapter illustrates a practical implementation of a low-pass filter using the ST10 DSP library, its results and its limitations.
July 2007 Rev 1 1/18
www.st.com
18
Contents AN2182
Contents
1 ST10 DSP library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2 Digital filtering principles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.1 Fourier transform of a sampled signal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.2 Linear filtering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.3 Finite impulse response filters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
3 Low-pass filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
4 High-pass filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
5 Passband filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
6 Cutoff band filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
7 Implementation example using the ST10 DSP library . . . . . . . . . . . . . . . 12
7.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
7.2 Sampling frequency and FIR coefficients . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
7.3 Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
7.3.1 Frequency response . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
7.3.2 Phase response . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
8 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
9 Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
2/18
AN2182 ST10 DSP library

1 ST10 DSP library

The ST10 DSP free library is a set of arithmetic and signal processing functions based on the ST10 MAC unit. These functions are callable from C and fully compatible with the Tasking compiler.
This library manipulates signed integers coded on 16 or 32 bits. These integers represent numbers belonging to the interval [–1, 1[. We name these formats: Q1.31 and Q1.15.
Table 1. Examples of integer representations
–1 -0.5 -0.25 0 0.25 0.5
Q1.15 0xFFFF 0xC000 0xA000 0x0000 0x2000 0x4000 0x7FFF 0x7FFF
Q1.31
0xFFFF
FFFF
0xC000
0000
0xA0000
000
0x00000
000
0x20000
000
0x40000
000
1 - 1/2
0x7FFF
0000
15
0x7FFFFFFF
1 - 1/2
31
For a detailed description of the ST10 DSP libra ry, please refer to the application note AN1442 “Signal processing with ST10-DSP”.
3/18
Digital filtering principles AN2182

2 Digital filtering principles

Assume a continuous signal x(t) (the complex form corresponds to the signal’s phase and magnitude at the instant t) with a pass band B. Assume that this signal will be filtered using a filter with a continuous impulse response h(t).
When digital processing has to be used, it is necessary to sample the input signal with a frequency of F from the samples obtained at the filter’s output.
Figure 1. Example of input and output signals
Input signal Output signal
The Shannon theorem states that when sampling a signal at discrete intervals, the sampling frequency F
= 1/Ts (Ts being the sampling period). The output signal is then reconstituted
s
Filter h
should be greater than twice the highest frequency of the input signal.
s

2.1 Fourier transform of a sampled signal

Signals are converted from the time domain to the frequency domain usually through the Fourier transf orm. With the Fo urier transf orm, the signal is conv erted to a magnitude and pha se at each frequency.
The Fourier transform of the sampled signal x(k) has the following expression:
Xf() xk()e
=
The time representation can be computed f rom the X(f) as follows:
=
xk() Xf()e
i2kπf
i2kπf

2.2 Linear filtering

Using the notations defined in the previous section, the output signal y(n) is the convolution of the input signal x(k) and the filter impulse response h(k) .
yn() hn k()xk()
==
hk() xk()()
n
where x(n) = x(nT
4/18
), h(n – k) = h((n – k)Ts) and y(n) = y(nTs).
s
AN2182 Digital filtering principles
The output signal frequency response is given by the following expression:
Yf() Hf() Xf()=
where H(f), X(f) and Y(f) are the respective Fourier transforms of h(k), x(k) and y(k).

2.3 Finite impulse response filters

The FIR (Finite Impulse Response) a re non-recu rsiv e filters , mean ing that the outp ut signal y( i) is a linear combination of N input samples x(k) in the case of a N–1 order filte r. Its equation is
N1
⎛⎞
yn() akxn k()
⎜⎟
=
⎜⎟ ⎝⎠
k0=
where a
are the FIR’s coefficients.
k
A FIR filter is characterized by its order and its coefficients and can be used to implement any kinds of filters (low-pass, high-pass, pass-band or cutoff band).
5/18
Low-pass filter AN2182

3 Low-pass filter

The aim of this section is to create a low-pass filter with a cutoff frequency Fc and a gain G = 1, by determining a FIR filter using the digital approach. The FIR coefficien ts correspond to h(n) where h is its continuous time response and h(n) = h(nT
In the frequency domain, the ideal filter corresponding to these criteria has the following response:
Figure 2. Ideal low-pass filter frequency response
Magnitude
1
).
s
-F
c
F
0
c
This filter’s impulse response in the time domain is
(1)
ht() Hf()e
This response is sampled with a rate F
2πift
fd
2Fcc2tF
()sin==
c
= 1/Ts (sampling frequency), so the discrete response
s
has the followi ng expression
( 2)
hst() hnTs()δtnT
=
The impact of sampling h(t) with a rate F around F
and a gain of Fs. In fact, the frequency response corresponding to the sampled
s
()
s
is a periodization of the analog signal spectrum
s
impulse response is
Hsf() FsHf nF
=
Therefore , t o obtain a gain o f 1, t he h
()
s
response filter should be divided by Fs. Using equations
s
(1) and (2), the low-pass filter time response becomes:
F
(3)
hst() 2
=
c
------ c 2 n FcT
F
s
()δtns()sin
s
Frequency
The impulse response is a sinus cardinal (sinc) function centered at the origin.
6/18
Loading...
+ 12 hidden pages