Author Topic: Audio filter: non inverting Sallen-Key with bias, is it possible?  (Read 3145 times)

0 Members and 5 Guests are viewing this topic.

Offline SaimounTopic starter

  • Frequent Contributor
  • **
  • Posts: 564
  • Country: dk
Hi :)

Is it possible to make a Sallen-Key low pass filter with a bias? Or more exactly, in my case, if I already have an AC signal (audio) that is biased to Vcc/2, can I just put it through an opamp with single supply?

This is what I have in mind: (attached)

Thank you!
Simon

PS: filter values calculated from http://sim.okawa-denshi.jp/en/OPseikiLowkeisan.htm

And just FYI - the background for this is I had a second order butterworth filter (inverting) which would have worked great - I tested it - but this filter has a low input impedance (of the input resistor) it turns out that I cannot use the DAC buffer inside the MCU, so I need a filter with a high-impedance input.
« Last Edit: October 27, 2020, 10:36:21 pm by simonlasnier »
 

Online MasterT

  • Frequent Contributor
  • **
  • Posts: 802
  • Country: ca
Re: Audio filter: non inverting Sallen-Key with bias, is it possible?
« Reply #1 on: October 27, 2020, 09:29:44 pm »
Only if omit R7 (replaced by internal DACs output imp. 15k) and rescale all other RC parts to new R7 value.
 

Offline srb1954

  • Super Contributor
  • ***
  • Posts: 1107
  • Country: nz
  • Retired Electronics Design Engineer
Re: Audio filter: non inverting Sallen-Key with bias, is it possible?
« Reply #2 on: October 28, 2020, 01:29:42 am »
Hi :)

Is it possible to make a Sallen-Key low pass filter with a bias? Or more exactly, in my case, if I already have an AC signal (audio) that is biased to Vcc/2, can I just put it through an opamp with single supply?

This is what I have in mind: (attached)

Thank you!
Simon

PS: filter values calculated from http://sim.okawa-denshi.jp/en/OPseikiLowkeisan.htm

And just FYI - the background for this is I had a second order butterworth filter (inverting) which would have worked great - I tested it - but this filter has a low input impedance (of the input resistor) it turns out that I cannot use the DAC buffer inside the MCU, so I need a filter with a high-impedance input.
Why not just add another voltage follower in front of the Sallen & Key filter to buffer the DAC output and eliminate the effect of the DAC output impedance?
 

Offline ejeffrey

  • Super Contributor
  • ***
  • Posts: 3797
  • Country: us
Re: Audio filter: non inverting Sallen-Key with bias, is it possible?
« Reply #3 on: October 28, 2020, 05:14:28 am »
You can pass a DC offset through a unity gain Sallen-Key low-pass filter with no problem.  However the Sallen-Key has a finite and frequency dependent input impedance.  So as MasterT explained, you will need to redesign the filter with the DAC impedance as part of the feedback network or you will not get the response you expect.  Or add an opamp buffer and use whatever filter you want.
 

Offline SaimounTopic starter

  • Frequent Contributor
  • **
  • Posts: 564
  • Country: dk
Re: Audio filter: non inverting Sallen-Key with bias, is it possible?
« Reply #4 on: October 28, 2020, 09:57:43 am »
Thank you all that helps a lot! Ideally would rather avoid adding an extra opamp to keep the cost low.

But if I understood well you are saying it would work fine without one :) Have I understood correctly that all I need to do is to make the calculations with the first resistor = R7+Zout?

My original question was more about whether the DC bias voltage Vcc/2 should be applied somewhere. My trail of thoughts were:
* Normally a non-inverting opamp with bias looks like that:



* In my case R3=oo, R4=0, and since my signal is already between 0V and VCC I can drop C2 and R5
* So at the end Vref (=Vcc/2 in my case) is not used.

