Crystal Oscillator Circuit - Page 1
Forum section: electronics / beginners

author: pietergoos
author_rank: Newbie
timestamp: September 28, 2017, 05:54:43 pm
content: Hi everyone,I'm currently working on a project for my university but we're being restricted in components. For the last section that I have yet to complete I need to make an oscillating circuit based off of a 75kHz tuning fork crystal.I have some other components to use, A 74HCT04 NOT Gate (Buffered I think), an MCP602 (opamp) and TL82CP (opamp). Any caps and resistors are available as well.The circuit must output a 5V peak to peak square wave with a 2.5V DC offset (so basically 0 to 5V square wave).The Crystal I have, I measured to have a frequency of 74997Hz, ESR of 33775 Ohm, Cp = 1.5pF, Cs = 1fF and L = 4503H. The series capacitance value was recommended by my lecturer.Does anyone have any recommendations for what I can try, as I've struggled to build anything let alone simulate it in LT SPICE.PS: I've tried to use the NOT gate, but it's not working as I think it is buffered (from what I can understand from the Data Sheet). Our lecturer recommended putting an LP filter between 2 op-amps in an inverting and non-inverting config; the crystal is then connected between the other ends of the op-amps. The problem is I have no idea of how to get this to workRegardless,If anyone has any advice for me, as I can't find much on low frequency oscillators, please do let me know.Thanks in advance!

author: PA0PBZ
author_rank: Super Contributor
timestamp: September 28, 2017, 06:13:27 pm
content: Normally you'd want an unbuffered HC04 for that, but I'm not sure it can't be done with a HCT04. For sure these guys suggest it can be done:Maybe increase the value of the cap because this uses a 3MHz crystal.

author: Benta
author_rank: Super Contributor
timestamp: September 28, 2017, 06:30:39 pm
content: Quote from: PA0PBZ on September 28, 2017, 06:13:27 pmThat won't fly, power levels are far too high for tuning-fork crystals, they are very easily overdriven.Something like this will work (you'll need to reduce the capacitances a bit):

author: edavid
author_rank: Super Contributor
timestamp: September 28, 2017, 06:36:40 pm
content: Look up any common 32kHz crystal oscillator circuit using an unbuffered CMOS inverter (4069, 74C04, 74HC04, etc.). Now replace the CMOS inverter and its feedback resistor with an MCP602 op amp circuit with a gain of -10 (or try a different gain if that doesn't work). Use the 74HCT04 to buffer the op amp's output.ETA: The circuit posted by Benta is fine, but as I said, replace the inverter that's used as an amplifier, with an op amp amplifier.

author: pietergoos
author_rank: Newbie
timestamp: September 29, 2017, 08:09:52 am
content: I'll give that a try, but unfortunately, I have no access to the labs here over the weekend, so it'll have to wait until Monday, for testing at least. Thanks for your advice, and everyone else's!

author: Ian.M
author_rank: Super Contributor
timestamp: September 29, 2017, 08:34:24 am
content: +1 for the MCP602 dual OPAMP. Use one half as the inverting gain stage of a Pierce oscillator and the other as a comparator to square up the output. N.B. use high value resistors for the input and feedback resistor round the OPAMP to minimise the load on the crystal.

author: danadak
author_rank: Super Contributor
timestamp: September 29, 2017, 11:58:42 am
content: This might help -http://www.ti.com/lit/an/slaa322d/slaa322d.pdfhttp://www.ti.com/lit/an/swra372c/swra372c.pdfhttp://ww1.microchip.com/downloads/en/AppNotes/00826a.pdfhttps://www.nxp.com/docs/en/application-note/AN3208.pdfhttps://www.fairchildsemi.com/application-notes/AN/AN-340.pdfRegards, Dana.

author: Zero999
author_rank: Super Contributor
timestamp: September 29, 2017, 12:08:53 pm
content: I like the 74LVC1GX04 because it's compact, but the 74LVC1404 should be better, because it has a Schmitt trigger buffer and a disable option to save power, when it's not needed.http://www.ti.com/lit/ds/symlink/sn74lvc1gx04-ep.pdfhttp://www.ti.com/lit/ds/symlink/sn74lvc1404.pdf

author: Benta
author_rank: Super Contributor
timestamp: September 29, 2017, 02:17:02 pm
content: Finding optimised parts is of course wonderful, but from reading the OP, this is not an option, the ICs are given.

author: Zero999
author_rank: Super Contributor
timestamp: September 29, 2017, 08:00:48 pm
content: Quote from: Benta on September 29, 2017, 02:17:02 pmYes that's annoying. I hate having to make do with parts which are not designed for the purpose, but I suppose that's the whole point of a university project.I agree with edavid's suggestion of using the MCP602 op-amp. The rise/fall times, nearly 2µs (page 9 on the data sheet), may not be fast enough to drive a digital circuit but that might not matter, if all that's required is answering the assignment question.http://ww1.microchip.com/downloads/en/DeviceDoc/21314g.pdf

author: edavid
author_rank: Super Contributor
timestamp: September 29, 2017, 08:02:59 pm
content: Quote from: Hero999 on September 29, 2017, 08:00:48 pmHe can use his 74HCT04 to clean that up (perhaps even making it into a Schmitt trigger).

author: orolo
author_rank: Frequent Contributor
timestamp: September 29, 2017, 09:31:20 pm
content: Just for fun, I tried to simulate an op amp Pierce oscillator for this crystal. Pierce needs lots of gain, and the gain limit for a single inverting TL082 stage at 75kHz is about -50. I think it's a good idea to buffer the inverting amplifier, so the resistors don't have to get too big. The power dissipated at the crystal is about 1.2uW, a little over the 1uW typical level. The oscillator takes about to 250ms to get to clipping oscillation, and outputs a ~5.3Vpp square wave.I don't have a 75kHz crystal around, so I can't test if this would work in reality. Maybe the circuit is overcomplicated, but at least it's an starting point if you want to try Pierce with op amps.

author: Zero999
author_rank: Super Contributor
timestamp: September 29, 2017, 09:48:56 pm
content: Quote from: orolo on September 29, 2017, 09:31:20 pmVery good.Unfortunately the TL072 model isn't part of the default LTSpice install, so many people won't be able to view the file you attached. What's odd is I do have TL072.sub and TL072.asy but the op-amp symbols appeared in the wrong place. Fortunately, it's possible to embed the model in the .asc file and use opamp2.asy for the symbol.The oscillation will start sooner if LTSpice is set to start the simulation with the power supply at 0V, then turn it on, which is more representative of real life.

author: BaconAndEggs
author_rank: Newbie
timestamp: October 01, 2017, 01:45:54 pm
content: Hi all. Sorry if I'm late to the party.I'm also doing the same assignment as what OP is doing and from the awesome advice in this thread I designed an oscillator with a 77.5kHz resonant frequency. I got the design from this link:http://endorphino.de/projects/electronics/timemanipulator/index_en.html.Please can you let me know if there is anything that I can change in the design to get a more clean output. Thanks!Also the spice model that was linked above has a VCC of 9V. We only have access to rails of 5V and 0V respectively with a "virtual ground" of 2.5V.

author: Benta
author_rank: Super Contributor
timestamp: October 01, 2017, 01:51:05 pm
content: Give U3 positive feedback to make it into a Schmitt trigger.Also, I think 33 pF is a bit high for the crystal load caps. I'd think something like 10 pF would be closer to the mark.

author: BaconAndEggs
author_rank: Newbie
timestamp: October 01, 2017, 01:53:17 pm
content: With regards to the positive feedback. What resistors would you recommend?ThanksEDIT: added an attachment to show the output of U2 during oscillation.

author: Ian.M
author_rank: Super Contributor
timestamp: October 01, 2017, 02:05:15 pm
content: The issue is probably the limited slew rate of the OPAMP. It probably needs a hybrid solution - Try using the 74HCT04 on the output to square up the signal. It will be very tricky to get a good 50% duty cycle though.

author: Zero999
author_rank: Super Contributor
timestamp: October 01, 2017, 05:47:38 pm
content: Try this. The hysteresis voltage is equal to RIN/RF×VCCand will be centred around the middle of the logic gate's threshold.

author: Benta
author_rank: Super Contributor
timestamp: October 01, 2017, 06:28:27 pm
content: Quote from: Hero999 on October 01, 2017, 05:47:38 pmYeah, that'll work if you use two 'HC04 gates. If you stick with the opamp for U3, try with 1 Mohm feedback and 10 kohm input resistor.

author: orolo
author_rank: Frequent Contributor
timestamp: October 01, 2017, 06:31:54 pm
content: If you are allowed only a 5V rail, it's no use giving you a TL082. This op amp is specified from 8V upwards. You can use a MCP602 with the same circuit from a 5V rail, though this op amp has much less slew rate.With logic circuits like buffered inverters you might try the classic two inverter oscillator mentioned above. I have found a spice model for a 74HC04 down to the transistor level, and it works quite well. Following Hero999's idea, for compatibility I put the spice model for the inverter into the asc file, and used the universal opamp symbol for the inverter: the noninverting input of the opamp symbol is connected to ground. The important detailk about this circuit is that resistor R3 should be a bit smaller than the crystal resistance.The spice model used is an HC04, not an HCT04, but with luck the idea is the same, just with the 1.4V transition. The first model I tried was in fact for a 74HCT04 from the Nexperia webpage, but I had to cannibalize several spice files in order to insert them into the asc file, so I don't know if it's reliable. With that model I got lots of parasitics, both in the Pierce circuit (too much gain for an unbuffered inverter, the same happens with this HC04 model), but also in the two inverter circuit. The Nexperia model includes package parasitics and likes to self oscillate in the 10-20MHz range.

author: Gyro
author_rank: Super Contributor
timestamp: October 01, 2017, 06:35:55 pm
content: Is there no possibility of you being able to us a 74HCU04?

author: Benta
author_rank: Super Contributor
timestamp: October 01, 2017, 07:10:31 pm
content: orolo, please read Reply #2 again.Your proposed circuit has waaaaay to much drive power for a tuning fork crystal, limit is around 1 uW. Yes, you read correctly: one microwatt.Here's a link for enlightenment:https://www.maximintegrated.com/en/app-notes/index.mvp/id/58

author: orolo
author_rank: Frequent Contributor
timestamp: October 01, 2017, 07:17:37 pm
content: Quote from: Benta on October 01, 2017, 07:10:31 pmI'm aware of the 1uW limit, see post #11 above. However, this is the only circuit I have managed to get to work (in simulation) with logic ICs for now, after many tries with the Pierce + inverter. BTW, using a Pierce + 74HCU works fine, but 74HC(T) fails for me. And yes, it's easy to see that the two inverter circuit drives the crystal into the tens of microwatts; I've just simulated the circuit.

author: Benta
author_rank: Super Contributor
timestamp: October 01, 2017, 07:22:11 pm
content: So why post it if it doesn't work?

author: orolo
author_rank: Frequent Contributor
timestamp: October 01, 2017, 07:42:05 pm
content: Quote from: Benta on October 01, 2017, 07:22:11 pmDepends of your definition ofdoesn't work: and overdriven crystal may fail earlier, age badly or fail instantly. The first two cases are good enough for experimentation, a quick demonstration or a beginner's exercise. It's certainly not advisable for a finished product. That this topology is relevant, even if overdriven, can be attested in the biblography (just review the ubiquitous Matthys book, where this circuit is suggested for up to 200-400kHz or so).

author: Benta
author_rank: Super Contributor
timestamp: October 01, 2017, 07:45:53 pm
content: meh

author: orolo
author_rank: Frequent Contributor
timestamp: October 01, 2017, 07:52:35 pm
content: Quote from: Benta on October 01, 2017, 07:45:53 pmCharming. Anyway, I'll try to get some time to build 32768 crystal oscillators with Pierce + 74HC04, the two inverter version, and Pierce + 74HCU04. I want to test if the first circuit doesn't work, the second explodes, and the third works. After a lot of spice time with them, I find the three variants very intriguing.

author: Benta
author_rank: Super Contributor
timestamp: October 01, 2017, 08:16:14 pm
content: Quote from: orolo on October 01, 2017, 07:52:35 pmGo ahead and have fun. I've built dozens of these with HC04, HCT04, HCU04, 4049, 4069 etc.They always work if you remember to limit the drive (220...470 kohms in series with the crystal), bias the inverter with a few Mohms and use the right load capacitors for the crystal (there are two flavours of 32 kHz parts on this parameter).Where you can go wrong is using an HC14 or another Schmitt trigger gate. It won't work.Mind you, we're not talking chronometer precision here, for that there are other solutions.

author: Beamin
author_rank: Super Contributor
timestamp: October 01, 2017, 08:39:22 pm
content: Quote from: BaconAndEggs on October 01, 2017, 01:45:54 pmThat time machine thing is quite an impressive build. Looks like it is an actual piece of test equipment.

author: Zero999
author_rank: Super Contributor
timestamp: October 01, 2017, 08:45:39 pm
content: Quote from: orolo on October 01, 2017, 07:52:35 pmCan't you get hold of a 75kHz crystal?Digikey has them and ship to Spain but I suppose it's not worth it, unless it's part of a large order.https://www.digikey.com/product-detail/en/citizen-finedevice-co-ltd/CFV-20675000DZFB/300-8851-ND/5970255

author: orolo
author_rank: Frequent Contributor
timestamp: October 01, 2017, 09:14:12 pm
content: Quote from: Benta on October 01, 2017, 08:16:14 pmHow about clipping the output of the second gate using 100k and then two diodes coupled by a capacitor? A bit complicated, but at first it seems promising to take the power under 1uW.Quote from: Hero999I'm not planning a big enough order just now. On the other hand, I've some100kHz tuning fork crystalsI could use instead of the 32k crystals. I guess these are more equivalent to the 75kHz case.If I get the time, I'll try tomorrow the two gates circuit @ 100kHz. I expect Benta to be right and the crystals not surviving a long time the drive of the circuit: in the simulation, the power at the crystal grows almost linearly for 0.3 seconds, way past 1uW. I wonder if with some kind of limiting it will get better.

author: Beamin
author_rank: Super Contributor
timestamp: October 01, 2017, 09:42:38 pm
content: How exactly do you get a signal out of the crystal its not as it has inputs and out puts. You apply DC to it and does it act like a capacitor sort of? Or along with your DC do get a tiny oscillation along with it? If you look at the first two circuits one has the xtal in between the op amps the other is before it. Why do both of these work?

author: Zero999
author_rank: Super Contributor
timestamp: October 01, 2017, 09:51:13 pm
content: Quote from: Beamin on October 01, 2017, 09:42:38 pmA crystal is just a resonator. It can be modelled as a resistor + capacitor & inductor in series, with another shunt capacitance in parallel, as has been shown in the LTSpice schematics posted previously. Look it up using a search engine.

author: pietergoos
author_rank: Newbie
timestamp: October 02, 2017, 08:26:42 am
content: I spoke to the lab manager, we are allowed to use the NOT gates that they have in stock, however, they only have 74HC04 and 74HCT04 available.Hence, I'm going to be trying it with the HC04, it seems like a better bet from what everyone is saying!

author: Ian.M
author_rank: Super Contributor
timestamp: October 02, 2017, 09:02:11 am
content: Attempt to bias a single gate of the 74HC04 inverter into its linear region with negative feedback and see if you can get stable, linear x20 inverting gain with reasonable amplitude. For the purposes of this experiment assume that a 74HC04 gate is equivalent to a very fast OPAMP, with its +in internally tied to Vcc/2. Tie all other gate inputs low for now.The capacitance at the gate input must be as low as possible - if its time constant with the feedback resistor is greater than the propagation delay it will probably form a RC oscillator. Start with just the feedback resistor, and check the output is near Vcc/2, and isn't oscillating, using a good x10 probe on a scope with 100MHz or better bandwidth. Then add an input resistor and a small coupling cap, and check it still isn't oscillating with the other side of the coupling cap grounded. Then apply a sinusoidal test signal and check it amplifies as expected. If all is good, you've got a gain stage that can be used in any of the oscillator circuits that have been suggested.If you cant get stable amplification, you'll need to go for an OPAMP for the oscillator itself followed by a chain of 74HC04 gates to square it up. In that case, capacitively couple the OPAMP output to the 74HC04 input of the first gate, and bias the gate input with a 10K pot with 10K end stop resistors connected as a potential divider between Vcc and Gnd. Adjust for 50% duty cycle at the output of the chain of gates (or use a 2.2K resistor and a 0.1uF cap as a low pass filter and adjust for an average output of Vcc/2 on a DMM). As you've got six gates in the package, you may wish to parallel multiple gates at the output for more drive capability.

author: Zero999
author_rank: Super Contributor
timestamp: October 02, 2017, 10:37:20 am
content: A single 74HC04 gate is buffered, therefore is really three CMOS inverters connected in series. If the input is connected to the output, via a resistor, it will form a ring oscillator, if you're not careful. I wonder if a small capacitor connected from the input to output, in parallel with the feedback resistor will help to prevent oscillation?

author: Ian.M
author_rank: Super Contributor
timestamp: October 02, 2017, 07:00:15 pm
content: NXP have component level 74HC/HCT SPICE models here:https://assets.nexperia.com/documents/spice-model/hc.zipThe 74HC04 model is defined solely in terms of MOSFETs and passives.I've extracted the 74HC04 model with PDIP-14 package parasitics and its prerequisites and patched them together in one file for LTspice.Use with the LTspiceopamp2symbol. Do not connect the +in.Set the value to74HC04and include the model by:Code:.lib 74HC04P.subNXP 74HC04 datasheet:https://assets.nexperia.com/documents/data-sheet/74HC_HCT04.pdf@Hero999: Yes, the dammed thing oscillates - *FAR* too much gain! Getting it stable and in its linear region is not so simple.@pietergoos,Unless they have 74HCU04 or 74HC04U,*DON'T*waste your time trying to use negative feedback round a 74HC04!Are there any discrete transistors, JFETs or small signal MOSFETs available?

author: floobydust
author_rank: Super Contributor
timestamp: October 03, 2017, 04:30:14 am
content: Similar circuits and discussion here:https://www.eevblog.com/forum/projects/low-jitter-100khz-oscillator-for-ad/msg1304001/#msg1304001

author: pietergoos
author_rank: Newbie
timestamp: October 04, 2017, 08:14:50 am
content: Just an update from my side, I managed to build the circuit shown in reply 19, this worked very well and is now implemented in my circuit.Thank you to all for the help, I'll attach an image of the resultant wave.Many thanks to all who've helped!

author: Ian.M
author_rank: Super Contributor
timestamp: October 04, 2017, 09:27:18 am
content: Unfortunately the reply#19 circuit may overdrive the crystal significantly which can result in frequency errors and early crystal failure. Check your crystal's datasheet for the maximum permissible drive power.In LTspice, when its reached steady state, plot the power in R2 by alt-clicking it, and average it over about 10ms by selecting that range on the plot then ctrl-clicking the waveform title. For the original reply#19 circuit, it will be about 10mW. To reduce it to about 1mW, insert a potential divider, 1K upper arm and 330R lower arm between U2 output and the crystal.In real life, to measure the drive power seehttps://www.idt.com/document/apn/830-quartz-crystal-drive-level

author: floobydust
author_rank: Super Contributor
timestamp: October 04, 2017, 10:23:36 pm
content: I think you mean 330kohm there, like this slide.I've never had success measuring LF crystal oscillators.That app note uses Tektronix CT-6 AC current probe, about $750 and using a JFET seems to miss the phase-shift, so very difficult to measure actual crystal drive power.Watchmakers use an inductive pickup for frequency, I should make that someday.NC-38 32.768kHztuning fork crystals seem to be around 1uW max. drive level. That is very tiny drive.

author: Ian.M
author_rank: Super Contributor
timestamp: October 04, 2017, 10:45:10 pm
content: No. the reply #19 circuit is the two inverter typeThe crystal has 5V peak to peak drive on one side and the other side sees the 30K resistor that's part of the feedback network to the first gate input. You cant increase the 30K resistor significantly without causing the gates to toggle at an integer fraction of the crystal frequency so the only option is to reduce the drive level by reducing the drive voltage. You *COULD* run the inverters at 2.5V Vcc, but if you need 5V logic compatibility, its simpler to put a fairly low impedance potential divider between the second gate output and the crystal.

author: orolo
author_rank: Frequent Contributor
timestamp: October 07, 2017, 04:52:58 pm
content: Okay, at last I managed to get some time to prove that circuit #19, with some common sense, needs not overdrive the crystal at all.The idea is to add a couple of Schottky diodes to limit the drive to the crystal.For a mathematical proof, the diodes will limit the drive into the crystal to a 200mVpp square wave. If we couple that drive to the first mode of the oscillator, we get the steady state excitation of the crystal. In voltage terms, it amounts to \$\frac{2}{\pi}V_{e}\frac{R_l}{R_s + R_l}\$, where Ve is the square wave excitation, Rs the series resistance of the crystal, and Rl the load resistance. In our case, the load resistance equals the series resistance, so the sinusoidal amplitude in the crystal reduces to \$V_e/\pi\$. The power dissipation is \$P \ = \ \frac{V_e^2}{2\pi^2R_s}\$ which, taking Ve=200mV and Rs=33775 Ohm, gives P = 0.33uW. Not bad. LTSpice is more optimistic and predicts about 0.2uW.I've built a quick version of this circuit, and it works, but with quite a few parasitics. I think the problem is the layout; if the diodes are removed the parasitics remain. In fact, the circuit self oscillates without crystal.In the picture I'm using a 100kHz crystal. I've also tested the circuit with a 32kHz crystal. I attach traces for the 100kHz oscillation, the 32kHz oscillation, and a trace of the schottky section at 32kHz. The RMS square wave is 163mV RMS, so the drive to the crystal is very soft.I can improve the oscillator to make it cleaner, but think this goes a long way proving that the two inverter topology needs not overload the crystal if done right.Sorry about the delay answering this. I've have had a long, hard week.

author: Beamin
author_rank: Super Contributor
timestamp: October 07, 2017, 07:13:33 pm
content: Quote from: orolo on October 07, 2017, 04:52:58 pmHow do you get the formulas to come up on a forum? I have only been able to copy/paste them which is a pain.

author: orolo
author_rank: Frequent Contributor
timestamp: October 07, 2017, 07:47:51 pm
content: Put your LaTeX equations betwen \ $ and \ $.See these older threads:https://www.eevblog.com/forum/chat/$latex$-instructions/msg867803/#msg867803https://www.eevblog.com/forum/suggestions/latex-for-eevblog/msg864707/#msg864707