Professional Documents
Culture Documents
Industrial
Wide Format&LCDs
Automotive, 130nm
350µA/MHz, 1µA standby
Challenge:
“More and More Sensors are required by our “Smart” devices
and reliable filtering is required to separate the signal from
the noise.”
Doctor, your
patient is in
distress
Inphase Filter Frequency Response
20
-20
Magnitude in dB
-40
-60
Wireless
-80
-100
0.0 2.5 5.0 7.5 10.0 12.5 15.0 17.5 20.0 22.5
Module
Frequency in kHz
Solution:
“This lecture will introduce you to some of the basic concepts of
Digital Filtering, low-cost Filter tools and help you avoid some of
the more common pitfalls when implementing filters on the
Renesas processor of their choice.”
4 © 2012 Renesas Electronics America Inc. All rights reserved.
Agenda
Instrument Board
MCU
60 Hz
Sensor Cabling ADC
Filter
Voice Recorder
MCU
Microphone
4 kHz
LowPass ADC
X[n-1] X[n-2]
X[n] Z-1 Z-1 Z-1 Z-1 X[n-N]
b0 b1 b2 b3 bM
Y[n]
+ + + + nD Y”[n]
Z-1 Z-1
bk1 bk2
X[n]
bk0 + + + + Yk[n]
-ak2 -ak1
Z-1 Z-1
FIR
Phase-linear
Simple instructions, single loop
Suited for Multi-rate (decimation or interpolation allows some calculations
to be omitted)
Desirable Numeric properties (finite-precision can usually be implemented
using lower number of bits)
Possible to implement with coefficients less then 1.0
May require more memory and calculations than the IIR
Some responses are just impractical to implement in FIR
IIR
Less memory and calculations for a given filtering characteristic
Arithmetic errors compounded by feedback
Harder to implement using fixed point
Not as easy to do multi-rate (decimation and interpolation)
Not phase-linear
Programs like ScopeDSP allows inputting ADC data and running FFT
Simply stated:
A signal can only be properly sampled if it contains no frequencies greater
than one-half the sampling frequency
Output (dB)
-
7K 7K
+
-12
4 nF
8 nF 0 1 2 4 6 8 10
Frequency (kHz)
-2 -2
-4 -4
dbV @ R1-P / dB
Output (dB)
-6-6
-8-8
-10
-10
-121k 2k 3k 4k 5k 6k 7k 8k 9k 10k
1Frequency / Hertz 2 3 4 5 6 7 8
Frequency (kHz)
-12dB line
Decimate results
Store every 4th sample
Only calculate filter at 8 kHz
Signal to
Sample
S1 S2 S3 S4 S5 S6 S7 S8 S9 S10 S11 S12
Problems:
Interrupt Skew
– 32 kHz requires sampling every 31.25 uS
Software start ADC possibility of sample skew
Other interrupts in the system
Long instructions required to complete
Solutions:
Possible - Make the start interrupt highest system priority
Preferred - Use ADC system that can be triggered by timer
– Some devices may have to loop a timer to ADC trigger
Problem:
Interrupt Overhead Storing ADC Data
– Assume ADC ISR takes 40 cycles
• context save + data save and pointer adjust + context
restore
Sampling at 32 kHz BW to store data = 1.28 million cycles
Solutions:
Use a DMA controller
4-5 cycles or less per transfer
CPU BW to store data <200 thousand cycles
MTU2
Channel 0
AD Trigger (160kHz)
AD Complete
Memory
DMAC Data to
AN7 ADC0 PING/PONG
Channel Filter Task
Buffer
Complete Intr
(PING/PONG Rdy)*
Coefficients:
-0.074778857796693535
0.020358522095065112
0.200149797853876850
0.366925297165379800
0.366925297165379800
0.200149797853876850
0.020358522095065112
-0.074778857796693535
-28 27 26 25 24 23 22 21 20 2-1 2-2 2-3 2-4 2-5 2-6 2-7 2-8 2-9 2-10 2-11 2-12 2-13 2-14 2-15 2-16 2-17 2-18 2-19 2-20 2-21 2-22 2-23
Radix point
Parameter Single Double
Floating point value = Precision Precision
(-1)sb + (1+Fraction) x 2 (exponent – bias) Total bit 32bits 64bits
Width
The exponent is expressed in Sign bit 1bit 1bit
biased form:
Exponent 8bits 11bits
e = E + bias field
Precision is function of fraction bits Significand 23bits 52bits
Floating supports a very large Precision 24bits 53bits
dynamic range
Bias +127 +1023
Emax +127 +1023
Emin -126 +1024
-28 27 26 25 24 23 22 21 20 2-1 2-2 2-3 2-4 2-5 2-6 2-7 2-8 2-9 2-10 2-11 2-12 2-13 2-14 2-15 2-16 2-17 2-18 2-19 2-20 2-21 2-22 2-23
Radix point
Double Precision
Min Value = ~2.0 x 10e-308, Max value = ~2.0 x 10e+307
63 62 52 51 32
S Exponent 11 bits Significand part 20/52 bits (implied 1)
-212 211 210 29 28 27 26 25 24 23 22 21 20 2-1 2-2 2-3 2-4 2-5 2-6 2-7 2-8 2-9 2-10 2-11 2-12 2-13 2-14 2-15 2-16 2-17 2-18 2-19
Radix point
31 0
Significand part 32/52 bits (implied 1)
2-20 2-21 2-22 2-23 2-24 2-25 2-26 2-27 2-28 2-29 2-30 2-31 2-32 2-33 2-34 2-35 2-36 2-37 2-38 2-39 2-40 2-41 2-42 2-43 2-44 2-45 2-46 2-47 2-48 2-49 2-50 2-51
S 24 23 22 21 20 2-1 2-2 2-3 2-4 2-5 2-6 2-7 2-8 2-9 2-10
Example :
Calculate a 4 tap box filter using fixed point
Assume ADC samples are
– 0x100 (256), 0x200 (512) , 0x120(288), 0x150(336)
Coefficients are all 0.25
Solution
– Scale coefficients to be integers by multiplying by 4 (shift
left 2)
– Multiply coefficients time ADC values
• 1*0x100 + 1 *0x200 + 1*0x120 + 1 *0x150 = 0x570 (1392)
– Restore proper scaling (shift right 2) = 0x15C (348)
30 © 2012 Renesas Electronics America Inc. All rights reserved.
Precision Requirements
X0
X4 X1 X2 X3
C0 C1 C2 C3
X1 X2 X3 X4 New Data
C0 C1 C2 C3
C0 C1 C2 C3 C0 C1 C2 C3
Loop2 X4 X1 X2 X3
C0 C1 C2 C3 C0 C1 C2 C3
Loop3 X4 X5 X2 X3
C0 C1 C2 C3 C0 C1 C2 C3
bk1 bk2
X[n]
bk0 + + + + Yk[n]
-ak2 -ak1
Z-1 Z-1
Xk[n] – Input Samples, Yk[n] Output Samples, bk[n]/ak[n] Filter Coefficients, Z-1 – Delay Line
Magnitude in dB
Passband - 1 kHz
-40
Stopband attenuation 40 dB
Passband ripple = 2 dB -60
-80
RX 17 tap IIR
– 353 cycles (3.53 uSec @ 100 MHz)
– 15% BW if run @ 44 kHz
Challenge:
“More and More Sensors are required by our “Smart” devices
and reliable filtering is required to separate the signal from
the noise.”
http://www.dspguru.com/