If all of this above is correct, I still have a few questions (if I may! :D ):
1. I am not 100% sure how to calculate Zout - I actually asked in another post about it ( https://www.eevblog.com/forum/microcontrollers/dac-on-stm8l151-output-buffer/ ), but I would guess it can vary from 8k to 12k (yes sorry 15k was wrong). Is there any way I can measure Zout? I was thinking putting a resistor on the DAC output pin to AGND, get the DAC to output VCC and measure the voltage drop.
2. Is it a problem is my DAC output signal is not exactly centered around Vcc/2, but f.x. (Vcc/2)-0.1V (because of Vcc errors between the opamp and the MCU)?
3. @ejeffrey you mentioned the input impedance is finite - but it is still very large for frequencies below the cut frequency of the filter, so that the signal can get through almost without being attenuated, correct?
(FYI the opamp is almost rail-to-rail)
« Last Edit: October 28, 2020, 10:00:39 am by simonlasnier »
 

Offline srb1954

  • Super Contributor
  • ***
  • Posts: 1107
  • Country: nz
  • Retired Electronics Design Engineer
Re: Audio filter: non inverting Sallen-Key with bias, is it possible?
« Reply #5 on: October 28, 2020, 11:53:34 am »
Thank you all that helps a lot! Ideally would rather avoid adding an extra opamp to keep the cost low.

But if I understood well you are saying it would work fine without one :) Have I understood correctly that all I need to do is to make the calculations with the first resistor = R7+Zout?

If you try to connect the Sallen & Key filter directly to the DAC output you have to account for the considerable variability of the DAC output resistance, which doesn't seem to be very tightly controlled according to the data sheet. Just using the DAC output resistance in place of R7 is going to cause major variations in the filter frequency response and it is probably going to require trimming of other components in the filter to get the desired response. This would potentially have to be done on a per unit basis and would be very time consuming.

Without having a buffer amplifier the only other way to compensate for the variable DAC output resistance to scale R7 to a much higher value so that it swamps out the variation in that output resistance. For example, if you increase R7 to 91K 1% then the effective value of the filter input resistor ranges from 98k - 104K; a total effective tolerance of +/- 3% which is just barely acceptable for a low performance filter. The downside of this is that the capacitors have to scaled down by the same factor to maintain the required frequency response. You are then looking at some smallish capacitors (47-100pF) so the effects of circuit stray capacitance become problematic.

It is just a whole lot easier to use another op amp as a buffer stage on the DAC output. If you use a dual or quad op amp package you are only looking at about $0.10- $0.15 for that extra op amp.
 

Offline SaimounTopic starter

  • Frequent Contributor
  • **
  • Posts: 564
  • Country: dk
Re: Audio filter: non inverting Sallen-Key with bias, is it possible?
« Reply #6 on: October 28, 2020, 02:42:00 pm »
Fair enough - I am not against the idea of using an extra buffer, but if I can get "good enough" without then it is both easier and cheaper :)

I tested a few different values on the website mentioned earlier - http://sim.okawa-denshi.jp/en/OPseikiLowkeisan.htm



With the values:
* R2 = 300
* C1 = 22nF
* C2 = 1nF

I got the following results (R1 is Zout in my case):
* Zout=6k  => Fc=25kHz, Q=1.00
* Zout=9k  => Fc=21kHz, Q=0.83
* Zout=12k => Fc=18kHz, Q=0.72

Unless I got something wrong somewhere, this is good enough for me, the Q=1 is a bit high but I doubt the impedance will go as low as 6k.
« Last Edit: October 28, 2020, 02:44:49 pm by simonlasnier »
 

Offline Jan Audio

  • Frequent Contributor
  • **
  • Posts: 820
  • Country: nl
Re: Audio filter: non inverting Sallen-Key with bias, is it possible?
« Reply #7 on: October 28, 2020, 02:55:19 pm »
Hi, it is possible, if you have rail to rail opamp ( if the DAC is from 0 to 5v )

