After having some moderate success getting a crystal to oscillate using an op amp (see viewtopic.php?f=19&t=33796&start=0), it is now time for me to turn my attention back to the original problem of trying to make a crystal oscillate using a NPN transistor. :D

My first concern right now is to try to make the transistor actually act like an amplifier. Here is my generic setup:

Generic Amp Circuit Schematic

amp-transistor.jpg (89.18 KiB) Viewed 3530 times

As was the case last time, my first attempt to build a circuit failed. I am now going through the process of re-reading Chapter 2 in my Art of Electronics (which I may abbreviate as AoE) book... and I am stumbling over transistor bias. I totally get the idea of why it is important to bias the transistor, but obviously I am struggling a bit with my selection of resistors R1, R2, Rc, and Re. (Not too worried about Ce now.) My Q1 is a 9014 transistor.

I am sure that I wil have many questions along the way, but for now let me start with what I hope is a relatively simple question:

AoE seems to suggest that the quiescent current through the transistor [collector] should be 1mA. Is there a particular reason why they like this value, or is it somewhat arbitrary? Can I choose whatever value I want, assuming of course that my choice results in power and current levels below datasheet max values?

I am sure that there will be questions about what component values I used, but I'll answer as this thread progresses. Right now, I am just trying to get my head around how to choose the quiescent current.

mauifan wrote:AoE seems to suggest that the quiescent current through the transistor [collector] should be 1mA. Is there a particular reason why they like this value, or is it somewhat arbitrary? Can I choose whatever value I want, assuming of course that my choice results in power and current levels below datasheet max values?

Short answer: it makes the math easier, and most small-signal transistors like working at 1mA.

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.

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.

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.

You can choose I.c (the quiescent current) to be anything you want. 1mA is a value that's easy to work with and gives you good all-around performance from the amp. Resistors generate noise, and the higher the resistance, the more noise you get. A large value for r.c also means your amp has a high output impedance, and can't send much current to whatever comes next in the circuit. OTOH, low values of r.c -- which give you low noise and lots of current for the next circuit -- also pour lots of current straight through the transistor to GND.

I.c = 1mA is a middle value that gives you reasonable performance at a reasonable cost.

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.

1) I believe that I am more concerned with output voltage right now. Since I don't believe that I need to drive anything with my circuit, I chose 1mA as the quiescent current.

2) Given that I am using Vcc=6V, I want the quiescent value of OUT- to be at 3V. Therefore I need a resistor Rc that will give me a 3V voltage drop at 1mA. Ohms Law: Rc = (Vcc - Vc) / Iq = (6V - 3V) / 1mA = 3k. As was the case in the op amp version of this thread, I used a potentiometer set at about 3k in my test circuit.

3) Although this step probably wasn't necessary given that Rc=3k, I chose Re=100 ohms. The datasheet for the 9014 I am using indicates that its maximum collector current is 150mA. That means that it needs Rc to be a minimum of 40 ohms. The smallest resistor I have is 100 ohms. Given that I will likely vary the pot I used for Rc to test gain, I just figured that Re=100 ohms would help protect the transistor from myself. :D

4) Given that Re=100 is small compared to Rc=3k, I assumed that about 1mA would flow through Re in quiescent state. The voltage drop through Re is therefore Ve = Iq * Re = 1mA * 100 = 0.1V.

5) The datasheet doesn't mention it, but I assumed that the forward voltage drop between base and emitter is .6V. Adding in the drop across Re, the quiescent base voltage needs to be about Vb = 0.7V.

6) I now need to select a voltage divider R1 and R2 in a manner that results in output Vb = 0.7V. On top of that, R1 || R2 needs to be much less than the impedance looking into the base of Q1. If Q1 is fully on, the impedance of Rc || Re is very close to Re, so I assumed that the transistor has a gain of about 100 and obtained the base impedance at 100 * 100 = 10k.

7) "Much Less" means that R1 || R2 needs to be about 1/10th of the base impedance, so I used a Thevenin equivalent power source of 0.7V with a 1K series resistor. My ElectroDroid calculator tells me that I need R1=4.7k, R2=1.6k, which I implemented in the form of a pot

