Upload
emon-alesando-khan
View
218
Download
0
Embed Size (px)
Citation preview
8/7/2019 Project6 Final Paper
1/25
ECHO CANCELLATION USING ADAPTIVE FILTERING
By
Thanis Tridhavee
And
Steve Vuco
T.A. Inseop Lee
5/4/99
Project Number 6
1
8/7/2019 Project6 Final Paper
2/25
ABSTRACT
This report discusses the implementation of the least mean-square (LMS)
algorithm on the Motorola 56K series digital signal processor in an echo cancellation
system. This scheme identifies the frequency response of the echo system so that the
adaptive filter generates an estimate of the echo and subtracts it from a distorted signal so
that the original signal can be recovered. The LMS algorithm design is used extensively
in communication networks to correct for the echoes created by line impedance
mismatches and is useful to compensate for the imperfection in telephony networks. This
paper shows how the LMS algorithm is useful to solve echo problems. This project is an
attempt by two undergraduate seniors to acquire more knowledge in digital signal
processing.
ii
2
8/7/2019 Project6 Final Paper
3/25
8/7/2019 Project6 Final Paper
4/25
iii
1.1 Introduction
A significant problem in communications is the generation of echoes. The echoes
arise for a number of reasons, with the primary reason being an impedance mismatch.
The impedance mismatch occurs when the two-wire network meets the four-wire
network, this interface is known as the hybrid. This impedance mismatch causes some of
the signal energy to be returned to the source as an echo [1]. This can be seen in Figure
1. (All figures/tables appear at the end of the report.)
The delays between primary and echo signals are directly related to the
transmission distance. For example, if a signal was sent to a satellite that redirected the
signal back to another location on earth, that signal would have a very large time delay
compared to a signal sent to a local switching station and back. Short delays (less than 50
ms) will not affect the quality of the signal as much as longer delays. Delays of this
length are not noticed by the receiver and therefore are not considered an annoyance.
However, these echoes may have an effect on data being transmitted through
transmission lines [3].
A sinusoid will be used as the input signal. The DSP board will create an echo of
the sinusoid and add the echo to the original sinusoidal signal, thus creating a distorted
version of the input signal. The DSP will then use LMS adaptive filtering to estimate the
echo, and remove the echo from the distorted signal creating a reconstructed signal. The
LMS algorithm seeks to minimize the excess mean-square error (MSE) between the echo
signal and the estimated echo. The excess MSE refers to the LMS algorithm fluctuations
about the adaptive filter coefficients after a large number of iterations [1].
4
8/7/2019 Project6 Final Paper
5/25
This project consists of designing and implementing an echo canceling system.
The Motorola 56K series DSP chip is used to simulate the echo creating system and to
implement the adaptive filtering system to cancel the echo in the distorted signal.
Initially, the adaptive filter coefficients are far from the ideal numbers. After several
iterations, the LMS algorithm will update these coefficients to converge on an optimal set
of coefficients. Simulations of the LMS algorithm will be done in MATLAB to get
approximate performance specifications before implementation. MSE plots that are called
learning curves in the DSP field will be attained. The learning curves as well as the
magnitude of the frequency response of the adaptive filter coefficients will be used to
determine the performance of our system. Convergence of the adaptive filter coefficients
and the similarity of the coefficient values in simulation and experimentation will also be
of vital significance.
1.2 Design Procedure
A sinusoid wave is be used as the test signal in simulation and in experiments.
The value in the LMS algorithm is an important value in determining the performance
of the echo cancellation. must be chosen between zero and twice the inverse total
input power.
0
8/7/2019 Project6 Final Paper
6/25
Nyquist Rate=2 *fBL (2)
There are many algorithms that could be used in echo cancellation or adaptive
filtering; most are variations of the least mean squared (LMS) algorithm. Some
variations include normalized LMS (NLMS) and the recursive least squares algorithm
(RLS). The LMS algorithm was chosen because it is the most commonly used algorithm
in echo cancellation and other adaptive filtering applications. LMS is the most
commonly used algorithm because it is powerful enough to accomplish the systems
requirements and is also relatively simple compared to the other algorithms. The LMS
algorithm uses relatively few calculations, which makes it suitable for the speeds of the
DSPs available today [1].
The LMS algorithm seeks to minimize the excess MSE between the echo and its
output. The communication network in Figure 1 has the necessary signals that are
required by the LMS algorithm. The adaptive LMS equation is given by:
w(n+1) = w(n)+ *e(n)*x(n) (3)
(a)w(n) are the present filter coefficients,
(b)w(n+1) are the future adaptive filter coefficients
(c) x(n) are the input values
(d) e(n) is the error value.
(e) is the step size
determines the convergence or divergence speed and precision of the adaptive
filter coefficients. If is large, the filter will converge fast, but could diverge if is
too large. When is large, the adaptation is quick, but there will be an increase in the
average excess MSE. This excess MSE may be undesirable result. If is small, the
6
8/7/2019 Project6 Final Paper
7/25
filter will converge slowly, which is equivalent to the algorithm having long memory,
an undesirable quality. Every application will have a different step size that needs to be
adjusted. When choosing a value, their needs to be balance between speed
convergence and the MSE. The value is decided through trial and error so that speed
at which the adaptive filter learns and the excess MSE is obtained within application
requirements. The values differs from simulation to real-time because of the inherit
differences between the systems.
The system equations used by the adaptive filter to determine the error and output
of the filter are listed below. The output of the adaptive filter is found though
convolution of the adaptive filter coefficients w(n) with the input signal x(n).
Output of adaptive filter:
y(n) = wT(k) * x(n-k) (4)
Sum over k from 0 to N-1 where N = 20
The error signal e(n) is created from the subtraction of the desired signal from the
output of the adaptive filter.
Error Signal:
e(n) = d(n) y(n) (5)
The output of the echo filter is
Desired Signal = Echo Signal:
d(n) = *x(n- ) (6)
is the delay in samples and is the attenuation constant.
Then d(n) is added to x(n) to create the distorted signal.
Echo and Input Signal:
7
8/7/2019 Project6 Final Paper
8/25
f(n) = d(n)+x(n) (7)
= *x(n- ) + x(n)
Next the reconstructed signal (n) is formed by
Reconstructed Signal:
(n) = f(n)-y(n) = d(n) +x(n) y(n) (8)
After many iterations, the echo signal resembles the output of the adaptive filter
and the reconstructed signal equals the input signal. The input signal is used as an input
to the adaptive filter so that the adaptive filters frequency response approximates the
echo systems frequency response. Then the error signal converges to approximately
zero. The error signal is feedback to the adaptive filter and is used as an input with the
original input signal to update the LMS adaptive filter.
The objective of the adaptive filter is to minimize the MSE between the echo and
estimated echo. Ideally, the error will go to zero after several iterations. The next set of
adaptive filter coefficients is equal to the previous set. This set of filter coefficients
approximates the transfer function that creates the echo. In this case, the hybrid of the
telephone network creates this transfer function that is model on the DSP. The adaptive
coefficients are an estimate of the echo systems transfer function. The hybrid system
may be nonlinear, but the echo system is modeled as linear time-invariant transfer
function with attenuation and time delay or phase shift. The cancellation is achieved by
making an estimate of the echo and subtracting it from the distorted signal. Our system
model is shown in Figure 2.
8
8/7/2019 Project6 Final Paper
9/25
1.3 Design Details
The system model of our echo cancellation device is shown in Figure 2. The
input signal will be a sinusoidal at 2.0 kHz because telephone voice frequency spectrum
exists from 0-4 kHz. The band limited frequency for telephone transmission is 4 kHz.
Thus the Nyquist rate is set to eight thousand samples per second.
The echo filter uses the original signal to create the echo signal. The transfer
function is chosen to be 0.5*z^-512. This signal will be delayed by 512 samples, which
corresponds to sixty-four milliseconds delay at our sampling rate with an attenuated of
fifty percent. This is a reasonable approximation for the system that creates the echo of
the input signal. Human hearing has been tested to be intolerable to echo delays of more
than 50 milliseconds [3].
The filter is chosen to be 20 taps. This number of taps was chosen for two
reasons. It was small enough to limit processing time, however it was large enough to
show good convergence in the MATLAB simulations. The adaptive filter taps at first are
initialized to the null vector. Figure 3 shows the frequency response of the MATLAB
simulation for the adaptive coefficients after several iterations with a value of 0.01. A
learning curve is shown in Figure 4 with the MSE approaching 40 dB after
approximately one hundred iterations. Figure 4 also shows the input signal added to the
echo signal and plotted under it is the reconstructed signal. After approximately a
hundred iterations, the original input signal is restored from the distorted signal. In
Figure 5 the adaptive filter coefficients are shown after several iterations when the
9
8/7/2019 Project6 Final Paper
10/25
8/7/2019 Project6 Final Paper
11/25
8/7/2019 Project6 Final Paper
12/25
cancellation works well if one can estimate the echo delays so that the values and
adaptive filter length are chosen properly.
12
8/7/2019 Project6 Final Paper
13/25
STANDARD HARDWARE
2.1 Introduction
A special circuit was assigned to those with primarily software based senior
design projects. The assignment was to design, assemble, and test a timer circuit. The
circuit was to meet certain constraints. The values that were constrained include the clock
voltage, the variance in frequency and high time pulse width. Two specification tests
were also assigned. The objective of these tests was to find the resistor values for given
variances of the chosen frequency and pulse width.
2.2 Design Procedure
The use of a linear 555 timer was chosen because it was suggested. The timer
circuit model is given in Figure 6. Variable resistors were used in the circuit to avoid
repeated assembly and disassembly of the circuit. The capacitors used were set to a
constant value.
The model shown in Figure 3 is the astable circuit model given by Motorola
analog IC device data. The external capacitor is charged through Ra and discharged
through Rb. Because of this, the duty cycle is controlled by the ratio of the two resistors.
The duty cycle was specified to be less than fifty percent high. The supply voltage does
not affect the charge and discharge times. The following equations were also given by
the Motorola source [6].
Charge time (time high):
th = 0.695 (Ra+Rb) C (9)
Discharge time (time low):
tl = 0.695 (Rb) C (10)
13
8/7/2019 Project6 Final Paper
14/25
Period:
T = th + tl = 0.695 (Ra+2Rb) C (11)
Frequency:
F = 1/T = 1.44/((Ra+Rb) C) (12)
Duty Cycle:
DC = Rb/(Ra+2Rb) (13)
Ra minimum:
Ra Vcc/.2 (14)
2.3 Design Details
The standard Ra and Rb values were found to meet the design constraints. The
following values were chosen:
Capacitor = 0.01 F
Frequency = 3700 Hz
Pulse width = 100 s
Duty Cycle = < 50%
The resistor values were found first. Those values were then used to determine
the theoretical values. The values derived from the equations did not match the values
obtained from the experiment. The values for both theoretical and experimental are given
in Table 1. Motorola literature suggested that a duty cycle of less than fifty percent would
be hard to achieve. The Ra value used here was chosen because Ra needs to be close to
Ra minimum. Choosing a small Ra insures that the duty cycle high is kept to a minimum
so that the duty cycle is less than fifty percent.
14
8/7/2019 Project6 Final Paper
15/25
The next step was to determine the values of the specification tests. Ra minimum
was found to be one hundred and sixteen ohms. Ra and Rb were then adjusted to meet
the frequency and pulse width requirements. With the requirements met, the tolerances
were then determined by varying Rb. The values for Ra were varied to test the
specifications again. These resistor tolerance values are listed in Table 2 for each
specification.
2.4 Conclusions
The task of the hardware portion was to determine the resistor values to set the
timer circuit. These goals were met and the values are listed in Table 2.
The theoretical values for the timer circuit did not match the experimental results
well. It appears that when the duty cycle is kept to less than 50%, the linear 555 timer
experiences nonlinear effects. Proper values of the variable resistors Ra and Rb were
determine by trial and error.
Varying the resistors had various effects on the period and pulse width of the
timer. As Rb increased by a small percentage, the pulse width and period increased. A
small decrease in Rb would decrease the period and pulse width. Increases and decreases
in Rb over a small range had very little effect on the duty cycle. In order to vary the
pulse width by five percent, the value for Ra had to be increased by a large percentage.
This also caused the duty cycle to go above the desired fifty percent level. Ra could not
meet the negative five percent pulse width specification because it would need a value
less than Ra minimum.
15
8/7/2019 Project6 Final Paper
16/25
COST ANAYLSIS
Labor
Salary hr = $20 per hr
2 Persons at 220 hrs each
Total Hrs = 220 x 2 = 440 hrs
Total Labor Cost = 20 x 440 x 2.5 = $22,000
Equipment
DSP Chip = $100
DSP EVAL Board = $120
MATLAB = Provide in lab
Circuit Components = $2.00
Total Equipment Cost = $222
Total Cost = $22,222
16
8/7/2019 Project6 Final Paper
17/25
Fig. 6. Clock timer circuit
Fig. 1. Schematic of telephone system
17
4
6
1 5
7
8
2
3555
Vcc
Ra
Rb
1. Ground2. Trigger3. Output4. Reset
5. Control Voltage6. Threshold7. Discharge8. Vcc
+
ECHO
CANCEL
ECHO
CANCEL
DELAY
4-wire 4-wire
2wirePHONE HYBRID
HYPH
DELAY
8/7/2019 Project6 Final Paper
18/25
Fig. 2. System model
18
Error
+
+
+
+
z^-
Adaptiv
Echo
Estimated
Recovere
Signa
Signa
8/7/2019 Project6 Final Paper
19/25
19
0 2 0 0 4 0 0 6 0 0 8 0 0 1 0 0 0 1 2 0 0 1 4 0 0 1 6 0 0- 1
- 0 . 5
0
0 . 5
1S i g n a l a n d E c h o
Am
p
T i m e s e c
0 2 0 0 4 0 0 6 0 0 8 0 0 1 0 0 0 1 2 0 0 1 4 0 0 1 6 0 0- 1
- 0 . 5
0
0 . 5
1O u t p u t o f S y s t e m
Am
p
T i m e s e c
4 0 0 6 0 0 8 0 0 1 0 0 0 1 2 0 0 1 4 0 0 1 6 0 01 0
- 1 5
1 0- 1 0
1 0- 5
1 00
L E A R N I N G C U R V E m u = . 0 1 e c h o d e l a y = 6 4 m s r u n s = 2
Estim
ated
M
SE,
dB
N u m b e r o f I t e r a t i o n s
F i g . 4 .
8/7/2019 Project6 Final Paper
20/25
20
0 2 4 6 8 10 12 14 16 18 20-0.06
-0.04
-0.02
0
0.02
0.04
0.06- - experimental (dashed) -- simulation (solid)
Fig. 5. Adaptive filter coefficients
8/7/2019 Project6 Final Paper
21/25
21
0 0 . 1 0 . 2 0 . 3 0 . 4 0 . 5 0 . 6 0 . 7 0 . 8 0 . 9 1- 1 0 0 0
- 8 0 0
- 6 0 0
- 4 0 0
- 2 0 0
0
2 0 0
N o r m a l iz e d f r e q u e n c y ( N y q u i s t = = 1 )
Phase
(degrees)
0 0 . 1 0 . 2 0 . 3 0 . 4 0 . 5 0 . 6 0 . 7 0 . 8 0 . 9 1- 7 0
- 6 0
- 5 0
- 4 0
- 3 0
- 2 0
- 1 0
0E x p e r i m e n t a l m u = . 3 t a p s = 2 0 d e l a y = 6 4 m s
N o r m a l iz e d f r e q u e n c y ( N y q u i s t = = 1 )
M
agnitude
Respon
se
(dB)
8/7/2019 Project6 Final Paper
22/25
22
0 0 . 1 0 . 2 0 . 3 0 . 4 0 . 5 0 . 6 0 . 7 0 . 8 0 . 9 1- 2 0 0
- 1 0 0
0
1 0 0
2 0 0
N o r m a l i z e d f r e q u e n c y ( N y q u i s t = = 1 )
Phase
(degr
ees)
0 0 . 1 0 . 2 0 . 3 0 . 4 0 . 5 0 . 6 0 . 7 0 . 8 0 . 9 1- 7 0
- 6 0
- 5 0
- 4 0
- 3 0
- 2 0
- 1 0
0
N o r m a l i z e d f r e q u e n c y ( N y q u i s t = = 1 )
M
agnitude
Response
(dB)
S i m u l a t i o n m u = . 0 1 t a p s = 2 0 d e l a y = 6 4 m s
8/7/2019 Project6 Final Paper
23/25
TABLE 1. COMPARISON OF THEORECTICAL AND EXPERIMENTAL VLAUES
Component Theory Experimental
Ra 146.2 146.2
Rb 6.45 k 6.45 kC .01 F 01 FF 11034 Hz 3700 Hz
th 45.87 s 100 stl 44.83 s 170 sT 90.7 s 270 s
Ra minimum 28.3 116.7
23
8/7/2019 Project6 Final Paper
24/25
8/7/2019 Project6 Final Paper
25/25
s=.4*sin(2*pi*freq*t);%Pure Signalx=noise+s;%input to adaptive filterecho_amp_per = .4; %Echo percent of signal%rand('state',sum(100*clock));%Reset Randome Generatorecho_time_delay = .064;echo_delay=echo_time_delay*samplerate;echo = echo_amp_per*[zeros(1,echo_delay) x(echo_delay+1:samples)];%LMSfor i=1:max_iterations;
y(i)=w*x(i:i+taps-1)';e(run,i)=echo(i)-y(i);%mule(i) = .5/(x(i:i+taps-1)*x(i:i+taps-1)'+ .01);w = w + 2*mule*e(run,i)*x(i:i+taps-1);
endend%%Mean Square Errormse=sum(e.^2,1)/max_run;b=x+echo;%Ouput of Systemout=b(1:length(y))-y;
subplot(3,1,1),plot(b);title('Signal and Echo');ylabel('Amp');xlabel('Time sec');subplot(3,1,2),plot(out);title('Output of System');ylabel('Amp');xlabel('Time sec');subplot(3,1,3),semilogy(mse);gridtitle('LEARNING CURVE mu=.01 echo delay=64ms runs=200');ylabel('Estimated MSE, dB');xlabel('Number of Iterations');%subplot(3,1,2),semilogy(iterations,e(1,:).^2);%grid%subplot(3,1,3),semilogy(iterations,e(2,:).^2);%grid