Let me elaborate on my previous post.
Let's assume there are two ignition advance tables which can only be changed by a reflash. Each of these tables is two-dimensional with an idential number of rows and columns, indexed by engine RPM and MAP. Each entry in the first table, which we'll call IGL, represents best ignition advance without knock for low octane gasoline. Each entry in the second table, which we'll call IGH, represents best ignition advance without knock for high octane gasoline. The ECU will never advance the ignition beyond IGH table values and never retard the advance below the IGL table values.
Now let's takes Shiv's Ignition Advance Multiplier (IAM), which he says ranges in value from 1 to 16, and form another scalar, called e, which ranges in value from 0 to 1:
e = (IAM - 1) / 15
e is used to form a "rough correction quantity," which we'll call AT, in the following way:
AT = IGL + e * (IGH - IGL)
In other words, AT is an interpolation between the low octane timing advance and the high octane timing advance. When e is zero (i.e. when IAM is one), the low octane timing is used and when e is one (i.e. when IAM is 16), then the high octane timing is used. Otherwise, a timing somewhere between the low and high octane timing is used.
There is also a table of learned "fine correction quantities," which we'll call AP, with the same dimensions as IGL and IGH, above.
Final learned ignition advance (IGTL) is:
IGTL = AT + AP
Assuming that IGTL is greater than IGL and less than IGH, it becomes the actual ignition advance.
The timing learning mode conditions (see my previous post) were selected to insure reliable knock detection - RPMs greater than 5000 means more engine noise and low engine load means low knock sensor output.
When timing learning mode is active, the ECU has a timer going. Every second or so the timer pops and the ECU checks to see whether there has been any knock during the interval, If not and if the IAM is not yet set to its maximum value, then it's incremented by 1. However, if, during the previous period, the number of knock events exceeds a threshold, then the IAM is decremented by a number, let's say 2. If the knock count is greater than zero but less than the threshold, then IAM remains unchanged. Whenever the IAM is changed, the fine correction table, AP, is zeroed out. If a knock event doesn't cause a change in IAM, then the appropriate fine correction table entry is adjusted.
P.S. So, If what I've written here is correct, it should take a full 8 seconds (not 5 seconds) for the Ignition Advance Multiplier (IAM) to change from its initial value of 8 to its max value of 16, assuming no knock.