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’re going to build a two-stage Analog Front-End (AFE) circuit and pair it with a digital filtering pipeline. The goal: capture the vertical voltage potential difference between electrodes placed above and below the eye, amplify it by a factor of 1000, and aggressively filter out noise. By the end, you’ll have a production-grade path for processing raw, noisy biopotentials into smooth vertical eye-tracking data without relying on any black-box external ICs.

What This Requires Before You Touch a Breadboard

You need to be comfortable with differential signaling and operational amplifiers — specifically gain, cutoff frequencies, and common-mode rejection ratio (CMRR). These aren’t optional background knowledge here; they’re the reason the circuit works at all.

For hardware, you’ll need:

  • An Instrumentation Amplifier (INA) — the AD620, INA114, or INA128 all work. A standard op-amp is insufficient for the first stage because of poor common-mode rejection.
  • General-purpose op-amps (TL072 or LM324) for the secondary active filter and gain stage.
  • A split dual power supply yielding +9V and -9V to power the op-amps. This allows the AC biopotential signal to swing above and below ground.
  • Any MCU with at least a 10-bit ADC and timer-based interrupt capability — an ATmega328P or STM32 both work.
  • Standard Ag/AgCl gel electrodes for low-impedance skin contact.

Filtering a Whisper Out of a Heavy Metal Concert

Detecting an EOG signal is 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. The circuit 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 differential signal between them. The second stage (the low-pass filter) cuts off high-frequency noise 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]

Setting the Gains and Cutoffs

EOG signals live between 0.1 Hz and 15 Hz. Anything above that is likely EMG from muscle movement or the 60Hz powerline noise. We configure the INA for a gain of 100 first.

For the 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. Then we design an active low-pass filter with a secondary op-amp, targeting a cutoff frequency (fcf_c) of 15 Hz: fc=12πRCf_c = \frac{1}{2\pi RC}. A 100 nF capacitor and 100 kΩ\Omega resistor hits this right on the mark.

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

Blocking ADC Reads vs. Timer-Driven Interrupts

The naive approach samples with a blocking loop:

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

void loop() {
    rawEOG = analogRead(analogPin); 
    delay(10);  // Attempting to sample at ~100Hz
    Serial.println(rawEOG);
}

This is brittle. The delay(10) doesn’t account for the execution time of analogRead and Serial.println, introducing phase noise that will corrupt algorithms trying to detect the subtle eye position shifts that signal skew deviation. There’s also no digital smoothing to catch the residual noise the hardware filter missed.

The better approach pushes sampling into a hardware timer interrupt and adds an Exponential Moving Average (EMA) filter:

// 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;

// 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;
}

void loop() {
    if (newDataReady) {
        newDataReady = false;
        detectSkewDeviation(filteredEOG); 
    }
}

By shifting sampling into an ISR, the main loop is freed up to run the stroke-detection algorithm. The EMA achieves infinite impulse response smoothing using O(1) time and exactly one float of memory — compared to a standard Simple Moving Average which requires storing N historical samples and iterating over them every update.

Why the INA Isn’t Optional: CMRR

The human body acts as a massive antenna, picking up 60Hz electromagnetic radiation from nearby wiring. Because this noise hits both the “above eye” and “below eye” electrodes at the same time and phase, it’s a common-mode signal. A standard op-amp can’t cleanly subtract these inputs because of internal resistor mismatches. An INA uses a three-op-amp topology with laser-trimmed resistors, producing a highly symmetrical circuit with a CMRR of over 100 dB. It mathematically cancels the 60Hz noise while amplifying the differential EOG signal by a factor of 100.

The Edge Cases That Can Ruin Your Data

Baseline DC drift. Skin is a dynamic organ. As a patient sleeps, they sweat, and the electrochemical boundary between the Ag/AgCl gel and the epidermis shifts. This changes impedance and causes a creeping DC offset — over an hour, a perfectly centered EOG signal might drift high enough to rail the op-amp at +9V and flatline the data. The fix is a high-pass filter between the two amplifier stages, configured for a cutoff of ~0.05 Hz, which blocks the slow-drifting DC component and forces the signal to constantly re-center at 0V.

Patient safety. Our project constraints require no more than 10 µA flowing through the patient. While op-amps have high input impedance, a catastrophic silicon failure could theoretically dump the ±9V rail directly through the electrodes across the user’s face. Medical-grade designs handle this with optical or magnetic isolation amplifiers (like the ISO122) that physically air-gap the patient-side circuitry from the MCU. No wire connects the patient to wall power — the signal crosses via modulated light.

Persistent 60Hz hum. Even with a high-CMRR INA, electrode impedance imbalances — one electrode having more gel than the other, for example — will convert some common-mode 60Hz noise into differential noise that the INA can’t reject. A digital 60Hz notch filter inside the MCU scrubs this final artifact before the signal hits the stroke-detection logic.

This circuit is the foundation of the entire stroke detection project. Without a clean, drift-free, artifact-resistant vertical EOG signal, detecting the subtle asymmetric eye position changes that indicate skew deviation would be impossible. Getting the analog front-end right is what makes the digital algorithms viable.

We respect your privacy.

← View All Tutorials

Related Projects

    Ask me anything!