Breaking

Be Strong Let's Try!

Tuesday, 31 August 2021

Filter coefficient quantization and implementation in cascade and parallel form | Digital Signal Processing

 

Filter coefficient quantization and implementation in cascade and parallel form

Objective:

Objective of this topic is to learn filter quantization theory and implementation in cascade and parallel form.

Description:

As we have seen the design of digital filters involves finding the coefficients of the filter. For computing and evaluating the coefficients of the digital system, we use precision floating point arithmetic. Precision floating point arithmetic is basically when we use numbers whose number of digits is only limited by the available memory of the system. This is done when the speed of calculations is not an issue, but the accuracy is. Hence, translating that definition of infinite precision arithmetic to DSP systems, we can say that the number of bits that we use in designing a filter is limited by the word length of the register used to the store them. The fact of the matter, however, is that most of the DSP systems that we use have a fixed number of bits in their registers. The capacity of registers is limited, practically. So how do we fit infinite arithmetic numbers in some finite space? We quantize them. Generally, we use quantization methods like rounding or truncating to quantize the filter coefficients to the word size of the register.

The location of poles and zeros of any digital filter directly depends on the value of the filter coefficients. But since we are quantizing the values of the filter coefficients to fit them into the register, there will be a change in the values of the poles and zeros.

This, in turn, causes the location of the poles and zeros to shift from the desired location. Thus, the quantization of filter coefficients creates a deviation in the frequency response of the system.

In summary, after quantization, we get a filter that has a frequency response that is different from the frequency response of the filter with unquantized coefficients.

How to reduce the quantization effect on filter coefficients?

We can minimize this drastic effect of quantization on the filter coefficients. The corresponding change in the frequency response can be minimized by realizing a filter with a large number of poles and zeros as an interconnection of second-order sections means to convert single order section to 2nd order section.

1.      Here filter is converted to seconder order section. You can see the coefficient word length is 30 and stystem is stable



2.      Now you can see the change in the coefficient word length but still the system is stable and no pole is outside from the unite circle.


3.      Now convert the filter to single section.


4.      Now you can see that the filte has a single section of coefficient and coefficient word length is 30. System is stable and all poles and quantized poles are in unit circle.


5.      Now reduce the coefficient word length and you can see that the system is no more stable and there are poles outside the unite circle.


We will try to understand this topic using the practical example:

1.      Design an IIR filter using FDA toolbox having double floating point precision. Quantize your system by changing filters’ coefficient word length. Decrease the length so that you can observe the stability and unstability of the system. Comment on what you have observed through pole zero plot in report.

Solution:

Low Pass IIR Filter of order 10 is designed:

 

Filter coefficient quantization and implementation in cascade and parallel form | Digital Signal Processing

The filter is designed using double floating point precision and is stable since all poles lie within the unit circle.

Filter coefficient quantization and implementation in cascade and parallel form | Digital Signal Processing

Now the filter is quantized by changing its coefficients’ data type to fixed point. Initially, the word length is 30 and the system is still stable as the position of poles is not changed, only zeros have moved a bit. Since zeros have no role in determining system’s stability, the system is stable as poles are inside unit circle.    

Filter coefficient quantization and implementation in cascade and parallel form | Digital Signal Processing

 As we are reducing word length, the frequency response is showing more deviation. 

Filter coefficient quantization and implementation in cascade and parallel form | Digital Signal Processing

2.      In this part convert your filter to 2nd order section. Implement your filter as cascade form and parallel form, apply on audio compare the outputs and comment.

Code:

% rec = audiorecorder(8000,8,1);   %create an object for recording

% record(rec,3);                   %record for 3 seconds

y =getaudiodata(rec);            %generate audio data   

Fs =8000;                        %sampling frequency

T = 1/Fs;                        %increment in time axis   

y3 = filter(newww,y);            %Pass through Second Order Section Filter (Double Precision)

OUT = dfilt.cascade(newww,newww);   %cascaded form

OUTPUT = filter(OUT,y);             %filter the input signal

OUT1 = dfilt.parallel(newww,newww); %parallel form

OUTPUT1 = filter(OUT1,y);           %filter the input signal 

%play all output and observe changes

sound(y)

sound(y3)

sound(OUTPUT))

sound(OUTPUT1)

figure

subplot(2,2,1)                      %plot original signal

t = 0:T:(length(y)*T)-T;

plot(t,y)

title('Original Audio Signal')

xlabel('Time')

ylabel('Amplitude')

subplot(2,2,2)                      %plot output of Second Order Filter Applied (Double Precision) 

t3 = 0:T:(length(y3)*T)-T;

plot(t3,y3)

title('Second Order Sections Filter Applied (Double Precision)')

xlabel('Time')

ylabel('Amplitude')

subplot(2,2,3)                  %plot output of Single Order Filter Applied    

t1 = 0:T:(length(OUTPUT)*T)-T;

plot(t1,OUTPUT)

title('Second Order Sections Filter Applied (Cascade Form)')

xlabel('Time')

ylabel('Amplitude')

subplot(2,2,4)                  %plot output of Second Order Filter Applied

t2 = 0:T:(length(OUTPUT1)*T)-T;

plot(t2,OUTPUT1)

title('Second Order Sections Filter Applied (Parallel Form)')

xlabel('Time')

ylabel('Amplitude')

 

 OUTPUT:

Filter coefficient quantization and implementation in cascade and parallel form | Digital Signal Processing


 

 Some of the Observations:

Output of Second Order Sections Filter Applied (Double Precision)

A hollow high pitch sound is added to the original audio and it sounds like more noisy and the original audio is not recognizable. There is not much difference observed in the output of these two. 

Output of Second Order Sections Filter Applied (Cascade Form)

A large hollow whistling noise is added to the audio.

Output of Second Order Sections Filter Applied (Parallel Form)

Sounds somewhat like the Output of Second Order Sections Filter Applied (Double Precision). However, a slight increase in the noise is observed. 

 

 

 

 

 

 

No comments:

Post a Comment

Pages