Analog filters used with digital sampling/signal acquisition.

GroupDIY Audio Forum

Help Support GroupDIY Audio Forum:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.

Analog_Fan

Well-known member
Joined
Mar 22, 2022
Messages
493
Location
Universe
Salen key filter.jpeg


1677334814431.png

Second-order Butterworth low-pass filter circuit.​


I wanna build a R2R array using cmos ic's, i got at home (SPI in broadboard is not working in my case).

What's the difference between the Sallen Key and 2nd order Butterworth Filter?
accep the 2 additional resistors they look the same.
Is it a hi pass filter and low pass filter combined?
To me it looks like a hi pass filter in the feedback of the opamp.

I made a "simulation" using the upper Sallen Key filter and concluded it makes the "angled" digital output more organic or so.

https://en.wikipedia.org/wiki/Butterworth_filterI'm not familiar with the math of these filters, appart from the known cutoff formula.

What component values would i need to use for 20 - 20kHz?
Later to be used on a MCP4921 DAC.






AN699 Anti-Aliasing, Analog Filters for Data Acquisition Systems

https://ww1.microchip.com/downloads/en/AppNotes/00699b.pdf
 
Thank you...

Sallen and Key are popular active 2 pole filters that are relatively simple to implement. I did a lot of work with filters back in the 70s when I was designing BBD delay lines and needed to execute anti-aliasing, and anti-imaging (output smoothing) filters.

This may be over analysis but one thing that concerns me about that topology for LPF in removing HF content is that input LP capacitor has to sink all of the above band noise into the op amp's output. In the real world, especially back in the 70s. op amp outputs weren't that low impedance at very high frequencies. For modest frequency applications it is probably OK but I preferred active topologies where the input LP pole is sinking the out of band HF noise to a real ground.

This is my bench experience from almost 50 years ago so take it with a grain of salt.

JR
 
I saw someone convert using Audicity, Bin2Hex to make a voice sample from a famous movie and other.
Saw on the scopes from people that when the DAC changes values you get spikes.

initially (in the upper image) in the sallen key filter, i saw a low pass setup just before the input of the opamp.
R2/C2, but i see R1/C1 as hi pass, since the capacitor is in the opamps feedback.
Not sure if that correct?

What math should be needed for plain audio?
To find the values of the components?
R1/C1, R2/C2.

to pin point the correct components rather soldering and desoldering parts, risking damage, etc to find good ones.

This is what the microchip application note says:
The active filter offers the advantage of providing “isolation” between stages.

Don't need any gain or so, just smooth transistion between stages.
added a schematic.

gonna use a R2R and got a few 74HC174 i got laying around to build a 12bit.
doesn't require to assign and setup pins in the MCU, like UART, SPI, etc, in 32 bits pic's.
Don't have made a dedicated pcb.
 

Attachments

  • Analog DAC.pdf
    13.3 KB · Views: 1
Some terminology clarifications:
Your question is actually about filters for signal reconstruction, not signal acquisition. The difference can sometimes be important because the signal properties of an analog input to an A/D converter could be much different than the signal properties at the output of a D/A converter sent into the filter.

What's the difference between the Sallen Key and 2nd order Butterworth Filter?

Sallen-Key refers to a circuit topology, i.e. the types of components and how they are connected together.

Butterworth filter refers to the frequency and phase response of a filter, which is determined by the component values. The frequency and phase response of a filter is sometimes referred to as the filter "alignment" as shorthand.

Sallen-Key circuits can have many different alignments, the most common being Butterworth, Bessel, and Chebyshev, named for the people who developed the mathematical description of each type of filter response.

Butterworth alignment filters can be made from several different circuit topologies, sallen-key being one common variety.

accep the 2 additional resistors they look the same.

The 2 additional resistors just adjust the overall gain of the circuit, they do not have an effect on the overall frequency specific behavior.

To me it looks like a hi pass filter in the feedback of the opamp.

That is probably a good description. The capacitor in the feedback loop increases the amount of high frequencies fed back to the input, and the result is lower gain at high frequencies. That is only the case over the frequency range where the op-amp has substantial gain, so if you measure over a wide enough frequency range the amplitude response does not continue to decrease with increasing frequency forever. At some point the amplitude response will begin to flatten, and even rise again at higher frequencies.

I wanna build a R2R array using cmos ic's

There are resistor companies which make R2R resistor arrays in a single package. The advantage is better matching of resistor values between the different resistors in the R-2R ladder.

What math should be needed for plain audio?
To find the values of the components?

