is it possible? a crystal oscillator from SN74LS04 TTL hex inverter  - Page 1
Forum section: electronics / beginners

author: ali6x944
author_rank: Frequent Contributor
timestamp: January 26, 2016, 06:52:10 pm
content: is it possible to make a 32.786khz crystal oscillator from SN74LS04 TTL hex inverter ?please help!thanks.

author: Ian.M
author_rank: Super Contributor
timestamp: January 26, 2016, 07:16:40 pm
content: I'd be very cautious about drive levels. U1A input with R2 feedback means the crystal sees a fairly low impedance and you may well exceed the permissible drive power for smaller package crystals

author: chris_leyson
author_rank: Super Contributor
timestamp: January 26, 2016, 07:22:50 pm
content: I wouldn't advise using TTL to drive a 32kHz xtal. If it's a tuning fork type crystal the motional resistance could be up to 50k ohm, secondly the drive level would be way to high, it's usually specified as 1uW max. You might get away with unbuffered CMOS inverters but getting the drive level down to 1uW is difficult.

author: PA0PBZ
author_rank: Super Contributor
timestamp: January 26, 2016, 07:25:47 pm
content: I agree that it would be better to use a cmos version but that was not the question, and maybe it's a full size xtal, who knows

author: ali6x944
author_rank: Frequent Contributor
timestamp: January 26, 2016, 07:42:08 pm
content: it is a tuning fork crystal i salvaged out of an old clock and i tried to use a cmos nand 74hc00n in the same configuration and it didn't work will,it was acting strange, it was picking am transmissions and i was able to hear a talking through a laud speaker, but it was not that clear thew.and it was not oscillating except when i put my fingers on the pins of the ic.

author: Zero999
author_rank: Super Contributor
timestamp: January 26, 2016, 08:25:21 pm
content: The 74HC00 should be ideal for a crystal oscillator.What circuit did you use?The circuit posted above is for the TTL IC. CMOS ICs are slightly different.

author: ali6x944
author_rank: Frequent Contributor
timestamp: January 26, 2016, 08:27:41 pm
content: how they are different?

author: ali6x944
author_rank: Frequent Contributor
timestamp: January 26, 2016, 08:32:10 pm
content: because i literately used the same exact circuit but i add not a 10nf cap but two 20pf caps in earthier sides of the crystal.

author: ali6x944
author_rank: Frequent Contributor
timestamp: January 26, 2016, 08:38:14 pm
content: and i did not use a coupling cap between gates

author: uncle_bob
author_rank: Unknown
timestamp: January 27, 2016, 09:16:02 pm
content: HiThe standard part to use always used to be the "un-buffered" version of the CMOS gates. A single inverter with about a 1 M ohm between output and input generally did the trick. Something like 20 or 30 pf to ground on both input and output kept things running properly. You may have a hard time finding UB (un-buffered) parts these days. Part numbers like CD4007UB still show up as available. The nice thing about "old" CMOS (CD series) is that the high frequency gain is not there. That's what messes you up doing 32 KHz with the LS, HC or (worse yet) AC gates.Depending on the characteristics of the crystal you have (it's loss) you may still need two inverters in series to get enough gain. If so, do something like the schematic at the top of this thread.Bob

author: ali6x944
author_rank: Frequent Contributor
timestamp: January 28, 2016, 04:13:57 am
content: Thanks a lot

author: alsetalokin4017
author_rank: Super Contributor
timestamp: January 28, 2016, 05:24:35 am
content: Using MCP14069UBCP:(note: Chip is being supplied with only about 3.5 V in; more voltage produces a distorted waveform with the component values I've used here; this was originally a 20MHz xtal oscillator but I just decided to try it with a watch crystal for this test and didn't change any of the other components.)Also tested, with same result, using CD4069CN and CD4069UBE. Does _not_ work with 7404 variants I tried: SN74LS04J or plain 7404.

author: ali6x944
author_rank: Frequent Contributor
timestamp: January 28, 2016, 06:12:49 am
content: That is graet if am using UB-CMOS devices but i don't have any,The only gates i have are from the low-power schottky ones and a HC nand, and a HC or gatesI will post all datasheets in the form soon

author: uncle_bob
author_rank: Unknown
timestamp: January 28, 2016, 06:30:15 pm
content: HiThe 4000 series CMOS will interface directly to your HCMOS parts. There is no problem driving one with the other. The "normal suspects" will sell you a DIP package part for next to nothing and get it to you in a day or two.The other alternative is to use a transistor (or two) rather than a gate.Bob

author: ali6x944
author_rank: Frequent Contributor
timestamp: January 28, 2016, 07:14:07 pm
content: bjt or jfet transistor?

