Monday, March 3, 2014

2/28: Op Amps III

in which Julia realizes the limitations of op amps

The two golden rules detailed before are not entirely accurate.
Golden Rule I*: Under negative feedback, the op amp will do everything it can to make V+ - V- = 0, but this will never truly be the case--there will always be a small offset voltage, Vos, between these two inputs.
Golden Rule II*: The op amp draws a tiny amount of current through its inputs (~pA).

Lab 9-1: Op Amp Limitations

A) Slew rate
The circuit diagram for measuring slew rate in a 411 or 741 op amp (H&H).
Part I: Square wave input
We drove the 411 with a 1 kHz square wave and did not observe slew with this excellent op amp, which has a slew rate of 15 V/μs.
The slew of a 411 op amp is quite small, not visible for 1 kHz input frequencies. (Here purple is input, yellow is op amp output; the DC offset was added by the function generator and removed from input by AC coupling.)
A 411 (yellow) accurately follows an input square wave (purple); the offset was caused by a DC offset from the function generator, removed by the AC-coupled oscilloscope.
Part II: Sine input
If we drive with a high enough frequency, we expect the output to greatly decrease (but maintain the same input frequency), as the finite slew rate of the 411 would prevent a rapid climb to the wave's amplitude.  We expect this effect to occur where:


omega*amplitude = 2*pi*f*Vin = 12 x 10^6 V/s

Vin(max) = 5
fmax = 382 kHz
So, for a 5 V input sine wave, we expect the 411 to accurately follow waves of up to 382 kHz frequencies, but to lag behind at greater frequencies.


The circuit can accurately reproduce quite high frequencies (158 kHz here) with no observable phase shift.
Driving the circuit with a sine wave of higher frequency (619 kHz here) causes a larger phase shift, but also a comparable decrease in amplitude of both input (yellow) and output (purple) signals.
The observed decrease in output amplitude corresponded with a decrease in input amplitude at frequencies in excess of 619 kHz, possibly because of physical limitations in the function generator's circuitry that prevented high amplitudes at high-frequency signals.  However, a more significant effect is that of the changing impedance of the oscilloscope probe.  At such a high frequency, the scope probe's impedance is small (it is inversely proportional to frequency), so the voltage may bypass the op amp (which has an impedance of 10^12 Ω) and instead flow through the scope probe to the oscilloscope.

We repeated the experiments with a 741 op amp, which has a "typical" slew rate of 0.5 V/us.  While the 411's slew rate was difficult to perceive, the 741's was quite clear at standard driving frequencies.
The falling slew rate of the 741 (yellow) was not high enough to accurately reproduce a square wave input (purple) at 1.9 kHz.
The falling slew rate is 2.88 V/4.680 us = 0.615 V/us.  This is slightly higher than the expected slew rate.
The rising slew rate was slightly higher.
The rising slew rate is 2.64 V/3.88 us = 0.69 V/us.  This is also slightly higher than the expected slew rate, and higher than the falling slew rate.


Measuring the slew rate from a 741 driven with a 1.9 kHz sine wave.


Calculation for the frequency at which a 741 would no longer accurately follow a sine wave:
max: omega*amplitude = 2*pi*f*Vin = 0.6 x 10^6 V/s
Vin(max) = 5
fmax = (0.6 x 10^6)/(31.4) = 86 kHz
This was in accordance with our experimental findings.

At 86 kHz input sine wave (purple), the 741 produces a triangle wave (yellow).
Part B) Offset voltage (Vos)

We attempted to measure Vos by driving with a 4.00 V, 1 kHz sine wave, but this produced a square wave out of the op amp as it saturated ("railed") because the gain of 10 was too high.  After quite some confusion, we eventually realized we had erroneously switched a few resistors, and we were quickly able to fix this problem.
A railing op amp (yellow) from a large input signal (purple).
A better way to measure: if input is shorted, then the output will be Vos amplified.  Here we measured Vos = 3.2 mV, which is quite reasonable.
Shorting the input (yellow) allowed for measurement of the offset voltage (purple).
To eliminate the bias current here, we ensured that both input terminals of the op amp were running through the same resistance to ground, so we added a 10 kΩ resistor between the V- input and ground.