Is this correct? If so, I need to look at my circuit again to see where I went wrong. :(

mauifan wrote:1) I believe that I am more concerned with output voltage right now. Since I don't believe that I need to drive anything with my circuit, I chose 1mA as the quiescent current.

Sounds reasonable. It's a good to get in the habit of adding a load though.. that's an important current path.

A large resistor is fine.. 100k to 1M.. but do throw it in. If you get used to thinking of the collector-emitter path in isolation, you pick up a set of expectations that get in the way once you actually try using transistor amplifiers.

mauifan wrote:2) Given that I am using Vcc=6V, I want the quiescent value of OUT- to be at 3V. Therefore I need a resistor Rc that will give me a 3V voltage drop at 1mA. Ohms Law: Rc = (Vcc - Vc) / Iq = (6V - 3V) / 1mA = 3k. As was the case in the op amp version of this thread, I used a potentiometer set at about 3k in my test circuit.

Sounds good.

mauifan wrote:3) Although this step probably wasn't necessary given that Rc=3k, I chose Re=100 ohms.

It may not be necessary, but it's a really good idea.

It's almost impossible to design a bias network without an emitter resistor and get it to work. The tolerances of your components are larger than the acceptable error margin for Vbe. To keep Ic within 5% of its expected value, you have to be within 1.25mV of the correct Vbe. If you build your bias network from 5% resistors (expecting Vbe to be .6v), you'll actually get a voltage somewhere between .585v and .615v.. 24 times wider your tolerance for Vbe, and enough to change Ic by a factor of 3. 1% resistors give you a narrower window, but it's still about 8 times wider than you want, and large enough to move Ic 10% either side of the correct value.

The emitter resistor lets you ignore the details. You choose an approximate value for V.re and the transistor automatically floats to the Vbe necessary to send the appropriate current through. The exact value of V.re will probably be a few millivolts away from the predicted value, but the error will only be a small fraction of V.re.

mauifan wrote:The datasheet for the 9014 I am using indicates that its maximum collector current is 150mA. That means that it needs Rc to be a minimum of 40 ohms. The smallest resistor I have is 100 ohms. Given that I will likely vary the pot I used for Rc to test gain, I just figured that Re=100 ohms would help protect the transistor from myself. :D

That's good defensive design, but having an emitter resistor at all will prevent most problems. If you reduce R.c to zero, the circuit will end up being an emitter follower.. the voltage at the emitter will always stay about .6v below V.be.

mauifan wrote:4) Given that Re=100 is small compared to Rc=3k, I assumed that about 1mA would flow through Re in quiescent state. The voltage drop through Re is therefore Ve = Iq * Re = 1mA * 100 = 0.1V.

That's a good value.. small enough it won't consume a lot of your output range, but large enough for the 'V.be adjusting itself' errors to be a negligible fraction of V.re.

mauifan wrote:5) The datasheet doesn't mention it, but I assumed that the forward voltage drop between base and emitter is .6V. Adding in the drop across Re, the quiescent base voltage needs to be about Vb = 0.7V.

Yep. The actual equation for base voltage is:

I.b = I.s * e^(V.b/V.t)

where I.s is very small and e^(V.b/V.t) gets really big really fast.

I.s is called the 'intrinsic current' or 'reverse saturation current'. The details are complicated, but basically the thermal energy in a silicon crystal bumps some of the electrons up to energy levels where they can travel freely through the lattice. The boundaries between P and N doped semiconductors form regions that are almost perfect insulators, but the thermal effects allow a small amount of current to leak through. Diodes and BJTs work by manipulating that effect.

The actual leakage current (I.s) tends to be around 100 femtofarads (10^-13).

Bias voltage affects I.s exponentially, and when you get up around e^23 (10^10), the current approaches 1mV (10^-3).

.6v/.026v =~ 23.07, so that's a convenient estimate for V.b.

mauifan wrote:6) I now need to select a voltage divider R1 and R2 in a manner that results in output Vb = 0.7V. On top of that, R1 || R2 needs to be much less than the impedance looking into the base of Q1. If Q1 is fully on, the impedance of Rc || Re is very close to Re, so I assumed that the transistor has a gain of about 100 and obtained the base impedance at 100 * 100 = 10k.

