Electrical – Crystal oscillator using 7404 is unstable

7400clockcrystaloscillatorz80

I am currently building a small Z80 microprocessor system and require some kind of clock generation. It is not my first design: Earlier I used an Arduino pin that generated a slow clock or a 555 timer. However, earlier designs only included the Z80 and some RAM and ROM.

Now I want to expand upon that and include peripherals. That's why I chose a 3686.4 kHz Quarz, so that I can divide it later via a frequency divider to not only generate my processor clock but also my UART clock.

I did some research on the internet, read some books and schematics and found out that most use a pierce oscillator or a series resonant oscillator. For my design I want to use plain 74xx or 74LSxx chips, because I have them around and ready to use. Fortunately, most books for the Z80 and websites also built them using 74xx chips. So I tried to rebuilt them. My pierce design did not work at all, so I quickly changed my setup to a series resonant oscillator.

For my oscillator I use a single 7404 inverter that has a 100 nF decoupling capacitor attached between 5V and GND. Then I simply copy-pasted the circuit from "Build Your Own Z80 Computer" page 94. I added the capacitor after seeing it on many schematics and without it, it didn't start oscillating anyways. I attached my schematic below (it does not show the decoupling capacitor between 5V and GND)

Schematic of my oscillator with a 7404

Now when I apply some voltage to this circuit it indeed starts to oscillate. However, the frequency is not stable at all, seems to be 200 kHz below the stated one and the duty cycle is not at all 50%. You can see my logic analyzer output below.
Logic Analyzer output

Whereas the logical high state seems to be quite stable with one unstable cycle seeable at the right end of the graph, the off state varies quite a bit.

Frankly speaking, I do not know how to fix this as I have not much experience with oscillators. However, I have a feeling that the capacitor does have quite an influence. When I changed it from 100 pf to 22 pf the frequency was completely unstable. When I changed it to a higher value, I didn't see much difference at all. I also tried to exchange the 7404 with an 74LS04 as some schematics use it, but that didn't change anything.

If somebody can point out my mistake to me I would be very glad.

Additional Info: The data sheet of the crystal calls states CL=20pf and Rr < 120 Ohm.

Best Answer

Something you need to be careful with when using the Saleae device is that it takes samples, not continuous measurements. At 24MHz it is taking a sample every 41ns or so. The period for your 3.686MHz clock is 271ns. I'd expect to see some aliasing as the ratio between the two is 6.6:1.

An oscilloscope would be a better testing option.