Part II: Minimize the effect of Vos

Upon viewing a flatline at -10.4 V no matter the input, we assumed our op amp was no longer operating.  A new 741 showed a reasonable signal, and we adjusted the potentiometer so Vout = 0, thus minimizing the offset voltage between V- and V+.

C) Bias Current
Now we removed the extra 10 kΩ resistor to see Ibias.
Suddenly we measured a -0.384 V line with no Vin (measured -384 mV output).
Thus we expect -0.384/(10 kΩ) = -3.8 x 10^-8 = -38 nA, in reasonable agreement with the 741's specs of 80 nA.

Lab 9-2: Op amp integrator

The integrator makes a nice integrating triangle wave when driven with square wave.

Driving with a 1 kHz, 1 Vpp square wave (yellow) causes a triangle wave output (purple), as expected with an integrator.
500 Hz square wave input (yellow) makes less frequent, larger-amplitude oscillations in the output  (yellow).
Driving with a 500 Hz, 2 Vpp square wave makes less frequent oscillations, with greater amplitude.

Removing the 10 MΩ resistor makes the output voltage steadily increase, as the capacitor charges.

Lab 9-4: AC Amplifier: microphone amplifier

To conclude our experiments in electronics, Kathryn and I build an AC amplifier to amplify sound signals--to act as a microphone.  We used a single-supply op amp here (the LM358) so we could easily power it with three AA batteries.  Our circuit amplified signals of less than 20 mV to a maximum of +4.5 V; the input bias voltage goes directly to the output, without amplification, so the DC gain is unity so the signal should be clearly evident over the DC offset.
We tried whistling into the microphone and observed higher pitches produced higher-frequency waves (generally they appeared to be sine waves, as expected when whistling), and louder noises increased the amplitude.


2/23: Op Amps II

in which Julia investigates current topics in op amps

Lab 8-5: Current source

Op amp current source diagram (Electronics pdf); we used a 220 Ω resistor for V- to ground.
This circuit provides a constant current through the ammeter.
The expected current was that corresponding to 0.75 V applied over 220 Ω of resistance.  Ohm's Law tells us that V = I*R so I = V/R; thus we expect (0.75/220 = ) 0.0034 A current, or 3.4 mA.  This was in good agreement with our experimentally measured value: 3.4 mA.

When the load resistance is varied, we would expect the current to drop, because increasing the load makes the voltage drop bigger, and voltage drop is capped at 12 V.  Assuming that the op amp can output 11 V, the maximum resistance for 3.4 mA of current is:
11 V = (3.4 mA)*(R)
R = 11 / 0.0034 = 3200 Ω
We confirmed this using a resistance decade box to vary the load; the current decayed an appreciable amount at 3.1 kΩ but not at 3 kΩ.


Our experimental setup.  Left: breadboard with op amp and +/- 12 V connections.  Middle: ammeter.  Right: resistance decade box (connected to op amp's output and directly to the ammeter).  Left foreground: the discarded potentiometer initially used to vary load resistance.
The main limitations of this current source are that it requires a "floating" load, where neither side is connected to ground, and its limited speed; a more complicated transistor circuit can begin to solve these problems.

Lab 8-6: Current to Voltage Converter

Part a) Photodiode
The photodiode circuit in H&H: we used an LED running backwards instead of an LPT-100.
We used an LED wired to an op amp to measure incident light on our circuit.

The photodiode's changing voltage response to the 60-Hz flicker of fluorescent lights.
The signal was clear when AC coupled, confirming that the peaks were caused by the fluorescent lights, as all outlets in the lab are coupled.

The photodiode's output decreases when it is covered (exposed to less light).

