Post Go back to editing

# Changing Q of State Variable also changes frequency.

Category: Software
Software Version: 4.7

Hi,

I've started to use the State Variable (Q/F input) block and I'm observing that changing the Q also changes the frequency, please see pictures below that show this.

Change Q to 10:

Increasing the Q reduces the frequency peak and vice versa. The problem is when trying to set the Q to something sensible like 0.7 then the frequency increases signifcantly and above nyquist, corrupting the signal, which makes setting and controlling this filter pretty awkward.

Have I made a mistake somewhere or is this a bug? If it's a bug, will it get fixed? I'm using version 4.7.

Thanks.

• Hello loggytek,

I switched over to the block that is GUI controlled so it can be simulated.

Here is what I got with a corner frequency of 1.5KHz. and a Q of 0.7.

The graph is going out to Nyquist.

Then when I enter a Q of 10 it gets a bit radical.

When I change the scale you can see the peak is at +20dB. Quite high.

You are probably clipping the serial port output.

That would create a lot of harmonics that a DAC would have issues reproducing.

How are you measuring this?

What hardware are you using? One of our evaluation boards?

Dave T

•      Hi Dave & loggytek,

Dave, that's a good idea to use the GUI filter to apply Stimulus-Probe.

Starting with the formula for external frequency control,  V = 2 sin (pi*(F/Fs)), we can work it backwards to get:

F = (Fs/pi) sin-1 (V/2)     At V=1.5 and Fs = 48K, the filter should tune to F = 12,960 Hz.   The frequencies which loggytek measured are considerably higher.  This suggests some inaccuracy in the filter's operation.  To investigate further, we can use Dave's idea to simulate filters of different frequencies and Qs.  First, two filters at 1296 Hz -- 1/10 the frequency of interest.  Here we see that the filter behaves properly.

Next, see what happens if we scale up the frequency to 12.960 Hz.  Now the performance deteriorates:

Why is this happening?  State-variable filters depend upon two integrators for their operation.  The analog variety uses op-amp integrators, while the DSP version works with algorithmic integrators.  Below I circled the two integrators in the State-Variable Filter:

According to Lyons, Understanding Digital Signal Processing, digital integrators suffer increasing errors as their operating frequency approaches Fs / 4, becoming even worse the higher we go.  Since the State-Variable Filter depends upon these integrators, it falls apart at high frequency.

To test this idea, let's run the filter exactly as above but at a sample rate of 96K.  Here, we see it behaves more accurately than in the example above:

Thus we may conclude that the digital State-Variable Filter deviates from its ideal theory as the operating frequency approaches or exceeds Fs / 4  (that is, half the Nyquist frequency).

Best regards,

Bob