Searching \ for '[PIC]: Suggest an approach to this filtering probl' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/math/filter.htm?key=filter
Search entire site for: 'Suggest an approach to this filtering probl'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: Suggest an approach to this filtering probl'
2001\07\09@160720 by adastra

flavicon
face
I need to measure the frequency (or period) of a sinewave signal in the
range of 1KHz to 10KHz, which is only present for about 0.5 second.

The trouble is that there is another signal present ALL of the time that is
in the same frequency range and of approximately the same amplitude.  It
seems I need to filter out the always-there signal so I can measure the
intermittent one.  The exact frequency of the interfering signal is not
known, and could be higher or lower than the signal of interest.  It
probably must be determined before the filtering can occur, but that part
shouldn't be too difficult since the interfering signal is there prior to
the appearance of the signal of interest.

I realize that if the signal-of-interest happens to be the same as the
interfering signal, I probably cannot detect it, but if the filter is narrow
enough, I can live with that.

I thought I could do this with a couple of analog PLLs ahead of the PIC, but
lately I am wondering if I need something more along the lines of a FFT
system, or maybe a DSP chip.  I would really like to do everything in a
16F877 if possible.

If anyone could point me in the right direction I would appreciate it very
much.  Any and all suggestions welcome.

Thanks, Foster

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email spam_OUTlistservTakeThisOuTspammitvma.mit.edu with SET PICList DIGEST in the body


2001\07\09@164823 by Dan Michaels

flavicon
face
Foster wrote:
>I need to measure the frequency (or period) of a sinewave signal in the
>range of 1KHz to 10KHz, which is only present for about 0.5 second.
>
>The trouble is that there is another signal present ALL of the time that is
>in the same frequency range and of approximately the same amplitude.  It
>seems I need to filter out the always-there signal so I can measure the
>intermittent one.  The exact frequency of the interfering signal is not
>known, and could be higher or lower than the signal of interest.  It
>probably must be determined before the filtering can occur, but that part
>shouldn't be too difficult since the interfering signal is there prior to
>the appearance of the signal of interest.
.........


Hi Foster, I have several ideas in mind - involving doing this in
software on a PIC. With an '877 running at 20 mhz, you can do A/D
sampling at 40 khz max. This would give you 4 samples/period with
your fastest signals, and should just about work.

1 - people have done FFTs on the PIC, but it looks like a lot of
   work, and you probably cannot get more than a few full calculations
   per second.

2 - since your interferring signal is always present, it looks like
   you could probably use an LMS adaptive filter, which would adapt
   to and reject the interference, but pass the target signal.

3 - if the signals are both sinewaves and the interfering signal is
   not doing any fancy phase jumps, it may be possible to simply
   lock onto the interfering signal with time sampling, and
   subtract it away from the composite target signal+interference
   to reveal the target signal alone.

With 20 mhz xtal and 40 khz A/D sampling, you have 200 intructions
to burn between samples, and you might be able to get away with doing
these kind of jobs.

However, since the PICs may not be fast enough to stay up with 40 khz
sampling rate, I was also thinking about the possibility of using a
Scenix, but those chips probably don't have enough RAM to do the job.

All in all, I think an adaptive filter, #2, might be something to
look at, short of going to a DSP chip.

best regards,
- dan michaels
http://www.oricomtech.com
========================

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email .....listservKILLspamspam@spam@mitvma.mit.edu with SET PICList DIGEST in the body


2001\07\09@170444 by Olin Lathrop

face picon face
> I need to measure the frequency (or period) of a sinewave signal in the
> range of 1KHz to 10KHz, which is only present for about 0.5 second.
>
> The trouble is that there is another signal present ALL of the time that
is
> in the same frequency range and of approximately the same amplitude.  It
> seems I need to filter out the always-there signal so I can measure the
> intermittent one.  The exact frequency of the interfering signal is not
> known, and could be higher or lower than the signal of interest.  It
> probably must be determined before the filtering can occur, but that part
> shouldn't be too difficult since the interfering signal is there prior to
> the appearance of the signal of interest.
>
> I thought I could do this with a couple of analog PLLs ahead of the PIC,
but
> lately I am wondering if I need something more along the lines of a FFT
> system, or maybe a DSP chip.  I would really like to do everything in a
> 16F877 if possible.

This is beyond a 16F877.  You probably want a DSP.  If you're very clever,
you might be able to squeak by with an 18 series PIC, but I wouldn't attempt
that unless you are pretty comfortable with digital signal processing
algorithms.  Unless this is a very high volume product where every cent of
parts cost counts, I would go for a DSP.  It's not going to cost that much
more and a decent 16 bit multiply/accumulate will probably be very handy.

As you mentioned, FFT is one possibility.  Another approach might be to do a
software PLL to find the noise signal, subtract it out, then look for the
occasional 500mS burst in the result.  Either way, there are some tricky
issues.  Go hire an expert unless you are very sure you're up to it.