We added a capacitor (0.1  μF) in parallel with the 10 MΩ resistor to try to eliminate fuzz.


Adding the capacitor smoothed the output signal and decreased fuzz.
When we added wires to attach a capacitor, the signal smoothed before we added the capacitor.  This result was quite puzzling until we looked closely at our breadboard--we had put two wires directly adjacent in the breadboard, and we think this made a small region of the breadboard act as a capacitor (by charging two parallel strips of the breadboard connections).  This effect was less prominent than that of the 0.1 μF capacitor.

The capacitor douses high-frequency oscillations because it is a low-pass filter.  At high frequencies, most of the current would go through capacitor, which has a small impedance so this current turns into a small output voltage signal.  At low frequencies, current instead travels through the 10 MΩ resistor, which converts a small amount of current into a large voltage signal.  Thus, high-frequencies become tiny voltage oscillations obscured by the large gain of low-frequency signals, and the output curve is smoothed.


Measuring at "X" showed a voltage of 0 V, as expected because the op amp is in negative feedback, so V- should equal V+, and V+ is at ground (0 V).
The average DC output level was approximately -82 mV (-0.082 V).
The percentage modulation was appxoimately 68% (there was a 56 mV difference from middle to top).
Calculating the input photocurrent for this output:
Vout = (Iphot)*(10MΩ)
0.082 V = (Iphot)*(10e6 Ω)
0.082/10e6 = Iphot = 8.2 x 10^-9 A so 0.00082 μA

Our photodiode isn't multiplying anything; there are 1/(1.6 x 10^-19) Coulombs per electron or 6.25 x 10^18 C/e-, so ((8.2 x 10^-9)*(6.25 x 10^18) = ) 5 x 10^10 photons/s, which is less than a high-powered laser and so seems plausible.

This op amp circuit is superior to the alternative simple resistor circuit shown in H&H, because if the latter circuit were connected to 1 MΩ oscilloscope, current would flow through the scope and not through the resistor, which would artificially decrease the voltage signal.


Part B) Phototransistor

While the signal was the same shape as in the photodiode circuit, the average DC output level was approximately -1.24 V; the peaks occurred at -80 mV, so modulation was (1.16/1.24 = ) 94%.  While this is much greater than the photodiode circuit, it is difficult to compare the two as the resistor values (and thus their gain) are different.
For this circuit, the photocurrent is 1.24 V / 100 kΩ resistor, so by Ohm's Law:
(1.24 V)/(100 kΩ) = 1.24 x 10^-5 A

The current is now 1.24 x 10^-5 A, which is nearly four orders of magnitude greater than that of the photodiode--as expected, because the phototransistor releases many more electrons per incident photon than the photodiode (which has a one photon:one electron ratio).

Lab 8-7: Summing Amplifier

The summing amplifier circuit from H&H; the arrow denotes a variable resistor (potentiometer here).
Changing the potentiometer's resistance here changes the offset voltage.  This circuit successfully adds a variable DC offset to an input signal!  To subtract voltage, we could first run one signal through an inverting op amp circuit (with a gain of unity).
Alternatively, we could attempt to add the offset voltage after the op amp (adding to output)--but that would greatly increase output impedance, so this could only be useful if it were the last step in a circuit.

Sunday, March 2, 2014

2/21: More with op amps

in which Julia operates additional op amps

H&H Lab 8-2: Inverting amplifier

