Diode clipper simulation instability

DSP, Plugin and Host development discussion.
RELATED
PRODUCTS

Post

itoa wrote:y = f*(in-feedback) + s - 0.00016 * sinhf( feedback*40.0);
Don't know how you got this, but on first glance this doesn't look like trapezoid, it looks like forward Euler. It wouldn't surprise me at all that forward Euler attempt to solve this circuit/ODE explodes (and version with C in series with input should be perfectly stable with any solver).
BTW1, at low level input (when ckt is linear) pole is around 6KHz, and this circuit should be perfectly stable with any kind of diode model.
BTW2, shouldn't stiffness be issue with higher order systems? And, despite common belief, this circuit does not have hard limit, with diodes that could sustain millions of amperes you could get 10s/100s of volts on output.

Post

It's a direct form II canonical trapezoidal integrator

Look at the cover:

http://www.native-instruments.com/filea ... _1.0.3.pdf

btw1,btw2: it behaves very well until certain level - still investigating this... most probably I operate on floats, and sinh goes quickly to infinity - so - numerical issues but not with inverse function
giq

Post

Try to solve it with C twice as big and check if level at which solution explodes is increased. Also, try with C decreased 10 times, does it blow up at much lover level?

Post

Its scheduled, testing a completely different method at the moment.
giq

Post

urosh wrote:BTW2, shouldn't stiffness be issue with higher order systems? And, despite common belief, this circuit does not have hard limit, with diodes that could sustain millions of amperes you could get 10s/100s of volts on output.
It's not used in isolation. Typically there's battery driven opamps in the circuit which is going to limit the maximum I/O voltage.

Richard
Synapse Audio Software - www.synapse-audio.com

Post

Possibly stupid question:

Should I solve this for place before or after integrator (output) ? I think this may matter in case of nonlinear systems. Integrator has the only state variable here.
giq

Post

I have tried to simulate it with trapezoidal integration / Newton's method and state-space representations on MATLAB, and it worked as expected until I put a lot of gain to the input (50+ V), which is a good way to hurt any Newton-Raphson's scheme. So using a precomputed table for example should remove any problem there.

Then, tell me if I'm wrong, but I wonder if using a direct form II canonical trapezoidal integrator is equivalent with using the trapezoidal integration method to solve an ODE, in the nonlinear case, if we don't consider the time varying case. Stiffness can't be a problem on the second, since the method is A-stable. But someone suggested it may be a problem for the first method. Did I miss something ?

Post

Unfortunately don't know the answer yet and still experiment with different configurations and I feel somehow lost :).

- I thought in nonlinear case solving for output should be 'worse' than solving for integrator input. But I don't see any difference.
- Using table for inverted function (that forms a sigmoid) doesn't improve it's stability (SIC) it still explodes for large signals.

I will get back soon.
giq

Post

Using a precomputed table for the diode saturation effect itself should be better than any other method in this case.

You could use such a table to modulate the current in a naive lossy integrator to get an audibly identical result, although given the circuit it really doesn't require a capacitor at all.

In an analog version of this circuit typically the input will pick up some radio frequency (khz, mhz) signals and the capacitor is there to dampen these before the clamp, as the non-linearity will result in some sum/difference and you could end up with a crystal radio.

In fact living next to (only a few km/miles) an AM transmitter and working on electronics makes you far too much aware of this irritating issue.

I ****ing hate it hearing some random 50s music playing on my distortion circuit... at least when I didn't run the signal through it intentionally.
Free plug-ins for Windows, MacOS and Linux. Xhip Synthesizer v8.0 and Xhip Effects Bundle v6.7.
The coder's credo: We believe our work is neither clever nor difficult; it is done because we thought it would be easy.
Work less; get more done.

Post

Wolfen666 wrote:Then, tell me if I'm wrong, but I wonder if using a direct form II canonical trapezoidal integrator is equivalent with using the trapezoidal integration method to solve an ODE, in the nonlinear case, if we don't consider the time varying case.
I think it was karrikuh, who argued that any trapezoidal integration scheme is equivalent to any other even in the TV case. Or, more generally, you can replace any LTI part of a TV structure with another one having the same TF. Afterwards, IIRC, I even kind of formally shown this for DF1 vs TDF2 trapezoidal integrator (I never published or verified the proof itself though, although in a way my book almost contains it).
Last edited by Z1202 on Thu Oct 09, 2014 8:49 am, edited 3 times in total.

Post

Accidentally pressed quote instead of edit. Deleting the wrong post.

Post

Hello Z1202 ;)

So, what you said implies that itoa did not implement the TPT the right way, since stiffness should never be a problem when the trapezoidal integrator is involved.

I have done my own implementation of this, using state space representations / trapezoidal integration method / a lookup table + linear interpolation to avoid the use of Newton-Raphson in the simulation. And I can send a sawtooth with an amplitude range of [-100 100] Volts, it works very well. I only have the usual ringing effect of the trapezoidal integration, which can be reduced a lot with oversampling. It was a very standard implementation, I did not do anything fancy here.

That's why I wanted itoa to share his code, so I would be able to see what is wrong in what he did ;) Because I think it is very easy to do something wrong when you mix various integration schemes with implicit equations resolution, and you may lose their stability properties in the process. I have done this several times in the past.

Post

Now, this might or might not be the problem .. but using Newton the diode exp() functions (and the sinh that results from the pair of them) can easily overflow even double precision if Newton overshoots somewhat (which it does all the time). The solution (or at least the best one) is to detect this before it happens and perform the relevant iterations using the inverse function. As usual, this stuff is explained in the famous "Qucs technical docs" PDF, check that out for details.

Post

The Qucs doc about Newton-Raphson is there for people interested : http://qucs.sourceforge.net/tech/node16.html

Post

Wolfen666 wrote:The Qucs doc about Newton-Raphson is there for people interested : http://qucs.sourceforge.net/tech/node16.html
Oh there's a HTML version too? But yeah, that's the thing, it's probably the best explanation I've seen.

Post Reply

Return to “DSP and Plugin Development”