4th order active filter output HF harmonics - Page 1
Forum section: electronics / projects

author: Verdefluox
author_rank: Contributor
timestamp: October 07, 2023, 02:58:59 pm
content: Hi folks,I'm trying to convert a 12 bit PWM from an Arduino Nano into a DC voltage. The PWM is generated from an Arduino uno via some software tweaking, but unfortunately it's limited to a very low frequency square wave (around 3906 Hz) with variable duty.The filter I'm trying to use is a 4th order low pass active filter using just one op-amp (as in attached figure, with values given; opamp is a classical LM324 powered with +-10 V), and my goal is achieve a low ripple DC voltage (maximum 2-3 mV, since my goal is to generate voltages with 2 decimals, i.e. 2.56 V; hence I would like some headroom).Test in LTSpice works as expected, even though for now I just tried to pick some values and test them into the simulator until I get something satisfactory.When testing a mounted circuit, I obtain a ripple of around 10 mV pk-pk as in scope figure (I'm using an Hantek 6022BE), and I can't figure out where does this come from.Mind that for now I arranged the component just by the space I have available, and I don't know if here the displacement plays an important role given the already low frequencies involved.Just out of curiosity, I tried to place a bigger cap directly at the opamp output, and the problem goes away, but before throwing caps for nothing I would like to understand where does this come from.How can I get rid of that?A last note: since I mounted the circuit on a perf board I don't actually have a PCB layout, but I still drew it on paper so that you have an idea on how it is soldered on the back.In case you need some additional info let me know, but I hope that I didn't miss any detail.

author: mawyatt
author_rank: Super Contributor
timestamp: October 07, 2023, 04:37:48 pm
content: The op amp model is likely just an idealized model. The LM324 and similar (LM358) have a quirky output structure with a large "dead zone". With the filter structure shown, the feedback coupling caps provide a forward path for pulse glitches to the output which isn't really close to ideal (read zero impedance), and thus couple thru, C12 likely is the biggest culprit!We published something about this long ago in EDN which plagues all Sallen-Key (VCVS) types, the simple solution to the output "dead zone" issue with the op-amp is to "load" the output with a shunt resistor to either VCC or VEE, this forces the output into a more class A type and reduces the dead zone and dynamic output impedance. A Pull Down Resistor to VEE is generally better if the signal doesn't need to swing up close to VCC, other wise then a Pull up to VCC is better.Another simple solution is add an emitter follower (2N3906 or 2N3904) to the output. Either NPN or PNP work with attention to output swing range. Of course one could add a Class A/B biased output buffer, but that gets a little more complicated, and maybe using a different op-amp is a better solution.Forgot to mention, adding a small resistor in series with each feedback capacitor also helps, as this provides a fixed impedance for the forward glitch pulses while working against the output impedance. ~200 ohms might be a good start.Anyway, hope this helps.BTW what does this active filter frequency response look like under simulation?Best,

author: moffy
author_rank: Super Contributor
timestamp: October 07, 2023, 09:11:11 pm
content: Just use a fourth order passive, you are not worried about sharp roll off or phase and then use the opamp as a buffer.

author: RFDx
author_rank: Regular Contributor
timestamp: October 07, 2023, 09:36:46 pm
content: Quote from: Verdefluox on October 07, 2023, 02:58:59 pmLooks like 5th order LP-filter. High frequency components from the PWM reach the output by bypassing the filter through C11 and especially C12. Use two separate op-amps in non-inverting unity gain configuration. The first solely for the feedback and a second one that buffers the voltage at C8.

author: Benta
author_rank: Super Contributor
timestamp: October 07, 2023, 10:16:32 pm
content: Sallen-Key filters are very popular, promoted in many books, and very miserable. I avoid them like the plague.What you've concocted I don't want to analyze, but:If you just want DC, what's wrong with a simple integrator? Do you need a certain response time?

author: srb1954
author_rank: Super Contributor
timestamp: October 08, 2023, 01:26:57 am
content: Quote from: moffy on October 07, 2023, 09:11:11 pmUsing a passive filter you will get a sharper roll-off and less settling time if you increase the resistance and decrease the capacitance for each subsequent stage so that there is less loading and less interaction between the RC stages.With the active filter configuration shown it has the poor performance of a passive filter with identical stages plus the problem of the higher frequency components bypassing the filter via C12 due to the inherent limitations of a Sallen & Key filter with a less than ideal op-amp.

author: mawyatt
author_rank: Super Contributor
timestamp: October 08, 2023, 03:14:13 pm
content: Here's something folks might find interesting and somewhat relevant. A 3rd Order Butterworth type LPF with equal valued components, also published in EDN long ago. See post #18https://www.eevblog.com/forum/projects/opamp-follower-and-sallen-key-filter-behaving-strange/msg4912561/#msg4912561Best

