🔬

Photodetectors


Lesson Objectives

  1. Understand how a photodiode converts light into current and voltage.
  1. Use Arduino to measure ambient light, darkness, and LED flicker.
  1. Deploy Red Pitaya STEMlab 125-14 to visualize high-speed light fluctuations

Theory & Introduction

Modern sensing systems often need to monitor not only slow changes—like a day/night cycle—but also fast fluctuations, such as flicker in lighting. Flicker can arise from AC mains, poorly regulated LED drivers, or purposeful modulation (e.g. IR remote signals). A photodiode is an ideal sensor for this task: under illumination it produces a current proportional to light intensity, which we can convert to a voltage and digitize with a microcontroller.

Photodiode Basics

  • Structure:
    • A photodiode is a p–n junction operated in reverse bias (or zero bias) so that incoming photons generate electron–hole pairs, resulting in a photocurrent.
  • Linear Response:Iph=R×P,
    • Within its operating range, photocurrent IphI_{ph}Iph is approximately proportional to incident light power PPP:
      Iph=R×P, I_{ph} = R \times P,
      where RRR (A/W) is the responsivity of the device.
  • Voltage Conversion:
    • To measure this current with an Arduino (which reads voltage), we use a pull-up resistor (here 10 kΩ). The tiny current flowing through the resistor develops a voltage V=Iph×Rpull−upV = I_{ph} \times R_{pull-up}V=Iph×Rpull−up, which the ADC samples.

Why Flicker Matters

  • Health & Comfort:
    • Flicker at 50–60 Hz (or higher harmonics) can cause headaches, eye strain, or neurological effects.
  • Signal Integrity:
    • In optical communications (IR remote controls, LiFi), flicker is the information carrier—so sensing speed and fidelity matter.
  • Performance Diagnosis:
    • Mechanical or electrical faults in lighting fixtures often reveal themselves as irregular flicker patterns.

Arduino vs. High-Speed Analysis

  • Arduino ADC:
    • Pros: Simple, built-in, direct.
    • Cons: Limited sample rate (~10 kS/s), averaging hides fast events.
  • Red Pitaya Oscilloscope:
    • Pros: 125 MS/s sample rate, real-time waveform, FFT analysis.
    • Cons: Requires external setup.
In this lab you will:
  1. Quantify ambient and dark conditions with Arduino’s ADC.
  1. Drive LEDs at controlled flicker rates and observe the photodiode’s analog readings.
  1. Visualize the same flicker in fine detail on the Red Pitaya—capturing fast edges, envelope shape, and spectral content.
By comparing Arduino’s coarse readings to Red Pitaya’s high-speed plots, you’ll learn both the capabilities and limitations of embedded ADCs—and see why high-speed instruments are indispensable for characterizing transient phenomena like light flicker.

1. Hardware Setup

Components

Component
Quantity
Purpose
BPW34 Photodiode
1
Light-to-current sensor
10 kΩ resistor
1
Pull-up resistor (converts current → voltage)
LED + 220 Ω resistor
1
Flicker source
Arduino Uno (or R4)
1
Analog sampling and LED drive
Breadboard & Jumper Wires
1
Prototyping connections
Red Pitaya STEMlab 125-14
1
High-speed oscilloscope & spectrum analyzer

Circuit Diagram

Wiring

  1. Pull-up network & photodiode:
      • +5 V → 10 kΩ → junction
      • Photodiode anode → junction → Arduino A0 & Red Pitaya IN1
      • Photodiode cathode → GND
      • Arduino GND ↔ Red Pitaya GND
+5 V ── 10 kΩ ──┬────────────â–ș Arduino A0 & Red Pitaya IN1 │ BPW34 Photodiode │ GND ──────────â–ș Arduino GND & Red Pitaya GND
notion image

2. Arduino: Measuring Light Levels

Part A: Ambient vs. Darkness

// Part A: Ambient vs. Dark const int photoPin = A0; void setup() { Serial.begin(115200); } void loop() { int v = analogRead(photoPin); // 0–1023 Serial.println(v); delay(200); // 200 ms between readings }
  1. Upload the sketch.
  1. Open Tools → Serial Plotter.
  1. Ambient: point photodiode at room light → ~600–800.
  1. Dark: cover photodiode → near 0.
 

