Chapter 8L

Lab 8: Op-Amps III: Positive , Part I: Benign

Contents

8L Lab 8: Op-Amps III: , Part I: Benign 1 8L.1TwoComparators...... 2 8L.1.1op-ampasComparator...... 2 8L.1.2 Special-Purpose IC...... 3 8L.1.3SchmittTrigger:usingpositivefeedback...... 4 8L.2 op-amp RC Oscillator ...... 4 8L.3 Easiest RC Oscillator, using IC ...... 5 8L.3.1RCfeedback...... 5 8L.3.2Sawtooth?...... 5 8L.4Applythesawtooth:PWMMotorDrive...... 6 8L.5 IC RC Relaxation Oscillator: ’555 ...... 7 8L.5.1SquareWave...... 7 8L.5.2 Triangle Oscillator ...... 8 8L.6 ’555 for low-frequency Frequency Modulation (“FM”) ...... 8 8L.7 Oscillator: Wien Bridge ...... 9

Time: Total time: 1 160min. (2 hrs, 40 REV 4 ; September 11, 2015. min)

1Revisions: insert note warning not to run sawtooth at 1MHz with 1000pF, using larger C instead (2/15); insert “op-amp”, replace an Xc with Zc (1/15); insert Ray redrawings (10/14); respond to Paul’s notes (8/14); add header, add index (6/14); amend references to 7555, adding refs to other CMOS parts (9/13); amend PWM circuit switch drive (8/12); add index (7/12); add FM-with-555 section (2/12); explain why op isn’t square (10/11); add PWM exercise after HC14 sawtooth (2/09); insert HC14 oscillator, make subscripts lower case (10/08); add contents, insert better drawings (not complete) (7/07).

1 2 Lab 8: Op-Amps III: Nice Positive Feedback

Positive Feedback: Good and Bad

Until now, as we have said in today’s class notes, we have treated positive feedback as evil or as a mistake: it’s what you get when you get confused about which op amp terminal you’re feeding. Today you will qualify this view: you will find that positive feedback can be useful: it can improve the performance of a comparator; it can be combined with to make an oscillator (“relaxation oscillator”: there positive feedback dominates); or to make a Negative Impedance Converter (this we will not build, but see AoE §4.107, fig.4.104: there, negative feedback dominates). And another clever circuit combines positive with negative feedback to produce a sine wave out (this is the “”).

Next time, in the fourth op-amps lab, we will see what a pain in the neck positive feedback can be when it sneaks up on you.

8L.1 Two

Time: 40 min. Comparators work best with positive feedback. But before we show you these good circuits, let’s look at two poor comparator circuits: one using an op-amp, the other using a special-purpose comparator chip. These circuits will perform poorly; the faster of the two, the restless circuit, will help you to see what’s good about the improved comparator that does use positive feedback.

A Marginally-stable comparator: open-loop

8L.1.1 op-amp as Comparator

Figure 1: op-amp as simple comparator

You will recognize this “comparator” circuit as the very first op-amp circuit you wired, where the point was just to show you the “astounding” high gain of the device. In that first glimpse of the op-amp, that excessive gain probably looked useless. Here, when we view the circuit as a comparator, the very high gain and the “pinned” output are what we want.

Drive the circuit with a sine wave at around 100kHz, and notice that the output “square wave” output is not as square as one would hope. Why not?2

2The rise and fall are slow, moving at a rate defined by the op-amp’s slew rate, a limitation that you recall from last lab: 15V/μsfor the ’411. Thus a rail-to-rail transition takes a couple of microseconds—and a bit more because the op-amp needs a little time to recover from saturation, the state in which this no-feedback circuit obliges it to spend most of its time. Lab 8: Op-Amps III: Nice Positive Feedback 3

8L.1.2 Special-Purpose Comparator IC

Figure 2: 311 comparator: no feedback