You can ignore R.c entirely. The path between the collector and base is a diode, and the 'active region' where amplification happens is defined to be 'the range of voltages where the collector-base diode is reverse-biased'. If the collector-base diode gets forward biased (V.c is more than about .4v below V.b), it's called 'saturation'.

In other words, all the base should see is the path through the emitter. The equation for input resistance is:

beta * (R.e + 1/g.m)

where 1/g.m is about 26 ohms when I.c = 1mA. In this case, the total impedance should be about 12.6k. You were close enough for back-of-the-envelope work.

mauifan wrote:7) "Much Less" means that R1 || R2 needs to be about 1/10th of the base impedance, so I used a Thevenin equivalent power source of 0.7V with a 1K series resistor. My ElectroDroid calculator tells me that I need R1=4.7k, R2=1.6k, which I implemented in the form of a pot

Hmm.. I show that pair of resistors having a center voltage of about 1.5v when the supply is 6v. My number crunching says you want the upper resistor to be about 7-1/2 times as large as the lower one ((6-.7)/.7)

Figuring the parallel resistance for that ratio and scaling to 1k says you want 8.5k and 1.13k. Adjusting that for values in the E6 series gives:

mstone@yawp.com wrote:Hmm.. I show that pair of resistors having a center voltage of about 1.5v when the supply is 6v. My number crunching says you want the upper resistor to be about 7-1/2 times as large as the lower one ((6-.7)/.7)

Figuring the parallel resistance for that ratio and scaling to 1k says you want 8.5k and 1.13k. Adjusting that for values in the E6 series gives:

The voltage divider calculator in ElectroDroid has an option to factor in load. The value in that load field was 10k and enabled, so my answer was wrong. (So close yet so far! :D ) Unchecking that gave me better results.

At some point I am going to have to build this circuit and test it. I have everything I need to build the amp, but I am not so sure that I have a means to feed a signal into it. I suppose I could use a microphone, but I don't think that I am talented enough to hum into the mic and produce a "clean" waveform to verify that the amp is working.

I am guessing that the answer is "buy a function/waveform generator" but the good ones on Amazon go hundreds of dollars. Anyone have any recommendations that don't break the bank -- while at the same time remain usable?

Yes... I still have the 32k crystal and others from the op amp endeavor. However, I am just trying to take this one step at a time, i.e. get amp working THEN add the crystal.

mauifan wrote:I am guessing that the answer is "buy a function/waveform generator"

Actually, no. This is one of those situations where a quick lash-up will do fine.

Function generators are expensive because they produce signals within a small, known error tolerance from a theoretically perfect waveform. You feed those into your amp and measure what comes out the far end to see how your amp distorts signals at specific frequency, or over the whole range of frequencies. Even then, the function generator is just a convenience (granted, a big one). Having a pure input means you don't have to compare distortion at the input to distortion at the output to see how much of the final mess you have to blame on your amp.

You're not trying to characterize distortion or frequency response, you just want to see if the gain is about what you predicted. It's easy to throw a function generator at the problem if you have one sitting around, but buying one for this specific purpose would be like getting a BMW to check your mailbox at the end of the driveway.

mauifan wrote:Anyone have any recommendations that don't break the bank -- while at the same time remain usable?

The basic idea is to create digital samples of a sine wave (or whatever you want) then filter out the sharp changes from one sample to the next. That's easy if you don't ask for bleeding-edge performance. The simplest RC low-pass filter you can make:

gets 10x more effective as the frequency gets 10x faster. It's easy to generate a 128-sample approximation of a sine wave, and if you subtracted that from a pure sine wave you'd get an uneven sawtooth wave that moves 128 times as fast as the sine frequency:

The amplitude of the jaggy bits will be much smaller than the amplitude of the sine wave, and a single RC filter will make them about a hundred times smaller still. The result will be pretty darn close to a true sine wave.

To approximate a 1kHz sine wave you'd send out a new sample every 7.8 microseconds, and to filter it you'd feed the ouput through a 150 ohm resistor to the top of a 1uF capacitor. Both are easy to do with an Arduino and a breadboard. You'd probably have to switch to fewer samples and a better filter around 10-20kHz, and getting up to what frequency generator do would be a whole other story, but it isn't bad for a few bucks and a few minutes of work.

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.