author: ali6x944
author_rank: Frequent Contributor
timestamp: January 28, 2016, 07:57:08 pm
content: https://drive.google.com/file/d/0B5vW-k7HbsL4MEtnZWo1dG4zTnM/view?usp=sharingfirst

author: uncle_bob
author_rank: Unknown
timestamp: January 29, 2016, 01:35:46 am
content: Quote from: ali6x944 on January 28, 2016, 07:14:07 pmHiBJT / JFET / MOSFET .... any or all will work if you have enough of them. The old standard designs either used multiple bipolars (to do the impedance conversion) or a JFET and a bipolar.Keep in mind that you will have something odd coming out of the circuit (like a clipped sine) that will then need to be converted to a square wave. A darlington BJT running in a colpits configuration is not a bad place to start. Cap from base to final emitter, cap from emitter to ground. Crystal goes from base to ground. Should see a nice signal on the emitter once it's biased up.Bob

author: ali6x944
author_rank: Frequent Contributor
timestamp: January 29, 2016, 05:48:07 am
content: But i was just wondering if i could use tri-state invrting buffers to achive the oscilation instade of an a regular inverter?

author: alsetalokin4017
author_rank: Super Contributor
timestamp: January 29, 2016, 06:42:39 am
content: I tried the one-transistor circuit attached below from Bowden's Hobby Circuits but could not get it to work, probably because I didn't have the right trimmer capacitor and used a fixed 30pf instead. It just wouldn't start oscillating for me. Tried several different watch crystals too, that did work in the CMOS version, but no luck. Tried 2n3904 and BC337-25, no luck.

author: uncle_bob
author_rank: Unknown
timestamp: January 29, 2016, 12:46:46 pm
content: Quote from: ali6x944 on January 29, 2016, 05:48:07 amHiTo make an oscillator work, you need to satisfy both phase and gain criteria. In order to do that, things need to be set up right. There is no guarantee that they will only be set up right at one frequency. By far the most common error with 32 KHz oscillators is using a device that *also* oscillates at a much higher frequency. Normally this is through some portion of the stray capacitance.Bob

author: ali6x944
author_rank: Frequent Contributor
timestamp: January 30, 2016, 02:05:37 pm
content: how?what? could you simplify more?please I'm a noob at these things

author: uncle_bob
author_rank: Unknown
timestamp: January 30, 2016, 02:41:33 pm
content: Quote from: ali6x944 on January 30, 2016, 02:05:37 pmHiThe simple / easy / quick / cheap way to do it is to grab a 4000 series un-buffered gate for < $1 and wire that up. There are only aa small number of parts involved and the chance of success is very high.Doing a 32 KHz oscillator with discrete parts is a trial and error process. You very much need to know what you are doing. There are a much larger number of parts involved and more of them are critical. That's why nobody does it that way anymore. You *can* do it. It has been done that way many times. It's not the easy way. The other (minor) issue is that it's only going to work with the right parts and they are going to cost more than the gate .....Bob

author: Zero999
author_rank: Super Contributor
timestamp: January 30, 2016, 03:12:47 pm
content: Quote from: uncle_bob on January 27, 2016, 09:16:02 pmIf using unbuffered parts is not an option, then how about adding an input resistor and feedback capacitor to reduce the cut-off frequency to something more sensible?

author: uncle_bob
author_rank: Unknown
timestamp: January 30, 2016, 05:23:24 pm
content: Quote from: Hero999 on January 30, 2016, 03:12:47 pmHiThe problem there is that the spurious oscillation is across the package its self on the high speed gate. The next issue is that the R and C have added a bit of a phase shift / load inside your loop. That's going to mess things up as well.Bob

author: ali6x944
author_rank: Frequent Contributor
timestamp: January 30, 2016, 05:36:38 pm
content: adding inductance to fix it back?

author: uncle_bob
author_rank: Unknown
timestamp: January 30, 2016, 05:43:52 pm
content: Quote from: ali6x944 on January 30, 2016, 05:36:38 pmHiThe size of the inductor at 32 KHz is going to be pretty big ...The bigger problem is the one that got this whole thread started. The high speed gate takes off on it's own when put in the linear region. It does that without much of a feedback path at all. Taming it is a real pain. Yes, with good layout techniques on your custom pc board it can be done at HF. Doing it at 32 KHz ... not easy.Bob

author: ali6x944
author_rank: Frequent Contributor
timestamp: January 31, 2016, 02:02:15 pm
content: any final schamatic

