Shining light on photodiodes
Photodiodes are the most versatile light-sensing component. They are also commonly misunderstood.
Let’s say you want to build a circuit that measures ambient illumination or receives data via an optical link. Today, if you start researching phototransistors, there’s a good chance you end up on a page filled with inane, AI-generated slop:
“Some phototransistors, especially the older models, are not capable of handling voltages higher than 1,000 Volts. “
“The last disadvantage of phototransistors is that the electrons in them do not move as freely as in other transistors. […] Because of this limitation, phototransistors are typically more expensive than regular transistors.”
Hit “back”, select another results, and experience a serious case of deja vu:
“Silicon-based phototransistors cannot handle voltages exceeding 1,000 Volts.”
“Furthermore, they do not allow electrons to move as freely as other devices like electron tubes.”
Even on websites that are written in good faith, some pain awaits. For example, almost every source insists on making a pointless distinction between “photovoltaic” and “photoconductive” operating modes of a semiconductor junction — never really explaining the difference, and then doubling down with nonsensical V-I plots that don’t have any conceivable real-world use.
In today’s episode, let’s do better. We’re going to focus on photodiodes, as they are the most versatile yet tricky of the general-purpose light-sensing elements.
Back to the basics: the p-n junction
To explain photodiodes, we need to start with a quick recap of the physics of conduction.
In non-conductive materials, the outer electrons are bound tightly to individual molecules; a considerable amount of energy is needed to dislodge them from the valence band. In metals, the most energetic electrons are not tied to any specific atom. They occupy the so-called conduction band and can move back and forth in response to external electric fields.
Semiconductors are an in-between case: the energy difference between the energy bands is so minor that some valence electrons are regularly knocked into the conduction band due to room-temperature thermal effects. That said, in pure (“intrinsic”) semiconductors, these charge carriers are short-lived and not particularly plentiful, so the resulting conductivity is poor.
This changes with the addition of carefully-selected impurities (dopants). In an n-type semiconductor, the dopant increases the number of long-lived conduction-band electrons. In a p-type semiconductor, a different additive creates valence band vacancies (“holes”) that allow lower-energy electrons to shuffle around in response to external fields. Both types of doped materials conduct electricity surprisingly well.
A standard semiconductor diode is formed by bringing together a p-type material and an n-type material. In a very narrow boundary region, n-side electrons diffuse into the p-type semiconductor and promptly fall into valence-band holes, emitting a photon on the way:
This process results in an unbalanced electric field that’s wholly contained to the depletion region and prevents the trapped electrons from venturing forth. The absence of mobile charge carriers in that zone renders the diode nominally non-conductive.
Plucking the electrons from the right (cathode) and depositing them on the left (anode) doesn’t accomplish much. It creates an electric field identical to that present in the depletion region, causing p-side electrons and n-side holes to drift toward the boundary and then get stuck. When connected this way (“reverse-biased”, cathode more positive than anode), the diode will not conduct — at least not until some form of breakdown occurs.
Going the other way round is another story. If the anode is made more positive, it offsets the junction’s internal field — eventually reducing it enough to get the electrons unstuck and the current flowing. For a typical silicon diode, this “forward” threshold is about 0.6 V.
The miracle of photocurrent
If electrons falling into a lower energy state emit photons, it’s probably unsurprising that the opposite can happen too: shining light on a semiconductor can knock some electrons into the conduction band. And if this excitation happens in the p-n junction’s depletion region, the existing internal electric field immediately accelerates the electron and tosses it over to the n-type (cathode) side!
In an open-circuit scenario — that is, if the diode’s terminals are not connected to anything — exposing the junction to light causes a small voltage to gradually build up within the component. The resulting field inevitably hinders the motion of additional electrons and shrinks the depletion region, so the effect is non-linear and self-limiting — but it’s quite easy to observe with a multimeter and any light source.
To illustrate, I placed a Marktech MT03-023 photodiode directly in front of a small, generic white LED. I connected the photodiode to a precise benchtop multimeter, and then used a signal generator to drive the LED with a smoothed 10 kHz square wave:
Alas, not only are the readings nonlinear, but at lower light levels, they simply cannot be trusted. In complete darkness, the photodiode behaves essentially like an open circuit — so stray voltages can build up due to RF interference, static electricity, and so forth.
To avoid these problems, the terminals of a photodiode should be shunted via some comparatively small impedance instead. In this mode, the device is free to keep moving charge carriers at the exact rate they’re created. If we plot shunt current as a function of light intensity, we get a supremely linear plot in conditions ranging from sunlight to candlelight:
It’s important to note that the photocurrent generated by the diode has a polarity opposite to the normal induced current through a forward-biased diode: electrons flow out of the cathode.
Building a photodiode amplifier
The main issue with photodiodes is that the currents they generate are fairly miniscule — at least until we scale the devices up to the size of solar panels (hey, it’s the same operating principle!).
To get the most out of a reasonably-sized photodiode, we need a linear, low-noise current-to-voltage (“transimpedance”) amplifier. A single-supply circuit employing a modern rail-to-rail (RRIO) op-amp is pretty easy to build:
First, note that the photodiode’s anode is connected to the ground. There are no negative supplies in this circuit, so we know the diode can never be forward-biased. It works solely as a photocurrent generator.
In a darkened room, the photodiode shouldn’t be doing anything of note, so we can temporarily ignore the grayed-out parts:
Op-amp afficionados should immediately recognize the remaining bits as a voltage follower (if you need a refresher on op-amps, click here). In essence, with the diode out of the picture, the amplifier is “following” (i.e., outputting) a fixed 0 V signal that’s present on its non-inverting leg.
The situation changes in the presence of a photocurrent. The diode starts moving electrons from the GND side toward the inverting input of the op-amp, making Vin- very slightly negative. Because Vin- is now lower than Vin+, the output voltage starts rising, and some current starts flowing via the feedback resistor (Rf) — thus fighting the diode to pull Vin- back up.
The equilibrium is reached when the Rf current is exactly equal to photocurrent, canceling out the influence of the photodiode. Per Ohm’s law, the output voltage swing needed to produce that feedback current is directly proportional to the value of Rf — e.g., a 100 kΩ resistor turns a 10 µA photocurrent to an output swing of 1 V. And that’s it!
Additional circuit notes
The choice of an op-amp in this circuit is not critical, but some operational amplifiers don’t work well (or at all) if their inputs or outputs are too close to the negative supply rail. If so, the necessary offset voltage — perhaps 0.5 V — can be created with a resistor-based voltage divider and a noise-filtering capacitor. The Vin+ leg can be then disconnected from the ground and connected to this reference voltage:
The 0.5 V offset will carry to the output — but with a simple single-supply architecture, them’s the breaks.
Moving on: the depletion region of some larger photodiodes can act like a substantial capacitor. In an inverting op-amp layout, excess input capacitance adds phase delay to the feedback loop, possibly causing ringing or other artifacts. A small lowpass capacitor — Cf in the schematic above — was added to keep the issue in check.
Another way to lower the diode’s capacitance without sacrificing bandwidth is to connect the anode to a lower voltage. This widens the depletion layer; reverse-biasing with -5 V to -10 V is well-tolerated by most diodes. The modification will cause some constant quiescent (dark) current through the junction, but — within the limits of reason — will not hurt linearity.
Should I even be using a photodiode?
Photodiodes are the best option if you need to make fast, accurate, and linear readings with a wide dynamic range. The diodes’ spectral characteristics are not linear — that is, they are more sensitive to certain wavelengths — but this can be addressed with color filters or buying a diode tuned for a specific use.
A phototransistor works quite similarly to a photodiode: most commonly, it’s essentially a see-through bipolar NPN, driven by a photocurrent in lieu of a standard base terminal. This architecture has a built-in current gain, so compared to a photodiode, you save on an amplifier. That said, this crude form of amplification is not particularly linear, the dynamic range is limited, and the response time is not as good as for a photodiode. Because of these limitations, phototransistors are most commonly used for “binary” sensing — photointerrupters, barcode readers, and so forth.
Finally, photoresistors (or light-dependent resistors, LDRs) are made from monolithic, junction-free semiconductor materials, most commonly cadmium sulfide. Their resistance decreases when exposed to light due to the excitation of electrons. They’re the OGs of light measurement; they’re hard to kill and easy to use. That said, LDRs are not linear and tend to be excruciatingly slow, with response times measured in hundreds of milliseconds. They’re OK for sunlight sensors and other simple devices, but they’re not as popular as they used to be.
For a thematic catalog of articles on electronics and other topics, click here.
Something I was planning to mention, but that didn't make the cut: regular LEDs work as (poor) photodiodes too, with a LED-color-specific spectral response. Experimental results can be found here:
https://learnmaketeachshare.org/sensors%20and%20circuits/2018/10/30/using-leds-to-measure-narrow-spectral-bands.html
Thank you for clearing up the differences between some components that have long confused me :)