"Zach R." <
[email protected]> wrote in message
news:
[email protected]...
>
> "Fred Marshall" <fmarshallx@remove_the_x.acm.org> wrote in message
> news:
[email protected].. .
> >
> > "Zach R." <
[email protected]> wrote in message
> > news:
[email protected]...
> > > Hi,
> > > The sample rate is 7040 Hz (the lowest that my ADC will go). As
far
> > as
> > > the order goes, I would like it to be longer but the program takes too
> > long
> > > to run when I use a larger order (such as 32). Should I make a point
to
> > get
> > > a higher order? How high?
> > >
> > > Thanks again,
> > > Zach
> > >
> > >
> > > "Fred Marshall" <fmarshallx@remove_the_x.acm.org> wrote in message
> > > news:
[email protected].. .
> > > >
> > > > "Zach R." <
[email protected]> wrote in message
> > > > news:
[email protected]...
> > > > > Hi,
> > > > > I have implemented a simple LMS algorithm w/ a 10th order
> filter.
> > > My
> > > > > goal is to completely cancel my reference signal. I can get it to
> > work
> > > > with
> > > > > a sine wave at about 75 Hz. When I try to cancel a 150 Hz signal
> all
> > I
> > > > get
> > > > > is an unstable response. Ultimately I would like to be able to do
a
> > > > decent
> > > > > job of cancelling a voice signal.
> > > > > My main question is: Is it even possible for a LMS algorithm
to
> > > cancel
> > > > a
> > > > > quickly changing signal such as voice or is it limited only to
> > > relatively
> > > > > simple signals?
> > > > >
> > > > > Another related question is: To increase stability would
> bringing
> > > the
> > > > > filter order down work?
> > > >
> > > > You need to provide more information. What is the sample rate?
That
> > will
> > > > determine the temporal length of the filter and other things.
> > > >
> > > > A length 10 filter is pretty short!
> > > >
> > > > Fred
> >
> > Zach,
> >
> > (As a matter of etiquette, most people don't "top post", i.e. replies go
> at
> > the bottom)
> >
> > I can provide no real advice about why your initial experiment would be
OK
> > at 75Hz and not at 150Hz - that issue raises all sorts of questions
about
> > actual signal structure, the algorithm being used, the block diagram,
bugs
> > in the code, etc. I also wonder if the implementation is
> under-constrained
> > by only trying to cancel a single sinusoid? It seems to be an
> > overdetermined situation - that is, there are lots of filters that
happen
> to
> > have amplitude and phase fixed at a single frequency. You might inject
> some
> > noise into the input of the filter and see what happens.
> >
> > It's probably best to analyze your way into the answer about length.
> >
> > First, let me say that I have assumed that you're using a FIR filter
> > structure of length 10. So, all of these comments apply to a FIR
filter.
> > If you have an IIR LMS filter, which I'm not familiar with, then you
might
> > get better resolution / change with frequency. That said:
> >
> > With a sample rate of 7040Hz and a filter of length 10, the temporal
> length
> > of the impulse response of the filter is (1/7040)*10 = 1.42
milliseconds.
> > The reciprocal of the temporal length is a good estimate of the
frequency
> > resolution that is possible. Or, if you like, the minimum width of a
> > transition band from passband to stopband or from stopband to passband.
> > So, a length 10 filter at this sample rate can change value
substantially
> in
> > a frequency span of 1/0.00142 = 704Hz.
> > Assuming that the filter has a dc response of "x" and the next response
> > value you want is "y", then you will substantially achieve "y" at around
> > 700Hz.
> >
> > Since you're trying to cancel 75Hz or 150Hz, I assume you're trying to
> make
> > a bandpass filter at one of those frequencies so you can add or subtract
> the
> > filter output from the "main channel" and, thus, cancel the specified
> > sinusoid.
> >
> > With a length 10 filter, about the best you can hope for is to adjust
> > amplitude and phase at exactly 75Hz or at exactly 150Hz and cancel that
> one
> > frequency.
> > Because 75 and 150 are close to zero compared to 700Hz, there won't be
> much
> > attenuation at 0Hz and there will only be substantial attenuation at
700Hz
> > and up to 3520Hz, which is the fs/2 frequency limit.
> > This means that the filter will pass energy over a few hundred Hz in
order
> > to cancel at 75Hz or 150Hz. Energy at other frequencies below 700Hz
will
> be
> > of "arbitrary" phase and substantial amplitude relative to what you
want -
> b
> > ecause there's really no control over them with such a short filter.
> >
> > If the input were a sum of a 75Hz sinusoid and a 150Hz sinusoid and you
> > wanted to cancel one but not both, and you wanted to not enhance
anything,
> > then you would need a filter that would be able to transition from pass
> band
> > to stop band in (150-75) = 75Hz.
> > To get 75Hz resolution, you need 1/75 = 13 milliseconds of filter length
> > which is 13/1.42 = 9.15 times longer than the length 10 filter or length
> 92
> > or so.
> > (Again, these are just arm-waving numbers - I'm not trying to be exact
and
> > could be off by a factor of 2)
> > You could use one of the many filter design programs to try this to see
> what
> > happens.
> >
> > All the adaptive algorithm can do is to move things around - the
> fundamental
> > relationship between temporal length and frequency resolution can't be
> > overcome in general.
> >
> > One should also suggest another aspect of this:
> >
> > The assumption is that there is substantial time delay between the input
> and
> > the output - in some sense the filter inserts a delay itself. You might
> > consider the following as an alternate method if the delay is short:
> >
> > 1) have a broadband amplifier/attenuator instead of a filter that is
> > followed by a variable delay.
> >
> > 2) Adjust the amplitude so cancellation can occur.
> >
> > 3) Adjust the delay so that cancellation does occur.
> >
> > I don't know what your block diagram really is. So, the delay here may
> have
> > to be in the "main channel" instead of in the cancellation channel for
> this
> > to work. Maybe you can do that and maybe you can't. The idea is to
> simply
> > match up the two channels in time and in amplitude for perfect
> cancellation.
> >
> > Another way to look at this is it's just an adaptive filter with all
> > coefficients zero except one. .... but it does require that the delays
can
> > be matched. If this can work, it can cancel noiselike signals as well
as
> > sinusoids.
> >
> > This is all a prelude to your real objective which is to cancel speech.
> > That implies a couple of issues:
> >
> > 1) Speech has noiselike components. A typical adaptive filter will
shut
> > off at frequencies where there's noise (unless there is temporal
matching
> > and, thus, correlated noise).
> >
> > 2) Speech moves all over the place in frequency and I don't think you
can
> > guarantee a phase relationship between frequencies that will remain.
> > So, the adaptive filter would have to adapt very quickly in order to
> adjust
> > for the new signal.
> > Also, the adaptive filter would have to have pretty fine resolution - be
a
> > long filter.
> >
> > I don't know that this can work. But then, I don't understand the block
> > diagram of what you're needing / wanting to implement.
> >
> > Here's the block diagram I've had in mind in the discussion above:
> >
> >
> > .---------<----------.
> > | |
> > | |
> > v ^
> > input ----.---->--------[adaptive filter]---->(+)----+---->output
> > | ^
> > | |
> > | |
> > '------->------------------->--------'
> > "main channel"
> >
> > Fred
> >
> >
> >
> >
>
> Fred,
> Thanks for the information it has definitely helped me in the
> understanding of the LMS. As a clarification, are you saying that I will
> most likely be able to see attenuation at frequencies above 704 Hz and
below
> fs/2 Hz? By any means I'll try some of those frequencies out (as sin
waves)
> and see what I get.
> I guess what my main goal should be is to extend this filter length.
> From what you have written it seems that having a longer filter definitely
> makes life easier. Thanks again,
> Zach
Zach,
A qualified yes. What I was trying to convey was this:
A length 10 filter with sample rate of 7040kHz will be *capable* of being
designed with this response. It all depends on the filter coefficients /
design that you evaluate. So,if your particular algorithm converges to a
filter like the one you describe above, then it will have the attenuation
you describe - by definition really.
Remember, I said these are arm-waving rules of thumb!
If you go to:
http://www.nauticom.net/www/jdtaft/fir.htm
you can design lowpass filters of length 10.
Here frequency "0.5" corresponds to your 3520kHz or fs/2
So 704Hz would be 0.1.
If you design a lowpass with cutoff at 0.1, the attenuation will be about
what the filter is capable of doing. If you gradually reduce the bandwidth
in steps of .01, you will see the attenuation get worse.
If you design a bandpass with center frequency of 0.25, the attenuation will
also be about what the filter is capable of doing. It will have 3dB down
points at roughly 0.2 and 0.3 which is 0.1 - the "resolution" or transition
width that a length 10 filter will provide.
As the bandwidth for a bandpass approaches 0.2 or as the band limit for a
lowpass approaches 0.1, then the attenuation will become "reasonable" - more
like 15dB. For bandwidth specifications less than this the attenuation will
be not as good.
All an adaptive filter can do is get close to these same responses -
depending on what you give it to work with and the algorithm you're using.
The adaptive filter can't do better in absolute terms. However, this point
confuses some folks. The adaptive filter *can* do better than a
specifically-designed filter *at any moment* because it does adapt - whereas
a hard-designed filter only does one thing.
Knowing what the hard-designed filters can do give you insight into what an
adaptive filter can also do in a stylized "best case" context.
I hope this helps.
Fred