Note: Descriptions are shown in the official language in which they were submitted.
20~2600
ADAPTIVE BANDWIDTH MOVING AVERAGE FILTER
FIELD OF THE INVENTION
This invention relates to digital filters, and more
particularly, to an amplitude-averaging digital filter
which exhibits a rapid response to received input
values.
BACKGROUND OF THE INVENTION
Digital filters are well-known in the prior art. Such
filters may be configured on general purpose computers
such as shown at 10 in Fig. 1. Such a general purpose
computer comprises an arithmetic logic unit (ALU) 12
that includes a portion reserved for filter software
14 (that has been previously loaded therein).
An analog to digital (A/D) converter 16 receives an
analog signal input applied thereto via conductor 18.
After the signal input is converted to digital values,
those values are emplaced on bus 20 and from there
transported to either random access memory (RAM) 22 or
disk store 24. ALU 12, in combination with its filter
software may then operate on the received digital
values, either in real time or on a delayed basis.
The filtered signal is then reimpressed on bus 20 and
fed via input/output interface 26 to a receiving
device.
A/D converter 16 periodically samples analog signal
inputs appearing on conductor 18 and provides discrete
digital amplitude values thereof. The rate at which
2052600
A/D converter 16 provides signals onto bus 20 is
controlled by commands from ALU 12. The filter is
updated once per sample.
One of the better known amplitude filtering software
algorithms creates a filter function termed a "moving
average filter". In such a filter, each input sample
value is multiplied by a fraction hereinafter called
the "filter factor" and is then added to the
previously averaged reading values, multiplied by 1 -
the filter factor to produce a new av~rage value. The
operation of this filter is expressed as:
(1 X) (AVG)i_l + X(RDG)i (1)
where:
AVGi = ith averaged value
RDGi = ith reading value
x = filter factor (less than 1)
The response of such a moving average filter is shown
in Fig. 2. Waveform 30 occurs in response to a step
input 32 which traverses from voltage El to voltage
E2. Filter waveform 30 can be expressed as:
E(n) = (l-x)E(n-l) + xE2 (2)
Equation 2 is the result of the application of
equation 1 to the waveforms of Fig. 2, with n
representing the number of the particular voltage
sample provided to the filter.
2052600
Using the moving average filter technique, the
discrete signal amplitudes which result from the
operation of equation 2 are as follows:
E(O) = El
E(l) = (l-x)E(O) + xE2 = E2 ~ (E2-El)(l-X)2
E(2) = (l-x)E(l) + xE2 = E2 ~ (E2-El)(l-X)3
E(3) = (1-x)E(2) + xE2 = E2 ~ (E2-E1)(1-x)
E(n) = E2 ~ (E2-El)(l-x) (3)
The inverse of the filter factor x, hereinafter called
the "filter constant" is usually, but not limited to,
an integer power of 2 for software efficiency.
It can be seen from equation 3 that, given a
relatively modest filter constant, (e.g., 64 or 128),
the time for the filter's output to reach 95% of its
steady state value can require many readings - on the
order of hundreds. This creates an unwanted delay in
further processing of the filtered signal and is to be
avoided.
Accordingly, it is an object of this invention to
provide a moving average filter which reaches a steady
state value more rapidly than prior art filters.
It is another object of this invention to provide a
moving average filter which alters its bandwidth in
accordance with input signal characteristics.
20S2600
SUMMARY OF THE INVENTION
A software filter is described which operates a
computer to perform a moving average filter method.
The method comprises designating an initial filter
constant to control the filter response time;
maintaining a moving average signal value of signal
amplitude; finding a difference value between the
moving average signal value and each new signal sample
amplitude before the new signal sample amplitude is
included in the moving average signal value; updating
the moving average signal value by adding to it, at a
time of each new signal sample, a value calculated by
dividing the difference value found for a new signal
sample by the initial filter constant; and when a
sequential plurality of the found difference values
manifest an identical polarity, dividing the initial
filter constant by an integer factor to create a
reduced filter constant which reduces the filter
response time. When, by contrast, a found difference
value manifests a different polarity from an
immediately preceding found difference value, the
filter constant is multiplied by an integer factor to
increase the filter response time.
DESCRIPTION OF THE DRAWINGS
Fig. 1 is a high level block diagram of a computer for
performing filter operations on a signal input.
Fig. 2 shows a step input waveform and resulting
output values from a moving average filter operating
in accordance with the prior art.
2052600
s
Figs. 3a and 3b illustrate a high level flow diagram
of the operation of the filter of this invention.
Fig. 4 is a set of waveforms which illustrates the
response of a filter configured in accordance with
this invention in response to a step input function.
Fig. 5 is a ~et of waveforms which illustrates the
response of the filter of this invention in response
to a pulse input waveform.
DETAILED DESCRIPTION OF THE INVENTION
Referring back to Fig. 1, the method of this invention
requires that within ALU 12, two registers exist
which are operated during the operation of filter
software 14. The first such register is an equal
polarity counter 13 which has both count and reset
inputs. The second register filter constant register
15. The functions of these registers will be further
understood from the description below of the flow
diagram of Figs. 3a AND 3b.
As shown in Fig. 3a, initially an input is provided
which establishes the maximum filter constant NmaX
(e.g. 64 or 128) (box 50). Next, the current voltage
reading Rdgi is captured from A/D converter 16 (box
52).
The previous moving average value Avg i 1 is then
subtracted from Rdgi to obtain a difference value
DIFFi that is indicative of the difference of the
newest voltage reading from the previously accumulated
average voltage value (box 54). The value of DIFFi is
2052600
now tested to determine whether it is equal to 0 (box
56). If it is found not to be equal to 0, the Diffi
polarity is tested to determine whether it is equal to
the polarity of DIFFi 1 (decision box 58). More
specifically, it is determined whether the difference
voltage achieved between the newest voltage sample and
the previous average is of the same polarity as the
difference voltage derived for the immediately
preceding voltage sample.
If the difference voltages are found to be of the same
polarity, then equal polarity counter 13 in ALU 12 is
incremented by l (box 60), and the value of the
counter is tested (decision box 62) to determine
whether its count is equal to or greater than S. That
is, if there have been at least 5 or more equal
polarity findings in the DIFF values, then it is
assumed that the signal has changed in one direction
and that the filter response time should be reduced to
allow the moving average to reach the input value
faster. The value of 5 is somewhat arbitrary and will
depend, to some extent, on the expected character of
the incoming signal. As a result, (see box 64) the
filter constant register, which presently indicates a
count of Ni, has its value decreased by dividing its
count by an integer factor, preferably 2. Obviously,
the count of the filter constant register cannot be
decreased to less than a value of 1, so that is set in
as a minimum limit.
At this stage, the software calculates a new value for
Avgi by dividing the value of DIFFi by the new value
of Ni. The result of this division is then added to
Avgi 1 to obtain a new moving average value (box 66).
205Z60U
It is to be noted that by using the decreased value of
Ni as the divisor, a larger portion of DIFFi is added
to the previous moving average (Avgi 1) so that the
input value is reached more rapidly.
Returning to decision box 62, if the "equal polarity"
count is determined to be less than 5, then the filter
constant register value Ni is not decreased and the
moving average value calculation shown in box 66
continues, with the latest filter constant used as the
divisor.
Returning now to decision box 56, if the value of
DIFFi is found equal to 0, then the program
immediately moves to box 68 where the Ni value, as
evidenced by filter constant register 15, is increased
by an integer factor, preferably 2. Its value is
limited so that Ni does not exceed NmaX. The same
action occurs if it is found that the polarity of
DIFFi is not equal to the polarity of DIFFi 1 (box
58). Thus, in either case, it is assumed that there
is a change in polarity occurring, and that the moving
average is close to the input value and that the
filter response time should be increased to reduce the
noise amplitude. This is achieved by resetting equal
polarity counter 13 to O (box 70) and then using the
increased value of Ni in filter constant register 15
in the calculation indicated in box 66.
Thus, using this greater value for the filter
constant, the value of DIFFi/Ni is reduced and the
filter response time is greater until the equal
polarity count again evidences a count of either
-
2052600
greater than or equal to 5. At such point, the filter
constant is decreased by an integer factor.
Subsequent to each calculation of the moving average
value Avgi, the program returns to box 52 to capture
the new reading Rdgi+l etc. and the program proceeds.
Referring now to Figs. 4 and 5, ex~ples are shown
which compare the action of the adaptive bandwidth
control filter operating as shown in Figs. 3a and 3b
with the prior art moving average filter.
In Figs. 4 and 5 it is assumed that the maximum filter
constant NmaX is 128 and the reading rate is 2.S
readings per second (period z 400ms). Further, it is
assumed that a step function signal 100 (see Fig. 4)
is applied to the filter function. It can be seen
that the values of Avgi will be as follows for each of
specifically indicated reading number (as calculated
by the equation shown in box 70, Fig. 3b).
(Avg)l = 100 + 50/128 = 100.39
(Avg)2 = 100.39 + 49.61/128 = 100.78
(Avg)3 = 100.78 + 49.22/128 = 101.163
(Avg)4 = 101.163 + 48.837/128 = 101.55
(Avg)5 = lOl.S5 + 48.45/64 = 102.30
(Avg)6 = 102.30 + 47.70/32 = 103.79
(Avg)ll = 135.78 + 14.22/1 = 150
It can be seen that the total number of readings for
the adaptive bandwidth filter of this invention to
2052600
reach its 100% of steady state value is 11. The total
filtering time is then:
T = 11 = 4.4 second
# of reading/sec
To find the time required for a prior art moving
average filter to reach 95% of its steady state value,
equation 3 indicates the following:
2 E2 (E2 ~ E~ 1/128)n)
where: E2 = 150
El = 100
The solution of the above equation shows that n = 242
readings and the time required for the process is t -
97 seconds
As shown in Fig. 5, a pulse input 102, having a period
less than 400 milliseconds (less than period of read
rate) is applied to the filter with a given filter
constant of 64 (Nmax = 64). Using the filter
algorithm as shown in Figs. 3a and 3b, the individual
Avgi readings are as follows:
(Avg)l = 100 + 50/64 = 100.781
(Avg)2 = 100.78 + -.781/128 = 100.755
(Avg)12 = 100.222 + -.222/1 = 100
It can be seen that 12 readings are required for the
filter to reach 100% of its steady. state value and
2052600
that the time required for this process is 4.8
seconds.
Using the prior art moving average filter with filter
constant = 64 the number of readings required for the
filtered value to read 99.92% of the steady state
value is approximately 144 and the time required is 58
seconds.
It should be understood that the foregoing description
is only illustrative of the invention. Various
alternatives and modifications can be devised by those
skilled in the art without departing from the
invention. Accordingly, the present invention is
intended to embrace all such alternatives,
modifications and variances which fall within the
scope of the appended claims.