## Personal web pages of## Tim Stinchcombe |

## Be wary of what SPICE simulation tells you!
Some years back I decided I would emulate the lower resonant peak of the TB303 diode-ladder filter in the ladder filter I was then designing. This required placing a second-order high-pass filter in the feedback loop, which used an LM13700 operational transconductance amplifier (OTA) [ref 1] for voltage-control of resonance, and one pole of this was easily accomplished by simple first-order The breadboarded filter made some interesting sounds, especially when the gains of the OTA were cranked up and the circuit was clearly resonating at So the question arises: how was SPICE so effectively able to collude with my naivety and fool me into thinking I had the high-pass effect I desired? The answer to this question was obviously going to require a detailed knowledge of the internals of the SPICE macromodel I was using for the OTA, and as it turned out, a
The red trace exhibits the problem—it looks like we
We start with the amplifier bias current pin, D, _{5}D and _{6}V. The artifice of the _{3}zero-volts voltage source V is that it measures the current through itself, and passes this as the control current into _{3}current-controlled current source (CCCS) F—thus the amplifier bias current is directly mirrored into the tail of the differential input pair _{3}Q and _{1}Q, equivalent to the actual circuit, though it is a _{2}behavioural equivalence, hence the two diodes plus current source behave the same way as the transistors of the current-mirror of the real circuit, rather than copying the exact circuit topology itself.The input stage consists primarily of transistors Q and the linearizing diodes _{2}D and _{1}D, which all behave in the model as the real IC, so require little further explanation (and the diodes are not used in the circuit in this investigation—no diode bias current is applied—and so they aren't considered any further). Zero-volts source _{2}V measures the input bias current into _{6}Q, which is used to generate an _{1}input offset current via source F—this contributes to a small 'imbalance' seen at the input, but the majority of the imbalance comes from the difference in the _{1}IS parameter, the saturation current, used in the transistor models Q and _{X1}Q used for _{X2}Q and _{1}Q respectively (_{2}IS=5E-16 & 5.125E-16 resp.). There are a further two current-measuring zero-volts voltage sources, V, in the collectors of _{2}Q and _{1}Q, feeding a further two CCCSs, _{2}F and _{4}F respectively, which form part of the output stage—both the current sources have slightly larger than unity gain (×1.022). If, for the moment, we ignore _{2}F and the diode/voltage structures at _{5}D and _{7}D, we see the simple operation of the model in emulating the real chip: the current at _{8}F subtracts from that at _{4}F, so when the positive input voltage is greater than the negative input, _{2}F is greater than _{2}F, and the difference is _{4}sourced out of the output pin (and when the opposite is true at the input, giving F greater than _{4}F, the chip _{2}sinks the current difference, i.e. current is into the output pin).The other CCCS G, and _{1}V, represent the output resistance, by sinking a current proportional to both the voltage at the output and the amplifier bias current (it looks to me that _{7}G and _{1}V are really just a little 'programming trick' to get the output voltage into a format suitable for passing into the polynomial in _{7}F). The two diodes _{5}D and _{7}D and their associated voltage sources, _{8}V and _{4}V, serve to limit the output voltage to just inside the supply rails—for example, when the output voltage rises to about a diode-drop above 1.4V below the positive rail, _{5}D will start to conduct and effectively clamp the output voltage at that level (_{7}D works similarly in conjunction with _{8}V)._{5}
By the very nature of a transconductance amplifier it is the I, where _{out} = 19.2×e_{diff}×I_{abc}I is the _{abc}amplifier bias current. (This ignores the predistortion diodes, which we are not using, and is basically equation (5) in ref [1]—something very similar often appears in other OTA datasheets.)For our set-up we have a 47kΩ resistor, which is virtually across the supply rails, providing I pin drop about 0.7V, then we will get _{abc}I = (24-2×0.7)/47k = 481μA. For the moment we will _{abc}short out the 1μF capacitor on the output (, to remove any frequency dependence on the output current, and check the current, and then work back towards the input. The standard AC source applies a 1V magnitude signal, which is attenuated by the 24kΩ:220Ω potential divider on the input = 1/110, so we expect to see C)_{8}I = 19.2×1/110×481μ = 84μA being output. This is the red trace in the following (it is about 82μA, close enough):_{out}However, if we look at the currents in the sources F, the green and blue traces, we notice what seems to be an 'anomaly'—they are very nearly _{4}equal at about 42μA (I have tweaked the plot a little to separate the two lines!). The sign sense for the probing is the same, so it looks as though the output current ought to be zero. This is our first lesson: we are performing an AC analysis, so currents and voltages are complex entities, i.e. they have both magnitude and phase, and the simple current probing is clearly just giving us the magnitude in the absence of us asking for anything more. If we specifically probe the current phases we do indeed confirm that they are 180° out from each other, and hence add rather than subtract, and so the 84μA is confirmed!Next if we expect to see the 481μA of F, we are in for another surprise—the mauve line is 0, zippo! Again this is because of the way SPICE works: an AC analysis works by first finding all the DC bias points in the circuit, it then _{3}linearizes non-linear circuit elements (e.g. diodes, transistors etc.) about these bias points, and then does it calculations. Because there is no AC component to I (the AC source used is only connected to the one OTA input terminal), the plot of _{abc}I reads zero._{abc}Turning to the differential pair at the input, these same issues apply: the F (ignoring the '×1.022' factor), i.e. they are 40-odd μA, and of opposite phase. We should now, however, start thinking about the _{4}DC components of the signals. We are applying a (DC) current of 481μA for I, and this _{abc}will be mirrored in source F in the tail of the differential pair. As there is essentially zero DC input at either base of the input pair (ignoring effects due to input bias currents etc.), this current splits roughly equally between the collector currents of the transistors, and as can be seen in a moment, the currents in _{3}F and _{2}F are also nearly equal, at roughly 240μA each. The calculation of the _{4}AC components of the collector currents is a deviation, plus in one collector, minus in the other (hence the 180° phase difference) due to the AC voltage amount applied at the bases (the AC source, magnitude 1V, attenuated by the input potential divider, 24k:220Ω): the expression for this is basically half that given for I above, which in fact derives directly from the calculations surrounding the differential pair (see, for example, my account in Section 2.1.1, leading to equations (6)-(7), in [6]). I think there is little doubt that it can be quite confusing trying to get one's head around all of this!_{out}So let's run a standard SPICE First we note that the currents in F are roughly equal at some 240μA each (as mentioned above); the small approx. 3μA in _{4}F is for the output resistance (it is an easy matter to remove this altogether to show it is not having any significant effect on the deleterious high-pass effect we seek); also note that there is _{5}no current in the deviant capacitor C, which is because SPICE treats capacitors as _{8}open circuits when doing its DC operating point calculations.Next we may observe that the voltage at the output is rather high, at 11.18V: the DC operating point calculations have decided that the output will saturate near the positive supply rail. Worse than that, diode conducting: it is dropping 584mV, and has just over 3μA flowing through it! This means that from the perspective of a small-signal, linearized equivalence for use in AC analyses, it behaves like a resistance—this then is the culprit!
Generally a diode's I-V curve is a smooth exponential increase; one of its SPICE parameters is I then estimated the tangent to the curve at the 3μA-584mV point, and came up with a value of 8.5kΩ for the resistor; I stepped the voltage source so that I-V curve of the idealised set-up, the green trace, more-or-less just touched the red one at that point (the exact value of the voltage source isn't particularly crucial as we don't need it for the following We can now make up an equivalent circuit for the output stage, including the deleterious capacitor and resistor at the output, which shows exactly how the high-pass effect originates, and thus why I got fooled in the first place: we replace all current sources with a single (AC) source outputing the 82μA we know we have; diode D as a 1GΩ resistor—it's not really needed at this level, but at a few steps 'further back' which I've not expounded here, I needed a 'DC path' replacing the diode in order to get the DC operating point calculating correctly, so it stays in as a little _{8}aide memoire for this fact! Note also that I've swapped the relative positions of D and _{7}D from 'above'↔'below', and that they now run to ground, as this is for use with _{8}AC analysis, and hence the DC voltage sources V and _{4}V don't matter):_{5}It is not too difficult to see that this is indeed a high-pass filter, nor in fact to do a little algebra to confirm this fact, and if we compare the response with that of the one showing the problem, we can see that it is pretty much bang-on: The pole causing the cut-off turns out to be from the 1μF capacitor coupled with the 8.5kΩ (for D, which derives from the differences in parameter _{7}IS for the input transistor models—had these two values, 5E-16 & 5.125E-16, been chosen to have been slightly different from what they are, then this may have moved the pole sufficiently that I would have been alerted to the fact that I had done something stupid sooner. I've not really checked what the waveforms in the real filter actually look like, but I expect there is an inordinate amount of clipping/voltage compliance effects etc. going on. SPICE can be incredibly useful, but this is a prime example of how it always pays to be aware of its limitations, to find out why things go wrong when they do, and to learn from them in order to be better prepared for the next time!I guess this instance is a classic case of 'Garbage in, garbage out'!
1. LM13700 datasheet at Texas Instruments. (Equation 5 is basically the expression that I use above—however I find the algebraic development there a little fraught, as there are several places where particular attention is needed as to whether signals are single-ended or differential, as this leads to a perceived 'factor of 2' error.) 2. 3. 4. 5. 6. [Page last updated: 17 June 2019] |