A good search term is "active filter design" if you would like to learn how to design filter circuits.
Texas Instruments makes software to help design active filters. Analog Devices and other vendors likely do as well.
TI Filter Designer software
 
Thank for for the extended answer.


A good search term is "active filter design" if you would like to learn how to design filter circuits.
Texas Instruments makes software to help design active filters. Analog Devices and other vendors likely do as well.
TI Filter Designer software


what type of flter do i need to choose?
https://webench.ti.com/filter-design-tool/filter-type
There are resistor companies which make R2R resistor arrays in a single package. The advantage is better matching of resistor values between the different resistors in the R-2R ladder.


Yes, i saw that in the Roland Juno-106, thnx for pointing that out, is also a lot smaller package than normal resistors.
I'm aiming for 5K/10K, around 200 micro amp, what values do you suggest?

they all lead to the same datasheet (Bourns)
https://nl.mouser.com/datasheet/2/54/r2r-1018811.pdfall are 8 bit, aiming for 12 or 16 bit.

lol, not so easy, if you have one value, they don't have the other, if you decide for 5/10k.
: )

roland tb-303 CV converter.jpegRoland Juno-106 cv converter.jpeg

Why has Roland used the aditional "CD4050" buffers on the high side of the R2R array?
Do the "new" 74hc series alos need these extra buffers vs the one made at the final 70ties, begin 80ties? or are they suffiently designed to deliver power?


I have a formula taken from an arduino library, it uses a look up table of 360 elements, one element per degree.
You would be looking at 4.515.480 Hz of switching for the highest note on a "midi" keyboard.
 
Both are low-pass.
Ah Thanks, than 1/(2 x PI x R X C) should be suffient.

Make them cutoff anything higher than 20kHz.
But some people on here mentioned that impedance is also a factor and you need need to seek a different cuttof point.
Not sure, it's not my daily activity.

Unity gain means 1:1, right?

What you mean be the second is "gain"?
That i get a amplitude drop?

"researchgate.net"
saw this page a couple of times before, not sure what to to think of it.
Valueable or not.
 
Ah Thanks, than 1/(2 x PI x R X C) should be suffient.
Barely. Th eratio between caps governs the shape of response.
You must read about filters, damping and the B'worth, Chebychev, Legendre, Bessel,... variations.
But some people on here mentioned that impedance is also a factor and you need need to seek a different cuttof point.
Impedance always matter, but the cut-off point is governed by other constraints.
Unity gain means 1:1, right?
Correct.
What you mean be the second is "gain"?
That i get a amplitude drop?
On the contrary, output evel is higher than input.
 
what type of flter do i need to choose?

You said previously you needed a low pass filter. That is appropriate for a reconstruction filter for a D/A converter.
For what you are doing a Butterworth alignment would be common, it has a good balance of flat frequency response and reasonably fast roll-off. Bessel has better phase behavior, but slower roll-off. Chebyshev has faster roll-off, but has less flat frequency response.

The filter tool at TI WebBench that you linked will let you compare the three alignments with the same bandwidth, and compare the frequency, phase, and step responses on the various tabs of the page.

all are 8 bit, aiming for 12 or 16 bit.

You are likely to find only 8 bit arrays, at least that is all I saw at Digikey and Mouser, the two most commonly used component distributors in North America. There was even a sales page from one vendor which mentioned 12 bit devices, but when looking at the product pages they only produce 8 bit devices currently.

When you get to 16 bits it is very difficult to match resistors well enough that the step size for each bit is the same. That is why most manufacturers of D/A converter devices stopped using that technique around 30 years ago, it was just too difficult and expensive to get the accuracy needed for 16 bit and higher bit depth devices.

Why has Roland used the aditional "CD4050" buffers on the high side of the R2R array?

Probably as you guessed the older devices could not supply the current needed reliably. Newer devices should be better, especially if you use a device made as a bus driver (which means it is made to drive multiple loads from each output).

it uses a look up table of 360 elements, one element per degree.
You would be looking at 4.515.480 Hz of switching for the highest note on a "midi" keyboard.

More common would be to keep the same sample rate, and modify the lookup table for each frequency. That would also allow you to add values together from different lookup tables to generate multiple frequencies simultaneously.
 
You are likely to find only 8 bit arrays, at least that is all I saw at Digikey and Mouser, the two most commonly used component distributors in North America. There was even a sales page from one vendor which mentioned 12 bit devices, but when looking at the product pages they only produce 8 bit devices currently.

