Introduction: A Cool Op-Amp Demonstration: Differential Light Meter

What is a differential light meter?

A differential light meter is a nifty little tool that will tell you how much brighter the surrounding light is on one side of the meter than the other.  With a little imagination and a little engineering, you could connect a whole bunch of these together in different directions, and make a little box that will tell you how bright the light in the room is from all directions.  You might call that box a 3D camera.

This Instructable is more of a demonstration of concept, and an introduction to how operational amplifiers work, but it's cool to think about how this can be generalized!  


What you will need:

Tools:
1) A breadboard that can source +15 V and -15V OR a regular breadboard with a +/- 15 volt power supply
2) Jumper wires
3) An oscilloscope + oscilloscope probe (If you do not know how to use an oscilloscope, there are plenty of good resources online!)
4) A multimeter (not strictly required, but useful.)


Components:
1) An Operational Amplifier (We used a TL082 - http://tinyurl.com/d49o3yy)
2) Two photodiodes
3) A capacitor and resistor such that 1/RC is about 2*pi* 1 kHz and R is large (so you can see the tiny little current from the photodiode.)
We used a 1.5 nF capacitor and a 100 kOhm resistor.
(where R is the resistance of the resistor, and C is the capacitance of the capacitor)


Safety:
Be VERY careful to connect the photodiode in the right orientation!! If you connect it the wrong way it will very quickly burn out and possibly shoot out of the board.  And then, http://www.youtube.com/watch?v=YleZvTSDC6s

Step 1: Intro to Breadboard

Gotta cover our bases.  Skip this if you've used a breadboard before.

A breadboard provide a stable and easily adjustable way of connecting and playing around with different circuit elements.

Each row of five holes in the main section of the breadboard is connected below the surface by a piece of metal, so current can flow between the 5 holes and each of the 5 holes is at the same voltage. So if you want to connect two elements, put them in the same row of the breadboard.

In the breadboard we used, there are four rows that are connected all the way across the top. They are as follows (from the BOTTOM up): ground, negative 15 volts, positive 15 volts, and +5 volts. We will not be using the top row. 

Step 2: Intro to Op-amp

This is an op-amp - otherwise known as an Operational Amplifier. 

What you will need to know about an op-amp:

As you can see on the diagram, it has two inputs - a "minus" (inverting) input and a "plus" (non inverting) input - and one output.  
It needs to be powered (we used +15 volts and -15 volts).
Ignore the other 3 terminals for this project.


How it works:

Nobody really knows....  It's a magical little guy that some clever engineers designed years ago.  If you're a really serious electronics geek (in which case good for you!) and want to know the complicated details of how this particular op amp works, check out http://www.ti.com/product/tl082.  

For the rest of us mortals, we can understand op amps by applying the three golden rules:

1) No current (ok, ok...very very little current) flows into the op amp inputs.

2) The op amp can put out current from its output (with negligible output resistance), but only up to a certain amount (about.25 mA for ours)

3) If you connect the output to the "minus" input (as we will), the op amp will try its darndest to make the voltage at the "minus" input equal to the voltage at the "plus" input.



Step 3: Intro to Photodiode

This is a Photodiode

What you will need to know about a photodiode:

It converts the light that it "sees" into electrical current.
It has to be put in the breadboard in a certain direction or it will not work (and might blow up!).

How it works:

When one photon hits the photodiode, it has a certain probability (the quantum efficiency) that it will knock loose one electron from the photodiode's metal guts.  This means that the number of electrons knocked loose is proportional to the number of photons hitting the photodiode, which is a measure of the intensity of light shining on the photodiode.  

This means that the current flowing out of the photodiode is proportional to the intensity of light hitting the photodiode.... if the electrons actually flow out of the photodiode.  To make sure they do, we will REVERSE bias the photodiode (as you will see soon.)

Step 4: Resistor

You will need a 100kOhm resistor. It will be marked with four stripes. The first three will be brown, black, yellow. The last stripe will be gold or silver. This doesn't matter too much for our purposes but we are using a resistor with +/- 5% tolerance, which is marked by a gold stripe.

You can also test the resistance by connecting it to a multimeter, as shown above.

Step 5: Part 1: a Regular Transimpedence Amplifier

We will be making what's called a transimpedence amplifier.  

Essentially, what this circuit does is it takes the current from the photodiode:  i(t)  and multiplies it by R = 100kOhm to make Vout(t).  You can then measure Vout(t) with an oscilloscope, which will tell you how the photodiode current is varying with time, and thus how the intensity of light that the photodiode "sees" is varying with time.

How does it do this?
Recall the three golden rules:

1) No current flows into or out of  the op amp inputs but 2) Current can flow OUT of the op amp, at the position labeled Vout.

