Crystal Oscillator Question (Transistor Based Amp)
Moderators: adafruit_support_bill, adafruit

Re: Crystal Oscillator Question (Transistor Based Amp)

by mauifan on Tue Feb 05, 2013 5:47 pm

Woot!!! I think I figured it out!

Up until this point, most -- if not all -- of the output traces I have shown in this thread were obtained through the use of my scope's AUTOSET feature. For reasons currently unknown to me at the time of this writing, my scope chose ALT triggering. When I changed it to SINGLE triggering, I got the waveforms below. The INPUT (in this case Vb) and OUT- signals are indeed 180 degrees out of phase as I expected!

Next step: Adding the crystal.... stay tuned. :D

Amp-Output-new.jpg
Waveform Trace with SINGLE Triggering
Amp-Output-new.jpg (241.49 KiB) Viewed 1573 times
mauifan
 
Posts: 161
Joined: Sun Aug 12, 2012 10:13 pm

Re: Crystal Oscillator Question (Transistor Based Amp)

by adafruit_support_mike on Tue Feb 05, 2013 9:28 pm

mauifan wrote:So the good news is that I am getting amplification, but why isn't the output inverted? I double-checked my connections and Channel 2 on my scope (yellow trace) does indeed connect to OUT-.


One thing I noticed from the photo: the two channels are at different scales. CH1 is at 100mV/div, CH2 is at 500mV/div. That gives the appearance of amplification without it necessarily being there.

When the output from the inverting end of a transistor doesn't invert, the usual reason is 'saturation'. The bias voltage is a bit too high, the collector voltage is nailed about 200mV above the emitter voltage, and you're basically pouring current through a diode. AC coupling the input actually makes it harder to see, since the 200mV offset gets lost when you throw away the DC information.

.7v is a bit high for a bias voltage.. the usual 1mV bias is somewhere around .6v, and every 60mV of offset sends ten times as much current through the transistor. Being .1v high at the base means you're getting about 14 times as much current as you want.

Rather than setting the bias pot for a specific base voltage, adjust it until the voltage at the bottom of Rc is VCC/2.
When you void a product warranty, you give up your right to sue the manufacturer if something goes wrong and accept full responsibility for whatever happens next. And then you truly own the product.
User avatar
adafruit_support_mike
 
Posts: 9148
Joined: Thu Feb 11, 2010 1:51 pm

Re: Crystal Oscillator Question (Transistor Based Amp)

by mauifan on Thu Feb 07, 2013 8:11 pm

mstone@yawp.com wrote:Long answer: When you design a transistor amplifier, you need to choose certain parameters so you can calculate the rest. One of the middle values that helps to calculate all the others is called 'g.m', where 'g' is the traditional symbol for conductance (the inverse of resistance).

g.m describes the transistor's 'transconductance'.. how much the collector current changes in response to a change in base voltage:

g.m = dI.c / dV.b

