PID Control
GenBoard uses PID control for various solanoids (IAC, Boost Control, etc...)
http://en.wikipedia.org/wiki/PID_controller
http://www.mae.ufl.edu/samm/Courses/EML4314cPID_gw.ppt#13
http://www.embedded.com/2000/0010/0010feat3.htm
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
- necessary duty to maintain target RPM (at given temp: remember this is temp dependent, there are 10 bins). These are called the reference positions. The algorithm will be allowed to deviate from the reference position with a certain amount, max deviation is (can be) different in the + and - direction, and is determined by
- the PID integral (I) term, and (effects both direction)
- iac integral decrease limit only effects - direction. Very handy! See below
- iac integral increase limit only effects + direction. This usually doesn't hurt even if too high
- slope of the duty vs RPM
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 and iac integral increase limit is not so interesting).
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
- mdi7E maintains RPM=1200
- mdi60 maintains RPM=800
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).
- Start from 0 and raise it until the controller can reach target RPM.
- If you set iac integral decrease limit too high, (especially if the PID D-term is also not tuned perfectly), the engine RPM will fall too low and this is disturbing: or might not recover at all (and stall).
Unfortunately the iac integral decrease limit user-input is currently NOT expressed in RPM or IAC duty. MegaTune could do the conversion
- for userinput in IAC-duty, it would be simple: iac_integral_limit_dec = const * iac_ilimit_dec_expressed_in_duty / iac_ki
- for userinput in RPM, the user would also have to enter the slope of the duty vs RPM, which is useful anyway, since from that, MegaTune could also calculate iac_kp (multiply with constant).
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.