Diode clipping in filters

DSP, Plugin and Host development discussion.
RELATED
PRODUCTS

Post

Some filters, like diode ladder in SH-101 has back-to-back diode clipper in feedback path. I learn electronics and my knowledge is still limited (I suppose these are Zener diodes). My question is: how to approximate its transfer curve (assuming I want to treat the clipper as a static waveshaper).

Is it like hard clipping with slightly curved corners and linear region?
giq

Post

It's remarkably easy to get something lilke LTSpice to plot you the response from a simple wave-shaper circuit: simply build the desired circuit and add a voltage source set to a ramp waveform (or triangle or whatever; there's a pulse thing where you can specify raise/fall times). Then you run transient simulation and click the output node, and it'll graph you the simulation result (which given a ramp input will draw the shaper for you). You can also write math in another curve (using the voltage source value as a parameter) to easily compare how your algorithmic shaper would compare.

So really, stop wondering and install LTSpice and just see for yourself. ;)

Post

I use iCircuit.. The problem is i'm not sure about the thing I'm testing. :) As said, still learning electronics.

Scheme looks like this (this is how I imagine an isolated feedback loop with clamp should look like)

gnd-- voltage source - res -- branch - res --- gnd

branch - 2 back-to-back diodes in parallel - connected to the ground



It doesn't clip at all (tried with different levels). All current goes through diodes.
giq

Post

What I mean is this: Image

We have 3 plots from transient analysis, the blue one is the raw voltage source, the green one is the voltage between the resistors (ie the clipped result) and red one is a scaled tanh() of the input voltage, which is not necessarily the best possible fit for this curve, but rather it's there to illustrate the point: you can write expressions in there and see how they agree with the simulation.

Post

Thanks, my circuit was obviously wrong :)
giq

Post

With no discrete inductors or capacitors in the circuit, the idealized response would be a memory-less input-output curve, probably emulated very well with some kind of direct formula or lookup table, made from software model or measurement of a real prototype circuit.

Real world components most always have at least some amount of resistance (or alternately conductance), capacitance, and inductance. Even wire spatial layout, wire characteristics and circuit layouts-- Each connection and run of copper on a board, every input and output connector and patch cable between units-- Has some combination of resistance, capacitance, and inductance.

A practical real-world example-- Often in microwave circuits, designers will add needed inductors or capacitors to a circuit just by careful designs of the size and shape of bare regions of copper foil on the circuit board. No component to solder in. The component is just a special shaped stripe on the circuit board.

Sometimes such small unintended and difficult to measure variables make no difference that discernably matters, but sometimes the differences are discernable and do matter. For instance a layout so bad that the circuit randomly and spontaneously goes into wild parasitic oscillation is significant, but you might also have situations where the circuit is on the borderline verge of getting that bad but never quite goes all the way over the edge. That situation might have odds of sounding different than the ideal, and some musician might decide he likes it thataway!

Diodes have several characteristic "defects" in addition to conductance, capacitance, and inductance, which may or may not have audible consequences. Some of which involve time and are not memory-less.

Wikipedia has some pretty good articles on diodes if you've not read them--

http://en.wikipedia.org/wiki/Diode

http://en.wikipedia.org/wiki/Small-signal_model

http://en.wikipedia.org/wiki/Diode_mode ... l_modeling

Post

Mystran why is there a signal ground in that schematic? Isn't the negative side of the voltage source the ground here? Just for posterity?

Post

camsr wrote:Mystran why is there a signal ground in that schematic? Isn't the negative side of the voltage source the ground here? Just for posterity?
Spice won't work without a ground reference (otherwise the system has infinite solutions).

Post

The same with iCircuit (much simpler but enough).

JCJR: Thanks for the deeper explanation. Actually I'm looking for a better static diode approximation curve. Got something reasonable with piecewise approximation.
giq

Post

If there is no memory, diodes can be solved explicitly, it's just an exp and a lambertW per diode - but that's very inefficient - cpu aren't that fast yet.
Last edited by Ichad.c on Thu Oct 23, 2014 1:23 pm, edited 1 time in total.

Post