where 'd' means 'the change in'. (the actual equations use greek letters, subscripts, and other things I can't type, so 'g.m' means 'g-subscript-m')

There's also an equation that defines g.m in terms of 'thermal voltage'. When you get down to the electron level, the difference between 'heat' and 'voltage' gets kind of fuzzy. They're both essentially 'energy per electron'. Thermal voltage (V.t) allows us to include the energy from thermal effects in electrical calculations, and it's *really* important when you start working with semiconductors. The good news is that we can choose a temperature, calculate Vt, and treat it as a constant from then on. At room temperature (25C or 300 Kelvin), Vt =~ .0258v or about 26mV.

The thermal equation for g.m is:

g.m = I.c / V.t

where I.c is the quiescent current. For I.c = 1mA, g.m =~ .0385 siemens.

If g.m is the transistor's conductance, 1/g.m will be its effective resistance.. 1/.0385s =~ 26 ohms (assuming I.c = 1mA). That value is called 'r.e'.

For a common emitter amplifier, the gain (A) is inherently limited by the ratio of your collector resistor (r.c) to r.e:

A.max = r.c / r.e

Dividing by r.e is the same as multiplying by g.m though, so:

A.max = r.c * g.m

g.m is the ratio of collector current to thermal voltage, so:

A.max = r.c * I.c / V.t

but 'r.c * I.c' is just the voltage across r.c when the amp sits at its operating point. That gives us:

A.max = V.rc / V.t

which tells us how much headroom we need in order to get a certain amount of gain. The interesting bit is that A.max is completely independent of the supply voltage. It's just a ratio of resistance to current that has to exist before you can get a certain amount of gain.

So.. if you know V.rc you can calculate the maximum possible gain easily (divide by .026v or multiply by 38.5s). If you know how much gain you want, you can get V.rc by running the equation the other way (V.rc = A*.026v). Either way, you end up with a voltage and need to choose a resistor. Choosing I.c = 1mA makes that simple.

Engineers like those equations so much that lots of common transistors are specifically designed to perform best near I.c = 1mA. The 2N3904 (my usual choice for such jobs) has a typical current gain of 300 when I.c = 1mA.


Are you talking about Ebbers-Moll here, mstone? I started reviewing the section about Ebbers-Moll in AoE and... well... let's just say that I think I need to read that section a few more times.

That said, I tried an experiment varying the frequency on my amp circuit and saw that gain diminished with higher frequency. Thinking ahead, I imagine that this will be fine when I add a 32kHz crystal to my circuit, but it is going to start becoming problematic when I get over 1MHz or so. The gain was definitely <1 at 4MHz, which means that it isn't going to oscillate unless I up the gain or something.
mauifan
 
Posts: 161
Joined: Sun Aug 12, 2012 10:13 pm

Re: Crystal Oscillator Question (Transistor Based Amp)

by adafruit_support_mike on Fri Feb 08, 2013 11:00 pm

mauifan wrote:Are you talking about Ebbers-Moll here, mstone?

Hybrid-pi, actually.. the small signal model. Ebers-Moll is a large-signal model, where 'large' and 'small' are measured relative to the thermal voltage Vt (26mV at room temperature).

BJTs and diodes follow roughly the same rules, the most noticable being "if the voltage across the diode rises by Vt, about 2.7 times as much current will flow through it." The actual function is exponential -- e^(Vbe/Vt) for BJTs -- so for changes larger than Vt, the exponential effects are too big to ignore.

For changes smaller than Vt, the exponential effects are less noticable. You can approximate the transistor's behavior with a resistor circuit, and the math will be much easier to do. There are several such approximations, and the hybrid-pi model is a compromise between the most popular ones.

mauifan wrote:I started reviewing the section about Ebbers-Moll in AoE and... well... let's just say that I think I need to read that section a few more times.

One of the big problems with explanations of transistor models (my own included) is that it's horribly tempting to plop out a page full of equations without taking the time to say, "look.. here's what we're trying to do".

From that perspective, Ebers-Moll is, "look.. here's how you get the numbers you need to design your bias network."

Hybrid-pi is, "look.. here's how you calculate gain."

mauifan wrote:That said, I tried an experiment varying the frequency on my amp circuit and saw that gain diminished with higher frequency.

That's normal. There's a bit of lag between "something going into the transistor" and "something coming out".. usually a few nanoseconds. The difference between the input and output during that lag is stored energy that the output hasn't caught up to yet.

Oscillating signals change direction though, so at some point the input will start going down while the output is still trying to go up. They'll meet somewhere in the middle of the stored energy, then the input will start pulling the output down rather than up. That means some of the stored energy will never make it to the output, and instead will be cancelled by the input.

For slow moving signals, the difference between input and output is practically zero, so there's practically no stored energy to lose. As the signal moves faster, the input can get farther ahead of the output during the lag. That means there's more stored energy to lose. If the input makes a full cycle during the lag, practically all the input turns into stored energy, gets cancelled by the input, and is lost.

mauifan wrote:Thinking ahead, I imagine that this will be fine when I add a 32kHz crystal to my circuit, but it is going to start becoming problematic when I get over 1MHz or so. The gain was definitely <1 at 4MHz, which means that it isn't going to oscillate unless I up the gain or something.

Here's an Application Note that discusses crystal oscillators, and shows a good all-rounder build around a transistor (figure 1e, page 2):

http://cds.linear.com/docs/en/applicati ... an12fa.pdf

Here's another that has an op amp circuit specifically designed for 32kHz watch crystals (figure 27, page 16):

http://cds.linear.com/docs/en/applicati ... /an75f.pdf

During the banging-the-head stage of learning a new circuit, reference designs come in handy. 'Doubting the design' is a major part of the learning process, but if you do it too long you find yourself questioning things like Ohm's Law. A set of references you can trust keeps things from getting.. well, staying.. silly.
When you void a product warranty, you give up your right to sue the manufacturer if something goes wrong and accept full responsibility for whatever happens next. And then you truly own the product.
User avatar
adafruit_support_mike
 
Posts: 9148
Joined: Thu Feb 11, 2010 1:51 pm

Re: Crystal Oscillator Question (Transistor Based Amp)

by mauifan on Sat Feb 09, 2013 12:07 am

Thanks for your response, mstone. I will have to read through it a couple of times. :D

In the meantime -- and perhaps while you were typing your post -- I did a quick experiment. Obviously I did something wrong, because it didn't work as I expected. :cry:

I verified that my transistor amp circuit was still working. Indeed I still get amplification at OUT- that is 180 degrees out of phase with the input. I then connected OUT- on the amp to INx in the circuit below. Likewise, I connected the amp's IN to OUTx. I fired up my scope, turned on the power to my circuit... and NOTHING. The junction at Vb was at .7V. OUT- varied with Rc (OUT- was @3V with Rc=4.8k).

xtal-filter.jpg
Filter Circuit
xtal-filter.jpg (21.2 KiB) Viewed 1548 times

For this test, I used a 32kHz crystal with C1 and C2 as shown.

As I recall from the op amp thread, a 32kHz crystal has an ESR of about 32k. The reactance of a 22pF cap at 32kHz is about 225k. Therefore, the capacitance reactance should "dominate" the ESR and cause a near 90 degree phase shift. Given that there are two caps in this "pi network," shouldn't there be a phase shift close to 180 degrees -- and thus invert that output so that the input is [almost] in phase?
Last edited by mauifan on Sat Feb 09, 2013 11:10 am, edited 2 times in total.
mauifan
 
Posts: 161
Joined: Sun Aug 12, 2012 10:13 pm

Re: Crystal Oscillator Question (Transistor Based Amp)

by mauifan on Sat Feb 09, 2013 10:47 am

mstone@yawp.com wrote:That's normal. There's a bit of lag between "something going into the transistor" and "something coming out".. usually a few nanoseconds. The difference between the input and output during that lag is stored energy that the output hasn't caught up to yet.

Oscillating signals change direction though, so at some point the input will start going down while the output is still trying to go up. They'll meet somewhere in the middle of the stored energy, then the input will start pulling the output down rather than up. That means some of the stored energy will never make it to the output, and instead will be cancelled by the input.

For slow moving signals, the difference between input and output is practically zero, so there's practically no stored energy to lose. As the signal moves faster, the input can get farther ahead of the output during the lag. That means there's more stored energy to lose. If the input makes a full cycle during the lag, practically all the input turns into stored energy, gets cancelled by the input, and is lost.

So a real-world BJT transistor is an "ideal" transistor with tiny capacitors (perhaps 1-2pF?) across the junctions (see picture below)? If so, it makes perfect sense to me why gain falls off at higher frequencies: Higher frequencies would bypass the ideal transistor through the caps.

real-npn-model.jpg
Model of a NPN Transistor?
real-npn-model.jpg (19.68 KiB) Viewed 1530 times
mauifan
 
Posts: 161
Joined: Sun Aug 12, 2012 10:13 pm

Re: Crystal Oscillator Question (Transistor Based Amp)

by adafruit_support_mike on Sat Feb 09, 2013 9:43 pm

mauifan wrote:So a real-world BJT transistor is an "ideal" transistor with tiny capacitors (perhaps 1-2pF?) across the junctions?

Spot on.. that's even a good guess for the capacitor values. You'll find exact values listed in the 'Small Signal Characteristics' section of a transistor's datasheet. I use 2N3904s a lot, and the values there are 4pF at the input and 8pF at the output.

mauifan wrote:If so, it makes perfect sense to me why gain falls off at higher frequencies: Higher frequencies would bypass the ideal transistor through the caps.

Your mental model is almost perfect, but you haven't included the resistors. The full spread looks like this:

Image

and isn't nearly as bad as it seems at first glance.

R.b, R.c, and R.e you already know.. they're the base, collector, and emitter resistors around the transistor. R.pi is the effective resistance between the base and emitter, R.o is the effective resistance between the collector and the emitter. R.l is the load resistance.

C.mu, C.pi, and C.l are the capacitors you postulated. C.mu is the capacitance between the base and collector, C.pi is the capacitance between the base and the base and emitter. There is some capacitance between the collector and emitter, but the transistor can't tell the difference between that and the capacitance of the load, so we lump it in with the load and call the whole thing C.l.

Whenever you put resistors and capacitors together, you get RC time constants. The RC time constant of R.b feeding current into C.pi and C.mu is what causes high-frequency attenuation.

For capacitive bypassing to happen, charge would have to go from C.mu to C.l. That path crosses the transistor's collector though, and the collector doesn't stand still. When the voltage at the transistor's base rises, the voltage at the collector falls. That leads to a phenomenon called 'Miller capacitance'.

Conceptually, the Miller effect is kind of like a seesaw. If we assume the circuit is arranged for a gain of 9 and raise the base voltage by 1mV, the voltage at the collector will fall by 9mV. C.mu sits between the base and collector, so we can imagine a point 1/10th of the way through it where the voltage never changes.. roughly like the fulcrum in the middle of a lever:

Image

Fixed points like that create information barriers. Circuits can only see changes that can be measured, so if a point never changes, the circuits on opposite sides of that point can't see each other. That's not an exotic idea BTW.. we treat Vcc and GND that way all the time. Putting one of those points in the middle of a component has interesting effects though.

Operationally, a capacitor implements the idea "if we send current in, the voltage rises". We measure the size of the capacitor in terms of the ratio between 'current that went in' and 'amount the voltage rose'. 'One microfarad' means 'one microamp of current changes the voltage by 1v per second.'

If we put a 1uF cap in the position of C.mu then send 1uA of current into it for a second, the voltage across C.mu will indeed change by 1v. 0.9v of that change will happen on the side that R.b can't see, though. As far as R.b is concerned, it sent 1uA of current into C.mu, and only saw C.mu's voltage rise by 0.1v. Plugging those numbers into the equation for capacitance gives us 10uF.

More generally, every test we can do on the R.b side of the circuit will tell us that C.mu behaves exactly like a 10uF capacitor connected between the transistor's base and GND.

That's the Miller effect.. as far as the input is concerned, you can replace a capacitor at C.mu with one (gain+1) times larger going to GND:

Image

Doing that removes any capacitive path to the output, so we can't get capacitive bypassing that way.

In theory, we could get capacitive bypassing through the new capacitor to GND (or the effective equivalent of it), but that would only happen for fast-moving signals on the transistor side of the input resistor (R.b). The fast-moving signal is on the other end of R.b though. Only the slow-moving parts make it through to the top of the capacitor, and the transistor only sees what happens at the top of the cap.

Taking that into account, the model ends up looking like this:

Image

where C.M is the Miller equivalent to C.mu and the diamond in the middle controls the current through R.c based on the current through R.pi. With all the other pieces in place, that's all that's left for the transistor to do.
When you void a product warranty, you give up your right to sue the manufacturer if something goes wrong and accept full responsibility for whatever happens next. And then you truly own the product.
User avatar
adafruit_support_mike
 
Posts: 9148
Joined: Thu Feb 11, 2010 1:51 pm

Re: Crystal Oscillator Question (Transistor Based Amp)

by mauifan on Mon Feb 11, 2013 6:13 pm

mauifan wrote:Thanks for your response, mstone. I will have to read through it a couple of times. :D

In the meantime -- and perhaps while you were typing your post -- I did a quick experiment. Obviously I did something wrong, because it didn't work as I expected. :cry:

I verified that my transistor amp circuit was still working. Indeed I still get amplification at OUT- that is 180 degrees out of phase with the input. I then connected OUT- on the amp to INx in the circuit below. Likewise, I connected the amp's IN to OUTx. I fired up my scope, turned on the power to my circuit... and NOTHING. The junction at Vb was at .7V. OUT- varied with Rc (OUT- was @3V with Rc=4.8k).

xtal-filter.jpg

For this test, I used a 32kHz crystal with C1 and C2 as shown.

As I recall from the op amp thread, a 32kHz crystal has an ESR of about 32k. The reactance of a 22pF cap at 32kHz is about 225k. Therefore, the capacitance reactance should "dominate" the ESR and cause a near 90 degree phase shift. Given that there are two caps in this "pi network," shouldn't there be a phase shift close to 180 degrees -- and thus invert that output so that the input is [almost] in phase?

Update:
I ran the above filter through a SPICE simulation and found that I wasn't getting anywhere near the phase shift I thought I would. But by the same token, I am scratching my head trying to figure out why.

Based on my understanding, the phase shift is the "inverse tangent" of Xc/R, aka:

angle = tan{-1} (Xc/R)

(Please excuse the poor ASCII graphics.)

So again... at f=32kHz, R=ESR=32k and C=22pF, Xc = 226k. Thus the phase shift for "stage 1" is about 82 degrees. I have a second 22pF cap with R2 at close to zero, so why don't I get a phase shift of something close to 180? What did I do wrong?
mauifan
 
Posts: 161
Joined: Sun Aug 12, 2012 10:13 pm

Re: Crystal Oscillator Question (Transistor Based Amp)

by adafruit_support_mike on Fri Feb 15, 2013 12:25 am

mauifan wrote:Based on my understanding, the phase shift is the "inverse tangent" of Xc/R

Ooh.. subtle one.

You're mistaken, but only by a point of semantics: -atan(Xc/R) is the formula for phase angle, which is different from phase shift. They're related, but it takes some translating to get from one to the other.

Phase angle represents the angle formed by the vector sum of the component impedances:

Image

where the vectors exist in the 'complex frequency' plane.

If you get far enough into calculus, you learn that complex exponentials are the cheat codes for math. Using exponents reduces multiplication and division to addition and subtraction. The function e^x is its own integtral and derivative, so it's one of the few functions that allows us to find usable solutions for differential equations. And by one of the most beautiful coincidences in mathematics, complex exponentials reduce trigonometry to basic algebra. Once you get used to translating back and forth, it's easy to do things with complex exponentials that would be really cumbersome if the ideas were expressed in any other form.

We use vectors because we those allow us to draw pictures that give us some intuition into what the complex exponentials are doing. In this case we have the boring (Real) axis where calculations are straightforward, and the 'complex frequency' axis, which allows us to represent things that depend on frequency. We draw resistors as vectors on the Real axis because resistors don't behave differently at different frequencies. We draw capacitors on the complex frequency axis because their behavior does depend on freqency. The vector sum tells us how a combination of resistors and capacitors will behave at a given frequency.

Phase angle is a convenient way to represent the results of that sum.

We really don't care about the angle though. What we care about are its components.. the relative sizes of the R and Xc vectors. Those allow us to calculate the output of an RC filter as a sine wave modified by an attenuation factor and a phase shift:

Image

The whole "find the arctangent of the impedances then get the sine and cosine" business is really just syntactic sugar.. theta = atan(Xc/R), sin(theta), and cos(theta) are easier to write (and harder to miscopy) than "divide by the square root of the sum of the squares".

The physical interpretation of "theta equals 82 degrees" is "when the input is at 90 degrees, the output (lagging behind) will be at 82 degrees." The phase shift is the difference between those angles, or "8 degrees". You can also say that the input and output curves will cross when the output is at 90 degrees and the input is at 98 degrees:

Image
When you void a product warranty, you give up your right to sue the manufacturer if something goes wrong and accept full responsibility for whatever happens next. And then you truly own the product.
User avatar
adafruit_support_mike
 
Posts: 9148
Joined: Thu Feb 11, 2010 1:51 pm

Re: Crystal Oscillator Question (Transistor Based Amp)

by mauifan on Fri Feb 15, 2013 5:13 pm

Thank you VERY much, mstone. I had to read your post a couple of times, but I think I more or less understood it -- or at least the phase angle math.

What I am less clear about is how you got the "phaseshift = cos(theta)" part. It has been a while since I last had a need to worry about trigonometery, though I do remember tan(theta) = sin(theta) / cos(theta)... or something like that. :D

Also... to revive a page from my thread on oscillators using op amps, a Pierce Oscillator looks like this:

Wikipedia-Pierce_oscillator_svg.png
From Wikipedia: Crystal [Pierce] Oscillator
Wikipedia-Pierce_oscillator_svg.png (4.12 KiB) Viewed 1487 times

In terms of the above diagram, U1 is simply the transistor amplifier. I get how the transistor shifts the signal 180 degrees. But I am far less clear about how the "pi network" (aka R1, C1, C2, X1) also shifts the signal 180 degrees.

Wikipedia wrote:Resonator

The crystal in combination with C1 and C2 forms a pi network band-pass filter, which provides a 180 degree phase shift and a voltage gain from the output to input at approximately the resonant frequency of the crystal. To understand the operation, note that at the frequency of oscillation, the crystal appears inductive. Thus, it can be considered a large, high Q inductor. The combination of the 180 degree phase shift (i.e. inverting gain) from the pi network, and the negative gain from the inverter, results in a positive loop gain (positive feedback), making the bias point set by R1 unstable and leading to oscillation.


I am somewhat of a visual/intuitive learner, and... well... if the crystal is acting as an inductor (which in itself makes sense to me given that it is designed to resonate at a specified load capacitance), won't it basically act to cancel out the impedance of the capacitors at resonance rather than add another 180 degrees of phase shift? Doesn't this mean that the combo of crystal and load capacitance be predominantly resistive, therefore resulting in little phase shift?
Last edited by mauifan on Sat Feb 16, 2013 12:17 am, edited 3 times in total.
mauifan
 
Posts: 161
Joined: Sun Aug 12, 2012 10:13 pm

Re: Crystal Oscillator Question (Transistor Based Amp)

by mauifan on Fri Feb 15, 2013 5:28 pm

mauifan wrote:I am somewhat of a visual/intuitive learner, and... well... if the crystal is acting as an inductor (which in itself makes sense to me), won't it basically act to cancel out the impedance of the capacitors rather than add another 180 degrees of phase shift?

This reminds me....

To further confuse myself, I created a test circuit consisting of X1, C1, and C2 as shown in the Wikipedia Crystal Oscillator circuit. (In this case, X1 was a 32kHz crystal, C1 and C2 were 22pF.) I connected the output of my signal generator to one side of the crystal and my scope probe to the other side. I saw attenuation (presumably due to the crystal's high ESR), but the output and input pretty much stayed in phase as I varied the signal frequency between 1kHz and 20MHz.

Why didn't I see a phase shift around 32kHz as Wikipedia promised? :D Per datasheet, the load capacitance for my crystal is 12.5pF.

A second experiment I tried was... well... I realized that C1 and C2 were effectively in series from the perspective of X1. With C1=C2=22pF, the total capacitance across X1 was about 11pF (perhaps a little more due to the breadboard wiring). I replaced the crystal with a 180uH inductor and calculated that the resonant frequency of this tank circuit was about 3.5MHz. I fed a sine wave signal into one side of the tank and monitored the output signal. I saw a phase shift approaching 180 degrees, but it occurred at a much higher frequency than 3.5MHz. What????

In my mind, I am aware of the following "rules" --
  • In an inductor, voltage leads current by up to 90 degrees
  • In a capacitor, voltage lags current by up to 90 degrees
  • In a resistor, voltage and current are in phase
However, I am just not "seeing" how the pi network affects phase shift in a practical sense.
mauifan
 
Posts: 161
Joined: Sun Aug 12, 2012 10:13 pm

Re: Crystal Oscillator Question (Transistor Based Amp)

by adafruit_support_mike on Sun Feb 17, 2013 12:26 pm

mauifan wrote:What I am less clear about is how you got the "phaseshift = cos(theta)" part. It has been a while since I last had a need to worry about trigonometery, though I do remember tan(theta) = sin(theta) / cos(theta)... or something like that.

Looks like I flew past an important detail.. sorry.

You're exactly right that tan(theta) = sin(theta)/cos(theta). More generally, the function tan(theta) describes a ratio between two values, and the inverse tangent, atan(y/x), can reduce any ratio to an angle. If we find ourselves needing the components of the ratio (the x and y), we can unpack them with y=sin(theta) and x=cos(theta).

It's really just a trick of notation. It's handy though, and since we're dealing with sine waves, experience has shown that it's useful.
Last edited by adafruit_support_mike on Sun Feb 17, 2013 3:29 pm, edited 1 time in total.
When you void a product warranty, you give up your right to sue the manufacturer if something goes wrong and accept full responsibility for whatever happens next. And then you truly own the product.
User avatar
adafruit_support_mike
 
Posts: 9148
Joined: Thu Feb 11, 2010 1:51 pm

Re: Crystal Oscillator Question (Transistor Based Amp)

by adafruit_support_mike on Sun Feb 17, 2013 3:29 pm

mauifan wrote:In my mind, I am aware of the following "rules" --
  • In an inductor, voltage leads current by up to 90 degrees
  • In a capacitor, voltage lags current by up to 90 degrees
  • In a resistor, voltage and current are in phase

Hmm.. the word 'leads' is technically accurate but misleading.. it suggests time running backwards.

Try these:

- In a resistor, voltage and current are in phase
- In a capacitor, voltage lags behind current
- In an inductor, current lags behind voltage

Stated that way, putting a capacitor and inductor together gives you two lags, not a lag and a lead cancelling each other out.

Mechanically, current is equivalent to the momentum of a moving weight, voltage is equivalent to the tension in a stretched or compressed spring. If you connect them, a moving weight has momentum, but its motion stretches or compresses the spring. Tension in the spring applies force to the weight, and that changes the weight's speed.

By definition, the weight's speed keeps increasing as long as the spring tension keeps pulling it, so the weight will reach its highest speed when at the point where the spring stops pulling. Also by definition, the spring's tension will increase as long as the weight keeps moving away from that neutral point, so spring will reach its highest tension or compression at the points where the weight stops moving.

The tension and momentum always oppose each other, and each reaches its maximum (and can change the other most strongly) when the other reaches its minimum. You can say either one leads or lags the other, but trying to decide which one lags while the other one is leading gets confusing.
When you void a product warranty, you give up your right to sue the manufacturer if something goes wrong and accept full responsibility for whatever happens next. And then you truly own the product.
User avatar
adafruit_support_mike
 
Posts: 9148
Joined: Thu Feb 11, 2010 1:51 pm

Re: Crystal Oscillator Question (Transistor Based Amp)

by adafruit_support_mike on Sun Feb 17, 2013 4:35 pm

And now for the main issue:
mauifan wrote:Why didn't I see a phase shift around 32kHz as Wikipedia promised? :D

In this case, you need a frequency microscope. ;-)

A crystal's range of interesting frequency-related behavior is extremely narrow.. usually a few millionths of the resonant frequency. For a 32kHz crystal, that's less than 1Hz. The crystal's impedance is nearly constant outside that range, and changes by a factor of a few hundred thousand within that range. That huge change within a narrow frequency band is what makes crystals such good timing elements.

If your frequency generator can do small frequency steps, look at the range beween 32766 Hz and 32770 Hz.. that's the broad range that includes device tolerances and thermal effects. When you find where the response happens, narrow it down to a range maybe 250mHz wide.

If your frequency generator won't do that, you can bit-bang a square wave with an Arduino that should work. The period of a 32kHz wave is about 30 microseconds, so counting operations with an 8MHz microcontroller should give you about 120 steps between even-Hertz frequencies in that range.
When you void a product warranty, you give up your right to sue the manufacturer if something goes wrong and accept full responsibility for whatever happens next. And then you truly own the product.
User avatar
adafruit_support_mike
 
Posts: 9148
Joined: Thu Feb 11, 2010 1:51 pm

Re: Crystal Oscillator Question (Transistor Based Amp)

by adafruit_support_mike on Sun Feb 17, 2013 5:36 pm

And this one:

mauifan wrote:A second experiment I tried was... well... I realized that C1 and C2 were effectively in series from the perspective of X1. With C1=C2=22pF, the total capacitance across X1 was about 11pF (perhaps a little more due to the breadboard wiring). I replaced the crystal with a 180uH inductor and calculated that the resonant frequency of this tank circuit was about 3.5MHz. I fed a sine wave signal into one side of the tank and monitored the output signal. I saw a phase shift approaching 180 degrees, but it occurred at a much higher frequency than 3.5MHz.

The capacitors are only in series if you feed the input into the end of one of them. If you feed it into the node where the capacitor and inductor meet, they're effectively in parallel. That makes the effective capacitance 44pF. The equation for a CLC pi filter cancels out the factor of two though, so you got the resonant frequency right anyway.

Thing is, the phase shift of a CLC pi filter is only 90 degrees at resonant frequency. The filter only approaches 180 degree phase shift asymptotically, but most of the shift shows up over the first decade (10x multiple) of frequency. In this case, you should see about 170 degrees of shift at 35mHz.
When you void a product warranty, you give up your right to sue the manufacturer if something goes wrong and accept full responsibility for whatever happens next. And then you truly own the product.
User avatar
adafruit_support_mike
 
Posts: 9148
Joined: Thu Feb 11, 2010 1:51 pm