Page 1 of 1
spice simulation of a crystal oscillator - circuit maker
Posted: Wed Mar 26, 2003 2:03 am
by 1202
Does anyone here use circuit maker, fingers crossed. I have tried some 6502 clock circuits and can't get it to simulate properly after ages of trying - basically the crystal isn't working - e.g. tried the mirco uk101 oscillator.
anyone? I have the circuit if anyone wants to see.
Update!
Posted: Wed Mar 26, 2003 2:22 am
by 1202
I now think its somthing to do with using digital logic on the analoge simulation mode, technically I should - shouldn't I be able to simulate spice - a squarewave oscillator with cmos or ttl inverters.
help!!!!!! - the outcome is a squarewave but with a freq higher than the crystal meaning that - the crystal is doing thing!
one circuit I simulated had a 9 mhz squarewave, another a 35 mhz wave - where the oscillator should be like 8 mhz for the 1st one and 2 mhz for the other...
THis is using circuit maker!! I also have access to ewb elsewhere and microcap if someone can give me an example in another spice sim.
Another update but still need help!!
Posted: Wed Mar 26, 2003 5:35 am
by 1202
I now believe there is a problem mixing digital logic with say the crystal of the analogue world of spice!! I'm using circuit maker 2000 but I also have access to ewb and microcap, anybody have any help on this!!
interesting but fustrating as I wanted to simulate a clock for a 6502 using digital logic and a crystal! now I can't see how I'm going to do that...

Posted: Wed Mar 26, 2003 7:37 am
by GARTHWILSON
Although I do various forms of electonic design work for a living from audio to minor digital to VHF MOSFET power amps, I personally have never used any software analog circuit simulators other than ones I myself wrote for particular purposes. Although I'm not familiar with simulation packages you mention, I might ask, what are the crystal models you're using? What's the circuit you're trying to simulate? As we've discussed recently, coming up with clock generators-- even crystal-controlled-- for a 6502 project is pretty easy. If using a $1.19 crystal can oscillator seems like cheating, you could use the circuit published in several 6502 data sheets. I can't draw the diagram here, but you should be able to reconstruct it from the following:
Use a 74LS04, which has one inverter's input on pin 1 and its output on pin 2, another with input on 3 and output on 4, another with input on 5 and output on 6. (Three more are on the other side.)
Draw the three inverter stages in a horizontal row pointing to the right, with pin numbers going 1, 2, 3, 4, 5, 6 in left-to-right order.
I'll refer to pin number here without writing "pin" every time:
Put a 470pF capacitor from 1 to ground,
a 2.2K resistor from 1 to 2
and another 2.2K from 3 to 4,
a 1.5K resistor from 4 to 1
with a .047uF capacitor across this resistor,
and put a series-mode 4MHz crystal from 2 to 3.
For output buffering, connect 4 to 5,
and get your output off of 6.
With the 4MHz crystal in there, it will give a square wave at 4MHz (BTW, 4MHz is 1,000,000,000 times as much as 4mHz!) but the symmetry won't be very good. This was intended for computers that would run at 1 or 2MHz, getting the final frequency by dividing the 4MHz down with a 74LS74 flip-flop, which also fixes the symmetry problem. Each divide-by-two stage uses half the 74LS74. Feed the input frequency to the clock input pin, run the Q\ output around to the data input pin, and take the output off the Q pin.
Hopefully this will be understandable.
Garth
Re: Another update but still need help!!
Posted: Sat Mar 29, 2003 10:21 pm
by kc5tja
I now believe there is a problem mixing digital logic with say the crystal of the analogue world of spice!! I'm using circuit maker 2000 but I also have access to ewb and microcap, anybody have any help on this!!
interesting but fustrating as I wanted to simulate a clock for a 6502 using digital logic and a crystal! now I can't see how I'm going to do that...

SPICE is a simulation tool designed to simulate
integrated circuits (the IC part of SPICE), both analog and digital alike. SPICE works by emulating individual components and their basic operation according to various models. SPICE isn't a 100% perfect simulation, of course, but it's often considered good enough. After all, the whole integrated circuit industry grew up around it.
That being said, SPICE can't possibly be applied to macroscopic circuits; not, at least, without some really funky measures taken. This is because SPICE can't fathom inter-trace capacitances and lead inductance in real-time. It has no idea of how the physical geometry of a circuit would affect operation, etc. All these factors are actually quite important in getting a circuit working as desired,
especially oscillators. In the amateur radio community, at least, there's an old truism: oscillators amplify, and amplifiers oscillate. You might be running into this problem. I'm not quite sure.
I've created circuits that I know would work in the real-world, but which patently didn't work at all in SPICE. For example, a doubly-balanced diode mixer will not simulate in the SPICE packages I've used.
It's been too long since I last used SPICE to tell you how to do it. But I've seen it done before. Maybe you should ask on some of the electronics-related newsgroups? I'm sure someone there would be able to offer assistance for this.
Just a suggestion.
Also, SPICE has built-in "ideal" clock waveform generation built-in. Might that work as well?