How fast does the noise signal change frequency?  How often do the 500mS
burst of the signal to be measured occur?


********************************************************************
Olin Lathrop, embedded systems consultant in Littleton Massachusetts
(978) 742-9014, olinspamKILLspamembedinc.com, http://www.embedinc.com

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email .....listservKILLspamspam.....mitvma.mit.edu with SET PICList DIGEST in the body


2001\07\10@022123 by Scott Dattalo

face
flavicon
face
On Mon, 9 Jul 2001, adastra wrote:

{Quote hidden}

Foster,

You didn't explicitly say it, but I'm assuming the "noise" is a sine
wave too. If so here are a couple of suggestions:

1) Digital phase lock loop

With the DPLL, you can lock onto the "noise" sine wave. As long as the
DPLL is locked, there should be little or no correction applied.
Suppose the loop filter has a very long time constant. It may take a
long time to lock, but it will tend to also stay locked or even
continue to "run" even if the reference is removed.

Use the error signal in this DPLL as an indicator for when the "noise"
is being perturbed by your signal. Let this start a second DPLL that
has a much shorter time constant.

Now if you're really clever, you could use the first DPLL to cancel
out the "noise" sine wave!

2) autocorrelation filter.

Suppose your unknown signal is not present.  If so, then you should be
able to take a sample of the "noise" and see that it's correlated to
itself. The easiest way is perhaps to do something like:


f(t+i*dt) = samples at t, t+dt, t+2dt, ... t+Ndt

I = sum( f(t+i*dt)  *  f(t+i*dt + M*T)) / sum(f(t+i*dt))
Q = sum( f(t+i*dt)  *  f(t+i*dt + (M+1/4)*T)) / sum(f(t+i*dt))

Where
M is an integer
T is the period of the known noise (determined by another algorithm)
dt is the sampling interval
N is the number of samples
I is the "in phase" component
Q is the "out of phase"

In other words, a sample window of the signal is multiplied with a
copy of itself that has been shifted an integer # of cycles and the
sum of products is obtained. Similarly, a second window is shifted an
integer # plus an extra quarter to obtain the "quadrature" component.
(The stuff in the denominator of the two expressions normalizes the
result.)

Strictly speaking, this is NOT autocorrelation. Autocorrelation would
compute an infinite number of the above computations and not just two.
In other words, the window over which the signal slides varies
continuously and not just M*T. However, the autocorrelation of a sine
wave produces a series of delta functions spread M*T units apart. So
if you can zero in on one of the delta functions you'd tend to save a
little computation time!

Now, the goal, like in the DPLL, is to determine when the
autocorrelation peak is perturbed. Again, like above,  you could
control the rate at which the window is adjusted. So sudden changes in
the input would manifest them selves in reducing the autocorrelation.
This information can be used as a trigger to begin looking for the
other signal.

One of the problems with the autocorrelation is that it is incapable
of distinguishing harmonics. In other words, if the noise is a 5kHz
sine wave and the signal is a 1kHz sine wave, the autocorrelation
would not change.

Another problem is that the autocorrelation approach is
computationally expensive.

3) Filter banks

Since we're talking about computationally expensive algorithms, we
might as well mention filter banks. In the brute force case, you can
imagine having say 10 notch filters centered on 1kHz, 2kHz, etc. and
each having a bandwidth of around 2kHz. You could monitor the output
of each of these filters and then look for changes in signal strength
output. When a change is detected, then that's a clue to start looking
more closely in another area.

A brute-force filter bank is a DFT. It will take the time domain
signal and place the energies of each frequency into the appropriate
bins. However, unless this information is going to be viewed by a
human, I'd argue that it's a total waste of resources. For one reason,
it computes all of the frequency decomposition up front - even for
those frequency band for which it's not needed. Second, a DFT provides
no way to control the width of the frequency bins.

Having a set of discrete filters solves both problems mentioned with
the DFT. In addition, a set of discrete filters requires fewer RAM
resources. However, this approach is not computationally efficient.
The DFFT is of order N*ln(N) and the filter bank is M*N where M is
the number filter banks. A bank of just 8 filters is about
computationally inefficient as a 256 point DFFT. However, instead of
discrete filter banks it's possible to construct cascaded filters
constructed from "Quadrature Mirror Filters". For example, suppose you
split the frequency band into two parts: LOW and HIGH. The LOW portion
is passed through another filter that splits it again into low and
high portions. Similarly the HIGH portion is split in two. This will
result in the original signal being split into four pieces. Now the
trick is that since the filters are cascaded there's certain
information known. For example, when the LOW portion is generated,
there are no frequencies from the "HIGH" portion. Consequently the
samples fed to the filters cascaded off the LOW portion can be
"decimated", i.e. the sample stream can be sub-sampled.