You have to look to your ripple.
A cleaner lowpass is 2 RC filter behind eachother ( resistor then cap to ground twice, then into opamp buffer )
Then it dont give something extra to your waveform.
 

Offline SaimounTopic starter

  • Frequent Contributor
  • **
  • Posts: 564
  • Country: dk
Re: Audio filter: non inverting Sallen-Key with bias, is it possible?
« Reply #8 on: October 28, 2020, 03:01:15 pm »
Thanks for the answer. The opamp is +/-0.2V and I can adjust the output of the DAC to match it.

I am not sure what you mean by "look to your ripple" though?  ???
 

Offline Jan Audio

  • Frequent Contributor
  • **
  • Posts: 820
  • Country: nl
Re: Audio filter: non inverting Sallen-Key with bias, is it possible?
« Reply #9 on: October 28, 2020, 05:06:52 pm »
I have to make a topic about this then i learn, i dont know.
What i know is there can be a ripple in that 2 pole filter schematic.
If you use the other filter it does not add some very small extra waveform to your original waveform.
As audio purist bla bla, if you dont care about the original shape then go ahead.
 

Offline srb1954

  • Super Contributor
  • ***
  • Posts: 1107
  • Country: nz
  • Retired Electronics Design Engineer
Re: Audio filter: non inverting Sallen-Key with bias, is it possible?
« Reply #10 on: October 28, 2020, 08:01:24 pm »
Fair enough - I am not against the idea of using an extra buffer, but if I can get "good enough" without then it is both easier and cheaper :)

I tested a few different values on the website mentioned earlier - http://sim.okawa-denshi.jp/en/OPseikiLowkeisan.htm



With the values:
* R2 = 300
* C1 = 22nF
* C2 = 1nF

I got the following results (R1 is Zout in my case):
* Zout=6k  => Fc=25kHz, Q=1.00
* Zout=9k  => Fc=21kHz, Q=0.83
* Zout=12k => Fc=18kHz, Q=0.72

Unless I got something wrong somewhere, this is good enough for me, the Q=1 is a bit high but I doubt the impedance will go as low as 6k.
Just looking at the calculated Fc and Q figures doesn't give you a full picture as the frequency response and transient response are affected by both parameters.

If you do a SPICE simulation using LTSpice or similar you will see the cut-off frequency, which for a Butterworth filter it is defined as 3dB down from the low frequency gain, varies over a greater range than the calculated Fc figures above would indicate.  This is due to the effect of the considerable peaking in the frequency response produced by the higher Q values.

The variation of the Q figure has a considerable effect on the transient response as well. With a Q of 1.00 you will get a considerable overshoot on the step response, about 17%, whereas the overshoot with a 2nd order Butterworth filter should only be about 5%.

All these figures will get worse if you include the tolerances in the the other passive components. To get the full picture you need to do a Monte-Carlo analysis with the SPICE simulator to test all combinations of component values over their respective tolerance ranges.

Lastly, I wouldn't rely on your assumption that the output impedance won't drop below 6k. It could go lower and the fact that the manufacturer didn't specify a lower limit on this indicates that it is not a well controlled parameter.

 

Offline SaimounTopic starter

  • Frequent Contributor
  • **
  • Posts: 564
  • Country: dk
Re: Audio filter: non inverting Sallen-Key with bias, is it possible?
« Reply #11 on: October 29, 2020, 03:43:47 pm »
Ok thank you for the information :)

I guess the whole problem here is I do not have a minimum value for Zout - is there any ways to have an idea, based on temperature or like?

Also when I read your message I am starting to think that maybe I misunderstood what the overshoot is: for me it is just the fact that a bit before the cut frequency the gain goes positive - e.g. here as you said getting a gain of 1.17 around 22k. Is that correctly understood or is there more to it?
 

Offline srb1954

  • Super Contributor
  • ***
  • Posts: 1107
  • Country: nz
  • Retired Electronics Design Engineer
