featured image

Isolating the Corneo-Retinal Dipole: Building a Robust EOG Analog Front-End

The human eye is a natural dipole. The cornea carries a positive charge while the retina is negatively charged, creating a resting potential of roughly 10 to 30 millivolts. The raw voltage potential reaching the skin is attenuated to the microvolt range and completely drowned out by surrounding electromagnetic interference (EMI) and electromyographic (EMG) muscle noise.

Published

Fri May 30 2025

Technologies Used

Arduino Op Amp EOG
Intermediate 29 minutes

The human eye is a natural dipole. The cornea carries a positive charge while the retina is negatively charged, creating a resting potential of roughly 10 to 30 millivolts. When a patient is sleeping, translating the rotation of this dipole into a clean, actionable digital signal is notoriously difficult. The raw voltage potential reaching the skin is attenuated to the microvolt range and completely drowned out by surrounding electromagnetic interference (EMI) and electromyographic (EMG) muscle noise.

To bridge the gap from our high-level stroke detection architecture to concrete implementation, we are going to build a two-stage Analog Front-End (AFE) circuit and pair it with a digital filtering pipeline. We will engineer a system that captures the vertical voltage potential difference between electrodes placed above and below the eye, amplifies it by a factor of 1000, and aggressively filters out noise. By the end of this tutorial, you will have a production-grade parser for processing raw, noisy biopotentials into smooth vertical eye-tracking data without relying on black-box external ICs.

The Biopotential Workbench: Components and Conceptual Prerequisites

Before touching a breadboard or writing firmware, you must understand the fundamentals of differential signaling. You should be intimately familiar with Operational Amplifiers (Op-Amps), specifically the concepts of Gain, Cutoff Frequencies, and the Common-Mode Rejection Ratio (CMRR).

To physically construct and code this pipeline, your environment will require:

  • Instrumentation Amplifier (INA): E.g., AD620, INA114, or INA128. A standard Op-Amp is insufficient for the first stage due to poor common-mode rejection.
  • Operational Amplifiers: E.g., TL072 or LM324 for the secondary active filter and gain stages.
  • Power Supply: A split dual power supply yielding +9V and -9V to power the operational amplifiers (allowing the AC biopotential signal to swing above and below ground).
  • Microcontroller (MCU): Any standard MCU with at least a 10-bit Analog-to-Digital Converter (ADC) capable of timer-based interrupts (e.g., ATmega328P or an STM32).
  • Electrodes: Standard Ag/AgCl (Silver/Silver Chloride) gel electrodes for low-impedance skin contact.

The Signal Sieve: From Skin Contact to Digital Conversion

Think of detecting an EOG signal like trying to record a whisper in a room where a heavy metal concert is playing. The 60Hz mains hum from the wall outlets is the concert; the tiny shift in eye position is the whisper. Our architecture acts as a highly directional microphone followed by a soundproof isolation booth.

The first stage (the INA) acts as the directional microphone, ignoring the loud “common” noise hitting both electrodes simultaneously and only amplifying the “difference” (the whisper). The second stage (the Low-Pass Filter) is the soundproof booth, physically cutting off high-frequency acoustic chatter before it ever reaches the digital brain.

graph LR
    E_UP[Electrode: Above Eye <br> Non-Inverting] --> INA
    E_DN[Electrode: Below Eye <br> Inverting] --> INA
    E_REF[Electrode: Forehead <br> Reference] --> GND(System Ground)
    
    INA[Instrumentation Amp <br> Stage 1 Gain: ~100x] --> LPF[Active Low-Pass Filter <br> Cutoff: ~15 Hz]
    LPF --> AMP[Secondary Op-Amp <br> Stage 2 Gain: ~10x]
    AMP --> ADC[Microcontroller ADC <br> 100 Hz Sample Rate]

Amplification and Acquisition: Turning Microvolts into Actionable Data

To implement this, we must first mathematically configure our hardware, then write the firmware to ingest the signal.

Hardware Configuration: Setting the Gains and Cutoffs EOG signals operate between 0.1 Hz and 15 Hz. Any frequency above this is likely EMG (muscle twitch) or 60Hz electrical noise. We first configure our INA for a gain of 100. For an AD620, the gain equation is G=49.4kΩRG+1G = \frac{49.4k\Omega}{R_G} + 1. A resistor (RGR_G) of ~500 Ω\Omega gives us exactly 100x gain. Next, we design an active Low-Pass Filter (LPF) with a secondary Op-Amp, configuring the RC network for a cutoff frequency (fcf_c) of 15 Hz using the formula fc=12πRCf_c = \frac{1}{2\pi RC}. A 100 nF capacitor and a 100 kΩ\Omega resistor achieve this perfectly.

With the hardware outputting a clean ±5V signal representing vertical eye movement, we move to the MCU.

The Naive Approach: Blocking ADC Reads A junior engineer might sample this analog signal using a standard blocking loop and a basic delay.

// NAIVE APPROACH: Blocking loop with no digital smoothing
const int analogPin = A0; 
int rawEOG = 0;

void setup() {
    Serial.begin(115200);
}

void loop() {
    // Blocking read - halts CPU, highly susceptible to timing jitter
    rawEOG = analogRead(analogPin); 
    
    // Attempting to sample at roughly 100Hz
    delay(10); 
    Serial.println(rawEOG);
}

Critique: This approach is brittle. The delay(10) guarantees jitter because the execution time of analogRead and Serial.println is not accounted for. This introduces phase noise into our signal, which will destroy the algorithms meant to detect “skew deviation” strokes. Furthermore, it applies no digital smoothing to catch the residual noise our hardware filter missed.