(This whole subject is heavy DSP {and beyond the scope of a [PIC]:
tag} and discussed in "Advanced Digital Signal Processing - Theory and
Applications", Zelniker and Taylor, ISBN 0-8247-9145-2. In fact, a
problem quite similar to this is discussed in the section that
introduces Wavelet Transforms.)

The filter bank approach won't find your signal per se. However, it
can be a relatively quick way of determing that the signal is present.
I imagine this couple with a DPLL would be the best solution. If
you're stuck with the '877 then there's always the "1-bit" tone
decoder that can be used to put the signal into frequency bins:

http://www.dattalo.com/technical/theory/dtmf.html

Scott

--
http://www.piclist.com hint: To leave the PICList
EraseMEpiclist-unsubscribe-requestspam_OUTspamTakeThisOuTmitvma.mit.edu


2001\07\10@095743 by Douglas Butler

flavicon
face
If you could synchronize your sampling to the zero crossings of the
interfering signal it would disappear.  I think filtering in the time
domain will be tough.

Sherpa Doug

> {Original Message removed}

2001\07\10@141353 by Dal Wheeler

flavicon
face
Well, I suppose it sort of depends on how fast the constant signal changes,
but...  I wonder if one could sample the continuous signal and synthesize an
equivilant waveform; continue the synthesized waveform based on the measured
signal just prior to the window of interest.  Then you might just subtract
the synthesized signal from the other.  O'Course I havent tried anything
like that so I might just be talking out my backside...

-Dal
----- Original Message -----
From: Douglas Butler <dbutlerspamspam_OUTIMETRIX.COM>
To: <@spam@PICLISTKILLspamspamMITVMA.MIT.EDU>
Sent: Tuesday, July 10, 2001 7:50 AM
Subject: Re: [PIC]: Suggest an approach to this filtering problem?


> If you could synchronize your sampling to the zero crossings of the
> interfering signal it would disappear.  I think filtering in the time
> domain will be tough.
>
> Sherpa Doug
>
> > {Original Message removed}

2001\07\10@153934 by Dal Wheeler

flavicon
face
Along those lines of thought, since we're just interested in the
frequencies, why not stick a zero crossing detector and count pulses with
the pic against a timer to get a frequency.  Subtract the current pulse
block count from that of .5 seconds ago, ifany significant increase from
zero --there's your intermittant signal freq. Again, your continuous signal
can't change significantly fast or this'd frag.

!???
-Dal
----- Original Message -----
From: Dal Wheeler <KILLspamdwheelerKILLspamspaminsightek.com>
To: pic microcontroller discussion list <RemoveMEPICLISTTakeThisOuTspamMITVMA.MIT.EDU>
Sent: Tuesday, July 10, 2001 12:09 PM
Subject: Re: [PIC]: Suggest an approach to this filtering problem?


> Well, I suppose it sort of depends on how fast the constant signal
changes,
> but...  I wonder if one could sample the continuous signal and synthesize
an
> equivilant waveform; continue the synthesized waveform based on the
measured
{Quote hidden}

> > > {Original Message removed}

2001\07\11@122108 by adastra

flavicon
face
Thanks to all who have responded to this post.  I still don't know the final
answer, but you have given me some new ways to think about the problem, and
new ideas to research.

To answer the questions regarding things I left out:

       1)  The interfering signal is a dirty sine wave, and changes    slowly,
typically over a very limited range from its starting   frequency.

       2)  The signal of interest occurs <4 times per minute.

       3) This is a relatively low volume requirement, so parts cost is        not too
great of an issue.

       4) I perhaps should have mentioned that there is also present   random
noise, but at a considerably lower amplitude than the other     2 signals.

       5) Finally, the system must also work in the rare case where there      is no
interfering signal.

Thanks again for your input.

       Foster

=======================================================================
ORIGINAL POST FOLLOWS:
=======================================================================
I need to measure the frequency (or period) of a sinewave signal in the
range of 1KHz to 10KHz, which is only present for about 0.5 second.

The trouble is that there is another signal present ALL of the time that is
in the same frequency range and of approximately the same amplitude.  It
seems I need to filter out the always-there signal so I can measure the
intermittent one.  The exact frequency of the interfering signal is not
known, and could be higher or lower than the signal of interest.  It
probably must be determined before the filtering can occur, but that part
shouldn't be too difficult since the interfering signal is there prior to
the appearance of the signal of interest.

I realize that if the signal-of-interest happens to be the same as the
interfering signal, I probably cannot detect it, but if the filter is narrow
enough, I can live with that.

I thought I could do this with a couple of analog PLLs ahead of the PIC, but
lately I am wondering if I need something more along the lines of a FFT
system, or maybe a DSP chip.  I would really like to do everything in a
16F877 if possible.

If anyone could point me in the right direction I would appreciate it very
much.  Any and all suggestions welcome.

Thanks, Foster

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


More... (looser matching)
- Last day of these posts
- In 2001 , 2002 only
- Today
- New search...