Help understanding "soft" clipping

Started by PBE6, February 25, 2014, 02:59:41 PM

Previous topic - Next topic

PBE6

I have a question regarding "soft" clipping, where the clipping diodes are placed in the feedback loop of an opamp.

I've read over the "Technology of the Tubescreamer" article at the GeoFEX website, and also done a few basic hand calculations. The first approximation seems reasonable enough - the clipping diodes can be ignored as open circuits when the input signal is below a certain threshold, but when the input signal gets too large the diodes are considered short circuits that clamp the feedback voltage to about 0.6 V and clamp the gain to 1x, effectively creating a 0.6 V ceiling. 

However, when I breadboarded and measured the output voltage of an opamp soft clipping stage (as well as the clipping stage in a Boss SD-1), I found the output voltage was higher than 1 V for a 1 V input signal (something like 1.6 V if I recall correctly).

Huh? How is the output voltage getting above the diode forward voltage? Inquiring minds want to know..

slacker

The answer's in here "diodes are considered short circuits that clamp the feedback voltage to about 0.6 V and clamp the gain to 1x," ignore the clamp the voltage to 0.6 Volts part and just think about the other bits.

samhay

slacker's correct if you are using the non-inverting input of your op-amp (which seems likely). You only clip the amplified signal, so a 1V input will be clamped to ~1.6V if you give it some gain.

However, if you use the inverting input, you will get clipping as you expected - equivalent to 'hard' clipping to ground.
I'm a refugee of the great dropbox purge of '17.
Project details (schematics, layouts, etc) are slowly being added here: http://samdump.wordpress.com

PBE6

Thanks slacker and samhay. I've discarded the notion that the voltage is clamped (you are correct samhay, it's a non-inverting stage) but I'm still having trouble modeling this kind of clipping.

I made a few columns in Excel to try and figure this out. I have "time", "Vin", "gain" and "Vout".  "Time" and "Vin" are what they say they are, and I'm using a 1 V amplitude sine wave as a test signal. Under "gain" I set up the spreadsheet so that if Vin*(set gain) is larger than the forward voltage of the diode then "gain" = 1, and otherwise "gain" = set gain. "Vout" is just the product of "Vin" and "gain".

What I got was a sine wave with varying sets of vampire teeth sticking out of it, not the vaguely mesa-esque waveform I was expecting. (To clarify, the initial part of the waveform is amplified until it hits the voltage ceiling, at which point it is knocked back to the original waveform level because of the unity gain condition.)

I don't think this goofiness is the result of an over-simplified model because even a varying gain version will just give me round vampire teeth instead of sharp ones.  Does anyone see the obvious thing I'm missing? I'm stumped.

ashcat_lt

#4
You must have something weird in your spreadsheet.  Is there some reason you're not using 5spice or something?  It should come out with straightish sides and rounded tops.  It amounts to a sort of crossover distortion.  In fact, with a big enough input signal, or enough "open diode" gain, the actual section where there is significant gain gets so much smaller than the rest of the swing that it starts to clean up, and looks and sounds exactly like typical crossover distortion, only without the gating.  (Course, in a real world TS, you'd clip the opamp before it got too clean...)

You can start by thinking of the diodes like switches which flip over when gain * input > forward drop, but that only gets you so far.  Diodes aren't actually switches, but voltage-dependent-resistors.  That is, they are resistors whose value decreases exponentially as the voltage across them increases.  These "resistors" sit in parallel with the gain pot, and as they "open up" the parallel value of the two components goes from almost exactly that of the pot to very small.  That resistance is the top half of the voltage divider which sets the gain.  

Does that help at all?

slacker

#5
Sorry I think I've lead you a bit astray, my earlier comment was only about the parts of the signal that are already above the forward voltage of the diode, in a simple model they get a gain of one. The parts of the signal that are below the forward Voltage get the gain applied to them clamped to the forward voltage of the diode. If you do this in your spreadsheet you'll see the classic soft clipping waveform.
What actually happens is more complicated and trickier to model, if you look at the forward voltage side of this image http://www.globalspec.com/ImageRepository/LearnMore/20131/diode58cd4e2f1b9114708851ac53e3d63e9c7.gif you can see that when the Voltage is below the "knee" very little current flows through the diode, so it looks like a high value resistor. Once the Voltage gets to the "knee" the current through the diode starts to increase, so it looks like a variable resistor whose resistance varies with Voltage.
This is how the soft clipping works, for the parts of the signal where the product of Vin * gain is less than the "knee" they just get whatever gain the opamp is set to applied to them, as the product of Vin * gain approaches the "knee" the resistance of the diode starts to decrease, reducing the gain of the opamp, limiting the output to about the forward Voltage of the diode. This also happens if Vin is greater than the "knee" but as the minimum gain of the opamp is 1 the output can't be less than the input, so the output is just Vin. In reality the resistance of the diode won't drop to zero so big signals will get a bit of a boost.