So you have photons hitting the photodiode, and knocking electrons loose.  The electrons will be repelled away from the -15 V (this is called a reverse bias - reverse because it's opposite to the usual way that current wants to flow in a diode), which means that the conventional positive current is flowing towards the -15V.  This positive current can't be flowing from the op amp inputs, so it must be coming from the output Vout.  

3) If you connect the output to the "minus" input, the op amp will try do its best to make the voltage at the "minus" input equal to the voltage at the "plus input"

Because Vout is connected to the "minus" input, the op amp will make sure that the voltage at the the "plus" input, V+, is equal to the voltage at the "minus" input, V-.  But since V+ is grounded, V- must also be "grounded".  This is called a "floating ground":  V- is not actually connected to ground, but its voltage is effectively at ground (to the best of the op amp's ability).  So now we know 2 things:  a) There is a positive current i(t) flowing from Vout, across the 100kOhm, to V- and b) V- = 0 volts.  

Thus we know that Vout - i(t)*(100kOhm) = V- = 0 which means that Vout = i(t) * (100kOhm) as promised!

Step 6: Powering the Op Amp

Now we will connect the circuit components shown in step 5.  
First, let's power up the op amp.

1. Connect the fourth pin on the op-amp to the negative power supply (-15 V) using jumper wires. This is shown with the yellow wire.
2. Connect the seventh pin on the op-amp to the positive power supply (15 V) using jumper wires. This is shown with the red wire.

Step 7: Making a Transimpedance Amplifier

Next, let's set up the op amp part of the transimpedance amplifier.

Connect the third pin to ground using a jumper wire. The third pin is the "plus" or noninverting input and is labeled "+" in the diagram in step 2. This step is shown with the green wire.

Connect the second pin to the sixth pin using the 100kOhm resistor. Pin two is the "minus" or inverting input and is labeled "-" in the diagram in step 2.

Connect a jumper wire to pin six, which is the output of the op-amp. Leave one side of the jumper wire out of the breadboard. This step is shown with the purple wire.  We will connect the purple wire to the oscilloscope to measure Vout(t), which as you recall will tell us how the intensity of the light that the photodiode "sees" varies with time.



Step 8: Direction of Photodiode

Soon, we will be ready to connect the photodiode and finish the regular transimpedence amplifier.  But first a word on the direction of the photodiode:

Current can only flow safely in one direction in the photodiode. This means it must be put in in the right direction. (Putting it in in the wrong direction might make something explode so don't just put it in the breadboard without knowing what direction it is in!)

You can test to see which direction the photodiode should be put into the breadboard by using a multimeter. Connect the two ends of the photodiode to a multimeter on the continuity setting (it shows a picture of a diode). If your multimeter does not show a number, there is no continuity and the diode is backwards. When the multimeter reads a number, current is able to flow through the photodiode from the red side to the black side. We want the wire connected to the red side to be connected to the input of the op-amp and the other to be connected to the negative power supply in the following step so that current can flow from from the op-amp to the negative power supply.

If you don't have a multimeter, or your multimeter doesn't have a continuity setting: If you look carefully you can see one side of the photodiode is flat. This is the "red" side and current flows from this side to the other. If you look at the diagram in the next step. The flat side of the photodiode is shown as a line in the diode symbol.

Step 9: The Regular Transimpedance Amplifer

Now we are ready to add in the photodiode.

1. Connect the flat or "red" side of the photodiode to the "minus" input of the op amp, as shown with the blue wire.

2. Connect the other side (the "black" side) to -15 V, as shown with the new yellow wire.

3. (Not shown, but do this if you want to see the signal from the regular transimpedence amp.):  Connect the oscilloscope probe to the purple wire, and connect the other side to the oscilloscope.  Connect the ground part of the probe to the same ground we have used thusfar.  You can see a picture of the probe setup in step 11.

Take a look at the picture of our oscilloscope screen.  The most immediately noticeable thing is that it looks like a sine wave.  If you measure the frequency of the sine wave, you'll find that it's at 120Hz.  Does that frequency ring a bell?  It's 2 times the 60Hz frequency of the AC power line where we live in the United States!   We are seeing the fact that our ceiling lights actually flash 120 times per second.  It's too fast for our eyes to pick up, but not for the transimpedence amplifier!

Next, you might notice that there is a lot of high frequency noise in the output.  We are not sure what the source of the noise is, but we are sure that we want to get rid of it!

So to quiet or "roll off" the high frequency noise, we will add a capacitor in parallel with the resistor and make a low pass filter...

Step 10: Add a Capacitor to Make an Improved Transimpedance Amplifier

We can filter out the high frequency noise by adding a capacitor in parallel with our resistor.  This forms what's called a low-pass filter (because it allows low frequency signals to "pass" through and blocks high frequency signals.)  

Instructions:
1) Use a capacitor such that (1/2pi) / RC = 1kHz.  In the case of our 100kOhm resistor, 1.5 nF works well.
2) Attach the capacitor in parallel with the resistor as shown in the picture.
3) Look at the signal on the oscilloscope. The signal should look a lot cleaner than it did before.