Now substitute a 311 comparator for the 411. (The pinouts are not the same.) You will notice that the output stage looks funny: it is not like an op-amp’s, which is always a push-pull; instead, two pins are brought out, and these are connected to the collector and emitter of the output , respectively. These pins let the user determine both the top and bottom of the output swing. If one uses +5 and ground here, for example, the output provides a “logic level” swing, 0 to +5V, compatible with traditional digital devices. In the circuits below, you will keep the top of the swing at + 15V, and the bottom of the swing to -15V. So arranged, the ’311 output will remind you of op-amp behavior.

Does the 311 perform better than the 411?3

Parasitic

A side-effect of the 311’s fast response is its readiness to oscillate when given a “close question”–a small voltage difference between its inputs. Try to tease your 311 into oscillating, by feeding a sine wave with a gentle slope. With some tinkering you can evoke strange and lovely waveforms that remind some of the Taj Mahal in moonlight—but remind others of the gas storage tanks on the Boston’s Southeast Expressway. Judge for yourself.

Here’s a pretty example:4

Figure 3: ’311 indecision: Gas Storage Tanks? Taj?

Minimizing Oscillations: Remedies other than Positive Feedback

You can sometimes stabilize a comparator without the remedy of , which we are about to promote. Let’s see how far these efforts can carry us. First, to get some insight into why the ’311 is confusing itself, keep one scope probe on the oscillating output and put the other on the +15V power supply line, close to the ’311. AC-couple this second probe, and see if the junk that’s on the output appears on the supply as well. Chances are, it does.

Keep those ugly ’311 oscillations on the scope screen, and try the following remedies:

3This question reminds us of a question posed to us by a student a few years ago: ‘I can’t find a 411. Is a 311 close enough?’ This person no doubt was recalling the many times we had said, ‘Put away that calculator! We’ll settle for 10% answers; 2π is 6,’ and so on. 4Two undergraduates produced this handsome waveform: Elena Krieger and Belle Koven, October 2004. 4 Lab 8: Op-Amps III: Nice Positive Feedback

• Put ceramic decoupling on positive and negative power supplies. If the oscillations stop, tickle them into action again, by reducing the slope of the input sine. • Short pins 5 and 6 together: these adjustment pins often pick up noise, making things worse. Again tease the oscillations back on, if this remedy temporarily stops them.

8L.1.3 Schmitt Trigger: using positive feedback Time: 15 min.

Figure 4: Schmitt trigger: comparator with positive feedback (& hysteresis)

The positive feedback used in the circuit above will eliminate those pretty but harmful oscillations. See how little hysteresis you can get away with. As input, use a small sine wave (< 200mV) around 1kHz, and adjust the pot that sets hysteresis until you find the border between stability and instability. Then watch the waveform at the non-inverting input. Here, you should see a small square wave (probably fuzzy, too, with meaningless very-high frequency fuzz not generated by your circuit; perhaps radio, visible now that you have the gain cranked way up). This small square wave indicates the two thresholds the ’311 is using, and thus (by definition) just how much hysteresis you are using. Finally, crank the hysteresis up to about three times that borderline value (for a safety margin).

If you describe your circuit as a “zero-crossing detector,” how late does it detect the crossings? Could you invent a way to diminish that lateness?5

Leave this circuit set up, for the next experiment.

8L.2 op-amp RC Relaxation Oscillator Time: 15 min.

can be pot with slider adjusted to top

Figure 5: RC relaxation oscillator

5You could—except that the world has already invented the method. See today’s class notes, describing AC positive feedback. Lab 8: Op-Amps III: Nice Positive Feedback 5

Increase the hysteresis by replacing the potentiometer of the preceding circuit with a 10k resistor, and then connect an RC network from output to the comparator’s inverting input, as shown above. This feedback signal replaces any external signal source; the circuit has no input. Here, incidentally, you are for the first time providing both negative and positive feedback.

Predict the frequency of , and then compare your prediction with what you observe. You can save yourself time by assuming that the ramps, as if fed a constant current equal to 15V/Rfeedback (as the class notes point out).

8L.3 Easiest RC Oscillator, using IC Schmitt Trigger Time: 15 min. Here’s another way to get a square wave output, timed by an RC. It is very similar to the RC relaxation oscillator of §1.2, but uses an IC that has hysteresis built-in. The output is a “logic-level” swing, 0 to 5V. The circuit’s weakness is the imperfect predictability of the part’s hysteresis, an uncertainty that makes the frequency of oscillation uncertain, But logic output and simplicity make it a circuit worth meeting.

