Do's and don't's when filtering prior to an inverting opamp

Started by hans h, August 15, 2022, 02:50:21 PM

Previous topic - Next topic

hans h

Hi fellow stompbox enthusiasts,

I've received great help here so far,  but somehow my questions keep bringing up new ones :icon_eek:

To the matter at hand: I'm still playing around with the honey bee scheme. I want to follow the Non-inverting clipper (hereafter Q1) and passive clipper by an inverting clipper (hereafter Q2), somewhat like the simplified scheme attached below.

However,  I got some weird results in ltspice with a huge negative gain at the inverting input so went digging online. There I found reference to the fact that a low pass filter at the input of an inverting opamp stage will not work as expected (sorry,  forgot to save the link to the website).

This raised the following question: will  any of the three filters (F1,  F2, F3) prior to the inverting Amp actually work? How much resistance does one need between the opamp input and the filter to make it work,  or will it not work period? And which of the resistors between noninv out and inv in count for the gain of the inverting stage?

I guess I am a little out of my depth here with my tinkering with schematics  :P any help to get my thinking straight is greatly appreciated!




anotherjim

The parallel diode clippers in the middle should either go to Vref or insert another DC blocking cap to the input of the final amp.
For gain calculation of the inverter assume the -input path parallel caps are absent and series caps are wire. I make it 33/11 or 3!


ElectricDruid

What you've got there after the output of the first op-amp looks to me like a right nightmare!

Frankly, I don't try calculating stuff when it gets that complicated. I'd simulate that to see what it was doing, and then tweak values in the sim to get the frequency response I was after. There are a lot of interactions between all those different networks.

In terms of the inverting op-amp and the lowpass filter you asked about, there's something important you need to bear in mind, which is that the -ve input acts as a "virtual ground". E.g. you can consider the 10K resistor that terminates at the -ve input as going to ground. Now, seen like that, it's clear that the 10K is therefore connected in parallel across the 22n. It also forms some crazy kind of voltage divider with the previous 10K, and the combination of the 47K/4n7/1K/220n. That's what I mean about "right nightmare", and that's why I don't calculate it.

A rule of thumb for stacked passive filters or passive filters feeding into something else like this is that you need to have a 1:10 ratio. So a filter with 10K/22n would need to feed a 100K input impedance (in your case the input resistor to -ve) as a minimum. This doesn't eliminate interactions, but it mostly keeps them down to a level we can ignore.


Jim's right about the clipping diodes in the middle too. They're separated from the bias on one side by the 1u, so they could be connected to ground, but then they're connected directed to an inverting amp which is DC-biased to Vref on the other side. That doesn't work. Either add another cap to separate them completely, or connect them to Vref not ground.

Rob Strand

QuoteHowever,  I got some weird results in ltspice with a huge negative gain at the inverting input so went digging online. There I found reference to the fact that a low pass filter at the input of an inverting opamp stage will not work as expected (sorry,  forgot to save the link to the website).

It's depends on who's expecting what.

If you had a much simpler circuit like:

     Non-inverting stage --> 4.7k resistor --> 47n to ground --->  10k resistor to inverting stage.

What you will find is, the circuit works perfectly as a 1kHz low pass filter.   The only difference is the
resistance you need to use in the calculations is R = 4.7k in parallel with 10k.   The 10k resistor
loads down the filter.

QuoteThis raised the following question: will  any of the three filters (F1,  F2, F3) prior to the inverting Amp actually work? How much resistance does one need between the opamp input and the filter to make it work,  or will it not work period? And which of the resistors between noninv out and inv in count for the gain of the inverting stage?

The way F1 and F2 are connected is fairly complicated because they connect back to the inverting input of the non-inverting opamp stage.   The filters are all connected together so they interact, in fact they interact with F3 as well.

To make things more complicated the way the filters work changes when the second set of diodes clip.   If you ask me that's the whole idea of the circuit.