Oh man! I am kicking myself for not thinking of this! Awesome suggestion... though now that you mention it, I think I could just use a PWM pin on an Arduino and the circuit diagram below.

Arduino-based Function Generator External Circuitry

arduino_Function_Gen_Schematic.jpg (14.77 KiB) Viewed 3352 times

In this case, the PWM pin would connect to a simple potentiometer (shown as R1 and R2 here) with a center tap connected to the output to control gain. C1 would be a "small" value cap to prevent the output wave from changing too quickly... though I am not sure that it would make much of a difference for what I need to do "today."

Hindsight being 20/20, I could have built my own function generator using parts I already have! I feel pretty confident that I could do this... and even expand it into more of a "full featured" function generator with square waves, triangle waves, etc.... but I copped out 1-2 days ago and went with the easier (albeit more expensive) approach and ordered a relatively inexpensive function generator that I found online. Yes, it will likely be overkill^10 for the purposes of this particular endeavor, but I expect that it will become almost as valuable to my electronics studies as my oscilloscope purposes has become over the few years that I have had it. And building my on Arduino-based model would have taken some time. Nearly all of the projects I take on seem to be easy at first, but never seem to quite as I originally expected.

Anyway... I expect my new "toy" to arrive in a few days. I'll give it a try with my amp circuit and post my findings.

The DAC output makes a stairstep pattern that's officially called a 'zero-order hold'. It's an approximation of the actual curve, but stays fairly close to the actual curve. When you run it through a filter, you get reasonably smooth output.

PWM is an on/off thing, so you have to filter it once just to get a sawtooth-like waveform that follows the curve you actually want. Ideally, you'd filter it again to get a smooth curve. That gets into 'second order filters' though, and those are more complicated than the one-resistor/one-capacitor version.

In both cases, making the digital signal a lot faster than your output signal makes the filtering easier. The PWM you get from an Arduino's AnalogWrite() function runs about 500Hz IIRC, which puts some serious limits on your output signal. You can get PWM frequencies up to about 60kHz if you use the timers directly though.

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.

With the amp circuit powered off, I saw more or less what I expected. When it was on, I got a really funky looking output wave. Again, didn't have much time tonight to dig... but this one has me scratching my head. Maybe it is a gain issue?

I rechecked my wiring... and I found a mistake. Again... didn't spend a whole bunch of time on this, but my output now looks more like I would expect -- except that the output (yellow trace) does not seem to be inverted.

Amp Output (Corrected Wiring)

AmpOut.jpg (847.14 KiB) Viewed 3289 times

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-.

Another ObservationI performed a manual sweep from about 1kHz up to 4MHz at 200mVpp. The output waveform OUT- remained pretty much in phase with the input (red waveform) throughout the sweep, but somewhere along the way (perhaps at about 1MHz) the gain started to degrade. At 4MHz, the gain was a little bit less than 1. (Note that the gain in my previous post at lower frequency. I had to use different scales to make both waveforms fit on the screen.)

Again, I am scratching my head on this one. Assuming that my eyes do not deceive me, this seems to suggest that the stray capacitances in my breadboard are inverting my inverted signal?????

And gain is controlled by that bandwidth-gain product thing discussed in my other thread?????

Zener wrote:I don't see any reason it would be inverted. It is a little out of phase which makes sense. The gain drops out with frequency which is typical. Why do you think it should invert?

Because the yellow trace connects to OUT- (inverted) and not OUT+ (non-inverted). If the voltage at Vb increases, Q1 allows more current to pass -- and thus causes the voltage at OUT- to lower proportionally. If Vb decreases, less current flows through Q1, thus raising OUT-1 proportionally.

Attaching a smaller version of the schematic I originally posted in the hope that it will be easier to see. (The original version requires scrolling -- at least for me.)

Schematic Used In This Thread

amp-transistor-schematic.jpg (37.64 KiB) Viewed 3249 times

Also as a reminder: The red trace is the voltage at the junction between R1 and R2 (aka Vb).