PID control mapping

PID control mapping

A general guide on how to use the PID (Proportional Integral and Derivative) tables when mapping a closed loop control system on Haltech ECUs.

What is the Difference Between Open Loop and Closed Loop Control

Open Loop

An Open Loop system refers to a control method where there is no Target that needs to be reached. Instead the ECU will simply output a certain amount that the tuner has manually entered into the system.  A good and common example of this is with Boost Control. When the Open Loop Boost Control method is used the boost control output will only follow the amount of duty that the tuner has programmed. The ECU itself will not make any changes from this programmed amount.  If the tuners desired boost amount of not reached then further tuning is required.   

Closed Loop

A Closed Loop system refers to a control method where there is a Target that is trying to be achieved, and the ECU will make active changes to the output to try and reach this Target.  To do this job there is often a Base Duty table that guides the ECU into the amount of output required to be near to the Target. From there if the Target is not achieved the ECU can make changes to try and reach the Target.  How the ECU does this is controlled by ProportionalIntegral, and Derivative (PID) Gains.  The gains regulate the way the amount of Target Error is reduced.


What is Proportional Gain

Proportional Gain directly outputs a negative amount of correction for the positive amount of error present.  i.e. of the error is a certain mount the short term amount of correction will also be a certain fixed amount based on the amount of Proportional Gain that has been entered.  This more or less controls how reactive the system will be.   

How to Tune Proportional Gain

Proportion in general controls how reactive the closed loop control system is, and in turn the limits of how high you can go with Proportional depend greatly on the loop time of the particular closed loop control system. 

The total loop time is the time between the ECU making a change and its effects being measurable.  A good example is with O2 Control.  When we make a fuel correction with the O2 Control Short Term Trim there are delays in seeing this change.  The fuel output needs to be calculated, the injector pulse is sent out usually a crank rotation ahead of combustion, the combustion takes place along with expansion, the exhaust valve phase needs to occur to then send everything out past the valve, which then needs to travel to the sensor, the sensor needs to take its measurement which is passed back to the ECU to make fuel changes again.   If we set the Proportional too high the correction can take place much faster than the system can measure this change, so we see this as a high speed oscillation.   Set it too low and the system appears slow to react to change.

The usual method is to increase Proportional until you see a high speed oscillation, then back it off a little, all the while considering in the back of your mind how quickly the system is responding.


What is Integral Gain

Integral Gain is an accumulated error correction, or in other words the area under the curve. Maybe you can remember back to high school Mathematics (way way back for me) when you had to work out Integrals for the first time and you thought "why are we doing this, we will never use this crap in real life.", yet here we are doing exactly that.  The Integral Gain has the main purpose of adding more correction over time based on how much error is present.  The more time an error is present the more the correction will build up to try and fix the error.  The purpose of this is to fill in the error left over by the Proportional when the Proportional cannot be set high enough to solve the problem. 

How to Tune Integral Gain

Integral Gain is almost always needed at least in small amounts, but it can be a much better way of controlling systems with a slow loop time, such as with O2 Control mentioned above and Idle Control.  The faster the loop time, the less Integral is usually needed. The method used to dial in the Integral is to increase until you see a low speed oscillation then back it off a little.  Setting Integral too low often shows as a small amount of error that takes a large amount of time to be solved.

It is also the basis over which the Long term learning can do it's job.


What is Derivative Gain

Derivative Gain is used to control the rate of change of the target error.  It works by pushing the correction in the opposite direction when approaching the target to help prevent overshooting of the target.  It is more used with high speed loop times, such as with Cam Control or CO2 Boost Control.

How to Tune Derivative Gain

Derivative Gain should be used where a fast loop time is present and pushing Proportional higher causes overshooting and oscillation around the target.  Increasing Derivative can help control the rapid rate of change caused by the Proportional.  Going too high can cause the error to remain high with the Target never being reached.  It also can create a very rapid oscillation while the error is still present.  Increase derivative until this is seen then back off a little.   

For low speed loop times like with Idle and O2 Control, and some Boost control methods, the derivative is generally left at zero or very close to it. 

Long Term Learning

How Long Term Learning Works

The Long Term learning of the Haltech ECU range really helped define the ECU range in the market place.  Having the capability of Long Term learning the Boost Base Duty, Idle Base Duty, Quad Cam Base Duty, O2 Fuel Control, and Ignition Knock Control means there is less the tuner needs to get right to make the tuning spot on, and for things like Cam Control it helps the tuner have cams that operate at follow the Target swiftly without having to spend any time setting them up. 

How this is done is quite simple.  The ECU simply looks at the amount of Short Term Output being applied, and increments the Long Term in that direction. So if the Short Term is negative, the Long Term will move in a negative direction.  

Long Term Gain

The Long Term Gain pretty much acts as an Integral controller.  The longer a Short Term correction is present the more the Long Term will increment to try and replace the Short Term.  As with normal Integral control mentioned above, going too high can cause the Long Term to react too quickly which can cause oscillation as it fights the Short Term.  Gradually increase the gain until this is seen then back it off a little. 

    • Related Articles

    • Intake Cam Control

      Setting​s Intake Frequency - The frequency used by the Intake Cam Control solenoids. Using a low frequency can give an increased usable duty range but may cause the solenoid to rattle. Using a high frequency can limit the usable duty range. Intake ...
    • Exhaust Cam Control

      Settings Exhaust Frequency - The frequency used by the Exhaust Cam Control solenoids. Using a low frequency can give an increased usable duty range but may cause the solenoid to rattle. Using a high frequency can limit the usable duty range. Exhaust ...
    • Line Pressure Control

      Line Pressure Control Most automatic transmissions use pressurised transmission fluid to control which clutches and bands are engaged at any one time in order to select the desired gear. The fluid is typically pressurised by a pump which is turned by ...
    • They see me cruisin’ – How to set up Cruise Control on your Elite ECU

      Events like Drag Week in the USA and Drag Challenge here in Australia are becoming increasingly popular. Because these epic challenges involve taking street registered vehicles and driving them over vast distances for multiple days hopping from one ...
    • Idle Control

      Idle Control The Idle Control function allows your ECU to control the engine idle speed. There are multiple ways this is achieved with either Drive-By-Wire (DBW) control, a Bypass Air Control (BAC) solenoid with either two or 3 wire types, or via a ...