The Refined Solution: Timer-Driven Interrupts and Exponential Smoothing A robust, production-grade approach utilizes a hardware timer to guarantee a precise 100 Hz sampling rate, combined with an Exponential Moving Average (EMA) filter. The EMA acts as a digital low-pass filter with minimal memory footprint.

// REFINED APPROACH: Timer-driven sampling with an O(1) EMA Filter
#define ADC_PIN A0
#define EMA_ALPHA 0.2  // Smoothing factor (0.0 - 1.0). Lower = smoother.

volatile int currentADCValue = 0;
volatile float filteredEOG = 0.0;
volatile bool newDataReady = false;

// Hardware Timer Interrupt Setup (e.g., 100Hz / 10ms)
void setupTimerInterrupt() {
    // 1. Disable global interrupts
    // 2. Configure Timer registers for 100Hz frequency
    // 3. Enable Timer Compare Match Interrupt
    // 4. Re-enable global interrupts
}

// Interrupt Service Routine - Executes exactly every 10ms
ISR(TIMER1_COMPA_vect) {
    currentADCValue = analogRead(ADC_PIN);
    
    // Apply Exponential Moving Average (EMA) Digital Filter
    // Formula: S_t = a * Y_t + (1 - a) * S_{t-1}
    filteredEOG = (EMA_ALPHA * currentADCValue) + ((1.0 - EMA_ALPHA) * filteredEOG);
    
    newDataReady = true;
}

By shifting the sampling into an Interrupt Service Routine (ISR), our main loop is freed up to run the actual stroke-detection algorithm (computing the confidence intervals).

void loop() {
    if (newDataReady) {
        // Reset flag
        newDataReady = false;
        
        // Safely consume the filtered vertical eye position
        // Positive values = looking up, Negative values = looking down
        detectSkewDeviation(filteredEOG); 
    }
}

The Physics of Noise: CMRR and Skin Impedance Under the Microscope

Let’s look under the hood at why the first stage of our circuit requires an Instrumentation Amplifier (INA) rather than a standard Op-Amp, and how our digital code affects the stack.

🔵 Deep Dive: The Magic of CMRR The human body acts as a massive antenna, picking up 60Hz electromagnetic radiation from the wiring in your house. Because this noise hits both the “above eye” and “below eye” electrodes at the exact same time and phase, it is called a Common-Mode signal. A standard Op-Amp cannot cleanly subtract these signals due to internal resistor mismatches. An INA is explicitly constructed using a three-Op-Amp topology with laser-trimmed resistors. This results in a highly symmetrical circuit with a Common-Mode Rejection Ratio (CMRR) of over 100 dB. It mathematically subtracts the 60Hz noise (canceling it out to zero) while amplifying the differential signal (the actual eye movement) by a factor of 100.

🔵 Deep Dive: Big-O Complexity of Digital Smoothing In embedded systems, computing a standard Simple Moving Average (SMA) requires an array to store NN historical samples, iterating over them to find the mean. This costs O(N)O(N) CPU time and O(N)O(N) memory on the Heap or BSS. By utilizing the Exponential Moving Average (EMA) in our refined code, we achieved infinite impulse response smoothing using only O(1)O(1) time complexity and exactly one float of memory (filteredEOG), ensuring our ISR executes in mere microseconds.

Taming the Wild Analog: 60Hz Hum, Drift, and Patient Safety

When interfacing silicon with human biology, the edge cases are severe and potentially dangerous.

🔴 Danger: Baseline DC Drift Skin is a dynamic organ. As the patient sleeps, they sweat, and the electrochemical boundary between the Ag/AgCl gel electrode and the epidermis shifts. This changes the impedance, resulting in a creeping “DC offset.” Over an hour, a perfectly centered EOG signal might drift so high that it “rails” the Op-Amp, maxing it out at +9V and flatlining the data. Mitigation: A High-Pass Filter (HPF) must be inserted between the two amplifier stages. An RC network configured for a cutoff of ~0.05 Hz blocks the slow, drifting DC voltage entirely, forcing the signal to constantly re-center itself at 0V.

🔴 Danger: Micro-Shock Patient Safety Our project constraints specifically demand “No more than 10 µA flowing through patient.” While Op-Amps possess high input impedance, a catastrophic failure inside the silicon could theoretically dump the ±9V rail directly through the electrodes across the user’s face. Mitigation: Medical-grade designs must incorporate optical or magnetic Isolation Amplifiers (like the ISO122). This physically air-gaps the patient-side circuitry from the MCU-side circuitry, utilizing a modulated light beam to pass the signal. No physical wire connects the patient to the wall power source.

💡 Pro-Tip: Addressing Persistent 60Hz Hum Even with a high-CMRR INA, electrode impedance imbalances (e.g., the top electrode has more gel than the bottom) will convert some common-mode 60Hz noise into differential noise. Implementing a digital 60Hz “Notch Filter” algorithm inside the MCU will scrub this final persistent artifact before the data hits your stroke-detection logic.

Mastering Biopotential Acquisition for Real-Time Diagnostics

You now know how to design and build a high-fidelity Analog Front-End tailored explicitly for biopotential acquisition. By combining the precision of an Instrumentation Amplifier with aggressive hardware filtering and an O(1)O(1) real-time digital EMA filter, you have successfully bridged the gap between noisy human biology and pristine digital logic.

This circuit is the foundational bedrock of the entire stroke detection project. Without a clean, drifting-free, artifact-resistant vertical EOG signal, algorithmic efforts to identify “skew deviation” would be impossible. You have effectively given your microcontroller the ability to “see” the exact position of a sleeping patient’s eyes, unlocking the ability to detect the onset of secondary strokes with clinical accuracy.

We respect your privacy.

← View All Tutorials

Related Projects

    Ask me anything!