Part B: Single-LED Steady Illumination

Wiring Update

  1. LED₁ (steady):
      • Arduino D9 → 220 Ω → LED₁ anode
      • LED₁ cathode → GND
  1. Photodiode network remains unchanged.

Sketch

// Part B: Steady LED const int photoPin = A0; const int ledPin = 9; void setup() { pinMode(ledPin, OUTPUT); Serial.begin(115200); } void loop() { digitalWrite(ledPin, HIGH); // LED₁ ON Serial.println(analogRead(photoPin)); delay(200); }

Observation & Explanation

  • When LED₁ turns ON, the photodiode sees maximum light, reading ~1023.
  • Plot: a flat high line—confirms full-scale photodiode response.

Single-LED 100 Hz Flicker

Wiring (no change)

  • LED₁ on D9 + photodiode as before.
notion image

100 Hz Blink

// Part C: Manual 100 Hz Flicker const int photoPin = A0; const int ledPin = 9; void setup() { pinMode(ledPin, OUTPUT); Serial.begin(115200); } void loop() { digitalWrite(ledPin, HIGH); delayMicroseconds(5000); // 5 ms ON @100 Hz Serial.println(analogRead(photoPin)); digitalWrite(ledPin, LOW); delayMicroseconds(5000); // 5 ms OFF Serial.println(analogRead(photoPin)); Serial.println("---"); // cycle marker }
  1. Upload the code.
  1. Observe the signal using the red pitaya oscilloscope. The signal captured on the photodiode resembles the square signal (on/off) we are powering the LED with.
    1. notion image
  1. Adjust the 5000 value to explore other frequencies.

4. Arduino: Dual-LED Flicker & Photodiode Response

In this section, we drive two LEDs at different blink rates and observe how the photodiode “sees” their combined light on the Red Pitaya oscilloscope.

Wiring Update

  1. Add LED₂:
      • Arduino D10 → 220 Ω → LED₂ → GND
  1. Photodiode remains the same:
      • Anode → A0 & Red Pitaya IN1 via 10 kΩ pull-up to +5 V
      • Cathode → GND
notion image

Arduino Sketch: Two-Rate Flicker

// Dual-LED Flicker const int photoPin = A0; const int led1Pin = 9; // LED₁ const int led2Pin = 10; // LED₂ const int burstCount = 200; const int sampleDelay = 100; // ”s void setup() { pinMode(led1Pin, OUTPUT); pinMode(led2Pin, OUTPUT); Serial.begin(115200); } void loop() { // Blink LED₁ at 50 Hz (10 ms on/off) digitalWrite(led1Pin, HIGH); delay(10); digitalWrite(led1Pin, LOW); delay(10); // Blink LED₂ at 100 Hz (5 ms on/off) digitalWrite(led2Pin, HIGH); delayMicroseconds(5000); digitalWrite(led2Pin, LOW); delayMicroseconds(5000); // Burst-sample photodiode for (int i = 0; i < burstCount; i++) { Serial.println(analogRead(photoPin)); delayMicroseconds(sampleDelay); } Serial.println("---"); delay(100); // pause between bursts }
  • LED₁ toggles at 50 Hz (20 ms period).
  • LED₂ toggles at 100 Hz (10 ms period).
  • The photodiode sees the superposition of both flickers.

Red Pitaya Oscilloscope

  1. Run the dual-blink sketch.
  1. Open Oscilloscope on Red Pitaya.
  1. Set:
      • Time/div: 5 ms/div (to capture both 50 Hz & 100 Hz)
      • Voltage: 0–1 V range, probe atten. = 1 (LV)
notion image

Connecting Results

  • Envelope (50 Hz): The taller peaks correspond to LED₁ on-cycles.
  • Sub-peaks (100 Hz): Within each 20 ms window, LED₂ adds a faster modulation.
  • Photodiode Output: Shows how two light sources at different frequencies combine into a single analog signal.
By comparing the captured waveform to our code, students can visually confirm superposition of flicker rates and appreciate how the photodiode plus Red Pitaya reveal complex light patterns—insights that simple Arduino sampling alone cannot capture cleanly.