author: T3sl4co1l
author_rank: Super Contributor
timestamp: October 08, 2023, 05:13:35 pm
content: LM324 sucks, yeah. You can improve it somewhat by biasing the output: pull it up or down (to +/-V) strong enough so that the output pin current does not reverse over any expected signal swing and load condition. This prevents crossover distortion at the output.Personally, I stock TLV2372 for this reason -- it's essentially the perfect general-purpose / jellybean type, though still more expensive than a jellybean proper. Perfect in that it has rail-to-rail input and output (RRIO), 16V rated (perfectly fine for 12V projects; not suitable for +/-15V say, but those are few and far between these days, and just use a TL072 or whatever in that case), and conventional specs (couple mV Vos, couple MHz BW). Free of weird behaviors (no input reversal, no unusual saturation recovery, no crossover distortion), modest current consumption.Especially since you have four amps on the one chip, consider breaking that up to a pair of 2-3 order filters. Higher order single stages are possible, but they are increasingly sensitive to component values; evidently you have accurate enough components to pull it off, but you'll get better flexibility this way, plus more attenuation at high frequencies -- where the op-amps aren't amping so well anymore (loop gain is under 100 by 10kHz or so: gain-bandwidth (GBW) means the two are directly proportional, gain reaching one at the GBW frequency itself).Cascading two filters means you double the asymptotic / HF cutoff attenuation. You also have the opportunity to add another real pole, if you don't mind it gives a non-standard response (all standard filter types have at most one real pole, when order is odd, and zero otherwise). Maybe make one of them modestly higher than Fc, so it doesn't skew the response (transition band, or step response) of the overall filter.Another consequence (somewhat equivalent to GBW) is the amp's output has an inductive characteristic at high frequency: its output is normally low-Z due to feedback, but as gain falls off, Z rises towards the normal impedance determined by the gain/output stages without feedback. Z rising with F means some inductive reactance. Which understandably has two problems with your filter: 1. it was designed on the assumption that the output is ideal; 2. you have a direct RC path from input to output, i.e. there is a feedforward term, a zero in the transfer function, proportional to amp Zo.Loading the output with a cap and nothing else, is generally frowned upon: it tends to make an oscillator. You can occasionally get away with it (LM339, a comparator, is sometimes presented as a potential op-amp substitute when so "compensated", though I think even for low-ESR 10uF bypass, it still oscillates, just at very small signal level (~mV)...), but preferably an R+C should be used, so that even at high frequencies, some resistance is present and the amp doesn't break into oscillation. Which means your feedforward divider isn't going to be ideal (amp Zo won't go to zero), but it can be better than the amp alone (usually Zo rises to 100s ohms to a few kohm, as frequency approaches GBW; dropping that to say 47-100 ohm is definitely an improvement).Tim

author: Doctorandus_P
author_rank: Super Contributor
timestamp: October 08, 2023, 06:51:00 pm
content: Apart from the suggestions already mentioned.Filters with all R's equal and all C's equal do not work properly. When you are far away from the "corner" frequency, they all have a rolloff of 20dB per decade for each additional order. However, a quick calculation shows that your "corner" frequency is somewhere around:>>> 1/(2*pi*47e-9*10e3)338HzWhich is only one order of magnitude below your PWM frequency, and that makes proper filter design necessary.You are using some spice variant. A good practice is to use a simple 3 order passive filter, and then increase the impedance of each consecutive stage. For example, first use 3 1k resistors, then use 1k, 3k3 and 10k. Also repeat with 1k, 10k, 100k, and with 1k, 100k, 10M and then observe the changes in your filter.Also, there are some nice articles on EDN on PWM filtering techniques. One of the techniques uses an opamp as a -1 amplifier, and it's output is then AC coupled into the output signal.https://www.edn.com/cancel-pwm-dac-ripple-with-analog-subtraction-revisited/EDN also has a bunch of other articles on filtering PWM. It's well worth spending some time there.

author: mawyatt
author_rank: Super Contributor
timestamp: October 08, 2023, 08:03:04 pm
content: Quote from: Doctorandus_P on October 08, 2023, 06:51:00 pmMentioned above in #6, not true for the equal valued filter we developed way back and published much later in EDN (probably late 1980s). This in LPF form has the 60dB/dec roll off of a 3rd Order Classic Butterworth response as shown here (note low pass response).https://www.eevblog.com/forum/projects/opamp-follower-and-sallen-key-filter-behaving-strange/msg4912561/#msg4912561Note the normalized S^3 + 2S^2 + 2S + 1, the Butterworth polynomial.Best,

author: Benta
author_rank: Super Contributor
timestamp: October 08, 2023, 08:49:36 pm
content: So, three opamps for three poles, just to have equal R and C values?Not really efficient to my mind.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: October 08, 2023, 09:09:22 pm
content: Keep in mind where mawyatt is coming from... those are probably single PHEMT amplifiers and takes optimal die space for a 10GHz filter.Tim

author: mawyatt
author_rank: Super Contributor
timestamp: October 08, 2023, 09:10:08 pm
content: Quote from: Benta on October 08, 2023, 08:49:36 pm4 op-amps come in a single package, small, inexpensive. To get multiple values of precision capacitors is likely more expensive, or even requires utilizing multiple values in parallel since the traditional 3rd order filters have highly differing values that don't necessarily fall on the standard tables values.We needed very precise highly matched filters for our work back then (sometimes still do), and this was the driver behind developing this unique filter. One can eliminate 1 op-amp by moving the input RC to the output if a high Z output is acceptable.The op-amps can be eliminated all together, as someone long ago just used emitter followers as they didn't need a precise Butterworth response in a commercial Doppler automotive radar application.Best,

author: mawyatt
author_rank: Super Contributor
timestamp: October 08, 2023, 09:19:35 pm
content: Quote from: T3sl4co1l on October 08, 2023, 09:09:22 pmFunny!!Altho we did do some active filter work at GHz frequencies with custom SiGe based Op-Amp types.DARPA even sponsored Northrup Grumman (I believe) to developed Ultra High Gain Bandwidth Op-Amps in InP for use with such and other various applications. Many folks back then were pushing well into the Microwave and MMW regions with old low frequency analog techniques by employing advanced high frequency semiconductor technologies, I know we certainly did such, altho not with PHEMTsBest

author: T3sl4co1l
author_rank: Super Contributor
timestamp: October 08, 2023, 09:33:16 pm
content: Ah sure, SiGe more likely.Fun thing about that (probably not related to such programs at all, just a similar idea behind it), there's a number of opamps from ADI (and probably many others now, I'm just familiar with the one example) with, very ordinary specs, like 18V, 10MHz, couple mV offset, etc., but like a third the usual supply current. Peek into the description, it's on their XFCB something or other process. Blazing SiGe tamed down to low currents for jellybean amps. Fun.Tim