Why does this work?

I won't go into the (literally) "complex" mathematical explanation of this circuit, but here's an intuitive explanation:

You can figure out the (frequency dependent) behavior of the transimpedance amplifier by (again) applying the golden rules, and noting that the difference between the regular transimpedance amplifier and the improved one is that in the new amp, i(t) has the "choice" of going through the resistor OR the capacitor.  

Now a resistor impedes signals by exactly the same amount, no matter what the signal's frequency is.  A capacitor, on the other hand, REALLY impedes low frequency signals, and really does not impede high frequency signals.  In fact, a capacitor will act like an (almost) infinite resistor to direct current and like a plain old wire to super high frequency signals.  

So imagine that you were a DC signal traveling from the op amp's output to the photodiode.  Would you choose to go through the infinitely resistive capacitor, or through the finitely resistive resistor?  I'd choose to go through the resistor too.  So for DC signals, the behavior of the improved amp is the exact same as the behavior of the regular amp.  None of the current passes through the capacitor, and its almost like it wasn't there at all.  

Now imagine that you were a very high frequency AC signal going from the op amp's output to the photodiode.  You hit the same obstacle as the DC signal did.  But to you, the capacitor looks like a wire with close to zero resistance!  So you happily prance down the wire, and as a result of its low impedance, you lose very little energy doing so, and so you drop very little voltage doing so.  But here's the thing:  because you didn't lose much energy going through the capacitor, the component of Vout at your frequency must be at nearly the same voltage as V-.  That is to say, Vout at high frequencies is about equal to V-, which is equal to 0 because it's a floating ground!  

As you might expect, for intermediate frequencies, the higher the frequency of a component, the less it now contributes to Vout.  Thus, the low pass filter has succeeded in its mission to let low frequency signals "pass" through, and block higher frequency signals. 

If you want, you can read the wikipedia article on low pass filters, google, or consult a textbook like Horowitz and Hill for a more technical (and mathematically precise) discussion how low pass filters work. 


It turns out that there's what's called a 3dB cutoff frequency, where the contribution at that frequency to Vout is reduced by the filter by a factor of 1/(square root of 2).  This frequency is given by f = (1/2pi)w = (1/2pi) / RC.  We wanted f = 1kHz, so we used a 1.5 nF capacitor to compliment our 100kOhm resistor.



Step 11: Differential Light Meter

Now we are finally ready to make the differential light meter!

Notice how this is very similar to the improved transimpedance amplifier, except that there are now two photodiodes.
Also notice how the two photodiodes are pointing in opposite directions, and reverse biased with different voltages.  

Apply the same procedure as before to make sure you do not connect the new photodiode backwards.  Remember: the flat, or "red" side of the diode corresponds to the line in the diagram.  Refer back to step 8 for a reminder on how to use your multimeter to check which side of the photodiode is the "red" side.


How does it work?

This works in the exact same way as the improved transimpedance amplifier, except that the current flowing out of Vout, through the resistor/capacitor barrier, to V- is now the sum of the two photodiode currents.  Furthermore, the photodiode currents are flowing in different directions, since one is reverse biased with -15V and the other is reverse biased with +15 volts (the electrons are repelled away from the -15V and attracted towards the +15V).  

If the -15V diode's current is Iminus(t) and the +15V diode's current is Iplus(t), then the total (positive) current flowing out of Vout through the barrier is Iminus(t) - Iplus(t).  So Vout is now measuring the difference between the two currents, and thus it's measuring the difference between the intensity of light into one diode versus the other!

If you bend the two diodes so that they point in opposite directions, you now have a device that measure the difference between the intensity of light on one side versus the intensity of light on the other.  A differential light meter.

Congratulations! 


Step 12: Final Product

Congratulations on building your brand new differential light meter!

This is what our final product looks like.

In the movie, I use my hand to cover up the light from one direction, and then from the other several times.  You can see the voltage read on the oscilloscope visibly shift in response to this!

Play around with it!  One of the things that we did when we built our first one was passed a flashlight back and forth over the photodiodes.  We saw the shift that we expected, but in addition to that, we discovered unexpectedly that our flashlight actually does flash...with a frequency of 150Hz.  (We saw ripples on the oscilloscope screen with that frequency, that didn't occur when we simply covered up the light in different directions.)  

Have fun :)