[sdiy] VCO unstable in Spice, stable in real world

David G. Dixon dixon at interchange.ubc.ca
Wed Feb 2 22:36:16 CET 2011


> I've been puzzled (and charmed) lately with the behaviour of a simple saw-
> core VCO I'm trying to model in B2 Spice. The saw-core is based around a
> charging capacitor that gets discharged by a switching transistor as soon
> as the output of a LM311 voltage comparator goes high. That happens when
> the voltage in the capacitors hits the  reference of 10V. So far nothing
> fancy.
> 
> But now the strangeness:
> In the real world this oscillator works and sounds like a charm. In Spice
> however, the LM311 output shows very erratic behaviour. It seems to
> respond so fast that the when 10V is reached the switching transistor only
> partly discharges the capacitor after which the 10V is very easily met
> again. The system hence starts to oscillate around the 10V point very
> quickly without the capacitor ever being fully discharged again. A minor
> improvement is achieved when the default B2 Spice capacitor is replaced
> with a 'real capacitor'. This model takes into account any induction and
> resistance happening inside a capacitor.
> 
> My hypothesis on the difference between Spice and the real world for this
> scenario currently is that the less-than-perfect conductive properties of
> the PCB tracks play a crucial role in this VCO. The small inductive and
> capacitive properties of PCB tracks may provide some type of hysteresis on
> the output of the LM311, such that the real world VCO generates a stable
> saw. I'm curious what you think? Is it really that simple and charming? Or
> is there another explanation?

I've just modeled a new VCO of my own design using LM311 as a hysteretic
switch in a triangle core (I will actually use the LM319 dual comparator
because I need two, but the spice model for that (LM119, actually) is
totally out-to-lunch -- see below).  Sometimes the model comparator gets
"stuck" on ground for no apparent reason, which I doubt would ever happen in
real life.

Also, if I put in the LM119 model (for LM319), the model is totally
unresponsive to changes on the GND pin of the comparator.  Whether I connect
it to ground, the negative rail, or nothing at all, the model comparator
does exactly the same thing: it goes to the negative rail on the downside.
I'm pretty sure this is not the true behaviour of the chip.

I have found many SPICE models which are either seriously flawed (the TL071
model has no offsets, while SOME TL074 models do, but you have to use the
correct suffix to see them) or quite simply defunct (CA3080 is a good
example -- the model simply does not work, although the LM13700 model
appears to be pretty much spot on).  You have to be very careful about using
SPICE models, particularly with highly non-linear components.  You also have
to make sure that your time-step is appropriate.  If a reset is supposed to
occur in less than 500ns, then it doesn't do to have a minimum timestep of
1us.  For fast comparators, I think it's appropriate to take a minimum
timestep of about 10ns.  However, you'll then not want to simulate a
waveform at 1kHz, because you'll be sitting there all day waiting for the
reset to occur!

In short, SPICE modeling is well worth the effort, but it can also be very
tricky, and many of the models don't appear to be very accurate.




More information about the Synth-diy mailing list