8L.3.1 RC feedback

Here’s all there is to it:

C

Figure 6: Simplest RC oscillator

Use a capacitor of 1000pF,6 and choose a feedback R to get fOSC ≈ 1MHz. As you choose R, note the following specifications:

• threshold voltages: – negative-going: 1.8V (typical), 0.9 (min), 2.2 (max) – positive-going: 2.7V (typical), 2.0 (min), 3.15 (max) • hysteresis: 0.9V (typical), 0.4 (min), 1.4 (max)

The range of possible values makes prediction of fosc look discouraging—but use typical values to choose your R, and see how close your result comes to the target of 1MHz (or “period of 1 μs,” to speak in terms more appropriate to your scope use, where you will see period rather than frequency).

Your feedback R: ______: observed frequency: ______

8L.3.2 Sawtooth?

The oscillator of § 8L.3.1 puts out a square wave; the waveform on the capacitor is not very interesting. Sometimes you may want an oscillator that produces a sawtooth. That you can easily achieve—as VCap—-by

6This value was chosen to be large relative to the scope probe’s roughly 10pF load, so that you can probe the capacitor without changing fosc appreciably. 6 Lab 8: Op-Amps III: Nice Positive Feedback replacing the feedback R with a current-limiting diode: the 1N5294 that you met as you were building a differential amplifier, in the second discrete-transistor lab. It is rated at 0.75mA.

With the 1000pF C of §8L.3.1 VCap is ugly. A larger C will produce a prettier sawtooth: try 0.1μF. Note the range of the sawtooth’s swing, because we are about to use this waveform.

8L.4 Apply the sawtooth: PWM Motor Drive Time: 20 min. You now have met the two elements of a “pulse-width modulation” (“PWM”) circuit: a ramping oscillator output, and a comparator. Let’s put them together to make a PWM driver. We’ll use it to spin a DC motor. Here’s the circuit, with some details omitted:

Figure 7: PWM circuit; some details left to you

Give your comparator circuit a little hysteresis: 50mV to 100mV should suffice. Note that the transistor loads the circuit somewhat, so that output swing rises not to 5V but to about 4V.

While you are testing the circuit, and perhaps adjusting values, you may want to install a resistor in place of the motor—100 ohms or more. Look at the sawtooth and comparator output waveforms, as you vary the threshold using the potentiometer.

Are you able to adjust the comparator-output’s “duty cycle” over a wide range—from perhaps 10% to 90%? (“Duty cycle” is jargon for “percentage of period for which the output is High.”) If the range is not so wide as you’d like it to be, tinker with the values of the resistors above and below the threshold potentiometer. Then check that the switch is doing its job.

When you are satisfied, replace the resistor that has been serving as test load with a small DC motor. You can use the 3-12V motor you used to drive the integrator in Lab 7.7 We have shown a 10V supply, to be sure we don’t overheat the 12V motor. But you’ll get away with +15V if you don’t have a 10V supply handy.

You may want to stick a bright pointer on the motor shaft—or perhaps the vane is still in place from Lab 7— to make it easier to judge how fast it spins, as you adjust the duty cycle. Try loading the motor—applying some braking with your fingers. You should find torque that’s not bad, at low duty cycles, whereas simply dropping the voltage to the motor—as your grandmother’s sewing machine rheostat did—gives poor torque at low speed.

7We use the Mabuchi FF-130SH-11340. But any motor that can stand 10V will do. Lab 8: Op-Amps III: Nice Positive Feedback 7

8L.5 IC RC Relaxation Oscillator: ’555 Time: 45 min.

The ’5558 and its derivatives have made the design of moderate-frequency oscillators easy.9 There is seldom any reason to design an oscillator from scratch, using an op-amp as we did in the proceeding exercise. The ICM7555 or LMC7555 is an improved 555, made with CMOS. (In these notes we will refer to the CMOS part as “7555” for brevity, though you may be using the LMC part.) It runs up to 1 MHz (7555) or 3MHz (LMC7555), versus 100 kHz for the 555, and its very high input impedances and rail-to-rail output swings can simplify designs. 8L.5.1 Square Wave Time: 15 min.