author: Benta
author_rank: Super Contributor
timestamp: October 08, 2023, 09:44:32 pm
content: Quote from: mawyatt on October 08, 2023, 09:19:35 pmI agree, I chuckled as well.But the OP has not reported back until now, so no one has any idea of the design constraints here.Perhaps a simple integrator can really do the job?If not, a 4th order LP filter using two MFB sections is far superior to what else has been proposed.AoE (X-Chapters) even shows a smart way of reducing settling time by using a second cap plus an inverter.Lots of possibilities.And really, it's 3.9 kHz PWM, not rocket science.

author: mawyatt
author_rank: Super Contributor
timestamp: October 08, 2023, 09:54:57 pm
content: Quote from: T3sl4co1l on October 08, 2023, 09:33:16 pmADI probably got the SiGe recipe from IBM, they started the whole thing back before 1990. Adding selective Ge to Si isn't expensive if one doesn't count the UHVD machine cost.BTW we found out about IBM SiGe from ADI, they built a 12 bit ADC in SiGe as a demonstration of analog type use back in 1990 when IBM was trying to find a use since they decided not to use SiGe for a fast single core ECL based CPU for the future IBM360 replacement.Didn't take us long to figure out what to do with it thoBest,

author: Benta
author_rank: Super Contributor
timestamp: October 08, 2023, 10:02:35 pm
content: OK, thread derailed completely by reminiscences and anecdotes.I'm out, cheers. I suggest the OP starts a new thread that'll keep on track.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: October 08, 2023, 10:21:00 pm
content: Quote from: Benta on October 08, 2023, 10:02:35 pmOn the contrary, now that all the experts have been summoned, further reply has an even greater chance of success. Anyway, the original problem has likely been addressed; drift away.Tim

author: mawyatt
author_rank: Super Contributor
timestamp: October 09, 2023, 01:43:11 am
content: Agree, think the OP got quite a bit of useful info, including the ADI XFCB processed GP type op-amps (like AD8040) to replace the lethargic LM324BTW XFCB is not SiGe, it's Complementary Bipolar on a Dielectrically Isolated wafer likely copied from Bell Labs CBICV2 and Harris Bonded Wafer UHF2 processes.Best,

author: MathWizard
author_rank: Super Contributor
timestamp: October 09, 2023, 11:51:24 am
content: Are there active filters using small numbers of BJT's ? Any time I see filters, there's passives, and then then ones with op-amps, but I've never seen the early days when they must have made something with small numbers of transistors/tubes

author: Barry Hardhouse
author_rank: Contributor
timestamp: October 09, 2023, 12:43:28 pm
content: Quote from: Benta on October 08, 2023, 10:02:35 pmI've enjoyed reading it though!

author: T3sl4co1l
author_rank: Super Contributor
timestamp: October 09, 2023, 09:39:03 pm
content: Sure. Anything you can do with a unity-gain (follower) Sallen-Key type, you can do with an emitter or cathode follower, to only a slightly poorer extent. Consider:6V6 model being used here as a stand-in for 5702 or 6AK5, which I had handy for this stage. It's around 5mS at this bias, and you could replicate it with a PN4391 or whatever JFET of similar gain. Triodes work worse here; preferably the screen would be bootstrapped to cathode to preserve gain, but the result was good enough it didn't seem worth bothering. The main consequences are, the gain being less than 1 limits maximum Q (not a problem for a ~Butterworth filter here), and the output impedance (~1/gm) allows feed-forward, in exactly the same way I described above, but the amp's output impedance is largely resistive (flat), not inductive, because there's no control/feedback process determining its impedance this time. Which limits the HF asymptote, but -40dB is still pretty good so it's fine.This applies to Wyatt's chain-of-+1's filter above, too. Making similar adjustments for lack of gain, and finite nonzero impedances.Conversely, common-emitter/source/cathode stages can be used for MFB filters, where the finite gain limits accuracy of the integrator element. The main downside for discrete stages is, if you need DC coupling, it's a lot harder to get accurate DC all the way through, without building a whole-ass op-amp in the first place.Tim

author: Terry Bites
author_rank: Super Contributor
timestamp: October 10, 2023, 05:15:21 pm
content: The grim reaper is on all our tails so:http://conradhoffman.com/4_pole_LP.zip

author: Verdefluox
author_rank: Contributor
timestamp: October 14, 2023, 03:07:03 pm
content: First of all, sorry for the delay; had a rough week and didn't manage to look at this project at all.QuoteAs simple as that, this actually solved everything.BTW I know, it was also suggested to use some other chip. I try to stay with the classics because I don't have enough knowledge yet to understand how to choose an op-amp. I'm still going with the easy things, unfortunately.QuoteThought also about this, but I already arranged the components on the perf and before finding space for additional resistors I preferred to ask.BTW I attached the output. I should have imagined that with a real op-amp situation would be different, but I didn't thought about the "dead zone".I'm not citing everyone else because you all both gave me new configurations ideas that I have to understand before, and also because I started to read all the replies yesterday and I haven't seen in depth all of them. I went with thanking the posts directly.In any case I'd like to thank everybody for their time, but for this question I'm fine with the simplest solution above. For any modification or else I'll need some other time to read everything in detail; maybe I'll write below if it doesn't pass too much time, otherwise a new post.Just a note: it was also asked if I needed a certain dynamic performance or particular constraint. In this case no, I just wanted to see if I could obtain a low ripple enough DC voltage given my PWM. I found this configuration (admitting that I don't understand it fully, so I'll have to go back to some theory) and decided to try with it mainly because it was the only opamp on the LM324 available (the others are already busy for other tasks).

author: Doctorandus_P
author_rank: Super Contributor
timestamp: October 14, 2023, 04:01:46 pm
content: Quote from: Verdefluox on October 14, 2023, 03:07:03 pmThis is very likely because as a deficiency of the LM324 (same as LM358). These opamps have some peculiarities (that can be fixed with a pull down resistor) that other opamps do not have.

author: mawyatt
author_rank: Super Contributor
timestamp: October 14, 2023, 06:24:40 pm
content: Quote from: Doctorandus_P on October 14, 2023, 04:01:46 pmThe article we published in EDN way back also noted that the ultimate stop band rejection in low pass active filters is limited by the op-amp output impedance, whatever type they are. Most GP op-amps don't have a very low open loop output Z to start with, the LM324 class is particularly bad, and as mentioned all types the output Z rises with frequency. This alone limits stop band rejection to relatively modest levels.This can be particularly troublesome for more complex types such as Elliptic, or inverse Chebshev, where one is utilizing the transmission zeros to squash a particular frequency (example the PWM rep rate).Anyway, improving the output impedance of an op-amp, especially over the frequency range of interest, generally improves the overall active filter transfer function and more closely approximates the idea function. There are many ways to improve the output Z as mentioned, some as simple as a shunt resistor, so generally worthwhile.Anyway, think the OP found an acceptable, simple solutionBest,