PID Control

GenBoard uses PID control for various solanoids (IAC, Boost Control, etc...) this page describes some strategies for tuning pid controllers as well as link to pages that provide some more insight about the subject

IAC tuning

First, we test the solenoid and engine's reaction (for the given setup and config) by forcing certain IAC duty. This happens with the mdi.. command (memorize as menu debug iac .. where .. is the 2 digit hexa number from 01 to FF. 00 is special, it enabled automatic control).

Using this cuts down to IAC tuning to about 1/10th.

This can happen from directly attached keyboard, serial TerminalProgram or MegaTune embedded terminal. Remember to issue Man to enter manual text-command mode, and bye to leave back to MegaTune mode so MegaTune can communicate. See GenBoard/MenuSystem. Maybe MegaTune is now capable to issue such commands from a simple (even non-hexadecimal) user-input into a field ?

The idea is to find out the

Reference position

Force IAC duty that maintains 200..400 RPM higher than your target. Set the reference position to this. The PID integral will operate in the negative region. That's why iac integral decrease limit is important to prevent stalling. iac integral increase limit can be (and sometimes need to be, to prevent oscillation) close to zero: the iac should only need to go above the reference position when AC compressor is ON, and the big fan at max RPM.

If the engine RPM does not consistently and monotonously (higher forced duty => higher RPM) react to forced IAD duty, you'll NOT be able to tune the PID so don't waste your time with it: go back check the wiring, config and IAC and anything related.

Also, if there is too much air leaking into the engine at mdi01 (minimal forced duty), resulting in higher than target RPM, the air-based IAC control is obviously not capable to reach the target (regulating power with ignadv or event skipping is still possible, but configuring those is NOT covered here).

Initially use PID I=0 and D=0 so only the P term of the PID has effect.

slope of the duty vs RPM => PID P term

Let's say

This means the slope is 30 steps (0x7E - 0x60 = 0x1E = 30; remember the mdi.. is in hexadecimal) for 400 RPM (1200-800).

For a higher valve, or smaller engine, this value is lower (less steps needed for same RPM change).

iac_kp (PID kp term) will be set proportional to this (TODO: calculate constant multiplier - assigned to Lezsak Gergely ;-).

In effect, with an error (error = current_RPM - target_RPM) '''of 400 RPM, the PID P term will command 15 steps. The PID I term will be responsible for the other 15 steps (30 required in the example).

PID I and D terms

Now, with the P term adjusted scientifically, you'll likely tune the I and D term with experimenting. This takes 1/10 of the time than with an unknown P value. If the RPM starts oscillating, some of the PID parameters is too high (often the D).

The iac integral decrease limit and iac integral increase limit must be higher than 0 to allow the PID I term to react. Since these terms will be finetuned after the I term, initially use guesstimate values such as 32 and 50 respectively.

iac integral decrease limit

If this is too low (such as 0), your engine will not be able to reach the target RPM (remember we set reference position to 200..400 RPM higher than target: it will not go much below that).

Unfortunately the iac integral decrease limit user-input is currently NOT expressed in RPM or IAC duty. MegaTune could do the conversion

Advanced section

Ignition advance based idle control

Initially disable this. At the very end, this can be used to smooth out a bit. We've seen racecars that maintained quite good idle with ignition advance based idle control (event skipping is also implemented now for much higher power-reduction capability, mostly useful for launch and ALS) but remember this is not as efficient as air-based, so apply proper airvalve for daily driven cars.

More info about pid controllers in general

Found this page today that has a great simulator program for MS Excel <its too bad they want $45 USD for it>

I found this picture was a great aid to understanding the principle behind Proportional (Gain)


The more you increase the gain the greater the scale of the reaction will be.

Some tuning strategies are shown here:

PID control of a home brewing plant with some nice general PID tuning and algorithm info:

See Also: PidController - a related and otherwise orphaned page.