Figure 8: 7555 relaxation oscillator: traditional 555 configuration

Connect a 7555 in the 555’s classic relaxation oscillator configuration, as shown in fig. 8. Look at the output. Is the frequency correctly predicted by

fosc =1/(0.7[RA +2RB]C)?

Now look at the waveform on the capacitor. What voltage levels does it run between? Does this make sense?

Sharkfin (?) Oscillator, again

Now replace RB with a short circuit. What do you expect to see at the capacitor? At the output? (A detail: the cap voltage now will fall a good way below the lower threshold value of VCC/3; this occurs because the 7555 takes a while to respond to the crossing of that threshold, and the voltage now is slewing down fast). Time: +15 min. (optional) 50% Duty Cycle The 7555 can produce a true 50% duty-cycle square wave, if you invent a scheme that lets it charge and discharge the capacitor through a single resistor.10 See if you can draw such a design, and then try it. Hint: the old 555 could not do this trick; the 7555 can because of its clean rail-to-rail output swing.

8Developed by Signetics, its initial part number was NE555. Now it is made by many manufacturers, and in many versions. (See AoE table of ’555 variants at §7.1.3.2). We use a CMOS version. 9And more recent IC’s, integrating the timing capacitor, have made designs even easier than the ’555’s. See, for example, Linear Technology’s LTC6906. We are not using these in this lab because they are not available in through-hole packages—the kind we need for breadboarding in this course. 10Well, “invent” may be a bit exaggerated, if you have read today’s class notes. 8 Lab 8: Op-Amps III: Nice Positive Feedback

7555 relaxation oscillator: an alternative configuration (your design)

When you get your design working, consider the following issues:

• In what way does the output waveform of this circuit differ from the output of the traditional 555 “astable” (as an oscillator sometimes is called)?

• Is the oscillator’s period sensitive to loading? See what a 10k resistive load does, for example.

If your design is the same as ours, then the frequency of oscillation should be

fosc =1/(1.4RC) a result that is the same as for the ‘classic’ configuration, except that it eliminates the complication of the differing charge and discharge paths. The ‘classic’ design yields the same equation, to a very good approxi- mation, so long as RA is much smaller than RB.

Does the value of fosc that you measure for your design match what you would predict?

Finally, try VCC = +5V with either of your circuits, to see to what extent the output frequency depends on the supply voltage.

8L.5.2 Triangle Oscillator

Time: 15 min. Two 1N5294’s can give you a triangle waveform at the capacitor. A full-wave bridge and one 1N5294 could also do the trick.

Triangle generator, using JFET or sources (your design)

If you’re in the mood, try out your design for the triangle generator.

8L.6 ’555 for low-frequency Frequency Modulation (“FM”) Time: +10 min. (optional) Here is a quick preview of a technique the class will use in the analog project lab, Lab 13, to send audio across the room as flashes of light. The rate at which a light-emitting diode (“LED”) flashes will convey the audio information. A ’555 can do the encoding, converting time-varying voltages (the music waveform) to variations in frequency. A simple parallel RLC circuit like the one you built in Lab 3 can decode the FM, converting it back to a time-varying voltage (the music waveform, recovered). Lab 8: Op-Amps III: Nice Positive Feedback 9

The ’555 can do this modulating because it brings out (to pin 5) a point on the 3-resistor divider that defines the upper comparator threshold. If a signal pushes that pin above its normal resting voltage of 2/3 × VCC, the ’555 oscillation slows; if it pushes pin 5 down, the oscillation speeds up.

Use this slope or the falling slope (the difference is only phase of output) delta ƒ (input) V+ 555 1.0 R + pin - delta V (output) (this will look ∆ƒ Voutout 3dBdB like AM: amplitude-modulation) R Vinin ƒ + resres - Q = R ∆ƒ 3dBdB ƒ ƒ 1 π √ resres = /(2 LC) One can adjust shape varying the ‘555 pin-5 voltage “Q” by adjusting R can adjust the ’555 frequency. …such an FM signal can be If a signal drives pin 5, this is demodulated with a simple RLC FM, frequency modulation… (LC in parallel, as in Lab 3) Figure 9: A ’555 can implement frequency-modulation; a parallel RLC can demodulate such a signal