When you get to 16 bits it is very difficult to match resistors well enough that the step size for each bit is the same. That is why most manufacturers of D/A converter devices stopped using that technique around 30 years ago, it was just too difficult and expensive to get the accuracy needed for 16 bit and higher bit depth device


Thanks for the clarification, i thouhgt of using a jumper to enable 12 or 16 bits.

More common would be to keep the same sample rate, and modify the lookup table for each frequency. That would also allow you to add values together from different lookup tables to generate multiple frequencies simultaneously.

That's what i'm trying to figure out.

https://en.wikipedia.org/wiki/MIDI_tuning_standard
"The frequency range starts at MIDI note 0, C = 8.1758 Hz, and extends above MIDI note 127, G = 12543.854 Hz."

round(12543.854) = 12544 x 360 = a switching frequency of 4515840 Hz.
Witch is something 74hc series ic can do.
The best is probably 74HC574.
Only the B port on the PIC32MX270F256D is 16 bit, but also has both I²C and i need those.
Port C is 8 bit and is free.

Than 48000000 ( clock of PIC ) ÷ 4515840 = 10,629251701 (prescalle value of pic timer1)
Nasty floating point numbers.

I did some reading: Wavetables and samplers

What you propose is having a steady stream of like 48kHz and some how blend in you look up table.
Not sure how to do this and will probably end up with floating point numbers.
That something i wonder about, how did they do/did it in my Waldorf Micro Q?

I'm thinking of using a "programable counter" for a second oscilator on the pic, where you normal connect a 32.768 hz to.
Porbablly easier to use than a onboard timer with prescale and stuff.

I found a cool stereo Audio codec, A cirrus Logic CS4272.
But has differential input, not sure what to do with that.
Many registers to setup.

Another one is AKM, but requires something more than a pic32mx270F256D.
like having 4 x spi.

Using 74hc is a cheap experiment, not requiring much software handeling to setup a real DAC or Audio codec.
The only bad part is mouser forces you to be 50€ for free shipping and i only need 3 parts.
: )

Maybe not precise as you mention, but gives it charrecter.
I really would like to try the "brute force" approach.
 

Attachments

  • CS4272_F1-1141881.pdf
    1.5 MB · Views: 0
Sallen-Key is a circuit. Butterworth filter is a mathematical approximation of the ideal filter. In particular, Butterworth filters make use of Butterworth polynomials, and these filters have the property that are maximally flat at the origin (0 Hz or Dc in this case). Bessel filters make use of Bessel polynomials, which create filters with maximally flat group delay response. Chebyshev filters make use of (suprise, surprise) Chebyshev polynomials, in particular these produce an equi-riple response in the pass band, which is the product of minimizing the maximum error norm. The are other filters like Cauer or Elliptic filters, which make use of Jacobi Elliptic Functions, these type of filters produce ripple both in the pass band and stop band. There are others, but they are not as common in audio as the ones I just mentioned.

A second order Butterworth filter has a Q = 1/sqrt(2), whilst a second order Bessel has Q = 1/sqrt(3), in the case of the Chebyshev filter, the Q varies depending on the selected amount of ripple in the passband.

A Sallen-Key circuit can be used to implement Butterworth, Bessel or Chebyshev (Type I) filters, but not Cauer, nor Chebyshev Type II.

The ideal filter cannot be realized due to something called the Paley-Wiener theorem or Paley-Wiener criterion (P.S. Paley was 26 y/o when he died). An ideal filter is such that it completely cuts all frequencies after a certain frequency, but leaves all other frequencies untouched, and its phase variation is linear, which means that every frequency gets delayed the same amount of time. Something that very closely approximates an ideal filter is a FIR digital filter of high order.

"Filter Math" is very hard and not for the faint hearted.
 
Last edited:
polynomials
Thank you for the info,

need to buy a dictionary
: )

i only want to filter out the digital artifacts of switching the 74hc574 between values or transistion, spikes.
Spikes you see in video from people on YouTube that have build a r2resistor array.

"Filter Math" is very hard and not for the faint hearted
Math aint the problem, but it's not something you do everyday.

They present: E = MC², but's it actually E = M x C².
Than you have to look up values of the variables to be able to complete the formula.
Kinda abstract.

If you check on these filters on wiki, the talk about Degree of Radiants and stuff.
The local libray althouhg a pretty building, lots of screens around, has nothing on this stuff, accept the basics, like how to build a led circuit.
I asked someone familiar to most of us, but i got a rude answer, entering a university is very expensive and would require reading/learning a lot before getting the actual info.

