Effectively, the DSM ECU uses two tables to calculate a “basic” ignition advance value. One table is used when the ECU believes fuel octane is at its highest value. The other table is used when the ECU believes fuel octane is at its lowest value. The ECU interpolates between these two extremes by adjusting its idea of fuel octane. This adjustment is done by monitoring knock retard (the amount of ignition delay added in by the ECU in response to knock sensor activity). More detonation means more knock retard and a lower “value” for the ECU's fuel octane rating.
Octane “update” only happens if the following are all true.
The airflow threshold is actually a table lookup indexed by RPM. So it varies slightly, but basically you can think of it as only active while running with a decent bit of airflow (not cruising or idling).
Once those conditions are met, the ECU will look at knock retard and adjust the long term octane scaling according to the following rules:
LTOctane has a scale of 0 to 255. A value of 0 means use the timing value retrieved from the “bad octane” table. A value of 255 means use the timing value retrieved from the “good octane” table. Values in between result in interpolation between these two extremes. At 128, for example, the timing value used will be the mid point between the “good” and “bad” octane table values.
The update is further gated by a timer that requires a certain amount of time to pass between updates. That time varies from 1G to 2G. For a 1G, it's a flat 0.4 seconds between updates. For a 2G, the ECU requires 1.2 seconds to pass after an increase in octane rating and 0.6 seconds after a decrease.