Since you are likely to be short of time, this afternoon, you may want to limit yourself to the easy task of confirming that this FM scheme works. You can drive pin 5 with a low-frequency sinusoid (try 100 Hz at amplitude of 0.5V) while watching the ’555 output on a scope. Don’t forget that you need a blocking capacitor between the and pin 5, since pin 5 normally rests at 10V when the ’555 is powered by +15V. You will see what looks like jitter on the ’555 output. If it is hard to interpret, try reducing the driving frequency well below 100Hz.

8L.7 Sine Wave Oscillator: Wien Bridge Time: 25 min.

Figure 10: Wien bridge oscillator

Curiously enough, the sine wave is one of the most difficult waveforms to synthesize. (Your function genera- tors make a sine by chipping the corners off a triangle, as you may recall.) The Wien bridge oscillator makes a sine by cleverly adjusting its own gain so as to prevent clipping (which would occur if gain were too high) while keeping the oscillation from dying away (which would occur if gain were too low).

The frequency favored by the positive feedback network should be

1/(2πRC) (8L.1) See whether your oscillator runs at this predicted frequency. 10 Lab 8: Op-Amps III: Nice Positive Feedback

At this frequency, the signal fed back should be in phase with the output, and 1/3 the amplitude of Vout.11 The negative feedback provided by the other path (the one that includes the lamp) adjusts the gain, exploiting the lamp’s current-dependent resistance. Convince yourself that the sense in which the lamp’s resistance varies tends to stabilize gain at the necessary value. What gain is necessary to sustain oscillations without clipping?12

You can reduce the output amplitude by substituting a smaller resistor for the 560 ohms in the negative feedback path.13

Try poking the non-inverting input with your finger and note the funny rubbery behavior at the output. Try sweeping the scope slowly as you poke: now you can watch the slow dying away of this oscillation of the sine’s envelope.

If you’re energetic, you can confirm that this sine is much cleaner than the function generator’s, by putting it through an op-amp differentiator. The differentiator fed by the Wien oscillator should show an output that looks like a very convincing sinusoid, not like the ziggaratoid14 that you saw when you differentiated the function generator’s “sine” back in lab 7 (and lab 2). Or, if you happen to be using a digital scope that includes an FFT, instead of using a differentiator you can simply compare the frequency spectra of the two sinusoids—function generator versus your little Wien bridge.

(lab8 op3 headerfile june14.tex ; September 11, 2015)

√ 11 { Z } R 2R At this frequency, where the magnitude of C = , the impedance of R and C in√ series (the upper branch of the divider) is 2 R V whereas the impedance of the R and C in parallel (the lower branch of the divider) is 2 . Hence the result that 1/3 of out is fed back, at this favored frequency. More surprising, perhaps, is the fact that this divider delivers a waveform in phase with the input. 12Yes, you’re right: exactly three. 13Pretty smart circuit, eh? Adjusts lamp’s R value to suit your new feedback resistor! 14We hope you will not spend your afternoon seeking this waveform in an reference work. Index

’311 (lab), 3 ’555, 7–10 #344 lamp (lab), 10 1N5294 current-limiting diode, 9 74HC14 (lab), 5 comparator (lab), 3–4

FM using ’555 see “oscillator...”,9 hysteresis (lab), 4

ICM7555 (lab), 7

LM311 (lab), 3 LMC7555 (lab), 7 operational amplifier as comparator (lab), 2 oscillator FM using ’555 (lab), 9 triangle (lab), 9 oscillator (lab) IC oscillator: ’555, 7–10 op amp relaxation, 5 PWM motor drive, 6 RC: IC Schmitt Trigger, 5–7 sinusoid: Wien Bridge, 10 parasitic oscillation (lab) comparator, 3

Schmitt trigger (lab), 4

Wien Bridge oscillator (lab), 10

11