Back to articles
TuningMarch 8, 2026

EGO Correction PID Setup

How to configure closed-loop EGO (oxygen sensor) correction with PID tuning on Megasquirt 3 for optimal air-fuel ratio control.

ms3egopidwidebandafrtuning

What is EGO Correction?

EGO (Exhaust Gas Oxygen) correction is a closed-loop fuel control system. It reads the oxygen sensor (lambda/wideband) and automatically adjusts fuel delivery to match your target AFR (Air-Fuel Ratio).

Without EGO correction, your engine runs purely on the VE table — any errors in the table result in a rich or lean condition. With EGO correction enabled, the ECU constantly fine-tunes the fuel to hit the target.

Prerequisites

  • A wideband O2 sensor (e.g., Bosch LSU 4.9) with a wideband controller
  • The wideband controller connected to an analog input on the MS3
  • A properly calibrated wideband input in TunerStudio

Step 1: Configure the Wideband Input

  1. Go to Fuel → AFR/EGO Control → EGO Sensor Settings
  2. Select your wideband controller type (e.g., AEM, Innovate, PLX, or generic 0-5V)
  3. Set the correct input pin (typically AD6 or AD7)
  4. Verify the AFR reading matches your wideband gauge

Step 2: Set Up the AFR Target Table

  1. Go to Fuel → AFR/EGO Control → AFR Target Table
  2. This 2D table maps RPM × Load to target AFR
  3. Typical values:
    • Idle (700-1000 RPM): 14.7:1 (stoichiometric)
    • Cruise (1500-3000 RPM, low load): 14.7:1 to 15.0:1
    • Full load / WOT: 12.5:1 to 11.5:1 (rich for safety)
    • Deceleration: 16.0:1 or disable correction

Step 3: Configure PID Parameters

The PID controller determines how aggressively the ECU corrects fuel based on the error (difference between target and actual AFR).

Go to Fuel → AFR/EGO Control → EGO PID Settings:

Starting Point Values

| Parameter | Value | Description | |-----------|-------|-------------| | P (Proportional) | 25 | How hard to react to current error | | I (Integral) | 15 | How much to accumulate past errors | | D (Derivative) | 5 | How much to react to error rate of change | | Authority | ±15% | Maximum correction allowed | | Step size | 1% | Maximum change per control loop | | Update rate | 10 Hz | How often the PID runs |

Tuning the PID

  1. Start with P only — set I=0, D=0, P=25
  2. Watch the AFR gauge — if it oscillates around the target, reduce P
  3. Add I gradually — increase I to eliminate steady-state error (AFR offset)
  4. Add D if needed — only if AFR overshoots significantly during transitions
  5. Adjust Authority — increase to ±20% if correction hits the limit frequently

Common Issues

  • AFR oscillates rapidly → P is too high, reduce it
  • AFR is consistently off-target → I is too low, increase it
  • Slow response to throttle changes → increase update rate or P
  • Correction is maxed out at ±15% → your VE table needs work, don't just increase authority

Step 4: Enable EGO Correction

  1. Set EGO Correction to Enabled
  2. Set Active Above to your normal operating coolant temperature (e.g., 65°C / 150°F)
  3. Set Active Above RPM to 600 RPM (above cranking)
  4. Set Delay After Start to 30 seconds (let the sensor warm up)

Best Practices

  • Fix the VE table first — EGO correction is for fine-tuning, not for compensating a bad VE table
  • Log everything — record datalogs while tuning and review the EGO correction percentage
  • If correction is consistently >10% in a zone, adjust the VE table in that zone instead
  • Disable during WOT tuning — tune WOT enrichment manually, then re-enable EGO