Re: Audio filter: non inverting Sallen-Key with bias, is it possible?
« Reply #12 on: October 29, 2020, 09:15:06 pm »
Ok thank you for the information :)

I guess the whole problem here is I do not have a minimum value for Zout - is there any ways to have an idea, based on temperature or like?

Also when I read your message I am starting to think that maybe I misunderstood what the overshoot is: for me it is just the fact that a bit before the cut frequency the gain goes positive - e.g. here as you said getting a gain of 1.17 around 22k. Is that correctly understood or is there more to it?
No, there is a lot more to it.

Overshoot is a "time domain" effect where the filter output, when displayed on an oscilloscope and in response to a step input, initially exceeds the expected final value before falling back to the final settled value. The output level may oscillate several times above and below the desired level before finally settling to the steady value. The amount of overshoot  is defined as the maximum height of the peak, in percent of the desired output value, above the final settled value.

For example, if we start with 0V on the input of your filter and then apply a 1V step, the filter output will start increasing until it reaches a peak of 1.17V after about 24us. The initial overshoot is thus 17%. After this initial peak the output will then start decreasing again until it reaches a minimum of 0.97V at about 48us. This is an undershoot of 3%. The output of the filter will continue to oscillate up and down, at decreasing amplitude, until it finally settles at its desired value of 1V. The oscillation of the output before it settles to a final value is called "ringing".

As you are using this filter on the output of a DAC the effect of this ringing is that you can't be sure that you are seeing the correct DAC output value until the ringing has died away sufficiently to have negligible effect on the measured output voltage. The time for this ringing to die away is called "settling time" and a poorly designed filter can extend this settling time excessively. In the case of your filter design the settling time is around 100us before you can be sure you are seeing the correct output voltage within the accuracy of your 12-bit DAC.

You can explore all these aspects of the filter time domain performance by doing a transient analysis in a SPICE program.

With the filter frequency response the rise in gain before roll-off is called "peaking". The "frequency domain" response of a filter can be used to predict the time domain performance of a filter but this requires some complex maths. As a general rule though the presence of peaking on the frequency response indicates that there will be significant ringing on the filter output in response to a step input. The larger the peaking of the frequency response the larger the amplitude of ringing will be and the settling time will be longer.

The converse does not necessarily apply as the absence of peaking in the frequency domain does not guarantee he absence of ringing in the time domain. For example, a Butterworth response filter has no peaking in the frequency domain but still has a small amount of ringing in the time domain.

Again you can explore these aspects of the frequency domain performance of the filter and link them to the time domain performance by simulating the circuit in SPICE. All the figures I have quoted above are from an LTSpice simulation using the nominal component values with your "worst-case estimate" of the DAC output resistance of 6k. The performance will only get worse when you add in effects of component tolerances or allow for more variation in the DAC output resistance.



 

Offline SaimounTopic starter

  • Frequent Contributor
  • **
  • Posts: 564
  • Country: dk
Re: Audio filter: non inverting Sallen-Key with bias, is it possible?
« Reply #13 on: October 31, 2020, 06:31:36 pm »
Ohhh alright!! Thank you mister 1954! :D
That really helps, now the rest of the information on that page makes a lot more sense :)

The thing is the project is not going to play actual audio, more like short sample sounds, so I am really not bothered about the audio quality. The only reason I filter is because I read DAC outputs can generate a lot of noise outside of the 20Hz-20kHz band which should be filtered for EMC reasons.

But I actually think I have a solution which should be fine regardless of the Zout value. I know my analysis is not as thorough as a proper LTspice (I have never tried these but I will be happy to give it a go), but it gives an idea:

Still with the same diagram:

And:
* R1 = Zout
* R2 = 4.7k +/- 1%
* C1 = 2nF +/- 10%
* C2 = 1nF +/- 10%