I'd have to look more closely but I think the idea behind F2 is to leak some high frequencies of the clean signal through to the output when the second set of diodes clips.  That makes it more transparent.    The idea behind F1 might be to boost the bass when the second set of diodes doesn't clip.  F1 will appear across the first set of diode and the gain pot.  Perhaps F1 is compensating for the HF boost from the 1k and 220n.

F3 is just removing HF junk. from the clipper.

If you want to simulate the circuit with AC analysis:  The normal analysis would be for the case where the diodes are not clipping.  If you wanted to simulate the response when the diodes are clipping (with distortion harmonics removed) you would need to replace the second set of diodes with a low valued resistor to simulate the diodes blocking the signal when clipping.
Send:     . .- .-. - .... / - --- / --. --- .-. -
According to the water analogy of electricity, transistor leakage is caused by holes.

hans h

Thanks for the detailed responses. Based on Jim's comment I will at least add a cap after the clippers or tie to vref. Can the bypass cap of the feedback loop also go to vref? I am thinking of a sort of nature pot that accomplishes several things at once in the scheme. Therefore I need to tie multiple points either to vref or regular ground.

Rob,  thanks for the explanation of F1 and F2,  really helpful.

Based on the suggestions of Tom and Rob,  which of the following schemes would be preferable (see also picture below) :

1: add resistance between + and vref in the inverting stage (I do not know whether this helps at all)

2: increase both the feedback and input resistor of the inverting stage.

3: scale the filters for lower resistance, divide resistors by 10 and multiply caps by 10.

4: keep it simple and go Non-inverting. Basically I would just copy the first stage including the passive clippers afterwards. This gives me some of the hard clipping I would otherwise get from the inverting stage.

Pictures of the options plus a Non-inverting scheme follow below. I hope the big schematic is readable. Don't look at the values of the caps in the feedback loop,  still need to look at these.








ElectricDruid

Quote from: hans h on August 17, 2022, 04:03:21 PM


Assuming (A) and (B) and proposed replacements for the second op-amp stage (the one that currently has 10K/33K around it) I'd say:

(A): No benefit. A carefully matched resistor to Vref in this position can help reduce DC offsets, but in a stage with so little gain, this doesn't matter, and you're probably going to follow the stage with a DC-blocking cap anyway, so there's really no point.

(B): No benefit. This lowers the 10K/1u HPF at the input to 100K/1u, but since 10K/1u is 15Hz and already lower than you care about, it won't make any odds. Arguably, it makes it worse, since it introduces more subsonics you don't want. 10K/33K uses more current but gives lower noise. 100K/330K uses less current but gives marginally more noise. In practice, you won't hear a difference. With really good equipment, there may be a measurable difference.

(C) Now I don't know what you're doing. This is the first op-amp.

hans h

B and c are both trying to reduce interference of the inverting input with the preceding filters. B does so by increasing the resistance between the filters and inv in. C does so by reducing the resistors in the filters,  which means the resistance between inv input and the filters becomes larger in a relative sense. Or I may have completely misunderstood the earlier post about reducing interference between inv in and the preceding filters.

ElectricDruid

Quote from: hans h on August 18, 2022, 02:06:08 AM
C does so by reducing the resistors in the filters,  which means the resistance between inv input and the filters becomes larger in a relative sense. Or I may have completely misunderstood the earlier post about reducing interference between inv in and the preceding filters.

Aha! I get it now! Thanks for explaining. Yes, you've reduced the resistor values so that they're each feeding into x10 larger resistors. That should help make things behave more like simple theory suggests it should, and reduces the need for spice modelling the situation!

hans h

Maybe a little more background on what I am trying to accomplish: in the large Non-inverting scheme above  the 'FM' pot does:
1 flat (left) VS mids and treble boosted response (right) for.   
  q1 and q2
2 2 noninv soft clippers (left) VS 2 noninv soft clippers plus.   
  2 hard clippers.
