Block: NotchBiQ



PIC




Inports


In

Input In(k)






Outports


Out

Output Out(k)







Mask Parameters



Name

ID

Description




method

1

Selection between bilinear and matched Z-transform discretization method




fn

2

Notching frequency in Hz




Q

3

Defines a quality factor of the filter




ts_fact

4

Multiplication factor of base sampling time (in integer format)





Description:

Calculates the filter coefficients for a second order notch filter and performs filtering on input signal.

Second order transfer function used:

H(z) = (b0.z2 + b1.z + b2) / (z2 + a1.z + a2)

Calculation:

Out (k) = In(k) ⋅ H(z)

The transfer function H(z) of the filter is

               - 1     - 2
H (z) = b0 +-b1z--+-b2z---
        1 + a1z-1 + a2z-2

with coefficients derived from the transfer function

          s2 + ω2
H (s) =  -2---ω0-0--2-
        s +  Q + ω 0

Two methods of discretizing a continuous transfer function are available: bilinear and matching.

Warning: In some cases, the function is very sensitive to the accuracy of the coefficients. Therefore, using a fixed-point implementation can sometimes give inaccurate results.

To illustrate this issue, see step responses in figures 1 and 2 below. Filter settings are fn = 50 Hz, Q = 10, fs = 10 kHz.


PIC

Figure 1: Step response for ts_fact = 1.



PIC

Figure 2: Step response for t_fact = 10.


Implementations:
FiP16 16 Bit Fixed Point Implementation
FiP32 32 Bit Fixed Point Implementation
Float32 32 Bit Floating Point Implementation
Float64 64 Bit Floating Point Implementation

Implementation: FiP16


16 Bit Fixed Point Implementation



Inports Data Type


In

int16






Outports Data Type


Out

int16




Implementation: FiP32


32 Bit Fixed Point Implementation



Inports Data Type


In

int32






Outports Data Type


Out

int32




Implementation: Float32


32 Bit Floating Point Implementation



Inports Data Type


In

float32






Outports Data Type


Out

float32




Implementation: Float64


64 Bit Floating Point Implementation



Inports Data Type


In

float64






Outports Data Type


Out

float64