Photodiodes & Phototransistors#
Photodiodes and phototransistors are the fundamental transducers for converting optical radiation into electrical signals. A photodiode generates a photocurrent proportional to incident light intensity, while a phototransistor amplifies that photocurrent internally, trading bandwidth for higher output. Choosing between them — and designing the analog front-end correctly — determines the sensitivity, speed, and linearity of the entire optical measurement chain.
Photodiode Operating Modes#
A silicon photodiode can operate in two distinct modes, each with different characteristics.
Photovoltaic Mode (Zero Bias)#
In photovoltaic mode, no external bias is applied. The photodiode generates a voltage across its junction proportional to the logarithm of light intensity. This mode offers the lowest dark current (typically sub-picoamp) and is preferred for precision low-light measurements. The tradeoff is nonlinear response and slower speed — junction capacitance is at its maximum with zero reverse bias, limiting bandwidth to tens of kilohertz for typical silicon photodiodes.
Photoconductive Mode (Reverse Bias)#
Applying a reverse bias (typically 1–15V) across the photodiode widens the depletion region, reducing junction capacitance and improving response speed. A BPW34 photodiode has roughly 72pF junction capacitance at 0V but only 12pF at 10V reverse bias. The bandwidth improvement is dramatic — from roughly 50kHz to over 1MHz with the same transimpedance gain. The penalty is increased dark current (typically 2–30nA at room temperature), which sets the noise floor for low-light measurements.
Photocurrent and Responsivity#
The photocurrent generated by a photodiode is:
Iph = R × E × AWhere R is the responsivity (A/W), E is the irradiance (W/m²), and A is the active area (m²). For silicon photodiodes, responsivity peaks around 0.5–0.6 A/W near 900nm and drops off at shorter visible wavelengths (roughly 0.3 A/W at 550nm). In practical ambient light measurement, photocurrents range from sub-nanoamps in dim indoor lighting to tens of microamps in direct sunlight.
Transimpedance Amplifier (TIA) Design#
The standard front-end for a photodiode is a transimpedance amplifier — an op-amp with a feedback resistor that converts photocurrent to voltage.
Rf
┌───/\/\/───┐
│ │
│ ┌───┐ │
────┤────│ - │───┴─── Vout
Iph│ │ │
│ │ + │
│ └─┬─┘
│ │
▽ GND
(PD)The output voltage is:
Vout = Iph × RfGain-Bandwidth Tradeoff#
The feedback resistor Rf sets the gain but also forms a low-pass filter with the total input capacitance (photodiode junction capacitance + op-amp input capacitance + parasitic PCB capacitance). A feedback capacitor Cf is placed in parallel with Rf to ensure stability:
Cf ≥ √(Cin / (2π × Rf × GBW))Where GBW is the op-amp’s gain-bandwidth product and Cin is the total input capacitance. Higher Rf values increase signal amplitude but reduce bandwidth. A 1MΩ feedback resistor with 20pF total input capacitance limits bandwidth to approximately 8kHz, while a 10kΩ resistor extends bandwidth to over 1MHz but requires 100× more light for the same output voltage.
Practical TIA with OPA380#
The OPA380 is a precision transimpedance amplifier optimized for photodiode applications, with 90MHz GBW and femtoampere-level input bias current.
/* TIA output read via STM32 ADC — photodiode on OPA380 */
#include "stm32f4xx_hal.h"
ADC_HandleTypeDef hadc1;
static void adc_init(void)
{
ADC_ChannelConfTypeDef sConfig = {0};
hadc1.Instance = ADC1;
hadc1.Init.Resolution = ADC_RESOLUTION_12B;
hadc1.Init.ScanConvMode = DISABLE;
hadc1.Init.ContinuousConvMode = DISABLE;
hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;
hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT;
hadc1.Init.NbrOfConversion = 1;
HAL_ADC_Init(&hadc1);
sConfig.Channel = ADC_CHANNEL_0; /* PA0 — TIA output */
sConfig.Rank = 1;
sConfig.SamplingTime = ADC_SAMPLETIME_84CYCLES;
HAL_ADC_ConfigChannel(&hadc1, &sConfig);
}
/**
* Read TIA output voltage and compute photocurrent.
* Rf = 1MΩ feedback resistor on OPA380.
* Vref = 3.3V, 12-bit ADC.
*/
float read_photocurrent_uA(void)
{
HAL_ADC_Start(&hadc1);
HAL_ADC_PollForConversion(&hadc1, 10);
uint16_t raw = HAL_ADC_GetValue(&hadc1);
float voltage = (raw / 4095.0f) * 3.3f;
float photocurrent_uA = voltage / 1.0f; /* Rf = 1MΩ → 1V/µA */
return photocurrent_uA;
}Oversampling for Low-Light Conditions#
In dim environments where the TIA output is only a few millivolts, hardware oversampling (available on STM32L4/G4/H7 ADCs) or software averaging reduces quantization noise:
#define OVERSAMPLE_COUNT 64
uint32_t read_adc_oversampled(void)
{
uint32_t accumulator = 0;
for (int i = 0; i < OVERSAMPLE_COUNT; i++) {
HAL_ADC_Start(&hadc1);
HAL_ADC_PollForConversion(&hadc1, 10);
accumulator += HAL_ADC_GetValue(&hadc1);
}
return accumulator / OVERSAMPLE_COUNT;
}This effectively adds 3 bits of resolution (64× oversampling), bringing the effective resolution from 12 bits to approximately 15 bits.
Phototransistors#
A phototransistor is essentially a photodiode integrated with a bipolar transistor, where the photocurrent acts as the base current and is amplified by the transistor’s current gain (β, typically 100–1000). This produces a much larger output current for the same light level, eliminating the need for a TIA in many applications.
Simple Phototransistor Circuit#
A common configuration uses a pull-up resistor from VCC to the collector, with the emitter grounded. The voltage at the collector node drops as light intensity increases:
VCC (3.3V)
│
├── Rload (10kΩ)
│
├──── Vout (to ADC)
│
▽ (phototransistor, collector up, emitter down)
│
GNDThe load resistor value determines the sensitivity-bandwidth tradeoff, similar to the TIA feedback resistor. Higher resistance produces more voltage swing per unit of light but limits response speed.
Spectral Response#
Silicon photodiodes respond to wavelengths from roughly 300nm to 1100nm, with peak responsivity near 900nm. Common part selections depend on the target spectral band:
- BPW34 — Broadband visible + near-IR (430–1100nm), 7.5mm² active area, general-purpose ambient light detection
- SFH213 — Fast near-IR photodiode (730–1100nm peak), 1mm² active area, optimized for data communication and proximity sensing
- VEMD5080X01 — Daylight-blocking IR photodiode (800–1050nm), used in IR remote control receivers and proximity sensors
Photodiode vs Phototransistor Comparison#
| Parameter | Photodiode (BPW34) | Phototransistor (SFH309) |
|---|---|---|
| Responsivity | 0.55 A/W at 900nm | Collector current ~1mA at 1mW/cm² |
| Current gain | 1 (no internal gain) | 100–1000 (β dependent) |
| Bandwidth (−3dB) | 1–10 MHz (reverse biased) | 5–50 kHz |
| Linearity | Excellent over 6+ decades | Good over 2–3 decades |
| Dark current | 2–30 nA | 50–200 nA (amplified leakage) |
| External circuit | Requires TIA or load resistor | Simple load resistor |
| Cost (qty 1) | $0.50–$2.00 | $0.20–$0.80 |
| Best for | Precision measurements, high-speed | Simple light/dark detection, low cost |
Dark Current and Temperature Effects#
Dark current doubles approximately every 10°C in silicon photodiodes. A BPW34 with 2nA dark current at 25°C produces roughly 8nA at 45°C and 30nA at 65°C. In photoconductive mode (reverse-biased), dark current is significantly higher than in photovoltaic mode. For applications that must operate across a wide temperature range, dark current compensation — either through periodic dark readings (shutter closed or LED off) or temperature-compensated calibration — is essential.
Phototransistors amplify dark current by their gain factor, making the problem worse. An SFH309 with 200nA dark current at 25°C can produce several microamps of collector current at 60°C even in total darkness.
Optical Filtering#
Ambient light contains both visible and IR components. For applications requiring sensitivity to only one band:
- Visible-only: Use a photodiode with integrated daylight filter (blocks IR above ~700nm), or add an external IR-cut filter
- IR-only: Use a photodiode with daylight-blocking filter (blocks visible below ~800nm), common in proximity sensors and remote control receivers
- Narrowband: Optical bandpass filters centered on a specific wavelength (e.g., 850nm for LIDAR applications) reject out-of-band ambient light and improve signal-to-noise ratio
Tips#
- Start TIA design with the OPA380 or LTC6240 — both have femtoampere input bias currents that prevent offset errors from dominating at high transimpedance gains
- Always add a feedback capacitor (Cf) across the TIA feedback resistor — without it, parasitic capacitance at the input creates a gain peak that rings or oscillates
- Use photoconductive mode (reverse bias) when bandwidth matters and dark current is tolerable — the capacitance reduction from 72pF to 12pF (BPW34 at 10V) dramatically improves step response
- Shield the photodiode signal trace on the PCB with a guard ring tied to the op-amp’s inverting input potential — leakage currents across FR4 (especially in humid environments) can exceed the photocurrent in low-light applications
- For simple light/dark threshold detection (e.g., object presence), a phototransistor with a comparator is far simpler and cheaper than a photodiode with TIA
Caveats#
- TIA oscillation is the most common failure mode — An unstable TIA produces a constant high-frequency output that looks like a saturated or railed ADC reading; always check stability with an oscilloscope before trusting ADC readings
- Ambient IR from fluorescent and LED lighting pulsates at 100/120Hz — This modulation appears as ripple on the photodiode output and can be mistaken for signal variation; either filter it digitally or synchronize measurements to reject it
- Long wires between photodiode and TIA destroy performance — Every centimeter of cable adds picofarads of capacitance and picks up electromagnetic interference; keep the photodiode within millimeters of the op-amp input
- Saturation is silent — A photodiode in bright light can produce enough photocurrent to rail the TIA output without any indication of clipping; implement a saturation detection flag in firmware by checking if the ADC reading is within a few counts of full scale
- Phototransistor response is temperature-dependent and nonlinear — Gain varies with temperature and collector current; phototransistors should not be used where measurement accuracy better than ±20% is required
In Practice#
- When bringing up a TIA circuit, probing the output with an oscilloscope before connecting the ADC reveals oscillation that would otherwise appear as an unexplained DC offset or noisy reading in firmware
- A photodiode circuit that reads zero in a dark room but jumps to mid-scale under fluorescent lighting — even when the object under test has not changed — is picking up 120Hz ambient modulation; a 10ms averaging window (one full 100Hz cycle) typically eliminates this artifact
- Matching the spectral response of the photodiode to the emitter wavelength in a proximity sensing application (e.g., SFH213 paired with a 940nm IR LED) maximizes signal-to-noise ratio and rejects ambient visible light without an external filter
- A TIA output that drifts slowly upward over several minutes in a temperature-controlled environment usually indicates increasing dark current as the photodiode self-heats or as the enclosure temperature rises — the drift rate doubles for roughly every 10°C increase