With this config, the highest Q is for Zout=R1=4.7k, and for C1=2.2nF and C2=0.9nF: that gives me Q=0.78 and an first peak overshoot of 1.07 - which I would say is acceptable?

On the other end, the worst cut will be with the highest Zout=11.5k, C1=1.8nF and C2=1.1nF. That cuts @15kHz with Q=0.58. That means a cut of about -5dB at 16kHz which is my Nyquist frequency (32kHz samples), which is not ideal but good enough for me.
 

Offline SaimounTopic starter

  • Frequent Contributor
  • **
  • Posts: 564
  • Country: dk
Re: Audio filter: non inverting Sallen-Key with bias, is it possible?
« Reply #14 on: November 01, 2020, 06:36:27 pm »
So today I made some measurements with the MCU:
* I get a Zout of around 15k-16k - which is strange since according to the datasheet the maximum value should be 11.4k!!  :palm: The way I measured it was by measuring the voltage drop when I put a resistor at the output. I tried a few different resistors (going from 1k to 100k) and the results were quite consistent.
* By mistake, the internal output buffer was on - and it actually works perfectly fine... I got an output impedance of 700 ohms, which will work fine with my setup. But I guess I gotta trust the datasheet and turn it off (ON is the default setting though  ::) ).
 

Offline mikerj

  • Super Contributor
  • ***
  • Posts: 3292
  • Country: gb
Re: Audio filter: non inverting Sallen-Key with bias, is it possible?
« Reply #15 on: November 01, 2020, 07:10:22 pm »
Did you try measuring the output impedance over the full DAC range?
 

Offline srb1954

  • Super Contributor
  • ***
  • Posts: 1107
  • Country: nz
  • Retired Electronics Design Engineer
Re: Audio filter: non inverting Sallen-Key with bias, is it possible?
« Reply #16 on: November 02, 2020, 03:50:31 am »

The thing is the project is not going to play actual audio, more like short sample sounds, so I am really not bothered about the audio quality. The only reason I filter is because I read DAC outputs can generate a lot of noise outside of the 20Hz-20kHz band which should be filtered for EMC reasons.

The function of the filter on the DAC output is not to reject EMC but to reconstruct the original analog waveform from the sampled output of the DAC. The sampled DAC output contains aliased copies of the desired output spectrum at multiples of the sampling frequency. The analog filter removes these aliased copies to restore the desired output spectrum.

With the 32kHz sample rate you really need a better performing filter than what you have designed if you want to get a reasonable quality analog output signal. A 2nd order filter which is -5dB at 16kHz will be no better than -17dB at 32kHz so you are not going to properly remove the aliased spectral content.

At the sample rates you are using the DACs themselves won't generate any significant EMC, which usually only becomes a problem for frequencies above 500kHz. Any EMC problems you have will come from the microprocessor itself because of the higher speed clocks it uses.

In any case you will find that the analog filter doesn't perform very well at rejecting higher EMC frequencies due to limitations of the op amp. It is misleading to rely on the attenuation curves from the filter design app as these figures are probably calculated on the assumption that the op amp is ideal i.e. it has infinite gain, infinite input impedance, infinite bandwidth and zero output impedance. If you simulate the circuit properly in SPICE with a realistic op amp model you will find that the filter performance will likely start to degrade considerably above 100kHz making it useless for EMC control.




 

Offline SaimounTopic starter

  • Frequent Contributor
  • **
  • Posts: 564
  • Country: dk
Re: Audio filter: non inverting Sallen-Key with bias, is it possible?
« Reply #17 on: November 02, 2020, 08:26:09 am »
Ok that is interesting, thank you :)
And very good point about the limtations of the opamp, I did not think about that! I guess I really need to get into proper circuit simulation, then!

But going back to my case, what is the point of trying to reconstruct the original analog waveform, since we cannot hear what is been filtered anyways (>20kHz)? Is it because those high frequencies could use/damage a loud-speaker?
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf