I did some more playing with the test circuit I built and finally got some repeatable success.
First of all, here's the test circuit:
The crystal's in the middle with caps to either side. The op amp is floating above, positive input is on the left (yellow wire), negative input is on the right (white wire), output is the blue wire. The female headers allowed me to play with gain and bias voltage. The bits of pin header sticking out are for scope probes (connected to the op amp's output, GND, and input reading from left to right).
I found that the bias voltage of Vcc/2 was unnecessarily low. Taking it up to at least 2Vcc/3 gave me much better oscillation from a cold start. I even removed the lower resistor from the voltage divider and just fed the positive input a straight Vcc, and it still oscillated by itself.
I got the best performance from feedback resistors between 1M and 10M. The 10M output showed some clipping, but the 1M output was fairly clean. Feedback below 1M showed a tendency to kick the crystal up to a harmonic, oscillating with much lower peak-to-peak voltage at 192kHz.
The signal from the op amp's output will be non-sinusoidal.. it ranged between trapezoidal and triangle waves as I tried various options. The signal at the op amp's input is sinusoidal, with clipping determined by the excess gain.
I did relearn something by experience though: Connecting a scope probe to the op amp's input will kill startup. It takes a couple of seconds for a crystal to start ringing, and even a 10M path to GND will swallow the tiny signals that get things going. It's okay to connect a probe once the oscillation gets going, but in a circuit you'd want to use a second op amp as a voltage buffer.
Crystal Oscillator Question (TS922 Op Amp)
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- adafruit_support_mike
- Posts: 67485
- Joined: Thu Feb 11, 2010 2:51 pm
- mauifan
- Posts: 174
- Joined: Sun Aug 12, 2012 11:13 pm
Re: Crystal Oscillator Question (TS922 Op Amp)
I trust that this is based on the schematic you provided a few posts ago?
- john444
- Posts: 443
- Joined: Sun Mar 04, 2012 2:42 pm
Re: Crystal Oscillator Question (TS922 Op Amp)
Mauifan,
An amplifier drives the crystal hard enough that the tops & bottoms of the 'wave' are chopped off at the + supply voltage and ground. The oscillator is usually quickly followed by divider circuitry.
You seem to have confused a sine-wave oscillator and a square-wave oscillator.
A sine-wave oscillator is a delicate balance between too much and not enough gain.
A digital oscillator simply has 'more than enough' gain so that it switches between fully-on and fully-off.
No.
The ATMega does not use a sine-wave oscillator.mauifan wrote:but AVR doesn't put a light bulb in their ATMega controllers, right? What do they do to get consistent oscillation?
An amplifier drives the crystal hard enough that the tops & bottoms of the 'wave' are chopped off at the + supply voltage and ground. The oscillator is usually quickly followed by divider circuitry.
You seem to have confused a sine-wave oscillator and a square-wave oscillator.
A sine-wave oscillator is a delicate balance between too much and not enough gain.
A digital oscillator simply has 'more than enough' gain so that it switches between fully-on and fully-off.
mauifan wrote:Does an inductor function as the "light bulb"?
No.
- mauifan
- Posts: 174
- Joined: Sun Aug 12, 2012 11:13 pm
Re: Crystal Oscillator Question (TS922 Op Amp)
No... The difference between a square wave and a sine wave seem to be one of the few things I understand. I am just getting really frustrated with this. Based on everything I have seen in terms of this thread, a square wave is an "overamplified" sine wave that gets clipped... so in theory and given that I am using potentiometers to tune my circuit, I should be able to find a gain setting that gives me the sine wave I once saw.john444 wrote:You seem to have confused a sine-wave oscillator and a square-wave oscillator.
Instead, I get circuits that sometimes oscillate and sometimes they don't.
It certainly makes me feel better to know that you experts struggle with this, too... but at the same time, it is somewhat disheartening to try the things y'all tell me (like mstone's circuit) and still not get it to work.
- adafruit_support_mike
- Posts: 67485
- Joined: Thu Feb 11, 2010 2:51 pm
Re: Crystal Oscillator Question (TS922 Op Amp)
Couple of points:
A) I was all set to say "yes, the test circuit matches the diagram I gave earlier" when I had a sudden burst of doubt which sent me back to the bench to double check the connections.. turns out, after double checking, that circuit shown in the picture does indeed match the diagram.
B) I know it's frustrating, but you're not alone in the slightest way. This app note by Jim Williams (former staff scientist for Linear Technology and revered analog circuit guru):
http://cds.linear.com/docs/Application% ... an12fa.pdf
starts off with three paragraphs that essentially say, "yeah.. these things are insanely fussy". To quote him:
There are times I'd swear the dam' things can detect brain waves and will stop working if they sense doubt.
In practice, every sine wave oscillator that actually works has some amount of clipping. If you're really careful (or really lucky), the amount of clipping can be really small. The closer you get to a pure sine wave, though, the more delicate the circuit's balance becomes.
Clipping represents the amount of energy in the circuit above the absolute minimum necessary to sustain oscillation. A perfect sine wave means zero extra energy, so even the slightest dip (which is guaranteed to happen) will push the circuit below the minimum level, and the oscillation will die out.
Potentiometers, meanwhile, are noisy. There's a lot of stick-and-slip action at the microscopic level when you adjust them. That noise echoes through the oscillator's feedback loop and can produce butterfly/hurricane effects. The best way to adjust pots -- and I'm serious about this -- is to move the knob while the power is off, tap the housing with a pencil a few times, wait a couple of seconds, then turn the power on. It's tedious as all get out, but is much more likely to give you repeatable results.
At the risk of frustrating you further, I can suggest modifications to the circuit I've already suggested, or other circuits that might start up more easily. I do feel like I've been throwing lots of fastballs at your admirably patient head though, and don't want to overload you if you aren't in the mood for more unknowns.
A) I was all set to say "yes, the test circuit matches the diagram I gave earlier" when I had a sudden burst of doubt which sent me back to the bench to double check the connections.. turns out, after double checking, that circuit shown in the picture does indeed match the diagram.
B) I know it's frustrating, but you're not alone in the slightest way. This app note by Jim Williams (former staff scientist for Linear Technology and revered analog circuit guru):
http://cds.linear.com/docs/Application% ... an12fa.pdf
starts off with three paragraphs that essentially say, "yeah.. these things are insanely fussy". To quote him:
.. and those are the 'easy' square wave versions.It is not uncommon in circuits of this type for gates from different manufacturers to produce markedly different circuit operation. In other cases, the circuit works, but is influenced by the status of other gates in the same package. Other circuits seem to prefer certain gate locations within the package.
There are times I'd swear the dam' things can detect brain waves and will stop working if they sense doubt.
I know exactly how you feel because I've been there myself.. and not all that long ago, either. Last month I spent two weeks glaring at a bone-simple RC phase shift oscillator that Just Would Not Behave. It was part of a potential kit design, but was so fussy that I shelved the whole project because I can't in good conscience sell people a kit that apparently has to be built during a specific phase of the moon. When I've stopped wanting to throw that particular breadboard through the wall quite so much, I'll go back and try again.mauifan wrote:It certainly makes me feel better to know that you experts struggle with this, too... but at the same time, it is somewhat disheartening to try the things y'all tell me (like mstone's circuit) and still not get it to work.
You're absolutely right about that.mauifan wrote:Based on everything I have seen in terms of this thread, a square wave is an "overamplified" sine wave that gets clipped...
This is the part that could potentially drive you mad.mauifan wrote:so in theory and given that I am using potentiometers to tune my circuit, I should be able to find a gain setting that gives me the sine wave I once saw.
In practice, every sine wave oscillator that actually works has some amount of clipping. If you're really careful (or really lucky), the amount of clipping can be really small. The closer you get to a pure sine wave, though, the more delicate the circuit's balance becomes.
Clipping represents the amount of energy in the circuit above the absolute minimum necessary to sustain oscillation. A perfect sine wave means zero extra energy, so even the slightest dip (which is guaranteed to happen) will push the circuit below the minimum level, and the oscillation will die out.
Potentiometers, meanwhile, are noisy. There's a lot of stick-and-slip action at the microscopic level when you adjust them. That noise echoes through the oscillator's feedback loop and can produce butterfly/hurricane effects. The best way to adjust pots -- and I'm serious about this -- is to move the knob while the power is off, tap the housing with a pencil a few times, wait a couple of seconds, then turn the power on. It's tedious as all get out, but is much more likely to give you repeatable results.
At the risk of frustrating you further, I can suggest modifications to the circuit I've already suggested, or other circuits that might start up more easily. I do feel like I've been throwing lots of fastballs at your admirably patient head though, and don't want to overload you if you aren't in the mood for more unknowns.
- mauifan
- Posts: 174
- Joined: Sun Aug 12, 2012 11:13 pm
Re: Crystal Oscillator Question (TS922 Op Amp)
I went back to the proverbial drawing board and built the following circuit:
R1, R2, and R3 are all pots that range between zero ohms and:
R1=10k
R2=1M
R3=100k
xtal = 32kHz
If U1 is the TS922, I get reliable ringing. The wave form varies depending on the settings of R1, R2, and R3 -- but I always get something, even if it isn't the [near] sine wave that I am shooting for.
If U1 is the LM324N, I get nothing. Zero volts output no matter what settings are on these pots. My breadboard is set up in a manner such that I just disconnect the TS922's pins and connect them to the corresponding pins on the LM324N.
Clearly, there is a difference in construction between the TS922 and LM324N... but how do you experts determine what that is? Obviously, you look at the datasheets... but do y'all look for something specific, or is it just trial-and-error?
(Again...this is part of the frustration for me. I am used to a "black box" approach, where it shouldn't matter what's inside the box.)
R1, R2, and R3 are all pots that range between zero ohms and:
R1=10k
R2=1M
R3=100k
xtal = 32kHz
If U1 is the TS922, I get reliable ringing. The wave form varies depending on the settings of R1, R2, and R3 -- but I always get something, even if it isn't the [near] sine wave that I am shooting for.
If U1 is the LM324N, I get nothing. Zero volts output no matter what settings are on these pots. My breadboard is set up in a manner such that I just disconnect the TS922's pins and connect them to the corresponding pins on the LM324N.
Clearly, there is a difference in construction between the TS922 and LM324N... but how do you experts determine what that is? Obviously, you look at the datasheets... but do y'all look for something specific, or is it just trial-and-error?
(Again...this is part of the frustration for me. I am used to a "black box" approach, where it shouldn't matter what's inside the box.)
- john444
- Posts: 443
- Joined: Sun Mar 04, 2012 2:42 pm
Re: Crystal Oscillator Question (TS922 Op Amp)
Hi MauiFan,
I had to go look this up in (one of my favorite books) “The Art of Electronics”.
The LM324’s inputs can go to ground but, cannot go above 1.5-V less than the + supply.
I suspect that is why the LM324 is not working for you.
If the inverting input is slightly higher than the + input, the output then goes low
and you are stuck there because with a single supply, you are operating both inputs
close to the (–) supply voltage.
See what happens when your circuit is powered from some AA cells.
Use say, 3 AA cells for the +V and an additional 3 AA cells for the –V.
The midpoint connection becomes ground.
Also, the LM324 does not like driving capacitive loads (the crystal is a capacitor).
The LM324 will need a series resistor to isolate the output from the crystal.
I will see if I can put something together this weekend so we can compare notes.
However, I do have a long list of 'honeydos'. We will see how it works out.
John
Did you ever use a split-supply?mauifan wrote:If U1 is the LM324N, I get nothing.
Sometimes, the mfg datasheets are not enough.mauifan wrote:Clearly, there is a difference in construction between the TS922 and LM324N... but how do you experts determine what that is?
I had to go look this up in (one of my favorite books) “The Art of Electronics”.
The LM324’s inputs can go to ground but, cannot go above 1.5-V less than the + supply.
I suspect that is why the LM324 is not working for you.
If the inverting input is slightly higher than the + input, the output then goes low
and you are stuck there because with a single supply, you are operating both inputs
close to the (–) supply voltage.
See what happens when your circuit is powered from some AA cells.
Use say, 3 AA cells for the +V and an additional 3 AA cells for the –V.
The midpoint connection becomes ground.
Also, the LM324 does not like driving capacitive loads (the crystal is a capacitor).
The LM324 will need a series resistor to isolate the output from the crystal.
I will see if I can put something together this weekend so we can compare notes.
However, I do have a long list of 'honeydos'. We will see how it works out.
John
- john444
- Posts: 443
- Joined: Sun Mar 04, 2012 2:42 pm
Re: Crystal Oscillator Question (TS922 Op Amp)
If op-amps were ideal 'black box' components, why do you suppose there are so many different ones?mauifan wrote:(Again...this is part of the frustration for me. I am used to a "black box" approach, where it shouldn't matter what's inside the box.)
There are lots of different op-amps because you can trade off some properties for others
but, you cannot have them all at the same time. Also, some things are easier to do than others.
The LM324 is the first (or one of the first) single supply op-amp.
It became available in 1974. The TS922 was released in Feb 2001.
There have been some improvements in the 27-years since 1974.
By comparing the datasheets you can see that compared to the LM324,
the TS922 is significantly closer to the 'ideal' op-amp but its still not perfect.
Here is a quote from "The Art of Electronics" by Paul Horowitz & Winfield Hill.
"The ideal op-amp has these characteristics:
1. Input impedance = infinity
2. Output impedance = 0
3. Voltage gain = infinity
4. Common-mode voltage gain = 0
5. V-out = 0 when both inputs are at the same voltage (zero offset voltage)
6. Output can change instantaneously (infinite slew rate)
Real op-amps depart from these characteristics...
All of these characteristics are independent of temperature and supply voltage changes."
Sorry, but it is not realistic to expect vastly different op-amps to be directly
interchangeable in a sensitive circuit like a sine-wave oscillator.
John
- mauifan
- Posts: 174
- Joined: Sun Aug 12, 2012 11:13 pm
Re: Crystal Oscillator Question (TS922 Op Amp)
Good point.john444 wrote:The LM324 is the first (or one of the first) single supply op-amp.
It became available in 1974. The TS922 was released in Feb 2001.
There have been some improvements in the 27-years since 1974.
By comparing the datasheets you can see that compared to the LM324,
the TS922 is significantly closer to the 'ideal' op-amp but its still not perfect.
Haven't checked the datasheet yet, but could this be remedied by connecting "large" resistors (oh... say 1-10Meg) to the LM324 inputs? The idea is that large resistors in series with the (+) and (-) inputs would help give the appearance that the impedance of the two inputs is closer to ideal.
As for the other questions, I am trying to attach some pictures... but not having the same success like I had for the diagram. Stay tuned.
- adafruit_support_mike
- Posts: 67485
- Joined: Thu Feb 11, 2010 2:51 pm
Re: Crystal Oscillator Question (TS922 Op Amp)
You'd get higher input impedance, but would pay for it with higher input error.mauifan wrote:could this be remedied by connecting "large" resistors (oh... say 1-10Meg) to the LM324 inputs? The idea is that large resistors in series with the (+) and (-) inputs would help give the appearance that the impedance of the two inputs is closer to ideal.
The LM324's input pins consume about 40nA of current in order to work.. that's the bias through the Darlington input stage. If you send that through a 10M resistor, you get 400mV of drop.
- john444
- Posts: 443
- Joined: Sun Mar 04, 2012 2:42 pm
Re: Crystal Oscillator Question (TS922 Op Amp)
Mauifan,
I am trying to help you here. I suspect that there is a fundamental
issue with using a single supply to power your LM324 oscillator circuit.
However, even though I have brought this issue up in several posts,
you do not seem interested in using split-supplies (as suggested in the
previous post) or using a different bias circuit. Is it just something
that you do not wish to try?
The input offset voltage goes up, gain and stability go down.
None of these properties will help make your oscillator work using the LM324.
Refer again to the comment above.
John
Does "Mauifan" mean you really like Hawaii's second-largest island?
I am trying to help you here. I suspect that there is a fundamental
issue with using a single supply to power your LM324 oscillator circuit.
However, even though I have brought this issue up in several posts,
you do not seem interested in using split-supplies (as suggested in the
previous post) or using a different bias circuit. Is it just something
that you do not wish to try?
Nope. Sorry, the input transistors 'need' a certain amount of current to operate properly. Adding excessive input resistance moves you further from the 'ideal'.mauifan wrote:could this be remedied by connecting "large" resistors (oh... say 1-10Meg) to the LM324 inputs? The idea is that large resistors in series with the (+) and (-) inputs would help give the appearance that the impedance of the two inputs is closer to ideal.
The input offset voltage goes up, gain and stability go down.
None of these properties will help make your oscillator work using the LM324.
Refer again to the comment above.
John
Does "Mauifan" mean you really like Hawaii's second-largest island?
- mauifan
- Posts: 174
- Joined: Sun Aug 12, 2012 11:13 pm
Re: Crystal Oscillator Question (TS922 Op Amp)
Alas... the forum will not let me upload the photos I took of my breadboard. I sent a query into Adafruit about this, but if someone knows the answer, please feel free to fill me in. I click on the "Upload attachments" tab, specify the file name and perhaps a comment, but no upload occurs when I click "add file."john444 wrote:See what happens when your circuit is powered from some AA cells. Use say, 3 AA cells for the +V and an additional 3 AA cells for the –V.
The midpoint connection becomes ground.
But to answer your suggestion about using 3 AA cells, I am already there. My breadboard is an old Radio Shack Electronics Learning Lab that I bought ~15 years ago. It is powered by six (6) AA cells in series. The breadboard has power rails that tap into these batteries, so I can get use Vcc values in 1.5V increments. My latest circuit connects to the 6V rail. (When I tried mstone's circuit, I tapped into the 6V rail and into the 3V rail for the Vcc/2 connection.) For the moment, I am not really trying to set a bias point at 3V. Yes, I will want to do that at some point, but for now, I am just trying to get results and avoid beating my head into a wall.
- mauifan
- Posts: 174
- Joined: Sun Aug 12, 2012 11:13 pm
Re: Crystal Oscillator Question (TS922 Op Amp)
And I greatly appreciate it!!! I thought I was answering you, but I guess I have misunderstood what you were saying. Sorry.john444 wrote:I am trying to help you here. I suspect that there is a fundamental issue with using a single supply to power your LM324 oscillator circuit. However, even though I have brought this issue up in several posts,
you do not seem interested in using split-supplies (as suggested in the
previous post) or using a different bias circuit. Is it just something
that you do not wish to try?John
As I thought I understood it, +3V and -3V is really the same thing as using a +6V supply with "ground" at +3V -- and that's what I did in mstone's circuit (i.e. connect op amp+ to the 3V rail). I also tried biasing my own circuit using the LM324 once "upon a time," though not in my most recent iteration.
Yep. Would love to go there again, but it is so expensive!john444 wrote:Does "Mauifan" mean you really like Hawaii's second-largest island?
- john444
- Posts: 443
- Joined: Sun Mar 04, 2012 2:42 pm
Re: Crystal Oscillator Question (TS922 Op Amp)
Maui fan,
I want to be sure we are on the same page.
You have the power connected like the drawing below? John
I want to be sure we are on the same page.
You have the power connected like the drawing below? John
- mauifan
- Posts: 174
- Joined: Sun Aug 12, 2012 11:13 pm
Re: Crystal Oscillator Question (TS922 Op Amp)
The simple answer based on where I think you are going with this: YESjohn444 wrote:Maui fan,
I want to be sure we are on the same page.
You have the power connected like the drawing below? John
The somewhat more complicated answer:
At this very moment in the space-time continuum , my circuit is NOT wired this way. Pin 4 connects to +6V and pin 11 connects to GND. Again, my basic thinking was "It works (does something) with the TS922 and not the LM324, so there must be something different about the LM324. It certainly wouldn't hurt to try your wiring on both the LM324 and the TS922 (i.e. create a "ground" that connects to the +3V power rail), but I just haven't gotten to it yet.
That said, I am almost certain that I tried this at some point before I bought the TS922 and started this thread. And I bought the TS922 because Adafruit describes it as more forgiving -- which certainly seens like a true statement right now.
Again, I really, really, really appreciate your help -- as well as the efforts of mstone. While it may seem like a small step to you, you both have helped me understand ESR -- and thus phase shift -- tremendously. For me, the problem right now seems to be transferring the theory into a real-life application. To date, just about the only thing I have been successful with using the LM324 is as a comparator (i.e. output is at Vcc when input is above some threshold, and zero when it is below that threshold).
I don't think I have subjected the LM324 to any extremes -- 6 AA batteries is only 9V -- but the fact that I get nothing makes me wonder if maybe I accidentally killed it (or perhaps just pins 1-3)?
Please be positive and constructive with your questions and comments.