author: uncle_bob
author_rank: Unknown
timestamp: January 31, 2016, 03:19:09 pm
content: Quote from: ali6x944 on January 31, 2016, 02:02:15 pmHiPower up the inverter (B+ and ground). Bypass the supply (always a good idea). With 4000 series the supply can be anything from 15V down to a couple of volts. Bypass can be anything from 0.01 uf to infinity, ceramic is a good idea.Use one inverter stage as the oscillator. Bias it into the linear region by putting a 1 M ohm resistor from output to input. At this point the inverter should be sitting with about 1/2 your supply on the output pin. It also will be pulling a couple of ma.The crystal goes in parallel with the resistor. At this point it probably will oscillate.A cap goes from output to ground. Something in the 10 to 100 pf range makes sense. It should be an NPO /COG type part. A similarcap goes from input to ground (same value). This is where the tinkering comes in. Higher values may stop it oscillating. Lower values may allow it to generate crud. The caps are what puts the oscillator on frequency, so if you are concerned with accuracy, that comes in as well.There are a few optional refinements that can be added.First is a tuning capacitor in series with the crystal. That way you can set it on frequency without messing up the oscillation.Next is a current limiting resistor in series with the output of the gate (but before the capacitor and other stuff). This allows you to reduce the crazy stuff without killing the oscillation.Last is to use another section of the inverter package (another inverter) to bufferer the output. That way, whatever you are driving does not mess up the oscillator.I hope that makes sense.Bob

author: ledtester
author_rank: Super Contributor
timestamp: January 31, 2016, 08:15:38 pm
content: I've had luck with this drive circuit:http://www.discovercircuits.com/DJ-Circuits/ultralowpwrxtlosc1.htm

author: uncle_bob
author_rank: Unknown
timestamp: January 31, 2016, 08:34:17 pm
content: Quote from: ledtester on January 31, 2016, 08:15:38 pmHiThat circuit will be highly dependent on the capacitance at the output. It really is designed for the load to be high-z (> 10 meg) and low C (around 12 pf). It will run fine into a scope probe. It's not clear it will run well into a heavy load. A simple solution would be some sort of buffer amplifier (emitter follower maybe) on the output. If you do put in a good buffer, you may need to add the 12 pf back in ....One other thing to be a bit careful of - not all 2N3904's are created equal. At 1ua collector current you are two decades below the typical data sheet information on the part. A part from source A may do absolutely perfect in the circuit. A part from source B may have issues.Bob

author: orolo
author_rank: Frequent Contributor
timestamp: January 31, 2016, 10:13:36 pm
content: I remembered reading something about TTL xtal oscillators and problems with variable impedances, and, after some digging, found it.The schematic attached is taken from "Crystal Oscillator Circuits" by Robert J. Matthys, Krieger Publishing Company, 1992. It is described in Sec. 11.3 "TTL Two-Inverters-7404", pp. 160ff. This kind of oscillators are described as "waveforms are fairly good" and "relatively insensitive to power supply and temperature" but "many versions of this oscillator are poorly designed".The idea is: a single resistor feedback around the inverter is acceptable only in the second one, but not in the first. The reason is that a TTL gate has a gain of 10X, but because of feedback, the 470 Ohm resistance has a dynamic impedance of 470 Ohm at the extremes, but only 47 Ohm when transitioning. Such unequal load is not aceptable as a crystal load.Hence the peculiar feedback around the first inverter. The resistor-capacitor tee is used to reflect the load RL to the crystal the whole oscillation cycle. This very much reduces distortion (and is recommended also for CMOS inverter oscillators). The shunt resistor R3 has two functions: pulling the inverter into the transition region, so both the input and the output of the inverter are somewhere near 1.6V. Second, to trim the duty cycle of the oscillator to a perfect 50/50 ratio.Now the circuit given is designed for operation at 1Mhz, whit crystal resistance of 240 Ohm (therefore, RL = 220, a little less). At 32Khz, the load resistance should be around 20K, so RL should be set to that value or a little less. I have no TTL inverters at hand, nor the time to test this circuit, but maybe it can help. Anyway, my guess would be RL = 18K, R3=200K.

author: uncle_bob
author_rank: Unknown
timestamp: January 31, 2016, 10:35:33 pm
content: HiA few bits of terminology in terms of crystal oscillators:A crystal operates into a load capacitance. That is the value that the manufacturer used when the set it to frequency. It will work into a wide range of load C.A crystal's equivalent circuit has four basic elements. The easy one is the capacitance across the device, often called C0. The rest of the model is a series circuit made up of Lm, Cm, and Rm (also called C1, L1 and R1). One way to look at Rm is that it is the impedance of the device when run at series resonance. That's not exactly correct (C0 gets in there) but it is a start. Since you operate the crystal into a load C, it's not going to be at series resonance. The effective resistance will actually be higher (strange but true).You can analyze an oscillator circuit a lot of different ways. The net result is always the same. If it is a stable oscillator, the losses in the circuit are perfectly made up by the gain of the circuit. If you want to think in terms of 10K ohms of loss, then the oscillator will provide -10K ohms of negative resistance from it's gain.A *much* more common way to do the analysis is to split the gain transistor in half. The base to emitter side is split from the emitter to collector side. You move a ground to the emitter to to this and re-arange the rest of the circuit. The resultant circuit must have zero phase (or zero phase modulo 360 degrees) and gain at the crystal's frequency. Good old LT Spice will let you run through this once you know the right numbers for your crystal. Some 32 KHz crystals have Rm up around 150K ohms, Q's in the 100,000 range are doing quite well. C0 of a pf or two is not unusual.Lots of fun.Bob

author: alsetalokin4017
author_rank: Super Contributor
timestamp: February 01, 2016, 02:59:11 am
content: Quote from: orolo on January 31, 2016, 10:13:36 pmUsing the resistor values you suggested, I could not get the circuit to work using generic unbranded 7404 or TI SN7404N. However it did "sort of" work with TI SN74LS04J and worked fairly well with RCA SN74HCT04E. Using about 2 1/2 volts for Vcc for LS and 3-5 V for HCT. See the scopeshots below. I tied unused gates to ground and used a 100nF local decoupling cap across pins 14 and 7.118=SN74HCT04E119=SN74LS04J

author: orolo
author_rank: Frequent Contributor
timestamp: February 01, 2016, 07:27:55 pm
content: Quote from: alsetalokin4017 on February 01, 2016, 02:59:11 amWhoa! Thank you for the tests, they are wonderful. Today at work I asked a kind friend with a stock of old ICs for 74LS04Ns, and he borrowed me two. I think they are Signetics dated '78 and '79! Okay, I set up a quick test, and failed to start the oscillator with the resistors I suggested. So I changed R3 and RL by pots, and started tweaking until I found a rather consistent circuit.The values that worked for me are: R1 = 2.2K (I didn't have 1.8K at hand, too lazy to use two resistors.) R3 = 15K. RL = 13K. R2 = 470 as suggested by the book. The 13K value for RL is reasonable: looking up the series resistance of 32Khz crystals, I found 18K being a typical value. I tried both 7404s and the oscillator worked. I also tried three crystals, and worked for them all. I have attached a waveform capture with my cheap 'scope, and a picture of the circuit.Some comments: the circuit sometimes locks to an harmonic (the fifth in my case), and oscillates heavily without the crystal. The duty cycle is not good: when I tweaked R3 to reach 50/50, the short pulses before and after the main waveform that plagued your SN74LS04J appeared. Some of these effects may relate to parasitics in the circuit, but perhaps the two TTL stages have not enough gain to drive the load of the crystal. I wonder what would happen if two more inverters were added, for additional gain.Thanks again for the experiments!

author: ali6x944
author_rank: Frequent Contributor
timestamp: February 05, 2016, 08:55:05 am
content: thanks guys, really good explanation and documentation!u r the best!

author: orolo
author_rank: Frequent Contributor
timestamp: February 05, 2016, 10:35:05 pm
content: Just to bring some closure to the topic, you mentioned you had at hand a 74HC00. I think TTL, as chris_leyson mentioned early on, is not good for 32768Khz: the low input impedance spoils the Q of the oscillator big time. Why don't you try Pierce with 74HC00?I have done just that in about half a hour, with the only problem of some ringing in the transitions, which I haven't bothered to track down. The schematic, image of the prototype and 'scope capture are attached. The duty cycle and stability are greatly improved in comparison to the TTL circuit above!

author: ali6x944
author_rank: Frequent Contributor
timestamp: February 06, 2016, 05:45:54 am
content: i looked at the second schematic and it worked just fine like the first one...but i was wondering why did u use a NAND 74HC00 instead of NOR 74HC32 ?will it make any difference ?and why didn't u connect both inputs of the 74HC00 together to form an inverter?

author: orolo
author_rank: Frequent Contributor
timestamp: February 06, 2016, 10:52:09 am
content: Quote from: ali6x944 on February 06, 2016, 05:45:54 amWell, some posts back you mentioned you had some 74HC00s but you couldn't make the two-inverter circuit to work. With CMOS inverters I thought it was better to use Pierce instead of the two-inverter circuit. Using NOR gates should not make any difference at all, any high-impedance inverter circuit with enough gain should work.Quote from: ali6x944 on February 06, 2016, 05:45:54 amI guess it would not make any difference, but since I had the power rails close to the gate inputs, I preferred to have as many inputs in a fixed state as possible. In fact, the normal arrangement is with both inputs connected, as you mention. Just to make sure there is not difference, I'll try with both inputs connected and let you know. Thank you for being so thorough.

author: ali6x944
author_rank: Frequent Contributor
timestamp: February 06, 2016, 10:57:43 am
content: thanks man for all the info, it was very helpful!