POCPA Conference 20..23 May @ DESY Michele Martino (TE-EPC-HPM) CURRENT MEASUREMENT DIGITAL...
-
Upload
alfred-bradley -
Category
Documents
-
view
217 -
download
0
Transcript of POCPA Conference 20..23 May @ DESY Michele Martino (TE-EPC-HPM) CURRENT MEASUREMENT DIGITAL...
POCPA Conference20..23 May @ DESY
Michele Martino (TE-EPC-HPM)
CURRENT MEASUREMENT
DIGITAL FILTERING - TUTORIAL -
1
POPCA 2012
𝐹 (𝑧 )=∑𝑗=0
𝑃
𝑏 𝑗 𝑧− 𝑗/1+∑
𝑗=1
𝑄
𝑎 𝑗 𝑧−𝐾𝑗
FIR or IIR?
CURRENT MEASUREMENT FOR CONTROL
2
voltage/current signal transmission
Converter
Control
CurrentTransducer
PowerCircuit
ADCAnti Aliasing
/ Signal
Conditioning
Control systems can tolerate some delay in the measurement chain but certainly don’t like it !
Fundamental trade-off of the measurement chain: accuracy vs speed !
Properly designed digital controllers can “easily” handle delays (RST), so what’s the problem?
Delays increase model order (Z transf) → Model mismatch become rapidly critical for stability!
SAMPLING BASICS
3
𝑓 𝑠=1𝑇
Ideal Sampling
Time Domain Frequency Domain
Spectrum of a critically sampled strictly band-limited signal: no alias!!!
Signals whose bandwidth exceeds will be corrupted!
Noise is always present so there are no strictly band-limited signals! Anti-aliasing filtering always needed!
If the controller runs at , what about sampling faster?
Quantization Noise
QuantizationNoise
WHY OVERSAMPLING?
4
Standard Nyquist Sampling
Oversampling
High Order Analog Filters Huge Delay
Small Transition Bandwidth High Order Filter
High Order Analog Filters No re-configurability
Analog filter
𝑓 𝑐
2𝑓 𝑝𝑎𝑠𝑠 : frequency at which the control algorithm runs
Anti-aliasing can be dealt with only analogically!
Digital filter
Analog filter
𝑓 𝑝𝑎𝑠𝑠𝑓 𝑐
2𝐾 𝑓 𝑐𝐾
𝑓 𝑐
2𝐾 𝑓 𝑐− 𝑓 𝑝𝑎𝑠𝑠𝑓 𝑐
Anti-aliasing filtering can be shared between analog and digital!“Quantization” Noise decreases of a factor
increases by a factor , by
Re-configurability now possible
DECIMATION
5
Take the average of the samples?
𝑦 𝑛=1𝐾 ∑
𝑖=𝑛𝐾 +1
(𝑛+ 1)𝐾
𝑥 𝑖
Ok oversampling works very well, but the control still runs at !!! Samples are produced at frequency, so what to do with them?
Take one sample out of ? Not really a brilliant idea
Replicas still occur due to decimation!
SNR not improved due to lack of filtering!
That’s better: it puts a notch at which can be the switching frequency of the converter!
𝐾=135𝑓 𝑐=50kHz𝑓 𝑠=6750 kHz
Convolving many of such filters, notches can be put at pathological frequencies and enough attenuation can be achieved close to
𝐷𝑒𝑙𝑎𝑦 ≅𝐾2samples
𝐷𝑒𝑙𝑎𝑦 ≅𝑇 𝑐
2
THE NEVER-ENDING DISPUTE: IIR VS FIR
6Charles M. Rader : The Rise and the Fall of Recursive Digital Filters – IEEE Signal Processing Magazine,
Nov 2006
(non-causal)
FIR order / -taps IIR order (, )
0 500 1000 1500 2000 2500 3000 3500 4000-150
-100
-50
0
f [kHz]
Am
plit
ude [
dB
] A
rbitra
ry S
cale
Spectrum of : order
0 50 100 150 200 250 300 350 400 450 500-150
-100
-50
0
f [kHz]
Am
plitu
de [
dB]
Arb
itrar
y S
cale
Spectrum of : zoom
WHERE THERE IS NO MATCH AGAINST FIR:
7
1-bit ADC: 1-bit only?
+-
H(f)
+g
n
+1
-1
Vref = 1
1-bit D/A Kfcanaloginput
Yto digital filter
X1-bit
A/D converter
Yes, 1-bit only! It is the digital filter that actually determines the ADC “precision”!
“shapes” the white, uniformly distributed (pseudo-quantization) noise ! model
Fundamental relationship for digital filter design:
Only 1-bit means that no multiplication are needed for filters!!!!
𝑜𝑢𝑡 [𝑘 ]=∑𝑖=0
𝑁
𝑏𝑖 𝑦 [𝑘−𝑖 ] , 𝑦 [𝑘− 𝑖 ]=±1
HOW TO SPECIFY DIGITAL FILTERS
8
𝐴𝑝𝑎𝑠𝑠=2|𝑅𝑖𝑝𝑝𝑙𝑒𝑚𝑎𝑥|𝑑𝐵=2 (1+𝑥𝑝𝑝𝑚 )𝑑𝐵
(1−𝑥𝑝𝑝𝑚 )≤𝐺𝑎𝑖𝑛 ( 𝑓 )≤(1+𝑥 𝑝𝑝𝑚)
Idle tones can be close to so a w.c.
has to be guaranteed by the filter!
0 500 1000 1500 2000 2500 3000 3500 4000-150
-100
-50
0
f [kHz]
Am
plit
ude [
dB
] A
rbitra
ry S
cale
Spectrum of : order
𝑁𝑜𝑖𝑠𝑒𝐹𝑙𝑜𝑜𝑟𝑆𝐹𝐷𝑅
𝐸𝑁𝑂𝐵=𝑆 𝐼𝑁𝐴𝐷𝑑𝐵−1.76
6.02
𝑆 𝐼𝑁𝐴𝐷𝑑𝐵=1.76+120− 𝑥𝑑𝐵≅ 121.8−𝑥𝑑𝐵→𝐴𝑠𝑡𝑜𝑝=121.8−𝑥𝑑𝐵
A precision of is required
- “alias-free” bandwidth
𝑓 𝑐
“alias-free” bandwidth
“alias-free” bandwidth of the converter (no overspecs)
: why????
MINIMUM-PHASE FIR
Minimum-phase filters: the delay in the passband (approx constant) is significantly lower than that of a linear-phase having the same frequency constraints:
A minimum-phase filter has additional advantages; the overall order of the design is less than that of a linear-phase : coefficients which are less sensitive to quantization
filters can have a nice linear phase, but is that important?
, , , , ,
Linear-Phase Minimum Order Minimum-Phase Minimum Order
Ok it looks promising, but minimum-phase has a lot more overshoot! Is that a problem?
Actually not if the filter is part of the measurement chain of a control loop!!!
Minimum-phase FIR can readily be used in single-stage or multistage decimators… That needs some tricks: , both and are not integers!
MINIMUM-PHASE FIR DECIMATION
Given the specifications a minimum-order minimum-phase with coefficients is calculated be means of FDATOOL – Generalized Equiripple Algorithm If then a new filter can be designed with ; the output at frequency
can then be generated by simply taking one samples out of If then a new filter has to be designed with ; in order to guarantee the
minimum delay filters need to be interleaved
: wordlength, : fraclength Coefficients wordlength has to increase by bits
IIR IMPLEMENTATION
11
Implementation on DSP hints Hints based on Texas Instruments TMS320C28x with CCS
The hints clearly work with floating point DSP such as the TMS320F28335 _IQmpy ↔ *
No multiplication round-off errors if =
IIR IMPLEMENTATION
12
Implementation hints on DSP : Break up Structure and Combine Terms
IIR IMPLEMENTATION
13
Implementation hints on DSP : Inline
Inline is automatic with –O3 Optimization mode
Source must be visible to calling file
Make data allocation/definitions visible to calling file
Compiler can make use of Direct Addressing Mode “@0..63
Two order filters + two -like controllers +…a bunch of other stuff running on a TMS320F28335
“INTERACTIVE” SESSION
14
MATLAB FDATOOL
15
Different algorithms are available for minimum-phase design
Generalized Equiripple calculates minimum (even) order filters!
Other algorithms can be successfully used once the filter order is approximately known
What about very long filters?
For filter orders larger than a thousand taps the algorithms fail
But the problem can be decomposed and the FDATOOL let you the “cascade”
You can also quantize coefficients and then create a .coe file
SOME SUBTLE PHENOMENA
16
What can go wrong?
SOME SUBTLE PHENOMENA
17
It looks very nice isn’t it? It looks very “white” !!!!
SOME SUBTLE PHENOMENA
18
Let’s have a look at the histogram:
SOME SUBTLE PHENOMENA
19
Let’s have a look at the impulse response:
CASE STUDY
The designed filter: , , ,
CASE STUDY
The designed filter: , , ,
CASE STUDY
The designed filter: , , ,
CASE STUDY
The designed filter: , , ,
CASE STUDY
Actual implementation by means of interleaved filters: and last taps equal to
CASE STUDY
Actual implementation by means of interleaved filters: and last taps equal to
CASE STUDY
DC performance
CASE STUDY
AC performance
CASE STUDY
AC performance
Making hardware or perform measurements as flat as the digital filter may turn out to be unfeasible or unworthy!
CASE STUDY
Sine-fit Amplitude Estimation
Clock had to be “corrected” by for the data to make sense!
REFERENCES
30
http://www.mit.bme.hu/books/quantization
IEEE Std 1241-2000 Standard for Terminology and Test Methods for Analog-to-Digital Converters
A. Tessarolo, Getting the Most from Your C Code on the TMS320C28x™ Controller Using Code Composer Studio™
Delta-Sigma Data Converters Theory, Design, and Simulation. Norworthy, Schreier, Temes, IEEE – Wiley-Interscience 1992
K. Steiglitz, T. W. Parks, and J. K. Kaiser, ”METEOR: a constrained-based FIR Filter design program,” IEEE Trans. Signal Proc., vol 40, no. 8, pp. 1901-1909, Aug. 1992
Digital Filters with MATLAB® : Ricardo A. Losada, 2009, The MathWorks, Inc.
New class of recursive digital filters for decimation: Horacio G. Martinez and Thomas W. Parks, 1978, Rice University Electrical Engineering Dept. Huston
M. Martino, et al. “Low emission, self-tunable DSP based Stepping Motor Drive for use with arbitrarily long cables,” IFAC Large Scale Systems Symposium, Villeneuve d’Ascq, France, 2010
BACKUP SLIDES
31
MINIMUM PHASE FIR FILTERS
32
Delay is minimized, but there is a lot more overshoot! Is that a problem?
100A10A
HOW TO SPECIFY DIGITAL FILTERS? 1
33
From Precision to Filter Specs
Full scale is considered as the reference level part-per-million will always be referred to it; if a precision of is required an ideal quantizer would then need to have a quantization step such that the maximum quantization error would be
Passband ripple
In order to guarantee a dynamic precision of all over the “useful band” the passband gain should change less than the precision required for a full scale signal.
Stopband attenuation
For the stopband attenuation an estimation of the noise “level” to be rejected is required!
In a relatively “silent” environment assuming noise components (worst case scenario) would turn out in heavy and sometimes meaningless over-specification complexity, computational power, delay!
Putting it (almost) all together
As an example if the expected, or measured, noise “level” ( amplitude) is times smaller than the , then should be specified smaller than what is reported in the table. So precision can be achieved with only of attenuation in the stopband and so on. This will save computational power and most important: delay!
HOW TO SPECIFY DIGITAL FILTERS? 2
34
From Precision to Filter Specs
Stopband attenuation w.c.
: quantization noise power of an ideal quantizer with quantization step
]1.74 x 10-5
1.74 x 10-4
1.74 x 10-3
What’s still missing? Oh yes: passband and stopband frequencies!!!
The easiest approach (minimum filter order - largest transition bandwidth):
end of passband “alias-free” band beginning of stopband “alias-free” band
The iterative approach: beginning of stopband “alias-free” band
Replicas occurring around will not affect the desired precision in the “alias-free” band : ↓ → delay ↑ ; ↑ → ↓ → order ↑
should be chosen by trading off delay and filter complexity!
HOW TO SPECIFY DIGITAL FILTERS? 3
35
From Precision to Filter Specs
Now we are done! Or maybe not?
Let’s see: what about the “alias-free” band? “alias-free” band results in over specifying
“alias-free” band (full precision might not be needed for the whole closed loop bandwidth especially for very high precision applications)
WHY OVERSAMPLING? 1
36
A “bit” of theory
Pseudo Quantization Noise model:
Still a bit too complicated Now the model is linear!
: Uniform Statistical Distribution White Independent of input signal
Quantization Process Quantization is a non linear process - vast and tricky subject Quantization of a signal Sampling its (Probability Density Function) Fortunately an approximated model works very well almost every
time!
Ok but what does that mean? Power of does not change with sampling frequency ideally
so increasing i.e. oversampling reduces the Power Spectral Density!!!!
WHY OVERSAMPLING? 2
37
𝑓 𝑝𝑎𝑠𝑠𝑓 𝑐
2𝑓 𝑐
𝑃 𝑆𝐷 𝑃𝑆𝐷𝑓 𝑝𝑎𝑠𝑠 𝐾 𝑓 𝑐𝐾 𝑓 𝑐− 𝑓 𝑝𝑎𝑠𝑠𝑓 𝑐
𝑓 𝑐
2𝐾
𝑓 𝑐
2
a) b)
It’s easy to see that for equal lowpass filters in a) and b) either analog or digital the still improves by a factor !
Easy analog filter design, reduced delay, re-configurability, Ok! Is that all? What about PQN power?
Let’s assume ideal brick-wall lowpass filters at for both a) and b) and consider the Signal-to-Noise Ratio :
a) ; b) → improves by a factor !
Sampling Frequency Bandwidth
Actual : , ,