https://en.wikipedia.org/wiki/Butterworth_filterScreenshot 2023-03-02 at 17-26-28 Butterworth filter - Wikipedia.png
Don't know the meaning these roman or greek signs.
: )

these filters are present in the datasheet of ADC/DAC ic from microchip.

Should i calculate a cut of point of 20kHz or 41kHz?

Wanna use a simple circuit, it's CHEAP but switch it very very fast, hence the look up table ot 360 elemens.

using:

https://nl.mouser.com/ProductDetail/652-4608X-102-103FLF (1% 10K)

https://nl.mouser.com/ProductDetail/652-4608X-102-203FLF (1% 20K)
 
Last edited:
Thank you for the info,

need to buy a dictionary
: )

i only want to filter out the digital artifacts of switching the 74hc574 between values or transistion, spikes.
Spikes you see in video from people on YouTube that have build a r2resistor array.


Math aint the problem, but it's not something you do everyday.

They present: E = MC², but's it actually E = M x C².
Than you have to look up values of the variables to be able to complete the formula.
Kinda abstract.

If you check on these filters on wiki, the talk about Degree of Radiants and stuff.
The local libray althouhg a pretty building, lots of screens around, has nothing on this stuff, accept the basics, like how to build a led circuit.
I asked someone familiar to most of us, but i got a rude answer, entering a university is very expensive and would require reading/learning a lot before getting the actual info.

https://en.wikipedia.org/wiki/Butterworth_filterView attachment 105769
Don't know the meaning these roman or greek signs.
: )

these filters are present in the datasheet of ADC/DAC ic from microchip.

Should i calculate a cut of point of 20kHz or 41kHz?

Wanna use a simple circuit, it's CHEAP but switch it very very fast, hence the look up table ot 360 elemens.

using:

https://nl.mouser.com/ProductDetail/652-4608X-102-103FLF (1% 10K)

https://nl.mouser.com/ProductDetail/652-4608X-102-203FLF (1% 20K)
Omega (the one that looks like a w) is called the angular frequency, it is just 2*pi*f, where f is the frequency in Hz. If you select a cut off point at 20 kHz, not only are you going to be attenuating 3dBs at 20kHz, but you will also attenuate frequencies lower than 20kHz. You don't want to do that. I don't know your application, but the cut off frequency should be selected based on the order and type of filter being used (Butterworth, Bessel, etc...), the maximum allowed attenuation in the pass band, and the minimum allowed attenuation in the stop band.
 
"Filter Math" is very hard and not for the faint hearted.
I am not a math head, pretty much the opposite but there are many simplified formulae around to help us design practical filters. I learned practical filter design back in the 70s from reading -"Burr Brown Operational Amplifiers Design and Application" Tobey, Graeme, Huelsman. I even wrote a computer program back then for my old H-11 computer to calculate the combined response of multiple cascaded stages with real values plugged in.

Over the decades I have designed many filters some pretty hairy unconventional*** filter alignments. There are probably easier more accessable books written in the decades since that old Burr Brown classic.

JR

**** [TMI] for TMI the hairiest filter alignment I ever did was around an analog shift register inside a BBD delay line. In addition to the anti-aliasing needed for clean analog BBD sampling, I included output smoothing (anti imaging). Further I incorporated HF pre-de/emphasis a common NR technique to reduce the apparent noise floor of the BBD with HF boost before and HF cut after. As if that wasn't complex enough I used the Chebyshev alignment that combines multiple underdamped active filter stages (peak before they roll off), with one real RC pole tuned for roughly .66x of the combined filter tuning. This real pole at .66x was placed right at the output of the BBD to absorb clock noise. [/TMI]
 
I don't know your application
Just build a simple & cheap R2R array for a digital VCO / sampler.

Check this video from Bitluni
DAC using R-2R resistor ladder

(start at the scope section of video and see the spikes and "distortions", 5min44).

I want to place this filter behind the dac in order to have a somewhat clean / smooth output with the spikes removed.
Salen key filter.jpeg

I could soldering / desoldering parts, till i get it somewhat right.
But would be cool to know what you doing, in the ball park.

(Bitluni) Arduino audio sampling tutorial (part 1) on YouTube

(Bitluni) Arduino audio sampling tutorial (part 2) on YouTube
 
I don't know your application

This appears to be a synthesizer type device with an R2R DAC built from discrete parts. I think a few dB attenuation at 20kHz is going to be the least issue. Of course no problem changing to 30kHz or whatever is desired, as long as the sampling rate is high enough.
Seems like a fun learning project.
 

Latest posts

Back
Top