PID control mapping

Technical Library › Functions and TuningUpdated Sep 2026

Boost, idle, cam and O2 control on a Haltech all lean on the same three numbers: proportional, integral and derivative gain. Once you understand what each one is doing, tuning any closed loop system gets a lot less mysterious. This is how we explain it to customers.

Open loop vs closed loop, in one minute

In open loop, the ECU outputs exactly what you put in the table and never second-guesses it. Open loop boost control is the easy example: you enter a duty, the solenoid gets that duty, and if boost comes in low, it's on you to change the table.

In closed loop, you give the ECU a target and it adjusts the output to reach it. Most Haltech closed loop functions still use a base duty table so the output starts near the right answer. The ECU then compares the measured value to the target, and the difference (the error) is fed through three gains, P, I and D, which decide how hard and how fast it corrects.

Tip

A closed loop system is only as good as its base table. If the base duty is close, the PID gains only need to clean up small errors, and the control stays smooth. If the base is way off, the gains have to do heavy lifting and you'll fight oscillation.

The idea you need first: loop time

Every closed loop system has a delay between the ECU changing its output and the sensor showing the result. We call that the loop time, and it decides almost everything about how aggressive your gains can be.

O2 fuel control is a good example of a slow loop. After the ECU trims fuel, the new pulse width has to be calculated, the injector fires (often about a crank revolution before that cylinder burns it), the mixture burns and expands, the exhaust valve opens, the gas travels down the pipe to the sensor, the sensor takes its reading and reports back. Only then can the ECU see what its correction did. Cam control, on the other hand, responds very quickly. Idle is another slow loop, while boost can land on either side depending on the control method.

Proportional gain: how hard it reacts right now

The P term produces a correction in direct proportion to the current error, pushing the opposite way. A bigger error gets a bigger correction, instantly, with no memory of what happened before. In practice, P sets how reactive the system feels.

The limit on P comes from loop time. If P is so high that the ECU keeps correcting before the sensor can show the result of the last correction, it overshoots, corrects back, overshoots again, and you see a fast oscillation around the target. Too little P and the system feels lazy.

How we tune it: raise P until you see a quick oscillation start, then back it off a little. While you do it, keep an eye on how quickly the system responds, since a slow loop will run out of P room early.

Integral gain: fixing the error that won't go away

The I term adds up error over time. Mathematically it's the area under the error curve, so yes, that high school calculus finally pays off. The longer an error sits there, the more correction the integral builds up.

Its main job is to finish what proportional can't. If P can't be turned up far enough to close the gap without oscillating, a small steady error is left behind, and the integral slowly grinds it out. Some integral is needed in almost every system. It's especially useful in slow loops like O2 control and idle control, where you can't lean on P. Fast loops usually need less.

How we tune it: increase I until a slow, rolling oscillation appears, then reduce it slightly. If I is too low, you'll see a small error that takes ages to disappear.

Derivative gain: the brakes

The D term looks at how fast the error is changing. As the value rushes toward the target, derivative pushes back against the correction to slow the approach and stop it sailing past. It's most useful in fast loops such as cam control or CO2 boost control, where a high P is needed and tends to overshoot.

How we tune it: add D when raising P causes overshoot and ringing around the target. Increase it until you see either a very rapid chatter while the error is still present, or the value stalling short of target, then back off a little. In slow loops, including idle, O2 control and many boost setups, D is usually left at zero or very close to it.

Quick reference

GainWhat it doesToo high looks likeToo low looks like
ProportionalImmediate correction sized to the current errorFast oscillation around targetSlow, sluggish response
IntegralBuilds correction the longer an error persistsSlow, wave-like oscillationSmall error that lingers for a long time
DerivativeResists fast changes to prevent overshootRapid chatter, or target never quite reachedOvershoot when P is high

Typical starting points by system

SystemLoop speedWhere the work usually happens
O2 fuel controlSlowMostly integral, derivative at or near zero
Idle controlSlowIntegral does a lot, derivative at or near zero
Boost controlDepends on the methodP and I, derivative usually zero or very low on slower setups
CO2 boost controlFastP with some D to stop overshoot
Cam controlFastHigh P with D to control it

A worked tuning session

Say you're setting up closed loop idle. First, get the base idle duty table close so the engine idles near target with the controller doing very little. Then:

  1. Set I and D to zero. Raise P in small steps, bumping the idle with a quick blip or an electrical load each time, until the RPM starts hunting quickly. Back P off a step or two.
  2. Bring I up gradually. You'll notice leftover error closes faster. Stop when you see a slow surge develop, then reduce it a touch.
  3. Leave D at zero. Idle is a slow loop, and derivative rarely helps here.
  4. Log target vs actual across cold start, warm idle, fans on and A/C on, and confirm it holds in all of them.

The same order (base table, then P, then I, then D only if needed) works for most systems. Always change one gain at a time and log every change.

Long term learning

Haltech ECUs can learn long term corrections for several closed loop systems, covering O2 fuel control, knock ignition control, and the base duty for idle, boost and quad cam control. It's a big part of why these ECUs are easy to get right: the ECU fills in small errors over time, and for cam control it helps the cams track their target quickly without much setup work.

The logic is simple. The ECU watches the short term correction and nudges the long term value in the same direction. If short term keeps pulling fuel, long term drifts negative until it has taken over that job and short term returns toward zero. Integral gain is the foundation this learning sits on.

Long term gain

Long term gain behaves a lot like an integral term: the longer a short term correction persists, the more long term moves to replace it. Set it too high and long term reacts so fast it starts fighting short term, producing oscillation. Increase it gradually until that appears, then back it off.

Troubleshooting closed loop control

SymptomUsually
Fast hunting around targetProportional too high for the loop time
Slow surging that takes seconds to settleIntegral too high
Small error that never quite goes awayIntegral too low, or the base table is off
Overshoots then comes backP high with no D in a fast loop, or base duty too high
Long term values keep swingingLong term gain too high

For system-specific settings, see the boost control user guide, tuning PID settings for cam control, idle control tuning and short and long term fuel trim.

PID FAQ

Should I always use all three gains?

No. Most systems need P and some I. Derivative is mainly for fast loops like cam control and CO2 boost. In slow loops it's usually zero.

Why does my closed loop control oscillate?

Fast oscillation usually means P is too high, and slow waves usually mean I is too high. Check that the base table is close first, because a bad base forces the gains to overcorrect.

Can long term learning replace tuning the base table?

It can tidy up small differences, but it isn't a substitute for a good base table. Get the base close, then let learning handle the drift.