Guys, can someone check my equations? (I'm just beginning ;)

( Mystran's image with only 1 diode).

v2/r2 + Is(e^(v2/vt)-1) = v1/r1
v1+v2 = vin

vin - source voltage
v1,v2 - voltages on r1 and r2+diode
note: 1st equation: sum of currents at node (point D2) = 0. Should it be -v1/r1 ?
giq

Post

This is good info, maybe the Shockley diode model can get you started:

Code: Select all

 float shockleyDiode (float Vi)
{
static const float n=2.5f; 
static const float VT=26e-3f;
static const float IS=1e-1f;

return IS *  lambert_W(exp((Vi/(n*VT))-1.f));
}
Now for a practical example (I learn by example - so maybe you do too) - a diode ringmodulator:

http://www.cgs.synth.net/modules/cgsrr.html

Completely ignoring the transformers(that require unholy powers to solve), the diodes are quite simple:

Code: Select all

float simpleDiodeRing (float Vinput, float Vcarrier)

{
float addTop = Vinput + Vcarrier;
float addBottom = -Vinput + Vcarrier;
float TopDiodes = shockleyDiode(addTop) + shockleyDiode(-addTop);
float BottomDiodes = shockleyDiode(addBottom)+ shockleyDiode(-addBottom);
return TopDiodes + -BottomDiodes;
}
Now this is exceptionally expensive, but if every diode is slightly different, it might be worth it - and could be done in SSE. But if you're a cheapskate like me, you'd realize that it can be done cheaper if you throw out the diodes (go with smoothed absolute value) and simplify it even further:

Code: Select all

float simplerDiodeRing (float Vinput, float Vcarrier)
{
float addTop = Vinput + Vcarrier;
float addBottom = Vinput - Vcarrier;
float TopDiodes = smoothABS(addTop);
float BottomDiodes = smoothABS(addBottom);
return TopDiodes - BottomDiodes;
}

Hope this helps.

Regards
Andrew

Post

Thanks a lot Andrew,

I think the best approach here is just to create a wavetable for this and I gonna use my equations.

Now looking for how to compute lambert_w function...
giq

Post

While reading the main wikipedia article on diodes, found myself wondering what a dual-whisker galena diode fuzz tone would sound like. :)

It would be very finicky to set up, not road-worthy at all, and probably need re-setting every time you use it. It would probably sound different every time you use it, after laboriously getting it to work at all.

When I was a kid, somewhere got an ancient crystal radio with a galena cats whisker detector. Dunno if it was an early deluxe factory model crystal radio or a labor of love by some technically minded turn of the century midwest farmer. The case was massive excellent woodwork, with old fashioned connectors for antenna and earphone, and a big knob that rotated a commutator around to connect with 10 or more big brass studs drilled thru the wood in a circle around the tuning knob.

Inside was a tapped coil wound on a form that might have started life as a quaker oats round oatmeal box, a capacitor made of a stack of foil and paper, a resistor that looked like a piece of pencil lead, though perhaps some other small cylinder of carbon. Cloth insulated wire.

The cats whisker was very well-machined, with big brass knurled connector studs. Built to last. A clamp to hold a shiny about 1 cm cube of galena, and ingenious spring loaded adjustable arm to manually adjust the thin springy cats whisker arm. The first thing to do was attach about a hundred feet of antenna, ground to a water pipe or whatever, then keep lifting and setting down the cats whisker until you find a "good" spot on the crystal, and then you would hear some sound.

Sometimes if you didn't bump the radio, the connection might last a few days, but sometimes you might have to readjust the whisker several times in a listening session, because the connections seemed to "get old" and you had to find another good spot.

A galena fuzz tone would have two whiskers to adjust.

Probably millions of crystal sets were made, most made by kids or amateurs crudely laid out on a rough plank of wood. And one can still buy small plastic modern kits with germanium diode and much better tuning and performance. But it was interesting to see a crystal set with such primitive components but so much effort and attention lavished on the cabinet and fittings. Was too dumb a kid, should have kept the box, possibly a valuable antique. Maybe it was a rich man's deluxe crystal radio, manufactured for the upscale customer before the invention of the triode tube. High tech, the MacPro of crystal radios! :)

Post

Ok, my equations seem wrong - iterative solving explodes :)
Looking for reasonable lambert_w implementation.

Some additional questions:
- as diodes are non ideal and there is a reverse leakage current, is there something that can be called "zero crossing distortion" ?
- can i generate a csv file or something from pspice?
giq

Post Reply

Return to “DSP and Plugin Development”