747 ECM Lag Filter

Robert Rauscher
10/14/2000

Copyright 2000, Robert Rauscher, All Rights Reserved.

This is specific to the 747 ecm. However, the methods and madness
applies to many of the GM ecm's. (Use at your own risk, no guarantee
that any of this is correct.)


INTRO:

Many internal ecm variables are lag filtered. The action of a filter
is to slow down, or to eliminate glitches in a data stream. An important
aspect of engine controllers is the dynamic nature of the beast. Nothing
is static, everything is changing. A good portion of the ecm logic deals
with variables that are changing at set rates.

The ecm also uses the variables rates of change. It is important for the
ecm to know whether the throttle is being opened or closed, and at what
rate. A lag filtered variable can also be used to tell whether the O2
sensor reading is moving toward a leaner or richer afr.


THE HOWS of a LAG FILTER:

This is easy. When I first started with ecm's, I thought that a lag
filter was some extravagant mess of mathematics. It's not! It is very
simple to understand and calculate.

The ecm will read sensor inputs on a regular basis. On the '747, the O2
sensor is read eighty times a second. This value is then filtered with
two different filter coefficients. This yields three different O2 values.
The original sensor reading, a fast filtered value, and a slow filtered
value. The slow filtered value will lag the current O2 sensor reading
by the greatest margin.


In order to lag filter a value, three inputs are required:

1. The original (old) value.
2. The new (current) value.
3. The filter coefficient.

The output will be the new filtered value.

The idea is to move the new filtered value toward the current value.

The filter coefficient defines how closely the new filtered value follows
the current value. A filter coefficient of 100% will cause the new filtered
value to be the same as the current value. A filter coefficient of 0% will
cause the new filtered value to be the same as the old filtered value.

Filter coefficients between 0% and 100%, will cause the new filtered value
to be between the old filtered value and the current value. A filter
coefficient of 50% will cause the new filtered value to be halfway between
the old filtered value and the current value.

As time goes by, and the sensor is again read, the new filtered value
becomes the old filtered value. The lag filter is again applied to
calculate the new filtered value.


An interesting use of a lag filter is for acceleration enrichment. The tps
is filtered with a coefficient that is coolant dependent. A delta is
calculated by subtracting the filtered tps from the current tps. A positive
result shows an opening throttle. This tps delta is then used as a lookup
index into a table of pump shot values. A colder engine, using a slower
filter, will have a greater tps delta, with a resulting greater pump shot.


THE MATH of a LAG FILTER:


NewFilteredValue =

OldFilteredValue + (NewFilteredValue - OldFilteredValue) * FilterCoef


So, what is happening is this: Take a percentage of the difference between
the old filtered value and the new value, and add this to the old filtered
value. Hence, a small filter coefficient will cause a slow filter action.
And a large filter coefficient will cause a fast filter action.



EXAMPLES:


Old filtered value: 25
New value (to be filtered): 30
Filter coefficient: 80% (a fast filter)


Math: 25 + (30 - 25) * 80%

= 25 + (5) * 0.8
= 25 + 4
= 29

As you can see, the new filtered value followed the new
input value closely.


Lets do the same sensor values with a slow filter coefficient
of 20%.

Math: 25 + (30 - 25) * 20%

= 25 + (5) * 0.2
= 25 + 1
= 26

As shown, with a small filter coefficient, the new filtered
value does not follow the input as quickly. Given the same
input each time, the new filtered value will eventually
catch up. The math for the next pass would be:

= 26 + (30 - 26) * 20%

= 26 + (4) * 0.2
= 26 + .8
= 27 (rounded up)


FILTER COEFFICIENT:

To convert a computer held filter coefficient to a percentage is like
all other conversions: % = N * 100 / 256. Or, ecm bin value * 0.3906.
Note that a filter coefficient of zero (0) is invalid. This is due
to the method of filter implementation in the software.


NOTE:

Filtered values are typically held in two bytes, sixteen bits. This
is done to reduce rounding errors. If you look at the code, a store
double is used to save a new filtered value. However, when that value
is retrieved to be used (for other than to be filtered), only the high
order byte is used.


-eof-