The inverting amplifier op amp circuit (from Electronics pdf).  In our circuit, R1 = 1kΩ and R2 = 10 kΩ.
A few notes on the inverting amplifier op amp circuit:
-Made by connecting Vout to V-
-Vout/Vin = -R2/R1 (from op amp golden rules and Ohm's Law)
-This means, if R2 > R1, Vout > Vin: the signal is amplified
-This gain is independent of the op amp's differential gain (Gdiff must be large though)
-Output is inverted

Driving the circuit with a 1kHz square wave of amplitude 1.00 Vpp made an output with an amplitude of 10 V, which means the gain was 10 for this circuit.
The maximum output swing was 21.6 V, which seems reasonable--it is slightly less than 24 V, as expected when powering the op amp with +/- 12 V.

A triangular input wave generates a triangular output (which is linear even at small timescales).
A sine wave input generates a sine output--but at some high frequency (around 1 MHz), the amplitude of the output wave becomes much less than the input amplitude. [We later learned this is a consequence of the non-ideal op amp property of slew.]

Next we measured the input impedance by adding a 1kΩ resistor in series with input.
This caused the output voltage amplitude to decrease from 10 to 5.4 V.
When we measure from the beginning of second resistor (right before the op amp), we measured a voltage of only 0.504 V.
Output voltage was 5.4 V with a 1kΩ resistor in series with the input.
Now it's a voltage divider, with Vout = 0.504 V and R1= 1 kΩ:

R2/(R1+R2) = Vout/Vin = 0.504/1.00
0.504(1 kΩ + R2) = R2
R2 = 1 kΩ
These calculations agree with the band colors on the resistor.

To attempt to measure the op amp's output impedance, we measured the voltage with an oscilloscope over a small varying resistor; theoretically, at a resistance comparable to the output impedance of the op amp, the voltage over the external resistor would be half the resistor-free output voltage.  However, a 1 Ω resistor would require a current of 1 A--and an op amp can only output about 25 mA of current.  Therefore we must use a very small voltage to test the output impedance--which causes the output signal to be very small.  We were unable to identify the output impedance of the op amp due to these complications.

Lab 8-3: Non-inverting amplifier



The non-inverting amplifier circuit (from Electronics pdf).
The output voltage was 11 V for an input wave of 1.00 V amplitude, so the average gain in this circuit was 11, contrary to the 10 gain observed in the inverting amplifier.

Putting the input signal through a 1 MΩ resistor causes no observable change in the output voltage (after dividing by 11 to negate the gain)--which suggests that the input impedance is huge (greater than 100 MΩ)!  The 411 op amp has an input impedance of 10^12 Ω, or 1000000 MΩ (according to the specifications sheet from Texas Instruments, http://www.ti.com.cn/cn/lit/ds/symlink/lf411-n.pdf), which would be in accordance with our observed results.

At an input frequency of 25 kHz, we get about 7.70 V output amplitude--so the 3dB point occurs at 25 kHz.
Output amplitude dropped 70% (11 V to 7.7 V) when driven by a 25 kHz wave.
ω(3dB) = 1/(R*C)
ω = 2*pi*(25 x 10^3) = 157079.633 = 1/(R*C)
R =1MΩ
C = 1/[(1 x 10^6)*(157080)] = 6.4 x 10^-12 = 6.4 pF

Without such a tiny Cin, Vout would be invisible.
Like in the inverting amplifier, the non-inverting amplifier has a low output impedance, because the circuit is essentially the same here--the output impedance depends only on the op amp, not on the external resistors.

Lab 8-4: Op amp follower

Op amp follower diagram (Electronics pdf).
An op amp follower circuit is simply a special case of the non-inverting amplifier, where R2 = 0 so the circuit has a gain of unity.  Here, Zin is huge because it is an op amp input; Zout is too small to measure for the same reason as the non-inverting amplifier.

2/18: Impedances of Test Instruments and Op Amps

in which Julia investigates instrument impedances and begins op amps

Lab 3-8: Measuring the oscilloscope's impedance with a 100 Hz sine wave

Circuit to measure the impedance of the oscilloscope.
4.04 V is the maximum amplitude for the oscilloscope in series with 1 MΩ resistor.
2.08 V is the maximum amplitude for the oscilloscope without resistor.
The low-frequency (100 Hz input signal) attenuation is Vout/Vin = 0.52.

1.16 V 
is the maximum amplitude for the oscilloscope without resistor.
4.08 V is the maximum amplitude for the oscilloscope in series with 1 MΩ resistor.
Thus the high-frequency (10 kHz) attenuation is 0.28.


The oscilloscope output (purple) for the low-frequency input signal (yellow); similar results were obtained for a high-frequency input signal.
Modeling the oscilloscope as a resistor in parallel with a capacitor:
Zcap = -i/(ω*C)
Zr = R
Zscope = 1/[1/R + 1/(ω*C)]

This is the impedance for low frequencies; for high frequencies, the capacitor's impedance is small, so the scope's impedance is approximately equal to its internal resistance.  For low frequencies, the capacitor's impedance is large, so the scope's impedance is:


In this situation, we know both Vout  and Vin, so we can solve for Zscope using Ohm's Law and the above formula:
V = I*R so Vin = I*Zscope; Vout = I*(Zscope + 1 MΩ)

Vin/Zscope = I

Vout = (Vin/Zscope)*(Zscope + 1 MΩ)

Zscope*(Vout/Vin) = (Zscope + 1 MΩ)
Zscope*(Vout/Vin - 1) = 1 MΩ
Zscope = (1 MΩ)/(Vout/Vin - 1)

For low frequencies (ω = 100 Hz), Zscope = (1 MΩ)/(3.57 - 1) = (1 MΩ)/(2.57) ≈  390 kΩ

Zscope = 1/[1/R + 1/(ω*C)] = 390 kΩ
1/(Zscope) = 1/R + 1/(ω*C)
 1/R = 1/(Zscope1/(ω*C)
R = 1/[1/(Zscope1/(ω*C)]
R = 1/[(ω*C - Zscope)/(ω*C*Zscope)]

R = (100*C*390 kΩ)/(100*C - 390 kΩ)
R = (C*39 MΩ)/(100*C - .39 MΩ)

For high frequencies, the attenuation (Vout/Vin) = 0.52, so Zscope ≈ 1 MΩ (the same resistance as is externally in series with the scope).  Thus R = (C*100 MΩ)/(100*C - 1 MΩ).


Note: the input impedance of an oscilloscope is frequency dependent, getting smaller as frequency of input signal increases.  Use a 10x scope probe (as we discovered during the first few labs) to minimize the effects of the measurement on the circuit; be sure to impedance-match this by adjusting capacitance before testing.

The Operational Amplifier ("Op Amp")

Key points:
The output impedance of a device can be thought of as its ability to provide current to a load.
When connecting to a "load" or a "source", the output impedance of the source must be small compared to the input impedance of the load: Zout < (1/10)Zin

To avoid "pickup", measure voltage difference (to cancel out 60 Hz signal).  The differential mode gain of amplifier, Gdiff, is found by the following formula:
Vout = Gdiff*(V+ - V-)
Generally, a large Gdiff is desired, for zero common mode gain: if the same input voltage is fed through V+ (the "non-inverting input") and V- (the "inverting input"), Vout should be 0; thus, as usual, a large Zin and small Zout is desired.  Op amps meet this criterion fairly well.

Lab 8-1: Open Loop Test Circuit

The op amp open loop test circuit.


Differential mode gain, Gdiff, is also known as "open loop gain"--it can be observed in an open loop op amp circuit.  Here we used a potentiometer of resistance 0 - 10kΩ, and attempted to adjust it so that the voltage divider would yield an input voltage of 0 V for the op amp.  After several attempts, during which we saw Vout switch between +12V and -12V just as Vin changed sign, we considered this op amp's gain (200 V/mV) and realized we were unlikely to ever see a 0 V output.
The oscilloscope switches to -12 V just as Vin changes sign.
It was impossible to exactly set the potentiometer to cause V+ to exactly equal V-; the gain of 200 V/mV means that a voltage difference as small as 6 x 10^-5 V would be magnified by a maximum of 2 x 10^5 and thus appear as about 12 V.

Next lab: More with op amps!