3 less treble filtering (left) VS strong treble filtering (right) after hard clippers.

Idea is to go from a fenderesque grit at low gain by setting fm to the left to a mesa'esque filtered cascaded gain on the right. An additional switch will break the connection from the 2u2's to the fm pot. In this setting the left side of the pot rotation has a bass cut together with reduced treble filtering and not so many cascaded stages (marshall'esque?). So in this case the fm and gain pots will swipe from jtm45 to Jcm800 to Mesa,  or so I hope:p.

hans h

Rob,  I am also very interested in getting gain VS frequency from Ltspice that takes into account clipping. To quote: "If you wanted to simulate the response when the diodes are clipping (with distortion harmonics removed) you would need to replace the second set of diodes with a low valued resistor to simulate the diodes blocking the signal when clipping".

I would expect that this method removes the same amount of gain from the entire frequency spectrum. In the case of clippers and a mid bump signal we mainly remove the mid bump. Or is there something I am missing?

Thanks in advance,  Hans

ElectricDruid

Quote from: hans h on August 19, 2022, 01:35:39 AM
I am also very interested in getting gain VS frequency from Ltspice that takes into account clipping.

I'd be very interested in this too, but I doubt it's directly possible. I don't trust the AC analysis for anything outside nice linear situations.
One way to do it indirectly is to generate an output soundfile and then analyse the frequency spectrum of that in other software like Audacity or something.
If it is possible, or if someone has a better way, I'd love to know!

Rob Strand

#11
QuoteRob,  I am also very interested in getting gain VS frequency from Ltspice that takes into account clipping. To quote: "If you wanted to simulate the response when the diodes are clipping (with distortion harmonics removed) you would need to replace the second set of diodes with a low valued resistor to simulate the diodes blocking the signal when clipping".

Trying get mental picture of what is going on in a non-linear circuit at different frequencies is a non-trivial task.   The guitar signal is complex.    What you expect say from the crispness of highs from the low E-string and the fundamental from the low E-string are quite different.   The lower harmonics are what causes the clippers to clip, that squashes the highs because there is a signal bottleneck through the diode clipper.     The *signal* from the highs from the low E-string and the harmonics caused by the distortion of the clipped lower harmonics occupy the same frequencies.   You need a way of separating the two, our brains can do it but looking at an FFT spectrum seems to be missing something.

IMHO, the idea behind the Honey Bee circuit is more about preserving the clean signal and making the pedal sound more transparent.

As far as understanding the effect of the filter:

- when the diodes aren't clipping the gain pot will sort of be in parallel with the filter impedances.    You have to consider that when the gain pot is set to a low resistance the pot will win out whereas when the gain pot is set to a high value to the filter impedance will win out.  Since the filter is frequency dependent they will have more effect with the gain pot is set high.

- You need to treat high gain *pot* settings and high *signal* separately.  If you crank the gain and pluck lightly the diodes might not clip.

- When the diodes clip the feedback signal from the filters is reduced.   That's going to remove the filter feedback
   to some degree.

- We also have some feed forward from the F2 filter marked on your circuit.

So what i've done here is show the simulations of the circuit with and without the filter.  I've put down two separate circuits in order to clearly separate the plots side-by side.

I show three settings of the gain control and in each case I step Rd, representing different attenuation in the forward path when the diodes clip.

The whole idea is to get a crude understanding of the circuit under various conditions.   It's fairly clear the filter flattens out the response when the diodes aren't clipping.



10k gain control is swamping effect of filter feedback


100k gain control we see some flattening when the diodes aren't blocking.


1MEG we see a lot more flattening when the diodes aren't clipping.
(probably should have a sim'd Rd=10ohm to emulate more diode blocking>)

Send:     . .- .-. - .... / - --- / --. --- .-. -
According to the water analogy of electricity, transistor leakage is caused by holes.

hans h

That's great Rob! The idea behind these interstate filters is starting to make some more sense now.

With regards to the clippers in my circuit: I think I'll go for noninv,  passive,  noninv,  passive for the moment. The 'fm'  pot wil allow me to select only the soft clipping Non-inverting stages on the left side,  and all four on the right.

Then I got to tune the caps to get a nice breakup tone all the way to quite large distortion. Tuning the cap values will be somewhat of a challenge ;D.  Luckily I have a cheapo scope consisting of two wires,  a 1/4 inch plug, a 1uf cap and volume pot so I can listen to what is happening in between the stages. I will post back as soon as I get it up and running.

As an aside: I sometimes see people post sims of clipping in action. Is that all in pspice or yet another programme?

ElectricDruid

Quote from: hans h on August 20, 2022, 08:21:07 AM
As an aside: I sometimes see people post sims of clipping in action. Is that all in pspice or yet another programme?

Yes, you can do that in spice(LTspice/pspice/whatever). It LTSpice that's called a "transient analysis" and it generates the time-domain waveforms you get feeding signals through the circuit. This type of analysis is not always reliable for non-liner situations either (the ideal op-amps don't clip at all, for example, so high gains give you KVolts of output!). But with judicious use of the right op-amp models and realistic diodes, you can get something that doesn't look far from what you get on the o'scope.

The important point is that that's a time-domain analysis, not the frequency domain.

Rob Strand

#14
QuoteThen I got to tune the caps to get a nice breakup tone all the way to quite large distortion. Tuning the cap values will be somewhat of a challenge ;D
Tuning pedals is where the time goes.  There's no formulas for best tone.  Spice sims certainly can help narrow down the choices.

Vivek has put up a number of posts using transient analysis over the last two years or so looking at frequency responses of non-linear circuits.   I've posted a fundamental extractor in the Simulation section on this forum.   Trying to work out the underlying ideas or interpreting the results is tricky.

As a simple example.  When you measure frequency response you inject a normally inject a fixed level then measure the output level over a span of frequencies.   However, think of a circuit like a tube screamer.   It has the 4.7k+47n gain setting components.  The gain increases upto about 720Hz.   If you inject x-volts at 100Hz the diodes might not clip, so the gain is like what you would get from an AC sim.  At 1kHz the gain is about 10 times higher than at 100Hz and the diodes clip.  When the diodes clip the level is squashed down.  So from outside the box gain isn't 10 times what you see at 100Hz, it's less.   How much less depends on the how heavily the signal is clipped.

Here's an example where a guy does a frequency sweep on a pedal.   While that method might be OK to compare two identical pedals, it's not going to let you to interpret frequency dependent behaviour so well because you don't know what is being squashed by the clipping and what is being reduce by the filtering.

See:  12:26
https://www.youtube.com/watch?v=-vgAju5M1Uo

The plotted response on the oscilloscope does not match the spice AC analysis because the diodes are clipping - sometimes or all the time? who knows.
(FYI his oscilloscope has a special frequency response sweep feature, that's not the same as an FFT, it's not a common feature.)
Send:     . .- .-. - .... / - --- / --. --- .-. -
According to the water analogy of electricity, transistor leakage is caused by holes.

hans h

That oscilloscope is really nice! Very insightful. If only I had one :( that would be great for tuning the circuit.

FiveseveN

Quote from: hans h on August 22, 2022, 04:09:01 PM
that would be great for tuning the circuit.
You can use a computer (PC, laptop, phone, watch, toaster) to look at waveforms and FFTs but they will not tell you more than your ears can when it comes to "tuning" a dirt box.
Quote from: R.G. on July 31, 2018, 10:34:30 PMDoes the circuit sound better when oriented to magnetic north under a pyramid?

hans h

Good point fiveseven!

BTW this is the current version of the schematic. Quite happy with the dual gang 'FM' (fender -> mesa) pot :)