EDIT: posted the same time as ashcat

Hope that makes sense.

slacker

Quote from: ashcat_lt on February 26, 2014, 01:06:52 PM
You must have something weird in your spreadsheet.

His spreadsheet model is wrong, he's applying a gain of 1 to the bits of the signal above the Vf  of the diode, which for a simple model is Ok but for bits of the signal below Vf he's appying the full gain and not limiting the output to Vf.

ashcat_lt

TBH, it's a whole lot (like a whole lot!) like diode-to-ground clipping with a bit of the clean signal mixed back in.

PBE6

Thanks ashcat_It. I always like to try and understand things from first principles, and I've found a spreadsheet is a good tool to use since it's so easy to tweak and you need to get the basics right before it works.

I'm getting closer. I found the Schokley ideal diode equation online and subbed in typical values for silicon diodes:

I = 1E-12*(exp(Vd/0.026)-1)

For Vd I used the value of Vin*set gain (is this right?). This gave me the diode current. I then divided Vin*set gain by the diode current to find the diode resistance, and then combined that with the feedback resistor in parallel to find the equivalent feedback resistance. This gave me the actual gain, which I then multiplied by Vin to find Vout.

Unfortunately, the vampire teeth are still there, and at high gain settings the output waveform matches the input waveform almost exactly (because the gain is almost unity everywhere), exactly the opposite of what it should be doing.

Yaaargh!!!

If anyone sees a conceptual error here, please let me know..I'm dyin' here!! Lol

PBE6

Didn't see those other posts, will check them out shortly..

ashcat_lt

Quote from: PBE6 on February 26, 2014, 01:58:57 PM
Unfortunately, the vampire teeth are still there, and at high gain settings the output waveform matches the input waveform almost exactly (because the gain is almost unity everywhere), exactly the opposite of what it should be doing.
Actually, that is pretty much exactly what's supposed to happen, and I mentioned it in my post.  With very high gain settings and/or very large signals it cleans up until your input starts to clip the opamp.

What are you using as an input to this thing?  A triangle wave will do the spikey "vampire teeth" thing.  A sine input should yield rounded tops, though. 

QuoteFor Vd I used the value of Vin*set gain (is this right?).
It's not quite right, though is it?  Vd at any given point in time is equal to the actual gain at that time multiplied by the input.  That gain, of course, is dependent on the equivalent resistance of the diode in parallel with the gain pot.  I do believe that this could be where you're running into trouble and getting somewhat unpredictable response, and frankly I don't know how to tell you to proceed.  Hopefully one of the big brains can come around and explain it in a way that we can both get our heads around it, and preferably without calculus.

samhay

For a reasonable approximation in a spreadsheet try this:

if( V*g < Vf, V*g, V+Vf )

where:
V is your signal (in volts)
g is the gain of 1 or more
Vf is the forward voltage of the diode (e.g. 0.6 V)

This will 'clip' the top of your signal if V*g > Vf and g > 1. If you want to clip the bottom of the signal too, then you will need a second/nested if statement.

If you want 'hard' clipping, then try:

if( V*g < Vf, V*g, Vf )
I'm a refugee of the great dropbox purge of '17.
Project details (schematics, layouts, etc) are slowly being added here: http://samdump.wordpress.com

PRR

> a spreadsheet is a good tool
> Unfortunately, the vampire teeth are still there


How many computation points per cycle?

You usually want like 1,000 points per cycle to get a clean waveform. 10/cycle will be very jaggy.

I tried to plot this in SPICE. It fights back. It "knows" that when the wave is changing rapidly, it "should" slow down and take smaller slices. The top image is set for 1mS wave computed every 0.3mS (3/wave). The initial rise is clearly interpolated to finer time-slices, but much of the wave is more like 9 slices per cycle, and is jaggy. Below that I forced 1000/cycle and it is incredibly smooth at all zooms.

  • SUPPORTER

Mark Hammer

I may be in way over my head here, but my understanding is that the behaviour of diodes is partly a function of the current applied to them.  And if the current is related to the output voltage of the op-amp (and the gain that produces it), wouldn't that be expected to alter how the diode conducts?

In any event, we tend to forget that the gain of the op-amp with diodes in the feedback path is a constantly shifting beast.  As the diodes begin to conduct, that automatically reduces the gain (more negative feedback from the output = less gain), which in turn changes the ability of the op-amp to "force" the diodes to conduct.  If the diodes don't conduct, then the gain is determined by the feedback resistance....until the diodes are pushed into conducting again.

In short, we think about it in terms of clipping, but it is actually behaving like a very substandard lo-fidelity compressor.

This is why diodes in the feedback loop result in a different sort of sound than diodes to ground after the output.  In the latter case, the gain of the op-amp is the gain, and is unaffected by whether or not it pushes the diodes into conduction.

This is patently obvious to those with more electronics training, but not readily apparent to those of us with less training.