Searching \ for 'filtering' in subject line. ()
Help us get a faster server
FAQ page: massmind.org/techref/logic/dsps.htm?key=filter
Search entire site for: 'filtering'.

No exact or substring matches. trying for part
'Digital Filtering'
1996\10\28@115248 by

I need to build a digital Low Pass filter (IIR or FIR). For "easy"
implementation I need integer or long integer coeficients. Does anyone
know a website with tutorials?

Thanks!
Cabral.

'Simplest filtering formula to high-pass filter _WA'
1997\03\20@001404 by
Good Morning/Day/Evening All !

I hear there are some simplest equation that
may be used as low-pass and high-pass filters.

The low pass filter formula is  Y{n-1} = ( Sum[i=0..n-1] X{i} ) / n ;
i.e. average value from some one period.

Did anyone know similar formula to high-pass filter ?

WBR Dmitry.

Of course, you can derivate the signal: Y(n)=(X(n)-X(n-1))/d where d is
the "time distance" between the samples. You can take n - (n-1), thus 1.

'Help needed with digital filtering.'
1998\01\16@054447 by
Hi Listers,

My project uses a PIC12C509 to monitor sensors and then outputs various
simultaneous tones.  The tones are recorded on audio tape using a compact
cassette recorder.
When the recording is finished, I want to take the recorder to a PC equipped
with a sound card and create a .WAV file from it. (or similar?)
I then need to analyse the WAV file to extract the tones and  the times at
which they occur. I need to know with some precision the time interval
between changes of any two tones.  I  imagine that I need to run various
software filters on the WAV file to do it.  Can anyone tell me the
principles of software filtering or point me to web sites that may help? I
also need to know  about the file format of a WAV file. Can anyone help

Best Regards,
Gerry Cox

1998\01\16@171826 by
> My project uses a PIC12C509 to monitor sensors and then outputs various
> simultaneous tones.  The tones are recorded on audio tape using a compact
> cassette recorder.

You may be able to save yourself some trouble if you record DTMF tones (if
that is enough) and then play it back through a DTMF decoder. You may be
able to find something on the web that will decode DTMF tones directly from
a .WAV file.

> Can anyone tell me the
> principles of software filtering or point me to web sites that may help?
I
> also need to know  about the file format of a WAV file. Can anyone help

For .WAV files; If you want lots of words, look for "Multimedia Programming
Interface and Data Specifications 1.0" by IBM and Microsoft. I think I got
it from Microsofts web site. If you want it in a simpler form, try
http://www.lightlink.com/tjweber/StripWav/Canon.html. It is a pretty simple
file format.

For learning DSP (now you're in the deep end), try
http://innet.com/~condor/wghome.html as a starting point and follow a few

Steve.

======================================================
Very funny Scotty.  Now beam down my clothes.
======================================================
Steve Baldwin                Electronic Product Design
TLA Microsystems Ltd         Microcontroller Specialists
PO Box 15-680                email: stevebkcbbs.gen.nz
New Lynn, Auckland           ph  +64 9 820-2221
New Zealand                  fax +64 9 820-1929
======================================================
Sean and Listers,

Thanks for the advice and file on WAV formats.
As to the simultaneous tones,  I am trying  to record the state of various
sensors onto audio tape. The sensors give a 1 bit digital output and I need
to extract rate information from them. e.g. one of the sensors will pulse
high  for 10mS at a repetition rate of say 0 .5Hz to 100Hz, representing a
shaft rotating at 30RPM to 6000RPM.
I intended to record on tape, a tone representing the high state and another
tone for the low state. For the next shaft I would do the same with a
different pair of tones.
The tape would be replayed and an accurate  reconstruction of the rates of
acceleration and velocity of the shafts must be obtained. This will be used
to determine performance and reasons for failure  etc;

Perhaps there is a better way? I will have a look at the possibilities of
PPM modulation though.

Any Ideas are welcome.

Best Regards,
Gerry

----------
From: Sean Breheny
To: GERRY COX
Subject: Re: Help needed with digital filtering.
Date: 18 January 1998 00:15

At 10:20 AM 1/16/98 -0000, you wrote:
>Hi Listers,
>
>snip........................................
>I have attached a file which explains most of what you need to know about
>WAV file formats.
>I am just curious, why do the tones need to be simultaneous?
>
>snip........................................
>
>The basic idea behind PPM is
this:>>snip........................................
>
>The great thing abt. PPM is that it is easy to sync to, easy to decode by
>computer means, relatively easy to code, and allows multiplexing without
>messy multiple subcarriers/tones, etc.
>Good Luck,
>Sean
On Tue, 20 Jan 1998 12:21:10 -0000 GERRY COX <gcoxDEK.COM> writes:
>The tape would be replayed and an accurate  reconstruction of the
>rates of
>acceleration and velocity of the shafts must be obtained.

Audio tape recorders don't preserve frequency and time very well,
especially recording on one machine and playing back on another.

>Perhaps there is a better way? I will have a look at the possibilities
>of
>PPM modulation though.

I think it would be best to record a digital code of the number of pulses
received on each input in a predefined interval of time controlled by the
recorder.  For example, the PIC would count for 0.1 second and record the
number ( 0 to 10) for each channel.  Using 6 bits to store the number of
pulses would take 60 bps for each channel, plus some overhead bits to
keep in sync and check for errors.

Even if the tape speed varies, exact rates and times could be recovered,
to the degree of accuracy of the clock of the PIC in the recorder.  Use
one of the modem standards and async data, and a standard PC modem could
be used to decode.  Some PC modems claim to support Bell 202 but details
are kind of uncertain.  If 300 bps is enough, use Bell 103.

'[OT] Thank you! - Eudora and Agent filtering'
1998\03\20@155644 by
At 13:23 20/03/98 +0000, you wrote:
>I wearily note that Web-browser/e-mailer software writers gladly spend time
>sorting out basic details. If they really want to impress, I'd like to see
> useful improvements like:
>
>* Detect and bounce binary attachments.
>* Binary attachments not copied when you press the "reply to" button
>* Detect and bounce messages from people trying to unsubscribe
>        by mailing to the PIClist instead of the list server.
>
>* Multi-priority stream and packet service channels.

Eudora (maybe Pro version only) gives good filtering - I can set it to
limit messages to any size, usually I leave it at 4kb. Later, when only the
first 4kb has been downloaded I can decide whether I want the lot or not.
it all to see what it was - it then stitched all the individual parts back
together automatically and created the zip file.

Agent (which I only use for Usenet) has good filtering too in it's email
functionality I believe.

Regards

WWW WW WWW   White Horse Design
WWWWWWWWWW   +44-385-970009 (SMS), +44-118-962-8913/4
WWWW  WWWW   whdzetnet.co.uk
WWWW  WWWW   http://www.users.zetnet.co.uk/whd
---
Developers of GPS satellite-based tracking systems

'A newbie quesiton: What«s EMI filtering'
1998\07\12@230932 by
Hi to everyone:

I«ve read somthing like: "EMI Filtering..."

What«s EMI ?

Other things that I«ve read is: "Regular E-I and toroidal transformer.
.."

So, What«s E-I ?
What«s toroidal ?

If somebody Can help me, thanks.

-----Original Message-----
From: Ricardo Ponte G <rniniverCANTV.NET>
To: PICLISTMITVMA.MIT.EDU <PICLISTMITVMA.MIT.EDU>
Date: Sunday, July 12, 1998 10:15 PM
Subject: A newbie quesiton: What4s EMI filtering

Hi to everyone:

I4ve read somthing like: "EMI Filtering..."

What4s EMI ?

Electro-Magnetic Interference.  AKA Noise, Hash.
by other systems.

Other things that I4ve read is: "Regular E-I and toroidal
transformer..."

So, What4s E-I ?

One part of the core looks like an "E" and the other part looks like an "I"
The windings are wound on a bobbin, slipped over the "middle finger" of
the E, then the I is glued on top.  In iron xfmrs, the E and I laminates are
stacked alternately.  Take apart an old 6V power transformer and see for
yourself.

What4s toroidal ?

Picture a ferrite donut (no strawberry filling!) with wires wrapped around
it.
It's harder to wind than the E-I type, but has less losses because it's all
one piece.

If somebody Can help me, thanks.

Since getting my temperature controller to work, I have been playing around
with various filtering techniques to remove noise from my ADC output (AN512)

Lawrence kindly sent me the code to implement a median filter, which most
people seemed to think was the one to use.  Certainly, it rejects silly
values very well, however it doesn't seem to remove the high frequency noise
that a mean filter does.  The high frequency noise seems to be my biggest
headache at the minute, although mostly stemming from the use of an emulator
I think.

What I need is a way of combining the advantages of these two filters, but I
don't have a lot of RAM left so minimal overhead is needed.  Unfortunately
I'm having to deal with 16 bit values.  I currently use a circular buffer
with 8 entries and just use mean filtering.

Does anyone have any cunning ideas?

My only idea so far is to do a conversion and check that the conversion is
within a pre-defined range of the current average before putting it into the
buffer and recalculating the average.  Trouble is, any genuine large steps
would be ignored, such as at switch on.  Sounds like some kind of auto
tuning filter is needed maybe?

Regards

Mike Rigby-Jones
mrjonesnortel.co.uk

Mike Rigby-Jones wrote:

|Since getting my temperature controller to work, I have been playing
around
|with various filtering techniques to remove noise from my ADC output
(AN512)
|
|Lawrence kindly sent me the code to implement a median filter, which
most
|people seemed to think was the one to use.  Certainly, it rejects silly
|values very well, however it doesn't seem to remove the high frequency
noise
|that a mean filter does.  The high frequency noise seems to be my
biggest
|headache at the minute, although mostly stemming from the use of an
emulator
|I think.
|
|What I need is a way of combining the advantages of these two filters,
but I
|don't have a lot of RAM left so minimal overhead is needed.
Unfortunately
|I'm having to deal with 16 bit values.  I currently use a circular
buffer
|with 8 entries and just use mean filtering.
|
|Does anyone have any cunning ideas?
|
|My only idea so far is to do a conversion and check that the conversion
is
|within a pre-defined range of the current average before putting it
into the
|buffer and recalculating the average.  Trouble is, any genuine large
steps
|would be ignored, such as at switch on.  Sounds like some kind of auto
|tuning filter is needed maybe?
|
|Regards
|
|Mike Rigby-Jones
|mrjonesnortel.co.uk

Normally use of a median filter, or rejecting highest and lowest, is
used when there are very strange "shot" noise problems. If you are not
having data points which lay outside of 3 sigma of the mean it is
probably best to use all values.

I have had good luck using infinite impulse response filters (IIRF) when
filtering. You will want to oversample, but that is the case with any
filtering. Example (in C):
FilterX16 -= FilterX16 >> 4;    // add 8 before shift to improve
rounding
FilterX16 += NewValue;

This decays the filter value by 1/16th, which results in a time constant
(3db down, or 50% settling) of about 10.74 sample periods. Double pole
filters, which use two storage elements can be used to improved phase
delay (response time) while keeping the corner frequency at the same
location. Any text on digital signal processing should cover the design
of these filters. I typically design my own using a simple spread sheet
and graphing the response to a step and to some high frequency noise.
This allows me to tune using simple to handle multiplier factors. I
typically try to tune for minimum phase delays, which would correspond
to a Bessel filter.

By the way, the ADC method covered in AN512 doesn't strike me as
providing 16-bit result quality. If you are trying to create that sort
of resolution you probably are fooling yourself.

Chip.

On Wed, 29 Jul 1998 09:25:07 +0100 "Rigby-Jones, Michael
[PAI01:4837:EXCH]" <michael.rigby-jones.mrjonesNORTEL.CO.UK> writes:

>My only idea so far is to do a conversion and check that the
>conversion is
>within a pre-defined range of the current average before putting it
>into the
>buffer and recalculating the average.  Trouble is, any genuine large
>steps
>would be ignored, such as at switch on.  Sounds like some kind of auto
>tuning filter is needed maybe?

This is a good idea.  A little logic could be added to handle sudden
large changes in the input.  If most of the samples are being rejected,
the rejection process should be bypassed until the average becomes close
to the new value.  One simple technique would use a counter that counts
up when a sample is rejected and down if it is accepted.  If the counter
rises above a threshold, start putting all samples into the average, but
process everything else the same.  After enough new samples have been
averaged, the count will reduce below the threshold and the outlying
sample rejection will start working again.

Outlying samples have to be relatively rare in order for this to work, so
the new average will be close to the actual average.   If this isn't the
case, something could be done by increasing the rejection threshold to a
finite value, so even in the "bypass" mode, really bad samples are still
rejected.  Or take a single sample and force the average to it, then see
if the next few samples are close enough.

_____________________________________________________________________
Get completely free e-mail from Juno at http://www.juno.com
Or call Juno at (800) 654-JUNO [654-5866]

Michael wrote:

> Since getting my temperature controller to work, I have been playing
> around with various filtering techniques to remove noise from my ADC
> output (AN512)
>
> Lawrence kindly sent me the code to implement a median filter, which
> most people seemed to think was the one to use.  Certainly, it
> rejects silly values very well, however it doesn't seem to remove
> the high frequency noise that a mean filter does.  The high
> frequency noise seems to be my biggest headache at the minute,
> although mostly stemming from the use of an emulator I think.

I'd look at two possibilities.  The simplest is the noise introduced
by emulator cables.  I usaually prototype with emulators as lttle as
possible, and use UV eraseable parts as much as possible, especially
trying to tune performance.  A nice beep from a speaker on a real
part sounds like a horrendous sqwaq on an emulator.

I often program test parts that will take a measurement, then
display it in some clever way like blinking the "power on" LED  or
beeping the piezo speaker.  In this way I can get the real
performance of the UV eraseable part and the feedback of an emulator.

The next thing to try might simply be analog filtering of your
signal.  Nyquist will tell you that you have to sample at more than
twice the maximum frequency of interest, and it is a good idea to
make sure that no frequencies above that are present.  A couple of
looking for signals that change over seconds, and measureing them at
megahetz.  In this case a simple decoupling cap might be all that is
needed.

What are the frequencies of interest?  What are the noise
frequencies?

Of couse, you have already thought of all these easy methods.  I
always try the simplest thing first.   One time I put a huge 16
number median filter algorithm with all kinds of limit checking on a
project, only to find that my signal source contained excessive
hysteresis and almost no noise at all.  No amount of filtering can
eliminate bad data.  Changing a single part in the signal source
solved the problem at zero additional cost.
-- Lawrence Lile

"An Engineer is simply a machine for
turning coffee into assembler code."

http://home1.gte.net/llile/index.htm

Lawrence Lile writes:
>beeping the piezo speaker.  In this way I can get the real
>performance of the UV eraseable part and the feedback of an emulator.

Piezo sounders are great for things like this because one can
emulate a JK flip-flop if you don't want to actually have another
chip, by exclusive-or ing the bit used to drive the speaker once for
each cycle.  Unless something is changing at ultrasonic rates, you
will always hear something when the bit changes.  If you happen to
hear mains buzz on a circuit or notice that your speaker clicks each
time the fan comes on, then you know your measurements are being
corrupted.

I once used the A/D converter in a Motorola 68HC11 to read the
output of an R network made between a series resistor and one of those
per second and the lower bits produced a very nice 120-HZ pulse signal
when an incandescent light bulb was on in the room.  I doubt that a
person would have seen any flicker on that port with a LED, but a
speaker produces a very nasty buzz.  The ear is quicker than the eye.
Obviously, this isn't something that one would want to have in his/her
circuit on a permanent basis, but the hardware and software to send
the sample to a speaker can give you incite on how clean the signal
is.  Of course, a scope can do that also.

Martin McCormick

Chip Weller wrote:

> By the way, the ADC method covered in AN512 doesn't strike me as
> providing 16-bit result quality. If you are trying to create that sort
> of resolution you probably are fooling yourself.
>
No, I don't think 16 bit resolution is realisticaly acheivable, the schmitt
trigger in the PIC was never designed for this use and I suspect dosen't
have terribly precise switching points.  However, I am getting around 9 1/2
bits over the temperture range of interest (15 to 45 degrees C) which is
more than adequate.  Thanks for the tips on digital filtering, it's
something which I would like to investigate further.

Mike Keitz wrote:

> This is a good idea.  A little logic could be added to handle sudden
> large changes in the input.  If most of the samples are being rejected,
> the rejection process should be bypassed until the average becomes close
> to the new value.  One simple technique would use a counter that counts
> up when a sample is rejected and down if it is accepted.  If the counter
> rises above a threshold, start putting all samples into the average, but
> process everything else the same.  After enough new samples have been
> averaged, the count will reduce below the threshold and the outlying
>       sample rejection will start working again.
>
Hmm..good idea, thanks Mike.  Given another few days of continuous bashing
of my head against the lab wall, I might have come up with this, you've
maybe saved some pain :)

Lawrence Lile wrote:
The next thing to try might simply be analog filtering of your
signal.  Nyquist will tell you that you have to sample at more than
twice the maximum frequency of interest, and it is a good idea to
make sure that no frequencies above that are present.  A couple of
looking for signals that change over seconds, and measureing them at
megahetz.  In this case a simple decoupling cap might be all that is
needed.

The trouble is, the adc technique outlined in AN512 tends to preclude the
use of analogue filtering, adding a cap to the thermistor would just screw
up the timing.  You wouldn't have thought that the adc would be that prone
to noise as it has a reasonable sized cap (440nF in my case) straight to
ground on the sense wire.  Goes to show I don't know what I'm talking about
I guess!  I have to agree with your comments on emulators and noise though.
I guess it's time to get out the JW parts and see what's really going to be
happening.

For anyone using AN512 for tempertaure control, can I suggest that if the
system is a closed loop, then the thermistor is linearised, either
electronically or in software.  I used an interpolated look up table and the
loop stability was improved massively.  Not surprising when you look at the
thermistor characteristics.  The slope at the lower temperature range was
around 8 times that at the top end. Trying to tune the loop was a nightmare
until that was sorted.

Another hint, be carefull with emulators, the ICEPIC 2 can leave all the pic
periperals running when the core has actually stopped (selectable option).
Trouble is I didn't actually notice until my peltier cooler had reached
about 145 degrees C.  Strangely it seems to have lost a certain amount of
efficiency :o).

Regards

Mike Rigby-Jones
mrjonesnortel.co.uk

Chip Weller writes:

> Normally use of a median filter, or rejecting highest and lowest, is
> used when there are very strange "shot" noise problems. If you are not
> having data points which lay outside of 3 sigma of the mean it is
> probably best to use all values.

I think Michael R-J has been getting both Gaussian noise and impulsive
noise. So some sort of non-parametric mean estimator (e.g. the median
estimator) is needed as well as a filter.

> I have had good luck using infinite impulse response filters (IIRF) when
> filtering. You will want to oversample, but that is the case with any
> filtering. Example (in C):
>     FilterX16 -= FilterX16 >> 4;    // add 8 before shift to improve
> rounding
>     FilterX16 += NewValue;

This exponential IIR filter is a great idea for filtering the Gaussian
noise - it is easy, simple and uses little memory.

Mal
--
Netherlands Foundation for Research in Astronomy
http://www.nfra.nl/~mgoris/
Phone:  +31 521 595 286 (work)                  Fax: +31 521 597 332
+31 528 274 156 (home)

Hi,

{Quote hidden}

How about using the 8 entry median filter as you are currently and taking
the middle 4 entries and averaging them.  This way you still throw the
extremes and you average out high frequency noise.

Niki

'OT: Spam Filtering'
1998\09\02@142843 by
Idea:  If a message has "http://remove-list.com" in it, then it most
likely is UCE SPAM, and can be spam-binned <VBEG>

'(OT)Filtering signal from telephone lines'
1998\10\24@062000 by
Hi, Bob,

What I meant to say was that I could connect a capacitor(say 47u/17V)
between
the lines when it is off-hook. The actual location can be after the
switching
circuit inside the telephone set. I just want to know the simplest way
to mute
signals form the line while the DC connection is still active. In my
projet I
have to switch the earphone to monitor another signal.

Best reguards!

> From:         Bob Carter <wolftechMIDWEST.NET>
> Subject:      Re: How to filter out signals from Telephone lines
> Mime-Version: 1.0
> Content-Type: text/plain; charset="US-ASCII"
>
> A 16V cap across the phone lines?? The DC voltage is roughly 50V, and
an
> AC ring siganl can be over 100 volts. Can you place an approx. 20mA
> (to simulate off-hook condition) across your lines and then switch
in/out
{Quote hidden}

'Digital filtering code needed'
1998\11\09@170958 by
Hi All,

Does anyone have any digital filtering code they would share, other than
the stuff posted by Microchip. I'm looking for an adjustable order filter
routine that runs quick on eight, twelve or sixteen bit samples (or even if
it just does one or two of these).

Any help is much appreciated.

Craig

Hi All,

I'm sending this again because it bounced back.

Does anyone have any digital filtering code they would share, other than
the stuff posted by Microchip. I'm looking for an adjustable order filter
routine that runs quick on eight, twelve or sixteen bit samples (or even if
it just does one or two of these).

Any help is much appreciated.

Craig

At 17:40 9/11/98 -0800, you wrote:
>Hi All,
>
>I'm sending this again because it bounced back.
>
>Does anyone have any digital filtering code they would share, other than
>the stuff posted by Microchip. I'm looking for an adjustable order filter
>routine that runs quick on eight, twelve or sixteen bit samples (or even if
>it just does one or two of these).
>
>Any help is much appreciated.
>
>Craig
>
>

Got your message, but we need to know "What type of filter you need" FIR,
FIIR 5 tap 10 tap 20 tap etc. You indicate adjustable order, by this what do
you mean? And for what processor?

Dennis

'Filtering PIC Power maybe?'
1999\03\09@012716 by
Hi all,
I have a PIC controlled CDI ignition circuit that I have been
building on for a while and I have got it down to all the voltages are
right but now when the PIC fires the SCR to discharge the CAP into the
coil the PIC seems to stop operating.

At first I believe the problem was that the I/O pins were being
rewritten so I re-initialized the I/O pins at different points in the
code and this allowed the PIC to operate longer but then it quit again
and I noticed that it had become very hot to the touch.

Does anyone have any ideas? Maybe some way to isolate the PIC from the
rest of the power. I am almost out of ideas. Anything will help.
Thanks
Troyignition.hell

"Troy P." wrote:
>
> Hi all,
>     I have a PIC controlled CDI ignition circuit that I have been
> building on for a while and I have got it down to all the voltages are
> right but now when the PIC fires the SCR to discharge the CAP into the
> coil the PIC seems to stop operating.
>
> At first I believe the problem was that the I/O pins were being
> rewritten so I re-initialized the I/O pins at different points in the
> code and this allowed the PIC to operate longer but then it quit again
> and I noticed that it had become very hot to the touch.

'Hot to the touch' sounds as if you are getting spikes on your
outputs that are running back into the PIC and shorting via
the protection diodes.

I have found nothing to be as fast as a tranzorb for absorbing
nasty spikes. Hook a 0.6Ke 5V tranzorb over the output pins.

--
Friendly Regards          /"\
\ /
Tjaart van der Walt        X  ASCII RIBBON CAMPAIGN
tjaartwasp.co.za  / \ AGAINST HTML MAIL
|--------------------------------------------------|
|                WASP International                |
|R&D Engineer : GSM peripheral services development|
|--------------------------------------------------|
| Mobile : tjaartsms.wasp.co.za  (160 text chars) |
|     http://www.wasp.co.za/~tjaart/index.html     |
|Voice: +27-(0)11-622-8686  Fax: +27-(0)11-622-8973|
|          WGS-84 : 26¡10.52'S 28¡06.19'E          |
|--------------------------------------------------|

At 08:46 03/09/99 +0200, Tjaart van der Walt wrote:
>I have found nothing to be as fast as a tranzorb for absorbing
>nasty spikes. Hook a 0.6Ke 5V tranzorb over the output pins.

they like some series impedance (in the path which you want to protect) to
take the energy, depending on the application.

ge

Troy P. wrote:
> and I noticed that it had become very hot to the touch.

The 'spikes' may be causing the PIC to 'latch up' causing internal
shorts.

> Does anyone have any ideas? Maybe some way to isolate the PIC from the
> rest of the power.

My programmable ignition kit is now in over 2000 cars and have been in
operation for over two years.

I have a 100R resistor in series with each input to the pic that is
controlling any engine components, ie points, coil drivers etc. After
this resistor, on the PIC side, are a diode to 5V and one to GND. I used
IN5819's, but I have heard that ordinary IN4002's work OK. There is also
a 10n cap from the diode junctions to GND.

You may need to isolate the SCR from the PIC.

--
Best regards

Tony

PicNPoke - Multimedia 16F84 Beginners PIC Tools.

http://www.picnpoke.com
Email picnpokecdi.com.au

At 12:21 AM 3/9/99 -0600, you wrote:
>Hi all,
>    I have a PIC controlled CDI ignition circuit that I have been
>building on for a while and I have got it down to all the voltages are
>right but now when the PIC fires the SCR to discharge the CAP into the
>coil the PIC seems to stop operating.
>
>At first I believe the problem was that the I/O pins were being
>rewritten so I re-initialized the I/O pins at different points in the
>code and this allowed the PIC to operate longer but then it quit again
>and I noticed that it had become very hot to the touch.
>
>Does anyone have any ideas? Maybe some way to isolate the PIC from the
>rest of the power. I am almost out of ideas. Anything will help.

Troy:

Could be internal latchup in the PIC. The automotive environment is
really NASTY, and CDI circuits generate huge transients on purpose!
You're probably going to need some massive decoupling between the
PIC and everything else. For starters, try powering the PIC temporarily
with a separate supply, like 4 NiCds or 3 D cells, well bypassed with
caps; and use maximum possible series resistance with I/O lines.
See if that makes a difference.

Reg Neale

I took all of the good (as usual) advice and applied it to my circuit and
it seems to be feeling much better now. Thanks alot to everyone. I don't
know that I can contribute a whole lot to other peoples problems but I will
certianly try. (in return for all the help that I have gotten)

On Wed, 10 Mar 1999 09:34:45 +1100, Tony Nixon wrote:

>
>You may need to isolate the SCR from the PIC.
>

I just finished the first prototype of a unit that controls
a Cheston heater.  It's phase controled via 2 inverse
parallel SCR's which at peak run 350 amps at 480 VAC.  To
achive the proper isolation beetween the SCR's and the CPU
I had to use a gate trigger transformer.  The CPU sits on
the primary side and the SCR is on the secondary side
connected to the anode and the gate.  To fire the scr you
pulse the xformer.  This sends several large spikes into
the gate and turns on the SCR.  Be warned all gate xformers
are not created equal and you need to do a little research
to get right one for your SCR.  (Or at least in my case
they were)

--
Richard A. Smith                         Bitworks, Inc.
rsmithbitworks.com               501.521.3908
Sr. Design Engineer        http://www.bitworks.com

On Fri, 12 Mar 1999 16:26:58 -0600 "Richard A. Smith"
<rsmithbitworks.com> writes:
>On Wed, 10 Mar 1999 09:34:45 +1100, Tony Nixon wrote:
>
>>
>>You may need to isolate the SCR from the PIC.
>>
>
>I just finished the first prototype of a unit that controls
>a Cheston heater.  It's phase controled via 2 inverse
>parallel SCR's which at peak run 350 amps at 480 VAC.  To
>achive the proper isolation beetween the SCR's and the CPU
>I had to use a gate trigger transformer.  The CPU sits on
>the primary side and the SCR is on the secondary side
>connected to the anode and the gate.  To fire the scr you
>pulse the xformer.  This sends several large spikes into
>the gate and turns on the SCR.  Be warned all gate xformers
>are not created equal and you need to do a little research
>to get right one for your SCR.  (Or at least in my case
>they were)
>

Might also try the MOC3010, MOC3020 series, etc.  These are
optically isolated triac drivers.

Harold

Harold Hallikainen
haroldhallikainen.com
Hallikainen & Friends, Inc.
See the FCC Rules at http://hallikainen.com/FccRules and comments filed
in LPFM proceeding at http://hallikainen.com/lpfm

___________________________________________________________________
Get completely free e-mail from Juno at http://www.juno.com/getjuno.html
or call Juno at (800) 654-JUNO [654-5866]

On Fri, 12 Mar 1999 19:58:31 EST, Harold Hallikainen wrote:

>>the gate and turns on the SCR.  Be warned all gate xformers
>>are not created equal and you need to do a little research
>>to get right one for your SCR.  (Or at least in my case
>>they were)
>>
>
>        Might also try the MOC3010, MOC3020 series, etc.  These are
>optically isolated triac drivers.

Oh yeah I forgot those... for non phase control stufff
these will probally work great.  I had  trouble useing them
because I had to use the line voltage (480) to trigger the
SCR's.  To keep the gate from being destroyed at the peak
of the cycle I had to have a large resistor in series with
the gate.  But the voltage drop across the resistor kept me
from being able to trigger at < 30 or > 300 degrees. Which
in my application was important so I had to switch to
xformers.

IMHO the MOC's will be an eaiser (less complicated hadware
and software) soulution.

--
Richard A. Smith                         Bitworks, Inc.
rsmithbitworks.com               501.521.3908
Sr. Design Engineer        http://www.bitworks.com

'[OT] List filtering [was: Beware!...]'
1999\05\17@135859 by
On Mon, May 17, 1999 at 10:01:21AM -0700, Mark Willis wrote:
> Many admins are a little hard to convince to install "censoring"
> filters that censor by CONTENT - In the US at least, lots of people feel
> anything that might infringe on free speech is a BAD Thing, and you
> wouldn't want a wrongly set up filter [...]

At least in the US, one aspect of this is that, if you
*attempt* to filter posts, then you damned well better
do a good job.  For if you attempt to do something, and
you claim that you are doing that something, then there
is a good chance that you can be held liable if you fail
to do that something. Thus, if a list admin says that he's
filtering viruses, but one gets through, then a judge might
have to think long and hard before concluding that it was
not the admin's fault that someone's PC got a virus off
that list (this would probably hinge in part on whether
with "appropriate" being to a large extent a function of
the admin's compensation -- or lack thereof -- for running
the list.)

If, OTOH, you do *not attempt* to filter viruses, and make
no claim that you are filtering viruses (or virus warnings)
or perhaps even *claim* that you make no attempt to filter
viruses or virus warnings, then it would be more clear
that the list admin is not responsible for the fact that
such are propigated via the list.

>   I 've learned to never downplay Virus/Worm warnings, they ALWAYS hurt
> someone far worse than I'd think at first.

In fact, in many cases, it seems that the virus warning
*is* the virus, with uneducated users acting as the vector.

--Bob

--
============================================================
Bob Drzyzgula                             It's not a problem
============================================================

Bob Drzyzgula wrote:
> On Mon, May 17, 1999 at 10:01:21AM -0700, Mark Willis wrote:
> > <snipped>
> >   I 've learned to never downplay Virus/Worm warnings, they ALWAYS hurt
> > someone far worse than I'd think at first.
>
> In fact, in many cases, it seems that the virus warning
> *is* the virus, with uneducated users acting as the vector.
>
> --Bob

Too true!

I think the PICList FAQ is going to have to get auto-posting this
week, It's going to be a NASTY week here for me so if I seem more
stressed than normal, please understand.  I'll post it from some free
e-mail service or another, that has automatic posting service available
(Netscape.Net or something.)  It'll definitely start off raw & ragged &
crummy, and improve over time, if I don't do it this week (despite
basically having ended up with all my stuff moved to the garage here),
I'll never get to it.  And I'm changing ISP's in a while here, might as
well not wait.

I think I'll put pointers to Virus Hoaxes pages and to Current Virus
Warnings pages in there, definitely, and remind people to not run .exe's
they get off the net unless they WANT to risk Virii; probably, those
their e-mail & looking for other warnings before sending virus warnings
to the list, unless the virus just came in (Bob caught this one
beautifully, as already I told him off list, he handled that one
beautifully - 100 Quatloo bonus! <G>)

Whatever we do, let's not argue about Virii here, as there're far
better listserves & web pages for virus information on the Internet,
than the PICList <G>  I'd rather have a few spare warnings than someone
get eaten by the "Unhappy 99" virus that I keep expecting some jerk to
write, that IS nasty and destructive and just as prolific as this one
has historically been.  That could take a lot of new users off the
Internet, and get them phobic of the 'Net at the same time, not a good
thing.

Mark

'Signal filtering through code'
1999\08\25@140729 by
My current robotics project requires me to design and build an accurate
and stable IR proximity detection sensor system. It should give feedback
of objects up to 5 feet. My chosen tools are the PIC16F84, the
LTC1298 12-bit ADC, and the VTR24F1 optosensor from EG&G.
The sensor simply contains an IR LED and a photodarlington in a single
package.

My current solution involves simple noise filtering through code. The
opto proximity method is through the use of intensity or signal
strength,
reflected off an object.

Algorithm:
Pulse HIGH!     ; LED ON.

Pulse LOW!      ; LED OFF.

SUB A-B ; Result C = (Signal+Noise) - (Noise)

C = pure signal strength.

This has proven to work well for distances up to 8 inches using an 8-bit
ADC. This is the first time I'm trying to extend the range, with a more
sensitive sensor and a 12-bit ADC.

Is there a better algorithm of filtering which would provide greater
results? A better sensor, or maybe a better method to the entire
project. I have played with Sharps' GP2D02 module as well; and have
gotten rather unsatisfactory results. If the current method cannot be
improved upon, then my next step is to try one of those 40 khz
Sharp IR modules. They won't give me proximity ranging, but
maybe reliable object detection; and atleast that's a start.

Sebastian

At 02:08 PM 8/25/99 -0400, Dwornik, Sebastian wrote:
>My current robotics project requires me to design and build an accurate
>and stable IR proximity detection sensor system. It should give feedback
>of objects up to 5 feet. My chosen tools are the PIC16F84, the
>LTC1298 12-bit ADC, and the VTR24F1 optosensor from EG&G.
>The sensor simply contains an IR LED and a photodarlington in a single
>package.
>

Does it have to be IR?  I think the biggest problem going out ot 5 feet
would be to get decent returns from the reflections.  I think the easiest
way to improve your SNR would be with a bigger LED, lenses and reflectors
to focus the IR energy, or an IR laser.

Other than this I would try an acoustic approach.  Then you could use temp
compensated timing to give really accurate results.

Good luck!

-E

An Everlight or Sharp 40Khz detector, when on frequency and
properly modulated, will give you 30 to 40 inches of
detection - depending on the object reflectivity. I've
gotten hits at over five feet before, but that certainly
wasn't very reliable and such a range is pretty useless on
my robots.  I usually tune the osc off frequency to get the
range down to less than a foot.  Since I wasn't trying for
long range, I would imagine that you could do a few things
to get it - like driving multiple LEDs, making sure they are
pumping at max current, focusing the beam, etc.

Be sure you shield the LEDs with foil. Ground the case of
the detector if you are using the Sharp module (already
grounded with the Everlight).

I've used the GP2D02 and there was just a discussion on it
on the SRS list. You need to ground the case of it for a
start.  The case is plastic, but it is conductive.  One
problem with it is its narrow beam - good for ranging, but
not for general object detection.  The other is that it
really requires a separate PIC or something to handle the
code overhead for triggering and shifting in the range
(IMHO).  Acroname was publishing PIC code for driving it -

Range detection by signal strength with IR is not very
reliable unless the target is stable,  has known
reflectivity and has consistent shape.  Which is not the
case for any target I'm looking for.

The GP2D02 detectors have very good noise filtering, the
Everlight and Sharp 40 Khz detectors are OK. I have not seen
a homebrew filter that would compete - though I'm sure it
could be done with PLL control of some sort.

If you want to see a PIC driver for an IR detector using an
Everlight module, then I've made one using a 12C508/9 and it
is on my site at: http://204.233.101.40/robots/brb.html . It
was also in last month's Encoder at http://www.seattlerobotics.org
.

Finally, before venturing into long range IR, why not try
Sonar? I get very consistent results with the Polaroid sonar
pack and it works out to 35 feet and in to about 6-11
inches.  You can see one at http://www.acroname.com .

Good luck,

Dan
{Original Message removed}
If you want something different, I don't know your cost restrictions, but
for \$25.00 each and \$18.00 in small qty. Siemens offers a 2.4 GHz Doppler
radar sensor, with antenna built in. (Part number KMY 24) A complete sensor
that will determine distance and direction by monitoring 2 sensor outputs
with your A/D microcontroller. Up to 15 feet possible,and very small in
size. (1.125"x1.5"x.375" approx.) I use them there are great. The Marshal
distributor in Kansas City MO. has stock.

Gordon Varney

{Original Message removed}
The PDFs I've pulled up on this sensor indicate it will not tell you absolute
distance.  Is there a way you are getting around this?

Gordon Varney wrote:
{Quote hidden}

> {Original Message removed}
I have two points of confusion:

1. You show prices of \$25 and \$18, but only one part number (KMY 24)?  What
is the difference?

2. Since the KMY 24 is a Doppler device, it will not recognize an object
that is NOT
in motion, correct?  Is this why you are using two devices?

Thanks for the clarification....

Larry Woods

> {Original Message removed}
Sounds almost perfect to what I need, except for one thing. They state,
"As the microwave radiation penetrates many materials, such as plastics
and ceramics which are opaque to light, the sensor modules can for many
applications be located hidden from view. ".  This is great for human
presence detection in automatic door opener applications, but I have no
way of telling what kind materials will come in front of the sensor
system. Have you tested it with many objects and surfaces? What kind of
results do you get? What are you using it for?

Thanks.

Sebastian

>{Original Message removed}
>Sounds almost perfect to what I need, except for one thing. They state,
>"As the microwave radiation penetrates many materials, such as plastics
>and ceramics which are opaque to light, the sensor modules can for many

Have you considered optical (laser) ranging?

Two laser transmitters set to converge at a spot at the far end of your
expected range.

Use a CCD to accurately measure the distance between the dots.  This is
linearly proportional to the distance.

Simple geometry --> simple code.

Andy

==================================================================
Andy Kunz               Life is what we do to prepare for Eternity
------------------------------------------------------------------
andyrc-hydros.com      http://www.rc-hydros.com     - Race Boats
==================================================================

How do you know that the CCD is seeing a laser dot and not some other bright
dot of light?
Isn't a CCD kinda expensive?
Can you modulate the Lasers and use a photo diode with a filter with Q at
modulation frequency directed by a mirror on a pager motor? the filter
output pluses only when it sees the correct frequency and the time between
the two pluses is proportional to the distance.

James Newton, webmaster http://get.to/techref
jamesnewtongeocities.com
1-619-652-0593 phoneÊ

{Original Message removed}
>How do you know that the CCD is seeing a laser dot and not some other bright
>dot of light?

With a CCD, you can measure the dot.  If it's not the size of the laser
(within reason), you got the wrong dot.  Also, the color would be a good clue.

>Isn't a CCD kinda expensive?

They are pretty cheap any more.  Any small camera module (<\$100) will do it.

>Can you modulate the Lasers and use a photo diode with a filter with Q at
>modulation frequency directed by a mirror on a pager motor? the filter
>output pluses only when it sees the correct frequency and the time between
>the two pluses is proportional to the distance.

Don't know - why not give it a try?

Andy

==================================================================
Andy Kunz               Life is what we do to prepare for Eternity
------------------------------------------------------------------
andyrc-hydros.com      http://www.rc-hydros.com     - Race Boats
==================================================================

> Two laser transmitters set to converge at a spot at the far end of your
> expected range.
>
> Use a CCD to accurately measure the distance between the dots.  This is
> linearly proportional to the distance.

there is actually no need for two lasers and two dots if the camera is
mounted a fixed distance from the laser simple trigonometry and quite
accurate if the distance between laser and camera is large enough compared
to the measured distance

The position of the dot is easy to determine
laser on, store image, laser off store image, subtract images , difference >
threshold .... this is the spot

Peter

On Wed, 25 Aug 1999 18:42:01 -0400, Andy Kunz wrote:

>>How do you know that the CCD is seeing a laser dot and not some other bright
>>dot of light?
>
>With a CCD, you can measure the dot.  If it's not the size of the laser
>(within reason), you got the wrong dot.  Also, the color would be a good clue.
>

Not to mention that you can turn the laser off, take a frame, and if the
dot is still there, it wasn't the laser.  Actually, you could just take
two frames. One with lasers on and the other with lasers off.  Subtract
them.  What's left are only the laser dots and some noise, which could be
easily filtered.  Motion in the video between frames might be
a bit more work to deal with, but you can still use the afformentioned
techniques to filter it even further.

Learned this from a fellow at our local robotics club.

Dan

{Quote hidden}

What I would add is an AGC circuit. Do the switching faster
than the time constant of the AGC circuit, and you should

--
Friendly Regards           /"\
\ /
Tjaart van der Walt         X ASCII RIBBON CAMPAIGN
tjaartcellpt.co.za / \ AGAINST HTML MAIL
|--------------------------------------------------|
|  GSM Technology for Positioning and Telematics   |
|  Cellpoint Systems SA    http://www.cellpt.com   |
|    http://www.wasp.co.za/~tjaart/index.html      |
| WGS84 -26.0124 +28.1129  Voice +27 (0)11 2545100 |
|--------------------------------------------------|

Can you elaborate on this "AGC" circuit? Any examples on the web would
help.

Thank you.

Sebastian

>{Original Message removed}
> The PDFs I've pulled up on this sensor indicate it will not tell you
absolute
> distance.  Is there a way you are getting around this?
>
>
> Gordon Varney wrote:
> >
> > If you want something different, I don't know your cost restrictions,
but
> > for \$25.00 each and \$18.00 in small qty. Siemens offers a 2.4 GHz
Doppler
> > radar sensor, with antenna built in. (Part number KMY 24) A complete
sensor
> > that will determine distance and direction by monitoring 2 sensor
outputs
> > with your A/D microcontroller. Up to 15 feet possible,and very small in
> > size. (1.125"x1.5"x.375" approx.) I use them there are great. The
Marshal
> > distributor in Kansas City MO. has stock.
> >

No, actually I am using it to determine that something has indeed stepped
into or has crossed its path.
The problem is the larger the object the more signal returned. Hence, if
small is it further away?
I may be wrroonnngggg... not right, but this might not be your solution.

Gordon Varney

> I have two points of confusion:
>
> 1. You show prices of \$25 and \$18, but only one part number (KMY 24)?
What
{Quote hidden}

one piece at @ \$25 ea.
one hundred pieces @ \$18 ea.
Same part, sorry for the confusion

With Doppler, a non moving object will appear as a higher level of DC, but
not in proportion, to its size or distance.
This device is for motion detection and direction.

Gordon Varney

> Sounds almost perfect to what I need, except for one thing. They state,
> "As the microwave radiation penetrates many materials, such as plastics
> and ceramics which are opaque to light, the sensor modules can for many
> applications be located hidden from view. ".  This is great for human
> presence detection in automatic door opener applications, but I have no
> way of telling what kind materials will come in front of the sensor
> system. Have you tested it with many objects and surfaces? What kind of
> results do you get? What are you using it for?
>
> Thanks.
>
> Sebastian
>
Most plastics and cloth materials have little or no effect on RF, There fore
it will only detect objects of mass like humans, animals, walls, vehicles
and other such items. Example if you have a robot and would like to have a
detector that will tell the controller to turn or avoid an object, this
would be a great item for steering and avoidance, however the more complex
the robot the more sensors needed to determine distance and depth.
I have used it for motion control and the detector will pick up on most
objects. The larger and closer the object, the stronger the return. By
approximating the speed and  direction of the device that is carrying the
sensor, it is possible to determine if an object that is near, is standing
still or moving in relation to the sensor. A moving vehicle can then
determine if it is nearing a wall or tree, or if the object is passing it
by, or determine the rate of closure.

Gordon Varney

<BLOCKQUOTE AUTHOR="Andy Kunz">...Have you considered optical (laser)
ranging? Two laser transmitters set to converge at a spot at the far end of
your expected range.  Use a CCD to accurately measure the distance between
the dots.  This is linearly proportional to the distance. Simple
geometry --> simple code.
</BLOCKQUOTE>

<BLOCKQUOTE AUTHOR="Peter van Hoof">...no need for two lasers and two dots
if the camera is mounted a fixed distance from the laser...</BLOCKQUOTE>

<BLOCKQUOTE AUTHOR="Dan Larson"> ...you can turn the laser off, take a
frame, and if the dot is still there, it wasn't the laser.  Actually, you
could just take two frames. One with lasers on and the other with lasers
off.  Subtract them.  What's left are only the laser dots and some noise,
which could be
easily filtered.</BLOCKQUOTE>

I've been hearing this solution for a while and I'm sure it would work
nicely. It is further described at:
http://www.cyberg8t.com/pendragn/actlite.htm

The problem(s) is(are):
1. CCDs are in the under a \$100 range. Ok for the dedicated hobbyist but it
makes it hard for kids, producible products, or wife/kid limited budgets
(me).
2. Reading a CCD and finding the right spot requires
A. Speed. the standard 4Mhz PIC just ain't going to do it in real time.
Maybe an SX.
B. Lots of RAM, especially to take two shots and compare. And the PIC
ain't got it.
3. It just seems to me (and I wish I had time to prove it) that its not
necessary. Again, modulate the Laser(s) and use a photo diode to a filter
with Q at modulation frequency directed by a mirror on a pager motor. The
filter outputs pluses only when it sees the correct frequency and the time
between the two pluses (or from the pulse to a reference provided by a
sensor that watches the mirror spin when using only one laser) is
proportional to the distance. Easily PICable, very low cost, etc...

Actually Scott Dattalo has done a brilliant page at
www.interstice.com/~sdattalo/technical/theory/dtmf.html
on how to pick out the presence a frequency by just sampling the signal at a
regular interval (ISR) and doing a DFT on it. He uses it for 0 hardware
DTMF. Scenix did it in their single chip modem. It could be used in a PIC to
eliminate the filter and just connect the photo-diode to the PIC. Another
pin for the reference pulse and maybe a PWM out for the motor speed.

Sigh... another for the "someday" bin.

James Newton, webmaster http://get.to/techref
jamesnewtongeocities.com
1-619-652-0593 phoneÊ

{Original Message removed}
>1. CCDs are in the under a \$100 range. Ok for the dedicated hobbyist but it

I thought it was for a commercial venture from the early part of the thread.

>   A. Speed. the standard 4Mhz PIC just ain't going to do it in real time.

We used a 20MHz PIC16C73 and had time to spare.  Used NTSC input to PIC.

>   B. Lots of RAM, especially to take two shots and compare. And the PIC
>ain't got it.

But you should already KNOW where the spot is (which lines) and only need
to scan them for which columns.  Using RLL encoding (how many pixels across
_didn't_ have the spot, when it appears, how many pixels does it occupy,
then how many don't again.  Three 1-byte entries per line.  Very little RAM.

Andy

==================================================================
Andy Kunz               Life is what we do to prepare for Eternity
------------------------------------------------------------------
andyrc-hydros.com      http://www.rc-hydros.com     - Race Boats
==================================================================

On Thu, 26 Aug 1999, James Newton wrote:

> <BLOCKQUOTE AUTHOR="Dan Larson"> ...you can turn the laser off, take a
> frame, and if the dot is still there, it wasn't the laser.  Actually, you
> could just take two frames. One with lasers on and the other with lasers
> off.  Subtract them.  What's left are only the laser dots and some noise,
> which could be
> easily filtered.</BLOCKQUOTE>
>
> I've been hearing this solution for a while and I'm sure it would work
> nicely. It is further described at:
> http://www.cyberg8t.com/pendragn/actlite.htm

Lawrence Livermore developed a verson of this technique to track rifle
projectiles. Apparently it was used in Bosnia to determine the source of
sniper fire.

> 3. It just seems to me (and I wish I had time to prove it) that its not
> necessary. Again, modulate the Laser(s) and use a photo diode to a filter
> with Q at modulation frequency directed by a mirror on a pager motor. The
> filter outputs pluses only when it sees the correct frequency and the time
> between the two pluses (or from the pulse to a reference provided by a
> sensor that watches the mirror spin when using only one laser) is
> proportional to the distance. Easily PICable, very low cost, etc...

It's one of those theory and practice dilemmas... The only problem with
this approach is that it only takes light 3ns to travel a meter. Now it is
possible to resolve this kind of resolution with fairly simple
electronics. I could envision two square waves: one being the square wave
gating the laser on and off and the other being the reflected signal. If
you took the difference between these and ran it through an integrator
then 'theoretically' you'd have a dc signal proportional to the phase
difference. The phase difference is proportional to the time-of-flight of
the laser pulse. The 'difference' circuit could be a 2-input AND gate and
the 'integrator' could be a low-pass RC filter. Now the major problem will
be multiple reflections. Additional problems would be calibration and
drift (specifically propogation delay changes through the various
components [because of temperature changes]). But it does sound fun...

Scott
PS thanks for the plug

<BLOCKQUOTE AUTHOR="Scott Dattalo">It's one of those theory and practice
dilemmas... The only problem with this approach is that it only takes light
3ns to travel a meter. Now it is possible to resolve this kind of resolution
with fairly simple electronics. I could envision two square waves: one being
the square wave gating the laser on and off and the other being the
reflected signal. If you took the difference between these and ran it
through an integrator then 'theoretically' you'd have a dc signal
proportional to the phase difference. The phase difference is proportional
to the time-of-flight of the laser pulse.</BLOCKQUOTE>

Err... I think you may have misunderstood me. I was suggesting the use of a
rotating mirror to direct the attention of the photo diode across the plane
of the laser. For example, if the laser and mirror are mounted horizontally
from one another, the laser reflection will be somewhere on the horizontal
line scanned by the mirror. As the mirror turns, different points along that
line become visible to the photo diode. When the mirror reflects the point
that the laser "dot" is illuminating, the signal from the photo diode begins
oscillating at the frequency of the lasers modulation. This signal is
detected by a filter (analog or digital) and produces the pulse that is
detected by the processor. If the laser is on the left and the mirror on the
right, closer objects will cause the reflected "dot" to appear further to
the left from the viewpoint of the scanning mirror (pulse appears sooner)
and more distant objects will cause it to appear farther to the right (pulse
appears later) . The purpose of the modulation is only to quickly
distinguish the laser "dot" from other light sources as the mirror scans
across it.

The first picture at
http://www.cyberg8t.com/pendragn/actlite.htm
shows the mechanical setup except that I would replace the laser with the
photodiode so that different lasers could be used.

<BLOCKQUOTE AUTHOR="Andy Kunz">... NTSC input to PIC. ... already KNOW where
the spot is (which lines) and only need  to scan them for which columns.
Using RLL encoding (how many pixels across _didn't_ have the spot, when it
appears, how many pixels does it occupy, then how many don't again.  Three
1-byte entries per line.  Very little RAM. </BLOCKQUOTE>

Andy, you are absolutely clever... the CCD NTSC to PIC pin and count the
lines then the level is brilliant. If the laser modulation was genlocked to
the NTSC frame then you could look for the dot to be there then not be there
etc... just one bit to hold the expected value. The final data after 2
frames is just the depth of the point the laser is hitting. My only
objection left is the cost of the CCD. And the advantage of the CCD is that
any of the scan lines can be searched which would allow a laser with a beam
to line lens to produce an entire (vertical) 3d profile using only as much
memory as you wanted to store the results. Shifting that side to side
(slowly) would get you an entire 3d map of the objects in front.

James Newton, webmaster http://get.to/techref
jamesnewtongeocities.com
1-619-652-0593 phone

Just sweep the laser -
get a rotating mirror (lots of them around surplus).
Put a photodiode in front of the laser as it starts it's sweep
across, and another behind a lense focused on the scene ahead.
When the laser reaches a given point, it will reflect off the
scene into the receiver. The time difference is a one to one function
of the range

Optical problem with this (and the CCD idea) is where to focuse
the lense.

BUT, what all these approaches fail to deal with is the
case where the "range" isn't constant across the
field of view. Imagine a robot approaching the corner of
a cubical box at
a 45 deg. angle to the sides. What the range is depends on where
you measure.

You can get an array of range measurements by combing my approach above
with the CCD approach. Scan the laser slowly, and take an
angle measuring snapshot with the CCD every degree or so. Work out
the trig and you'll get a set of points that should represent the
reflecting surface.

::Annie is seen dragging a glass topped table down the hall,
a look of gleam in her eyes::

The really serious hi tech solution

Use two CCD's - mount them a distance apart to make stereo vision.

Use the morphing algorithm to map pixels in one "eye" to pixels in the
other. The distance between pixels is a function of 1/distance, so
you have a map of distances.

Voila! Depth perception.

--
Anniepoo
Need loco motors?
http://www.idiom.com/~anniepoo/depot/motors.html

OK - my sickest range finder yet.

I take the issue is to get some overall sense of the proximity of
an obstructing object, with information about it's proximity
(more than one bit).

(And, I raise the question, do you need more than one bit? If
it's collision detection, probably not).

Put a fan on the front of the robot. Off to the sides mount
small aluminum foil "flags" on a low - friction bearing (say
a length of fine thread) and photodetectors to sense the
position of the foil.

When the robot approaches an obstruction, the wind will be
reflected back and move the foil flags.

::Annie is seen dragging a roll of chicken wire down the
hall, cackling with glee::

--
Anniepoo
Need loco motors?
http://www.idiom.com/~anniepoo/depot/motors.html

We are now aiming for the Rube Goldberg award.  However, I
think this is weird enough to almost work. If some method of
getting the resolution down to, say, the width of a chair
leg (chair legs are not nice - office chairs with those five
different arms that trap unsuspecting 'bots are EVIL) then
it would be a hoot to make one.

Dan

{Original Message removed}
> OK - my sickest range finder yet.
>
>
> ::Annie is seen dragging a roll of chicken wire down the
> hall, cackling with glee::
>
>
>
> --
> Anniep

Stand back Anne is on a roll.

Anne,
I am impressed, your ideas might just work. Do you hold patent's on these
ideas?
Can I use them? how much do you want in royalties?

Gordon Varney

>Optical problem with this (and the CCD idea) is where to focuse
>the lense.

Sorry,  I assumed you all know that because the laser is intense, you can
cut the aperture _waaaay_ down.  This allows you to have a VERY WIDE focus
range.

Andy
==================================================================
Andy Kunz               Life is what we do to prepare for Eternity
------------------------------------------------------------------
andyrc-hydros.com      http://www.rc-hydros.com     - Race Boats
==================================================================

Dan Creagan wrote:
>
> We are now aiming for the Rube Goldberg award.  However, I
> think this is weird enough to almost work. If some method of
> getting the resolution down to, say, the width of a chair
> leg (chair legs are not nice - office chairs with those five
> different arms that trap unsuspecting 'bots are EVIL) then
> it would be a hoot to make one.
>
> Dan
>

Years ago MIT had a robot maze race, and the winner was
a wall follower made, if I recall, from a fan ducted
under a piece of styrofoam board to make a tiny hovercraft.
Seems like a natural for such a beasty.

--
Anniepoo
Need loco motors?
http://www.idiom.com/~anniepoo/depot/motors.html

Anne Ogborn wrote:
>
> Just sweep the laser -
> get a rotating mirror (lots of them around surplus).
> Put a photodiode in front of the laser as it starts it's sweep
> across, and another behind a lense focused on the scene ahead.
> When the laser reaches a given point, it will reflect off the
> scene into the receiver. The time difference is a one to one function
> of the range

I had an idea that I've been trying one of my buddies
(Hi Jules!) to try in his security R&D business.

It goes like this :
You suspend a light circular mirror from a stiff nylon fibre
with the reflective surface pointing down (dia = 3cm)
Stuck to the back of the mirror, there are three small magnets
(pointing up). Above the magnets, there are three small coils
with enough pull to deflect the mirror 45deg. Now you can scan
360deg. with a laser diode pointing upwards. Next to the diode
you have a light dep diode. As you scan the mirror, you record
the light intensity levels in, say 90 steps. These values are
saved in RAM, and the average calculated. The average is used
to normalise the saved values. This set of normalised, saved
values is compared to a pre-saved set of values (RMS sounds OK
for an indication), and any funny values will indicate an object
that shouldn't be there.

You could also use an AGC (Automatic Gain Control) circuit to
keep the measured values useable. For an AGC circuit, I think
the easiest would be to use a MOSFET like a VN10KM (Supertex)
in series with the Ri of an opamp. You need a non-inverting
amplifier for it to work. Stick the light level ouput of the
optical device into Ri. Use an integrated version of the output
to drive the MOSFET.

I probably didn't make any sense...

--
Friendly Regards           /"\
\ /
Tjaart van der Walt         X ASCII RIBBON CAMPAIGN
tjaartcellpt.co.za / \ AGAINST HTML MAIL
|--------------------------------------------------|
|  GSM Technology for Positioning and Telematics   |
|  Cellpoint Systems SA    http://www.cellpt.com   |
|    http://www.wasp.co.za/~tjaart/index.html      |
| WGS84 -26.0124 +28.1129  Voice +27 (0)11 2545100 |
|--------------------------------------------------|

"Dwornik, Sebastian" wrote:
>
> Can you elaborate on this "AGC" circuit? Any examples on the web would
> help.

I did in another post.

--
Friendly Regards           /"\
\ /
Tjaart van der Walt         X ASCII RIBBON CAMPAIGN
tjaartcellpt.co.za / \ AGAINST HTML MAIL
|--------------------------------------------------|
|  GSM Technology for Positioning and Telematics   |
|  Cellpoint Systems SA    http://www.cellpt.com   |
|    http://www.wasp.co.za/~tjaart/index.html      |
| WGS84 -26.0124 +28.1129  Voice +27 (0)11 2545100 |
|--------------------------------------------------|

I must thank you all for the excellent input to my
dillemma. It has been very helpful, and amusing.

I have experimented some more with just the VTR24F1
retro-reflective opto-sensor, and the results are
excellent for short range (4-8 inches). Which I
may then use as a downward looking sensor for path
correction. As for a reliable frontal object
detection with greater range; I will do some more
R&D and experiment with some of Sharps' modulated
IR devices. This seems to be a popular and proven
method, used by many robots. Proximity detection
and path prediction of the object being sensed
will come a bit later. I speculate that a variety
of IR sensing methods will be used to determine
as much valuable information of whats up ahead
as possible. Maybe three different sensing methods.
Long, medium, and short range tracking. Such a
combination, with added redundancy might prove
to be accurate and reliable
(hopefully fast too, 50+ Hz).

The economics of such a solution might be
high (\$100+ for full setup), but worth it if
the results are good.

Thanks.

Sebastian

>{Original Message removed}

'Software filtering?'
2000\01\21@112401 by
Does anyone know of a software library (source code) that I could port to
the PIC for real-time filtering?  I'm grabbing A/D data and want to do some
basic artifact removal in software (real-time hopefully, before sending it
to another processor) but I need a starting place of some working code.  Any
language would be fine...

Thanks if you can help!!

On Fri, 21 Jan 2000, Jeffrey Siegel wrote:

> Does anyone know of a software library (source code) that I could port to
> the PIC for real-time filtering?  I'm grabbing A/D data and want to do some
> basic artifact removal in software (real-time hopefully, before sending it
> to another processor) but I need a starting place of some working code.  Any
> language would be fine...

Could you be more specific? Are you wanting to implement a low-pass,
high-pass, iir,fir,correlation, median, OT, or what filter?

Except for OT filters, solutions of each of these has been presented one
time or another on the Piclist.

Scott

> Could you be more specific? Are you wanting to implement a low-pass,
> high-pass, iir,fir,correlation, median, OT, or what filter?
>
> Except for OT filters, solutions of each of these has been presented one
> time or another on the Piclist.
>

Low-pass, high-pass, notch....  I did a general web search and didn't come
up with much.  Thanks though - I'll check the archives for more info.

> On Fri, 21 Jan 2000, Jeffrey Siegel wrote:
>
> > Does anyone know of a software library (source code) that I could port to
> > the PIC for real-time filtering?  I'm grabbing A/D data and want to do some
> > basic artifact removal in software (real-time hopefully, before sending it
> > to another processor) but I need a starting place of some working code.  Any
> > language would be fine...

I accidently deleted you're other response... dammit.

Let me ask the question more specifically. In the low-pass filter case,
for example, do you want to implement an FIR or an IIR? What kind of
signal bandwidth are you seeking. How much passband ripple are you willing
to tolerate? Are you just trying to remove some sampling clock artifact?
What's the application?

If you're looking for general purpose signal processing, then you probably
don't want to waste your time with pics - at least not the 12 and 14 bit
cores. Digital signal processing (as taught at your college) relies
heavily on multiply and accumulate operations. The low end pics don't have
a multiplier, the high end ones do, but can't do a single cycle MAC. Butt,
there's always a trick. Unfortunately, the tricks are seldom generic. For
example, the 'twist' routine I posted the other day, can be used as
low-pass, one-tap, IIR filter. It implements this 'transfer function':

f = (m*x + n*y)/N

Subject to the conditions:

log2(N) is an integer (N is a power of 2, e.g. 16, 32, 64...)

m + n = N

x and y are the inputs and f is the output.

Now if you make f = y, which is to say that for the next iteration through
the filter, you use the results of the previous iteration for y, you'll
have a low pass recursive (IIR) filter. The pole can be adjusted by
varying the coefficients. I haven't performed any kind of frequency
analysis on this, but if you take the z transform:

f = y(i+1) = (m*x(i) + n*y(i))/N
zY(z)  = (m*X(z) + n*Y(Z))/N
m*X(z)  = (N*z - n)Y(z)
Y(z)        m        m/N
-----  = -------- = --------
X(z)     N*z - n    z - n/N

The pole, n/N, is always less than one and thus within the 'unit circle'.
Consequently the filter is stable. If you make n small, you get a slower
response. As n approaches N and the pole gets closer to one, the response
is faster.

Now it's possible to cascade these blocks too, and somewhat tailor your
filter's cutoff, ripple, etc...

But theory aside, this simple example ignores many practical issues. The
original code I posted used N=16. This gives you only 4 bits of dynamic
range on your coefficients. You'd be hard pressed getting arbitrary pole
placement with this much dynamic range. Quantization erro will kill you.
But again, it depends on your application.

So, what is it you said you're trying to do?

Scott

Putting in my own two pennies worth, I have an application
that might benefit from a digital lag filter.  Though I can find
a theoretical description, it isn't enough to suggest what
the actual code might be.  Any pointers?
Brian Aase

Hello Jeffrey,

May be all you need is math library. If all you want to remove from
signal is short peaks, exponential filter is enough. It has the
following transfer function
1
W(s)= ------
Ts + 1
Calculation scheme is very simple.
Let us call x the result from ADC and filtered result.
Alpha is  ]0,1[ and determines time constant T. The bigger is alpha,
the smaller is T.
0) measurement ( x = ADC_result )
1) y = x
2) y_before = y
3) measurement ( x = ADC_result )
4) delta = x - y_before
5) y = y_before + alpha*delta ---> the next filtered number is ready
6) goto 3

So all you need is signed addition and multiplication. Be aware of
number of binary digits used to store y_before and to do all
calculation. If your ADC is 8-bit, I think you need 16-bit to get true
exponential filter. Your filter's step response shall look like this

|output
|
|1                 +++++++++++++++++++++++++
|            ++++++
|        ++++
|     +++
|   ++
|  +
| +
|+
+--------------------------------------------------- time
0

Sorry if I say trivial things :))

JS> Does anyone know of a software library (source code) that I could port to
JS> the PIC for real-time filtering?  I'm grabbing A/D data and want to do some
JS> basic artifact removal in software (real-time hopefully, before sending it
JS> to another processor) but I need a starting place of some working code.  Any
JS> language would be fine...

--
Best regards,
Oleg                             remove_this_word.serginfcita.dn.ua

2000\02\18@201824 by
The following useful (to me) idea, though obvious, has just occurred to me.
I offer it for others to consider.

I'm using Internet Exploder 4
PICList generates a vast number of daily messages.
Most are comments rather than new topics.
I often have difficulty locating the original topic referred to.
While it is possible to set my browser up to sort by threads this takes
messages out of overall date order and has certain disadvantages for me.

So

I set up a new mailbox called eg PIC new.

I set a filter to move all PICList incoming  messages with "Re:" in the
title to existing PICList mailbox
I then have a second filter copy all remaining PICList messages to the PIC
new box and THEN move them from inbox to the existing PIC mailbox.

Result: -
ALL PIC messages are in PIC mailbox.
New threads are also in PIC new mailbox.
I can delete these duplicates in due course if I wish.

Hope someone finds this useful :-)

Russell McMahon
_____________________________

>From other worlds - http://www.easttimor.com
http://www.sudan.com

What can one man* do?
Help the hungry at no cost to yourself!
at  http://www.thehungersite.com/

(* - or woman, child or internet enabled intelligent entity :-))

'Data Filtering'
2000\05\09@121322 by
I am working on an application based around a PIC16C715 that monitors the
density a gas in a closed vessel.  If there is a leak in the system, I need
to be able to predict a time-to-alarm value.  I have sensors and
conditioning circuitry that provide pressure and temperature analogs to the
PIC every five minutes.  From these two values, I calculate the density of
the gas.  I want to use the slope of roughly an hour's worth of density
values to calculate the time-to-alarm value.

The basic part of this scheme is fairly straight forward.  Where I am
having trouble is with filtering spurious data values.  In the environment
in which this monitor will be installed, there will definitely be
occassional spike values that if not filtered out, could yield a
time-to-alarm value that would cause undo action.  The filtering must be
done in the PIC code.

I have played all kinds of games with routines to pick out single oddball
values by comparing the relationship with points before and after each
value and throwing out values that are out of whack, by using linear
regression to smooth out an hour's worth of data, etc.  I dropped out of my
stats class in college and struggled through numerical methods.  Now I'm
hurting for it.  Can anybody point me to a source that could provide some
information and methods for data smoothing and filtering?

Thanks.

Mark P

I think what you want is a median filter.  Take multiple samples, sort them,
then pick the one in the middle of the list.  Your spurious readings are
extrema, right?

Andy

Go to this web site and download the original QST article for a GPS based
frequency standard (originally published in QST, July 1998). The software in the
PIC has filtering to stop glitches upsetting the VCO which is locked on to the
satellite. This sounds like the sort of filtering software you are after. You
may be able to get him to supply you with the source code, which you may well be
able to cut and paste into your application.

This time I will try putting the web address in
http://www.rt66.com/~shera/

<x-flowed>At 12:24 PM 5/9/00 -0400, Andy wrote:
>I think what you want is a median filter.  Take multiple samples, sort them,
>then pick the one in the middle of the list.  Your spurious readings are
>extrema, right?

A more efficient, but just as stable, filter is a 10% or 20% trimmed mean:

E.g., collect a set of fixed size (e.g., 6-10), drop the high and low
result and average the remainder. With a set of size 8-10, you could also
drop the next highest and next lowest measurements.

The effective loss of information is only about 1/2 the number of points
dropped.

Obviously filtering of this type will cut the bandwidth by an equivalent
amount.

================================================================
Robert A. LaBudde, PhD, PAS, Dpl. ACAFS  e-mail: rallcfltd.com
Least Cost Formulations, Ltd.                   URL: http://lcfltd.com/
824 Timberlake Drive                            Tel: 757-467-0954
Virginia Beach, VA 23464-3239                   Fax: 757-467-2947

"Vere scire est per causas scire"
================================================================

</x-flowed>
On Tue, 9 May 2000, Robert A. LaBudde wrote:

> At 12:24 PM 5/9/00 -0400, Andy wrote:
> >I think what you want is a median filter.  Take multiple samples, sort them,
> >then pick the one in the middle of the list.  Your spurious readings are
> >extrema, right?
>
> A more efficient, but just as stable, filter is a 10% or 20% trimmed mean:
>
> E.g., collect a set of fixed size (e.g., 6-10), drop the high and low
> result and average the remainder. With a set of size 8-10, you could also
> drop the next highest and next lowest measurements.
>
> The effective loss of information is only about 1/2 the number of points
> dropped.
>
> Obviously filtering of this type will cut the bandwidth by an equivalent
> amount.

Here's an implementation that I put on my web page for Bob Blick:

http://www.dattalo.com/technical/software/pic/medfilt.html

It does the sorting, median filtering, and averaging. It works with 12-bit data
samples and conserves memory by packing two samples into three bytes.

Scott

Hi,

you,

On Tue, 9 May 2000, Mark Peterson wrote:

> I am working on an application based around a PIC16C715 that monitors the
> density a gas in a closed vessel.
[snip]
> I have played all kinds of games with routines to pick out single oddball
> values by comparing the relationship with points before and after each
> value and throwing out values that are out of whack, by using linear
> regression to smooth out an hour's worth of data, etc.  I dropped out of my
> stats class in college and struggled through numerical methods.  Now I'm
> hurting for it.

Could we learn what was the problem with trials described above?

Regards,
Imre

I did not see my correction for the missing URL posted on the list, so will
repost it now. Sorry if this results in a repeat message in your mailbox.

Go to this web site and download the original QST article for a GPS based
frequency standard (originally published in QST, July 1998). The software in the
PIC has filtering to stop glitches upsetting the VCO which is locked on to the
satellite. This sounds like the sort of filtering software you are after. You
may be able to get him to supply you with the source code, which you may well be
able to cut and paste into your application.

This time I will try putting the web address in
http://www.rt66.com/~shera/

Hi,
I have an recursive moving average filter,
52 points with 3 bytes each, which works ok.
However the ram usage is 'a bit' high :-)
( almost the entire two top ram banks on my 16f876, )

Are there any other, more space conservatory, techniques
one could use to accomplish the same filtering ?

I do have 24 bit's of data for each sample, ofcource
not all bit's will change from one sample to next. But
was thinking of implementing an variable window ( 8 - 56 samples )
moving average filter to have an faster step-responce.
( big step = small window, little step = big window,

This however will not affect the ram usage, but also
was thinking about only saving the difference in successive
samples ( maybe 1.5 - 2 bytes ) and if difference is more
'reset' filter ( make the window very small ) until once
again the samples are in range. But think that this might
require quite abit of code to accomplish.

Anyone have any ideas ? or expirience with this ?

/Tony

Tony KŸbek, Flintab AB
ÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓ
E-mail: tony.kubekflintab.com
ÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓ

12/5/2000

This depends on what the actual data is to represent and the
procesing time that you have for each sample. If you have time, then you
could look at each sample as a delta function on change from the last. This
could means that if the data is converted to 4 bits (this can even be done
by breaking up the sample into nybbles), and then apply the filter function
to each with the required weighting. Of course this will make the filter run
three times longer but save 2/3s the RAM.

Dennis

> {Original Message removed}
KŸbek Tony <PICLISTMITVMA.MIT.EDU> wrote:

> I have an recursive moving average filter, 52 points with 3 bytes
> each, which works ok. However the ram usage is 'a bit' high :-) (
> almost the entire two top ram banks on my 16f876, )
>
> Are there any other, more space conservatory, techniques one could
> use to accomplish the same filtering ?

Tony:

The usual way to solve this problem is this:

TEMP = AVERAGE * WIDTH
TEMP = TEMP - AVERAGE
TEMP = TEMP + NEW_SAMPLE
AVERAGE = TEMP/WIDTH

If you do it that way, you need only enough storage for TEMP,
AVERAGE, and your NEW_SAMPLE.  If you set WIDTH to a power of 2, the
multiplication and division become trivial; if you pick a value of
256, the multiplications and divisions don't even require any code.

-Andy

=== Andrew Warren - fastfwdix.netcom.com
=== Fast Forward Engineering - San Diego, California
=== http://www.geocities.com/SiliconValley/2499

At 09:28 PM 5/11/00 -0700, you wrote:
>KŸbek Tony <PICLISTMITVMA.MIT.EDU> wrote:
>
>> I have an recursive moving average filter, 52 points with 3 bytes
>> each, which works ok. However the ram usage is 'a bit' high :-) (
>> almost the entire two top ram banks on my 16f876, )
>>
>> Are there any other, more space conservatory, techniques one could
>> use to accomplish the same filtering ?

It sounds like you have implemented an FIR filter with 52 taps.

What Andy has suggested is an IIR.  You can plug both of these into matlab
and compare the filter responses to see if the IIR is adequate.

I forget the exact transfer functions for both, but any introductory DSP or
linear systems book will have them in there.

{Quote hidden}

Erik Reikes
Senior Software Engineer
Xsilogy, Inc.

ereikesxsilogy.com
ph : (858) 535-5113
fax : (858) 535-5163
cell : (858) 663-1206

Thanks to all who responded, I will whip up Matlab
and se what effect will come of the FIR vs. IIR filters.
If it has the filtering/freq responce(damping) I need
then one could not comlain about ram usage :-) .

Dennis wrote:
>This depends on what the actual data is to represent and the
>procesing time that you have for each sample. If you have time, then
you

Data is from an AD7730 ( Transducer ADC ) measuring on strain gauges
in 2mV/V range. 5V AC to feed the brigde, will give me at most
10mV->24Bits
input signal. Aiming for, at least, 1uV verifiable resolution.
I want to cater for both high filtering application
where data output should be very stable but also applications where
a fast step-responce is crucial ( thats why the variable window idea ).
And yes I have quite a bit of 'free' time, I dont think data processing
time would pose as a problem.
( I'm more concerned over ram usage :-) )

All in all fun stuff...

/Tony

Tony KŸbek, Flintab AB
ÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓ
E-mail: tony.kubekflintab.com
ÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓ

<x-flowed>At 09:28 PM 5/11/00 -0700, Andy wrote:
>KŸbek Tony <PICLISTMITVMA.MIT.EDU> wrote:
>
> > I have an recursive moving average filter, 52 points with 3 bytes
> > each, which works ok. However the ram usage is 'a bit' high :-) (
> > almost the entire two top ram banks on my 16f876, )
> >
> > Are there any other, more space conservatory, techniques one could
> > use to accomplish the same filtering ?
>
>Tony:
>
>The usual way to solve this problem is this:
>
>     TEMP = AVERAGE * WIDTH
>     TEMP = TEMP - AVERAGE
>     TEMP = TEMP + NEW_SAMPLE
>     AVERAGE = TEMP/WIDTH

The simplest method is to use an exponentially-weighted, moving average filter:

where
NewData = current data point (measurement)
alpha   = weighting factor

This is asymptotically equivalent to a moving average filter of run length
approximately 1/alpha. So alpha = 0.125 would roughly correspond to an
8-sample moving average, etc.

Notes:

1. Obviously there is a time lag between the filtered estimate and the
latest data (as there is in all integration filters) of about 1/(2 alpha)
samples.

2. If you are concerned about the increased error in the first few samples,
you can generate a slightly more complicated optimum (Kalman) filter. (This
involves a changing weighting factor).

3. The optimum value for alpha is about equal in magnitude to the 1-order
autocorrelation of the data.

================================================================
Robert A. LaBudde, PhD, PAS, Dpl. ACAFS  e-mail: rallcfltd.com
Least Cost Formulations, Ltd.                   URL: http://lcfltd.com/
824 Timberlake Drive                            Tel: 757-467-0954
Virginia Beach, VA 23464-3239                   Fax: 757-467-2947

"Vere scire est per causas scire"
================================================================

</x-flowed>
KŸbek Tony wrote:
>measuring on strain gauges
>in 2mV/V range. 5V AC to feed the brigde

Curious: Why AC to the bridge?

/Morgan

On Fri, 12 May 2000, Robert A. LaBudde wrote:

{Quote hidden}

Another way to view this formula is:

And taking Robert's alpha=1/8 example:

NewEst = (7/8) *OldEst + (1/8)*NewData
=  ( 7*OldEst + 1*NewData) / 8

This formula is efficiently computed with this routine:

http://www.dattalo.com/technical/software/pic/twist.asm

I wrote it to adjust the relative wieghts of DTMF tones, but it works equally
well for these one-pole IIR filters. This version works for 8-bit values instead
of 24-bit values. However the efficiency concept is equally valid regardless of
the size of the data (it's the coefficients of the filter that are tweaked).

{Quote hidden}

I posted an analysis of the frequency response of this filter back in Jan '00. I
don't have time to search the archives now. If you're going to perform any
matlab analysis this could be of use.

Scott

> From: KŸbek Tony
>
> Thanks to all who responded, I will whip up Matlab
> and se what effect will come of the FIR vs. IIR filters.
> If it has the filtering/freq responce(damping) I need
> then one could not comlain about ram usage :-) .

A couple of things to take into account with digital filters:  While FIR
filters are more memory and computationally intensive, they do have one
great advantage, they are universally stable- no matter what, if you have a
filter that is N taps long, no input more than N+1 delays ago will affect
the output.  IIR (*Infinite* Impulse Response) filters have no such bound.
IIR filters can have stability problems (meaning that it may oscillate after
an input, possibly out of control).  In a system like a PIC where you are
most likely to use fixed point math, you must be much more careful in
implementing the filter and studying the effects of quantization, sampling
rate, and a limited dynamic range on your filter.  Doing your analysis in
Matlab can give you a false sense of security, unless you build these things

Bang for the byte- IIR is best, but sometimes, an IIR will misfire.

Matt Bennett

http://www.dspguide.com/

-Randy Glenn
PICxpertANTISPAMtechie.com (remove ANTISPAM)
http://i.am/PICxpert

"My Finder has died of fits, chokin',
My Finder has quite ceased to be.
OS X's new Finder looks broken,
Please bring back my Finder to me!" - A concerned Mac user

===========
To unsubscribe, send a message containing the text "unsubscribe PICLIST" to
LISTSERVMITVMA.MIT.EDU

Any questions about the list? http://www.piclist.com/

{Original Message removed}
>Curious: Why AC to the bridge?
>/Morgan

:-) , why not ?

Just kidding, the AD7730 can drive an brigde in AC-mode
where the excitation ( DC ) for the bridge is reversed
on alternate cycles hence the term 'AC'. This will 'elliminate'
thermocouple, offset and drift effects that one has in DC mode.
I.e. illiminate most DC errors.
Just a tad more complex system but much better performance.
( the only drawback is the settling time for the input after
the swithing, but even that is easily handled, for example
the AD7730 has an delay register to cater for this )
Optionally I will also drive the bridge with 10V ( +7.5 - -2.5 ) to get
more input.

/Tony

Tony KŸbek, Flintab AB
ÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓ
E-mail: tony.kubekflintab.com
ÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓ

Hi again,

Scott Dattalo wrote:
>I posted an analysis of the frequency response of this filter back in
Jan '00. I
>don't have time to search the archives now. If you're going to perform
any
>matlab analysis this could be of use.

Cant seem to find it ? ( not in january atleast ).

Anyway my initial findings indicate that these filters are
, as stated by others, not equal. They have different freq.
responce and calculation properties.
The FIR I implemented is, albeit memory hungry, very fast
to calculate and have a linear step-responce.
( one additon and one subtraction/sample after initialisation )
I will look at the 'twist' routine by Scott and see what could
come out of it with some modifications to 24 bit, but I doubt
it will be more suitable than the original FIR.
I'm concered about the non-linear step-reponce in the IIR filter,
but it might not matter in the end.

But I'm by no means literate in filtering so I'm probably wrong :-).

Robert wrote:

>2. If you are concerned about the increased error in the first few
samples,
>you can generate a slightly more complicated optimum (Kalman) filter.
(This
>involves a changing weighting factor).

Do you mean that the weighing should leans towards the new sample
more at the start ? In that case that was my idea, I would also
use this in the 'running' filter to increase the step-repsonse.
( would have a similar effect as the variable window in the FIR )

>
>3. The optimum value for alpha is about equal in magnitude to the
1-order
>autocorrelation of the data.

Sorry, dont know if it's my english, but I dont really understand what
You mean here.

Nice to read all the comments though, never to late to learn.

/Tony

Tony KŸbek, Flintab AB
ÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓ
E-mail: tony.kubekflintab.com
ÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓ

<x-flowed>At 01:25 PM 5/13/00 +0200, Tony wrote:
>Anyway my initial findings indicate that these filters are
>, as stated by others, not equal. They have different freq.
>responce and calculation properties.

True. You adjust those parameters to suit requirements.

>The FIR I implemented is, albeit memory hungry, very fast
>to calculate and have a linear step-responce.

The IIR EWMA formula I gave [ Y(n+1)=Y(n) + alpha*(X(n+1)-Y(n)) ] is about
as simple as it gets.

The formula is linear, so the filter is linear. I don't see the advantage
of a 'linear step-response'.

{Quote hidden}

The Kalman filter is (without an error term) the exact average of all the
data so far experience, with a formula in recursive form.

The presence of a stochastic term de-tunes those exact formula to not
feedback all the information in the next same to the next filtered value.

The asymptotic form of the Kalman filter (after 100 samples or so for
transients to die out) is the EWMA form I gave above. The size of 'alpha'
is dictated by the relative size of the stochastic term. As I mentioned
before, the simplest interpretation is 1/alpha   ~ window length of a
moving average. In actuality, the weighting coefficients are alpha,
alpha^2, ..., a exponentially declining (geometric) series.

> >3. The optimum value for alpha is about equal in magnitude to the
>1-order
> >autocorrelation of the data.
>
>Sorry, dont know if it's my english, but I dont really understand what
>You mean here.

This is true only for small autocorrelation, in any event.

An 'exact' formula is:

autocovariance: C(k) = sum(k+1,n) {[ X(i)-Xave]*[X(i-k)-Xave]} /n

autocorrelation: r(k) = C(k)/C(0)

alpha = [1-sqrt( 1 - 4 r(1)*r(1) )]/(2*r(1))

This is 'invertible' (i.e., stable) for abs(r(1))<1/2.

================================================================
Robert A. LaBudde, PhD, PAS, Dpl. ACAFS  e-mail: rallcfltd.com
Least Cost Formulations, Ltd.                   URL: http://lcfltd.com/
824 Timberlake Drive                            Tel: 757-467-0954
Virginia Beach, VA 23464-3239                   Fax: 757-467-2947

"Vere scire est per causas scire"
================================================================

</x-flowed>
Robert wrote:

>The IIR EWMA formula I gave [ Y(n+1)=Y(n) + alpha*(X(n+1)-Y(n)) ] is
>as simple as it gets.

Yes, ofcource but as it uses multiplication ( even though
one could simplify with shifting data ) I meant that the
FIR with only addition and subtraction is 'lighter'.
And concerning PIC's in particular, to avoid rounding errors
one alomost is FORCED to use an 'alpha' that is 2,4,8,etc .
In the case of FIR the only time an 'uneven' window size matter
is during initialisation of the filter ( which is not required really ).
the FIR, but using the IIR i'm more or less forced to step up/down )

But anyway as the ram usage for this IIR filter is very low compared
to the FIR I will probably have both version and try them out in
'real life'.

>The presence of a stochastic term de-tunes those exact formula to not
>feedback all the information in the next same to the next filtered
value.
>The asymptotic form of the Kalman filter (after 100 samples or so for
>transients to die out) is the EWMA form I gave above. The size of
'alpha'
>is dictated by the relative size of the stochastic term. As I mentioned
>before, the simplest interpretation is 1/alpha   ~ window length of a
>moving average. In actuality, the weighting coefficients are alpha,
>alpha^2, ..., a exponentially declining (geometric) series.

Thanks, very clear and consice, I think I'm starting to understand
more of the implifications now.

/Tony

Tony KŸbek, Flintab AB
ÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓ
E-mail: tony.kubekflintab.com
ÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓ

I did not see my correction for the missing URL posted on the list, so will
repost it now. Sorry if this results in a repeat message in your mailbox.

Go to this web site and download the original QST article for a GPS based
frequency standard (originally published in QST, July 1998). The software in the
PIC has filtering to stop glitches upsetting the VCO which is locked on to the
satellite. This sounds like the sort of filtering software you are after. You
may be able to get him to supply you with the source code, which you may well be
able to cut and paste into your application.

This time I will try putting the web address in
http://www.rt66.com/~shera/

We (the list admins) have found a new feature in the list server software
that may provide a much better way of handling on and off topic (and sort of
off topic, etc..) posts. It would cause the list to work a bit differently
and might cause some confusion at first so we want to explain it and get
some feedback from the list on how best to implement it.

The new version of the list server can track "topics" by looking for
keywords or tags at the start of the subject line (after skipping past the
fw: or re:). It will then filter posts FOR the list members according to
which topics they wish to receive. For example, if we set the possible
topics to:
we can set "topics of interest to subscribers" to [PIC] only and you will
only see posts with subject lines that start with "[PIC]:" (or "re: [PIC]:"
or "FW: [PIC]:" etc...). Of course you can send a simple command to the list
server that "turns on" the other topics as well. For example if you also
wanted to see [EE] posts (not directly related to the PIC, but still about
engineering) you could send:
LISTSERVMITVMA.MIT.EDU?body=SET PICLIST TOPICS: +[EE]

Now, that is not the really good part.... here it is... <GRIN> if someone
DOESN'T put a topic tag at the start of the subject line, the list server
puts the post in a special topic called "OTHER" and if you haven't told the
listserver that you want "OTHER" posts, you wont get it! Cool huh?

The default settings for new subscribers will be with all topics including
OTHER turned ON so if they post without a topic, they will see their own
post. Also, we can set up an autoresponder that gets ONLY "OTHER" posts and
replies with a nice message that says "Um, you forgot to add [PIC]: [EE]:
[OT]: or [AD]: to your subject line, so, pretty much, I'm the only person
who saw your post, didn't you read the welcome message or the piclist.com
page?" followed by an explanation of what the topic tags mean, a mailto link
to turn off the OTHER topic (and the... other ([EE], [OT], [AD]) topics as
well), and a brief review of the list guidelines. And before anyone freaks
about looping on the autoresponder idea, we will put an [AUTOMATIC RESPONSE]
tag in and the autoresponder will know not to autorespond to posts
containing that.

Now, this is all a bit backwards from the way we are doing it now; rather
than asking that people be good and add [OT] to off topic posts, we will say
that all posts are not only off topic, but also completely ignored by
everyone but the autoresponder, unless you remember to put the topic at the
start of the subject line.

To get to the list and be read by all us members who are interested in
PIC's, a person will have to type [PIC]: at the start of the subject line.
This has the huge benefit of reminding people to think about whether or not
their post is really about PIC's. I personally think that this is an easy,
automatic and very complete solution to the problem of constant off topic
posting on the list. If it's really not about [PIC]:, you can add [EE]: or
[OT]: or [AD]: and it will go though to those people.

Using the same [OT], [EE] and [AD] strings for the topic names will allow
people who have set up automatic filters, sorters and classification rules
to continue using them. I know a lot of people move [OT]'s into a separate

Of course, replying to an existing post will not change at all and people
may still take a [PIC]: related thread off into never, never land, but...
admins have to have something to do right? The no-HTML thing has been such a
big help that this list may get to be semi-self running and then we can
focus on other things like improving the FAQ or archives.

Ok, sorry for the long explanation, but we think this is an important new
direction for the list and will solve a lot of problems and make life a lot
nicer for members. What do you think?

---
jamesnewtonpiclist.com 1-619-652-0593
PIC/PICList FAQ: http://www.piclist.com or .org

I personally hate having machines think for me.

I would hope the default for current members would be to enable everything, and
only if they don't want it they can opt-out.

Andy

On Tue, 16 May 2000, Andrew Kunz wrote:

> I personally hate having machines think for me.

Me too, they're so much better at it
>
> I would hope the default for current members would be to enable everything, and
> only if they don't want it they can opt-out.
>
> Andy
>
it would be a nice feature if the system would "drop" posts you make
that didn't conform to the categories you were registered for.
E.g. if I only wanted to hear about PICS (which is why I joined the
then I would register for [PIC], ok so far. Now if I post something
without [PIC] I would hope that the system would throw my post away
as I would not get to see any of the responses.

Hmmmm,
Pete

Yes, the default for new (and old) members would be for all the topics to be
enabled. Most current members would turn off the OTHER: topic pretty quick.
Anyone who didn't want off topic discussions would turn off [OT]: Don't want
posts? Off goes [EE]: That leaves just [PIC]: as the minimum...

---
jamesnewtonpiclist.com 1-619-652-0593
PIC/PICList FAQ: http://www.piclist.com or .org

-----Original Message-----
From: pic microcontroller discussion list
[PICLISTMITVMA.MIT.EDU]On Behalf Of Andrew Kunz
Sent: Tuesday, May 16, 2000 10:29
To: PICLISTMITVMA.MIT.EDU
Subject: Re: BIG NEWS! Server Topic Filtering [ADMIN]

I personally hate having machines think for me.

I would hope the default for current members would be to enable everything,
and
only if they don't want it they can opt-out.

Andy

Correct, Actually it would tag it as being of topic OTHER: and send it only
to people who have OTHER: turned on.

---
jamesnewtonpiclist.com 1-619-652-0593
PIC/PICList FAQ: http://www.piclist.com or .org

{Original Message removed}
What would happen, say, if you had [PIC] turned on but [AD] turned off
but they were both in the subject line?

Thanks,

Jeff

The following is an off-topic joke:
> ----------------------------------------------------------
> YOU HAVE NOW RECEIVED THE UNIX VIRUS
>
> This virus works on the honor system:
>
> If you're running a variant of unix or linux, please forward this message
> to everyone you know and delete a bunch of your files at random.

I'm concerned that we now have to add a [PIC] tag. I mean this is what
the list is all about, most posts are about it (yup, believe it or not
:-) ) and the changes you propose is to filter out all the other stuff
from the PIC stuff. Now you want PIC posts on a PIC list to be filtered
as well.

Or am I missing the boat here?

Quentin

The way it works is that if someone sends a message with topics [PIC]
and [AD], and you have EITHER [PIC] or [AD] one turned on, you get the
message.

So, use filtering, Trash anything with [AD] in it, is the best I can
suggest.

Mark

Jeff Frohwein wrote:
{Quote hidden}

--
I re-ship for small US & overseas businesses, world-wide.
(For private individuals at cost; ask.)

That is a very good point and is the one down point I can see in this.

Right now, if you want to post something about PICs to the PICList, you have
to:
A) Click on "New Message" or whatever button triggers your email client to
send email
B) Enter PICLISTMITVMA.MIT.EDU in the "To..." field
C) Enter a subject line
D) Enter the post text in the body.

With the new system, step C would be modified to read:
C) Enter [PIC]: and the rest of the subject line.

Replying to a message would not be any different.

So... we are talking about requiring 6 extra keystrokes when posting. Its
not a lot, but it is extra work and I do understand that basically, this is
asking 99% of the PICList to do (a little) more so that the 1% that can't
bother to add [OT] reliably, will be reminded that they are on the subject
of PICs.

That's why we are asking for feedback on this idea. I still think its the
way to go, but I really will respect whatever the bulk of the list decides.
It may just not be worth it.

---
jamesnewtonpiclist.com 1-619-652-0593
PIC/PICList FAQ: http://www.piclist.com or .org

{Original Message removed}
Notice however, that any posts marked [ADMIN] would go to the [OTHER]
autoresponder, and get a rude message back :) Just a thought...

Josh Koffman
joshymb.sympatico.ca

Awww, you spoiled my surprise for James <G>

Mark

Josh Koffman wrote:
> Notice however, that any posts marked [ADMIN] would go to the [OTHER]
> autoresponder, and get a rude message back :) Just a thought...
>
> Josh Koffman
> joshymb.sympatico.ca

I'm still getting some posts marked [OT] after I used the new
commands to reject these posts. I'm wondering if it was
abandoned, or if I did something wrong. I did get a response from
the server indicating that the removal of [OT] was sucessfull, but
still get them (I dont know if I get all of them or not).

> I'm still getting some posts marked [OT] after I used the new
> commands to reject these posts. I'm wondering if it was
> abandoned, or if I did something wrong. I did get a response from
> the server indicating that the removal of [OT] was sucessfull, but
> still get them (I dont know if I get all of them or not).

It has not yet been adandoned.  The reason you are still getting
posts labelled [OT] is because many folks *still* aren't using the
tags correctly.  To correctly use the tags, there *MUST* be a colon
directly after the tag.  And many folks are forgetting the colon.
Either that, or just not even bothering with the tags at all.

This is kinda important, so I'll go over it all again:

THERE MUST BE A COLON AFTER THE TOPIC TAG!

The topic tags are:
[PIC]: - for discussion of Pics and Pic related hardware (such as
Pic programmers).
[EE]:  - Discussion of topics not necessarily directly related to
Pic micros, but of interest to the EE community.
[AD]:  - Posts of a commercial nature, such as iems for sale, also
[OT]:  - Posts that don't fit the above topics.

The tags go at the *beginning* of the subject line, not at the end.
When replying to a tagged post, the Re: of Fw: that the email program
puts on the front of the subject line is okay - the server can deal
with those.

AND DON'T FORGET THE COLON!

::wanders off mumbling::  Wonder if that'll get it across ...
--
Mike Werner  KA8YSD           |  "Where do you want to go today?"
|  "As far from Redmond as possible!"
'91 GS500E                    |
Morgantown WV                 |  Only dead fish go with the flow.

We are working on it - I was going to get a post out but got swamped
this weekend.

The problem that happens is that senders MUST send a post with "[OT]:"
for the filter to work properly - if that colon is not there, it's
classified as an "Other" category post.  Send the output of "Query
PICList" my way if you don't see how to turn off the other category (of
course, if you do that, you'll lose any post from someone who's not
properly setting theit topic - This post included!)

We need more education on the list, I need to get on it.

Mark

>
> I'm still getting some posts marked [OT] after I used the new
> commands to reject these posts. I'm wondering if it was
> abandoned, or if I did something wrong. I did get a response from
> the server indicating that the removal of [OT] was sucessfull, but
> still get them (I dont know if I get all of them or not).

--
I re-ship for small US & overseas businesses, world-wide.
(For private individuals at cost; ask.)

Hi,
Recently I asked the list of various techniques for
filtering ( in particular lowpass ). I received some excellent
replies and managed to implement most of them to try with
real-life data. My findings so-far is that, even though
fast step responce and high damping are normally, well,
opposite each other, I achived VERY good result by combining
an FIR with an IIR. I known to filter an filtered signal is
not really recommended but in this case, as the FIR
always are garantued to include all values within an specific range
( as the value just outside window is removed ) I though
that this should not impose any weird behaviour.
Anyway by using an FIR ( recursive average filter ) of fairly
small length 8,16 or 32 samples, feeding each new value into an
variable step IIR filter I get real life accuracy below 100 nV
( and this in an laboratory, i.e. all cables are loose
no ground-planes etc ). Measuring the delta between the FIR and current
FIR
very fast step responce when signal is variating and very high
dampening when signal is fairly stable.
The FIR's task in this case is ( mostly ) to remove low freq.
high amplitud disturbances ( for example an +/- 400 uV at 7 Hz )
of cource it will also filter out most noice ( +/- 200 nV ) also.

Are there something I'm missing here ? Can this setup cuase any
side effects ?

/Tony

Tony KŸbek, Flintab AB
ÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓ
E-mail: tony.kubekflintab.com
ÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓ

'[PIC]: Suggest an approach to this filtering probl'
2001\07\09@160720 by
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 listservmitvma.mit.edu with SET PICList DIGEST in the body

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

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
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 listservmitvma.mit.edu with SET PICList DIGEST in the body

> 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, olinembedinc.com, http://www.embedinc.com

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

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
piclist-unsubscribe-requestmitvma.mit.edu

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}
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 <dbutlerIMETRIX.COM>
To: <PICLISTMITVMA.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}
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
can't change significantly fast or this'd frag.

!???
-Dal
----- Original Message -----
From: Dal Wheeler <dwheelerinsightek.com>
To: pic microcontroller discussion list <PICLISTMITVMA.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}
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.

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

--

'[PIC]:Digital filtering using a PIC'
2001\08\13@080005 by
Hello for all.

I'm looking for way to do
60Hz BAND-PASS FILTER and
60Hz NOTCH FILTER using a PIC.
Is it possible to do this with a PIC?
Have you ever seen something like this?
Thanks in advanced goes any help    Luís Fernando

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

Yeap ... it's possible....
.... try with the IIR filters algorithms of the embedded handbook.

----------------------------------------------------------
Ing. G. Quilosa
Development Dept.
----------------------------------------------------------

----- Mensaje original -----
De: antoniasse <antoniasseBRAILE.COM.BR>
Para: <PICLISTMITVMA.MIT.EDU>
Enviado: lunes 13 de agosto de 2001 9:01
Asunto: [PIC]:Digital filtering using a PIC

Hello for all.

I'm looking for way to do
60Hz BAND-PASS FILTER and
60Hz NOTCH FILTER using a PIC.

Is it possible to do this with a PIC?

Have you ever seen something like this?

Thanks in advanced goes any help

Lums Fernando

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

_________________________________________________________
Do You Yahoo!?

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

In article <001f01c123f4\$6bb91a90\$0101a8c0@desarrollo01>, Ing. Gustavo Quilosa <quilosabeyahoo.com> wrote:
> Yeap ... it's possible....
> .... try with the IIR filters algorithms of the embedded handbook.

Doesn't that depend on the signal's sample rate?

> De: antoniasse <antoniasseBRAILE.COM.BR>

> I'm looking for way to do
> 60Hz BAND-PASS FILTER and
> 60Hz NOTCH FILTER using a PIC.

--
Harald Milz           |     hmlinux-magazin.de     | If a messy desk stands
Linux New Media AG    | phone  +49 (0) 89 993411-20 | for a messy mind, what
Stefan-George-Ring 24 | fax    +49 (0) 89 993411-99 | does an empty desk
D-81929 Muenchen      | http://www.linux-magazin.de | stand for ?

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

part 1 1641 bytes content-type:text/plain; charset=us-ascii
for 60Hz notch... sample at an even harmonic frequency and average the
result.

Scott F. Touchton
1550 Engineering Manager
JDS Uniphase

Harald Milz
<hmilz@LINUX-M        To:     PICLISTMITVMA.MIT.EDU
AGAZIN.DE>            cc:
Sent by: pic          Subject:     Re: [PIC]:Digital filtering using a PIC
microcontrolle
r discussion
list
<PICLIST@MITVM
A.MIT.EDU>

08/13/01 12:12
PM
to pic
microcontrolle
r discussion
list

In article <001f01c123f4\$6bb91a90\$0101a8c0@desarrollo01>, Ing. Gustavo
Quilosa <quilosabeyahoo.com> wrote:
> Yeap ... it's possible....
> .... try with the IIR filters algorithms of the embedded handbook.

Doesn't that depend on the signal's sample rate?

> De: antoniasse <antoniasseBRAILE.COM.BR>

> I'm looking for way to do
> 60Hz BAND-PASS FILTER and
> 60Hz NOTCH FILTER using a PIC.

--
Harald Milz           |     hmlinux-magazin.de     | If a messy desk
stands
Linux New Media AG    | phone  +49 (0) 89 993411-20 | for a messy mind,
what
Stefan-George-Ring 24 | fax    +49 (0) 89 993411-99 | does an empty desk
D-81929 Muenchen      | http://www.linux-magazin.de | stand for ?

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

part 2 3178 bytes content-type:application/octet-stream; (decode)

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

Hey Luis,

We did somehting similar, you can have a look at my webpage. Look under
filters, there's some files that may help (FIR implemenetaion, but should
give an idea).

(Though, I must say I dont think you really need to do this on a PIC!)

Regards,

S. Sinha (Saurabh)
----------------------------------------------------------------------------
----
Tel: (012) 343-4912
Cell: 0825405577
Visit: http://home.mweb.co.za/si/sinha ['H']
Visit: http://ieee.up.ac.za/members/saurabhs ['W']
me!]
ICQ: 82010326
work)

{Original Message removed}
On Mon, 13 Aug 2001, Scott F. Touchton wrote:

>
> for 60Hz notch... sample at an even harmonic frequency and average the
> result.
>

With the added benefit that you'll notch 30Hz, 15Hz, 7.5Hz, ...
and in general 60/N Hz, including when N -> inifinity. In other words,
you'll filter DC too!

I'm not sure of the application, but you'll probably want to filter
60Hz by integrating over 1/60'th of a second time interval. For
example, if you had a voltage to frequency converter as your A/D then
you can count the pulses it emits for 16.6666 mSec. Or if you have a
successive approximation A2D, then you could synchronously sample say
60*16 times per second and average the last 16 samples (add them
together and then shift right 4) to get a representation of the
signal minus 60Hz. Note that both of these suggestions are really low
pass filters with a notch at 60Hz and not Notch filters per-se.

Scott

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

Hello Luis,

Absolutely possible. We did a full elliptical filter on a processor with 20%
of the Pic's power to filter flourescent light from an IR signal. You
obviously already have the problem well in hand since you are dealing with a
slow frequency. We used a commercial filter design package to determine
coefficients and algorithms, then determined sampling rates that would a) be
amenable to fixed point processing and b) allow some of the terms to drop
out. Since most of the filtering work is done by multiplying finite values
by trig functions, we used a lookup table to accomplish the multiply by a
factor, then by a trig function.

The result had virtually no gain in the pass band and an extremely fast drop
off.

Tom

> {Original Message removed}
Cheers, Vasile

On Mon, 13 Aug 2001, Saurabh Sinha wrote:

{Quote hidden}

> {Original Message removed}

'[EE]: What is low pass filtering'
2002\02\28@094347 by
This may sound like a dumb question, but I have not run across a good "plain
English" description of low-pass.  I completely understand low-pass
filtering with regards to RF and AF.  But when it comes to this stuff, I am
unsure of what it means.  I am under the impression that it is logically
related to the process of low-pass filtering AF and RF but not necessarily
physically related.  By my thinking, it is a way of obtaining a general (but
accurate) "reading" of some type of signal, without processing all the
minutia.  If someone could kindly point me to some "understandable"
description of the process along with some simple examples I would be much
appreciative.  I am thinking that I have probably incorporated this process
without "knowing" it.  To me, this is like PID a fairly simple idea with a
complex definition.

Michael Brown
Instant Net Solutions
http://www.KillerPCs.net

"In the land of the blind, he who has one eye is king"

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

michael brown wrote:
>This may sound like a dumb question, but I have not run across a good
>"plain
>English" description of low-pass [...]

A time-varying signal can be represented as a function of time, f(t).
The same function can be represented in "frequency space" via a linear
transformation called the Fourier transform as F(w), which tells you
how much sinusoidal component the original function has at each
frequency w (read as omega). If you know much linear algebra, you can
think of f(t) and F(w) as being vectors related through a change of
basis, though of course we are talking here about an infinite-
dimensional function space rather than the (possibly) more familiar
finte-dimensional euclidean vector space. A low-pass filter is very easy
to define in frequency space: it lets through the low-frequency
components but blocks the high-frequency components. Mathematically,
you Fourier transform the original function, multiply by the filter
function (as represented in frequency space), then invert the Fourier
transform to get the filtered time-varying signal.

Hm, this isn't really "plain English" is it? Try again.

A low-pass filter lets the slowly-varying part of a signal through,
but blocks the quickly-varying part. Like, if you had a 1kHz wiggle
superimposed on 60Hz mains voltage, then after filtering with an
appropriate low-pass filter, you would recover the 60Hz part with the
1kHz wiggle blocked out. A simple low pass filter is a resistor
followed by a capacitor to ground:

Vin o----^v^v^v---*-----o Vout
(Resistor)  |
---
--- (Capacitor)
|
GND o-------------*-----o GND

(Please excuse my hideous ASCII "graphics"). The capacitor serves to
shunt any high-frequency component of Vin to ground (a capacitor has
low impedance to high-frequency, high impedance to low-frequency). It
is easy to show that the 3dB point of this filter is at 1/(2 pi R C).
In frequency space, this simple filter falls off at higher frequencies
rather gently: it is not a very precise low-pass filter. For better
filtering you can use active filters.

Michael V

Thank you for reading my "little" posting.

_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.com

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

See below

> michael brown wrote:
> >This may sound like a dumb question, but I have not run across a good
> >"plain
> >English" description of low-pass [...]
>
> A time-varying signal can be represented as a function of time, f(t).
> The same function can be represented in "frequency space" via a linear
<SNIP>
>
> Hm, this isn't really "plain English" is it? Try again.

Not to me, it pretty much reads like the rest of the "explanations" I've
seen.  ;-)

> A low-pass filter lets the slowly-varying part of a signal through,......
<SNIP>

DSP's are good.

filtering electrical or electro-magnetic "waves".  I am looking for the
definition as it applies to EE and sampled data.  Also I hear/see the term
"integrate" and am not completely clear as to what this means in the context
of EE and data samples.  I hear these terms being used frequently, but I've
never taken any EE type classes, so I'm not sure what it means.  Never took
a calculus class either.

michael brown (unedumacated foole)

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

michael brown wrote:
>
>filtering electrical or electro-magnetic "waves".  I am looking for the
>definition as it applies to EE and sampled data.

One simple approach to digital low-pass filtering is just to do a
windowed average. That is, if you have a sequence of measurements
(samples) of a signal, then you average together every N of them
(like every pair, or every 10, or every 10000, as appropriate). In
this way, you average out the high-frequency "wiggles" and get just
the lower-frequency variations in the signal. By "average" I mean
exactly what you think I mean: add them up and divide by the number N.

>Also I hear/see the term
>"integrate" and am not completely clear as to what this means in the
>context
>of EE and data samples.

"Integrate" in the case of discrete samples just means "add 'em up".
Same as the averaging technique I mentioned above.

Michael V (still trying to be helpful...)

Thank you for reading my little posting.

_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.com

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

Hi,

> filtering electrical or electro-magnetic "waves".  I am looking for the
> definition as it applies to EE and sampled data.  Also I hear/see the term
> "integrate" and am not completely clear as to what this means in the
context
> of EE and data samples.  I hear these terms being used frequently, but
I've
> never taken any EE type classes, so I'm not sure what it means.  Never
took
> a calculus class either.

There are many ways to describe a low pass filter, let's see if I can
make it without the math...

Imagine a wide water tube that is connected to a swimming poll by a
narrow tube. The water level on the wide tube will follow the poll level but
will be much less "wavy" than the pool. That is a low pass filter for water
level, the wide tube does the function of the capacitor and the narrow tube
is the resistor.

On the algorithm side... If you take 8 samples of a signal and average
them to decide what the 9'nth sample will be and keep doing that with the
last 8 samples all the time you have a low pass filter also, you will
minimize the effect of fast varying signals in your sample window. Finite
impulse response filters, very used in DSP's, are almost impossible to
describe without the math :-( Imagine that a low pass filter is always
something that "smooths" the signals.

Hope this helps...

best regards,
Alexandre Guimaraes

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

Let's try plainer plain Inglitsch:

A low pass filter will allow low frequencies through without much loss, will
tend to block high frequencies, and at some magic frequency determined by
the values of the components will attenuate the signal by about half.
Frequencies above this are attentuated more, below this are attenuated less.

A classic low pass filter (there are dozens of different types) is simply:

Vin--------R--------OUT
|
C
|
GND

This is useful in PICs to take a high frequency signal, say a PWM output,
and turn it into a smooth nearly DC signal, say for an input to a
comparator.

Calculus is handy for figgering out how this stuff really works, but it is
possible to understand it in a practical way without it.  I was building
stuff with low pass filters long before I ever studied calculus.

OK, what about sampled data?  An old fella named Nyquist said that you need
to sample your data at least twice the highest frequency present in the
signal for it to make any sense.  Another fella named Lile said that Nyquist
was an optimist.  A low pass filter is often used in front of a data
acquisition system of any kind to limit high frequencies.  If the high
frequency cutoff of your filter is 10KHZ, you need to sample at least 20KHZ
(per Nyquist) and realistically even faster (per Pessimistic Mr. Lile) to
get good useful data without aliasing and other problems.

Next you are going to ask how to calculate the cutoff frequency of such a
filter.  I'll bet there are some good cookbook methods that don't involve
any calculus.  I, being lazy, just chuck parts into BSpice and let it figger
the answer for me.  Anybody want to weigh in?

--Lawrence Lile

{Original Message removed}
At 10:18 AM 2/28/02 -0600, Michael wrote:
> > michael brown wrote:
> > >This may sound like a dumb question, but I have not run across a good
> > >"plain
> > >English" description of low-pass [...]
> >
> > A time-varying signal can be represented as a function of time, f(t).
> > The same function can be represented in "frequency space" via a linear
><SNIP>
> >
> > Hm, this isn't really "plain English" is it? Try again.
>
>Not to me, it pretty much reads like the rest of the "explanations" I've
>seen.  ;-)

A low-pass filter is simply a moving-average in a sampled data system.

An analog system is continuous, so you have to visualize an infinite number
of infinitesimal pieces going into the moving-average. In this case, the
moving-average is called an "integral" and the process of adding up the
infinite number of pieces is called "integration".

================================================================
Robert A. LaBudde, PhD, PAS, Dpl. ACAFS  e-mail: rallcfltd.com
Least Cost Formulations, Ltd.            URL: http://lcfltd.com/
824 Timberlake Drive                     Tel: 757-467-0954
Virginia Beach, VA 23464-3239            Fax: 757-467-2947

"Vere scire est per causas scire"
================================================================

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

Hi Lawrence,

Very good explanation and I'm glad to see that you have introduced Lile's
Law ;-)

One little correction, though: to be able to recover the information from a
signal, it is NOT necessary to sample at a rate which is more than twice
the maximum frequency content. It is only necessary to sample at a rate
which is more than twice the bandwidth. So, for example, if you have a
signal at 10MHz which is amplitude modulated by a 10kHz signal, the
spectrum looks like a narrow band (20kHz wide) way up at 10MHz and nothing
else. The signal bandwidth in this case is actually 10kHz (half the width
of the band of freqs that you see) and you need only sample at 20kHz (or
preferably a little higher to prevent problems, as you say). You DO,
though, need an ADC which has a very small sample aperture (i.e., it's
sample and hold just looks at a very small region in time to grab each sample).

This makes it easier to do things like software radio where you do
demodulation and IF filtering in DSP. Your IF may be at RF frequencies, but
you need only sample according to the bandwidth.

Sean

At 10:44 AM 2/28/02 -0600, Lawrence Lile wrote:
{Quote hidden}

----------------------------------------------------
Only \$9.95 per month!
http://my.netzero.net/s/signup?r=platinum&refcd=PT97

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

> filtering electrical or electro-magnetic "waves".  I am looking for the
> definition as it applies to EE and sampled data.

Inside a computer a simple low pass filter working on successive samples is:

Filt <-- Filt + (New - Filt)*FFrac

Where FILT is the filter that is being updated, and NEW is the new sample
being accumulated into the filter.  FFRAC is the filter fraction, a value
from 0 to 1 for a normal low pass filter.  It governs how "heavy" the
filtering is.  A value of 0 is infinitely heavy, which means the filter
output never changes at all.  A value of 1 causes the input signal to be
passed thru without any filtering.  Do an example on paper to see how this
works.  I often cascade two of these things, called "poles", to make a "two
pole" digital filter.

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

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

> michael brown wrote:
> >  question about low-pass filtering]
> >
> >filtering electrical or electro-magnetic "waves".  I am looking for the
> >definition as it applies to EE and sampled data.
>
> One simple approach to digital low-pass filtering is just to do a
> windowed average. That is, if you have a sequence of measurements
> (samples) of a signal, then you average together every N of them
> (like every pair, or every 10, or every 10000, as appropriate). In
> this way, you average out the high-frequency "wiggles" and get just
> the lower-frequency variations in the signal. By "average" I mean
> exactly what you think I mean: add them up and divide by the number N.

So basically, it means to use quality sampling instead of quantity sampling.
Just pick an arbitrary pattern (that hopefully doesn't synchronize or beat

> >Also I hear/see the term
> >"integrate" and am not completely clear as to what this means in the
> >context
> >of EE and data samples.
>
> "Integrate" in the case of discrete samples just means "add 'em up".
> Same as the averaging technique I mentioned above.

That's simple enough for my pea-brain.  ;-) Why don't they just say that???
I'd learn this stuff faster if it wasn't for the language barrier.  ;-D

> Michael V (still trying to be helpful...)

You were, thanks.  ;-)

michael brown (not a linguist)

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

> A low-pass filter is simply a moving-average in a sampled data system.

Ding! Ding! Ding!  The perfect "plain english" description.  I get it now.
Thanks!  ;-)

michael brown

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

'[EE]: What is low pass filtering'
2002\03\01@015343 by
I already know that you know this Michael.  The way that you probally know it
the best would be the simple RC (resistor-capacitor) network.  A typical RC
network would be one where the resistor is in series with your signal and the
capacitor is to ground.  The "physically related" process that you seek is an
understanding of the capacitor and the rate that it charges and discharges.

Example #1:  You have a large diameter garden hose that you are turning on and
off at a slow rate.  When the garden hose is on, water goes out. When off, water
is sucked back up into the hose.  Put the garden hose into a small bucket and
have it turn on and off once per minute.  You can EASILY watch the level of the
water rise and fall within the bucket.

Example #2:  Small garden hose inside a large bucket and you are turning the
garden hose on and off at a high rate (lets say 20 times per second).  You would
not notice the water rise and fall very much if at all.  Mostly due to the small
amount of water going in and out of the small bucket.

Apply this to the real world:  The larger the size of your resistor, the smaller
the diameter of the garden hose (less current).  The smaller the size of the
capacitor, the smaller the size of your water bucket.

For any given size of resistor and capacitor (hose and bucket), there is a rate
of flow in which you will see the level of the cap (or bucket) rise and fall.
For a smaller resistor (lots of currents) and a small capacitor, it doesn't take
long to see the rise and fall and you can have a higher rate of turning the
signal on and off.  At some point, the capacitor doesn't have enough time to
fully charge and discharge and you don't see the level change as much (filtering
is now in progress).

Increasing the resistor (less flow / current) means it takes longer to charge
the cap (or fill the bucket) and you cannot have as fast of a rate of change (or
frequency).  Likewise, changing the value of the cap will have simular effects
(less capacitance means you can charge/discharge faster and have a higher
frequency).

michael brown wrote:

{Quote hidden}

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

> Inside a computer a simple low pass filter working on successive samples
is:
>
> Filt <-- Filt + (New - Filt)*FFrac
>
> Where FILT is the filter that is being updated, and NEW is the new sample
> being accumulated into the filter.  FFRAC is the filter fraction, a value
> from 0 to 1 for a normal low pass filter.  It governs how "heavy" the
> filtering is.  A value of 0 is infinitely heavy, which means the filter
> output never changes at all.  A value of 1 causes the input signal to be
> passed thru without any filtering.  Do an example on paper to see how this
> works.  I often cascade two of these things, called "poles", to make a
"two
> pole" digital filter.

Woohoo, way to go Olin.  This is the best description yet, and it even
includes a formula.  ;-D

michael brown

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

> > >Also I hear/see the term
> > >"integrate" and am not completely clear as to what this means in the
> > >context
> > >of EE and data samples.
> >
> > "Integrate" in the case of discrete samples just means "add 'em up".
> > Same as the averaging technique I mentioned above.
>
> That's simple enough for my pea-brain.  ;-) Why don't they just say
that???

Because there's a lot more to it than that in many cases.  You can only wing
it so far.  You need to go learn some math if you really want to use this
stuff for more than a one-off hobby project.

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

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

> > A low-pass filter is simply a moving-average in a sampled data system.
>
> Ding! Ding! Ding!  The perfect "plain english" description.  I get it now.

Not so fast.  That's only one way to achieve a low pass filter.  In
techno-speak that's called a box filter, which is usually not what you want
to implement in a PIC.  For most ordinary situations, there are better
methods that are actually easier to implement.

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

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

On Thu, 28 Feb 2002 08:01:15 -0800 Michael Vinson <mjvinsonHOTMAIL.COM>
writes:
> michael brown wrote:
> >This may sound like a dumb question, but I have not run across a
> good
> >"plain
> >English" description of low-pass [...]
>

If you can put up with a long download, have a look at
http://www.hallikainen.org/cuesta/et113/RcLPF.pdf where an RC low pass
filter is analyzed.
http://www.hallikainen.org/cuesta/et113/RcHpfBreakFreq.pdf shows a Bode
plot approximation for a high pass filter. The same approach works for a
low pass filter.

Harold

FCC Rules Online at http://hallikainen.com/FccRules
Lighting control for theatre and television at http://www.dovesystems.com

________________________________________________________________
GET INTERNET ACCESS FROM JUNO!
Juno offers FREE or PREMIUM Internet access for less!
Join Juno today!  For your FREE software, visit:
dl.http://www.juno.com/get/web/.

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

I was just wondering how people arrive at a choice of power supply filtering
capacitors.  I'm thinking  of a regulated 5V supply, around 1A (7805).

Looking at published plans, it seems that some people routinely specify 2 x
2200.  Others just put in a single 1000.  What's a guy to do?

Also, data sheets indicate 0.33 "or larger" on the input if an appreciable
distance from the filter caps, but published plans seem to use 0.1 or 0.22.
Anyone know why?

And, on the output, 0.1 seems to be standard.  Motorola says values less than
0.1 could cause instability.  Wouldn't this tempt you to use more than 0.1?

As I say, it's a mystery to me.  Any enlightenment on the Zen of capacitor
selection would be appreciated.

Thanks,
Colin

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

At 11:41 AM 3/5/02 -0800, you wrote:
>I was just wondering how people arrive at a choice of power supply filtering
>capacitors.  I'm thinking  of a regulated 5V supply, around 1A (7805).
>
>Looking at published plans, it seems that some people routinely specify 2 x
>2200.  Others just put in a single 1000.  What's a guy to do?

Hi, Colin:-

Okay, the most important thing is to make sure that with the minimum
line voltage, maximum load and minimum capacitor and worst-case voltage-
regulator drop that the regulator never "drops out". The first part is a
function of the line voltage range you want to cover (-20%? -25% from nominal),
that later) and the diode drop(s). The regulator dropout you get from the
data sheet. It is 2V at 1A 25'C typical, and 2.5V guaranteed over temperature.
Which one should you use? Right, 2.5V. Then you have to look at the ripple.
You can make the assumption that the capacitor is only charged in brief
pulses the peaks of the AC waveform. Thus, we have a peak-to-peak ripple
of Vr = (tx * I)/C  (time for one half cycle with full-wave rectification
or one cycle with half-wave, I is the regulator input current, C is the
capacitance). So, with a 4400uF cap, 60Hz, full-wave, you'll have
Vr = 1.9V (p-p). That means your average input voltage measured on a DVM
because the "troughs" of the input waveform will be down at 7.6V, just
about the 7.5V minimum. Note that half-wave rectification means the caps
have to be doubled for the same ripple. 1000uF is not enough for any
reasonable 1A supply, but it's often fine if you only need 100mA or 200mA.

The actual transformer voltage will be a bit lower than you might expect
because the 1A is supplied in brief pulses of much higher current, depending
on the transformer winding resistance and other factors.

The other requirement is that the ripple current be less than the maximum
spec on the capacitor, and the more below that the better, because the
capacitor will last longer. Using two capacitors means that you can double
the ripple current spec unless your layout is really silly.

>Also, data sheets indicate 0.33 "or larger" on the input if an appreciable
>distance from the filter caps, but published plans seem to use 0.1 or 0.22.
>Anyone know why?

Maybe they are not far from the filter cap? I don't use any unless the
regulator is off-board, but there is a bit of a conflicting requirement-
the capacitor should be kept cool (away from regulator) but it has heavy
traces to, and should be close to the regulator. 1/2" or 1" is no problem.
If it's a through-hole electrolytic, 10uF/50V is about the smallest that
makes sense unless you're into the really small (7mm or less) heights.

>And, on the output, 0.1 seems to be standard.  Motorola says values less than
>0.1 could cause instability.  Wouldn't this tempt you to use more than 0.1?

7805's don't require an output capacitor for stability. The output cap reduces
the output impedance. What Motorola means is that you should not put a 0.01uF
capacitor on there, if you do use one (and you usually should) then make it or
them >= 0.1uF total. Usually there's more distributed capacitance around
the board
on  chip bypasses anyway. LDOs and negative voltage regulators do require
an output
cap and you should follow the data sheet recommendations.

Hope this helps,

Spehro Pefhany --"it's the network..."            "The Journey is the reward"
speffinterlog.com             Info for manufacturers: http://www.trexon.com
Embedded software/hardware/analog  Info for designers:  http://www.speff.com
9/11 United we Stand

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

You can almost certainly find some design papers on the net.

Briefly -

> I was just wondering how people arrive at a choice of power supply
filtering
> capacitors.  I'm thinking  of a regulated 5V supply, around 1A (7805).
>
> Looking at published plans, it seems that some people routinely specify 2
x
> 2200.  Others just put in a single 1000.  What's a guy to do?

Depends largely on what peak ripple YOU wan't to tolerate and why.
Larger caps generally never hurt performance. Smaller caps might.
Also depends on "headroom" you ae providing the regulator. As this drops you
can tolerate less ripple before regulator dropout and will ned larger caps
in the limiting case.

Note - quite incidentally to this discussion, that a SMALL series R feeding
the main filter cap will often IMPROVE noise performance and will guive caps
a MUCH more gentle time as cap charging is "spread" across more of the AC
cycle. Many don't use this method. A little arcane (despite its apparent
simplicty) and you need to read more about it if doing it. Leave this until
you are happy with basic filtering. .

> Also, data sheets indicate 0.33 "or larger" on the input if an appreciable
> distance from the filter caps, but published plans seem to use 0.1 or
0.22.
> Anyone know why?

This is NOT a ripple spec per se but an impedance one related to stability
of the *AMPLIFIER* that also happens to be a regulator. (If you don't think
it's an amplifier, explain how it oscillates when you don't talk nicely to
it :-) ).

The 0.33 is probably design worst case and the 0.2 is someone knowing it
will work OK with a bit less and the 0.1 is people being lazy or assuming it
is NOT an appreciable distance from the filter caps.

> And, on the output, 0.1 seems to be standard.  Motorola says values less
than
> 0.1 could cause instability.  Wouldn't this tempt you to use more than
0.1?

Yes. 0.1 uF is the mother duck value. They are commkn and cheap and also

Note that 0.1 uF was about the right value for general bypass capacitors in
older systems or new slower systems. It "just so happens" that for a typical
0.1 uF monolithic ceramic cap the series resonant combination of cap plus
lead inductance for a cap soldered with minimum lead length was good for
processors with clocks in the 1 to 10 MHz range which was good for most
systems. If you arenusing a 50 MHz clock (or 100 or 133 or 200 or ....) then
you want smaller bypass caps. The world has moved on buy many designs
haven't.

Much more on this subject but this should start things off.
As regards caps around actual regulator, until you are comfortable doing
otherwise, do what the data book says unless it's really hard to do so - and
then, do it anyway at first.
Note that some regulators have min and max cap size specs or spec in terms
of ESR rather than capacitance.

>  As I say, it's a mystery to me.  Any enlightenment on the Zen of
capacitor
{Quote hidden}

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

Colin Constant wrote:

>I was just wondering how people arrive at a choice of power supply filtering
>capacitors.  I'm thinking  of a regulated 5V supply, around 1A (7805).
>
>Looking at published plans, it seems that some people routinely specify 2 x
>2200.  Others just put in a single 1000.  What's a guy to do?
>
T=RC
T=1/F
F= ?120Hz. (or 100 Hz , or 60 Hz or 50 Hz...)
(Full wave rectified transformer in the USA is 120 Hz.)
R = E/I
E = Raw unregulated voltage. (8 volts MIN. for your 7805)
I = 1 Amp.

>
>Also, data sheets indicate 0.33 "or larger" on the input if an appreciable
>distance from the filter caps, but published plans seem to use 0.1 or 0.22.
>Anyone know why?
>
I use a 1 Microfarad on the input.
a .1 is too small, and I have had oscillations.

{Quote hidden}

--
*
|  __O    Thomas C. Sefranek  tcscmcorp.com
(*)/ (*)  Bicycle mobile on 145.41, 448.625 MHz

ARRL Instructor, Technical Specialist, VE Contact.
http://www.harvardrepeater.org

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

True confessions of a circuit board layout man...........

There is no real magic in selecting filter or bypass capacitors for a given
circuit.

I have been in the business of laying out circuitboards since 1972. I have laid
out over 1000 circuitboards and designed many products with power supplies. I've
had engineers hand me a schematic (TTL, CMOS, analog) and have been told to
"scatter" bypass caps where ever I have the room.

True, there are many theoretical articles and references as to what the proper
capacitor values should be but this is not the time and place to to it.

There are two types of power supply capacitors. Filter and bypass. In specifying
the exact value of a filter cap, you would need to know the parameters of the DC
source, half or full wave rectifier, no load peak voltage, minimum and maximum
load current, temperature, and probably a few more things I can't remember. A lot
also depends on whether this is a one time project or a product that will go into
production for consumer, industrial/automotive applications, mil-spec, etc.

Obviously, the most important factor is the amount of ripple that can be
withstood under full load by your project. The more filtering capacitor, the
better....to an extent. Too much can be costly and bulky. Not enough, and your
project will become unstable under load.

Bypass capacitors in your circuit should be placed liberally. Usually as close to
the +5 and ground pins of the most sensitive devices you use. Not every chip has
to have them although a processor, PLL, counters, should be bypassed. The value
for most digital circuits is 0.1uf. From 1 to ~50 mhz, use 0.01uf. Above 50mhz
use a 0.001uf.

If you want to get into the theory and design of a power supply, a good reference
would be the ARRL handbook available from http://www.arrl.org
This is a good all around reference for most common electronic parts.

If you just want your project to work, like your post, (7805 1A) make sure your
DC input is no less than 3 volts over your regulated output, 470 to 1000uf is
adequate for filtering and NEVER omit a 0.1uf cap across the input of the 78xx
and ground pin, as close to the device as possible to keep it from oscillating.
Don't put too much capacitance on the output of the 78xx. A no load condition and
a drop in voltage on the input of the78xx will blow it. I have seen some circuits
with a diode placed across the 78xx, anode to the output, cathode to the input to
protect it.
Rick

Colin Constant wrote:

{Quote hidden}

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

Thanks guys ( Thomas, Russell, Spehro, and Rick).

That's just what I was looking for.

Ragards,
Colin

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

"Rick C." wrote:

> A no load condition and a drop in voltage on the input
> of the78xx will blow it. I have seen some circuits with
> a diode placed across the 78xx, anode to the output, cathode
> to the input to protect it.

I've never seen this approach with 78xx regs - interesting. I've only
seen it with 317 types.

--
Best regards

Tony

mICros
http://www.bubblesoftonline.com
salesbubblesoftonline.com

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

At 09:02 AM 3/6/02 +1100, you wrote:

>I've never seen this approach with 78xx regs - interesting. I've only
>seen it with 317 types.

It's valid- look at the internal schematic for the 7805, here's
a pointer to one, and analyze what happens for Vout > Vin.

http://www.onsemi.com/pub/Collateral/MC7800-D.PDF

It's only a concern under the following conditions:

Substantial capacitance on the output (but if you need it, you
need it)

AND either

A)      A very heavy load on the unregulated supply such that the
current from the resulting dv/dt at switch-off could
cause excessive current through the regulator. This is
rather an unlikely scenario.
Or

B)      There is some possibility that the input could be short-
circuited and there is no series diode. This is more
likely where you'd use it. If there is a bridge or
polarity protection diode, it's not a concern unless
there is a possibility that it could be shorted on the
*other* side of the diode.

Not all data sheets cover this issue, so it's a good point. Like
an input capacitor, it's wasteful to put it in there if it is
unnecessary.

(BTW, on the previous post, 470uF is about 10 times too small
for 50/60Hz mains filter for typical 1A supply, also the ripple
current rating will not likely be high enough to be reliable).

Best regards,

Spehro Pefhany --"it's the network..."            "The Journey is the reward"
speffinterlog.com             Info for manufacturers: http://www.trexon.com
Embedded software/hardware/analog  Info for designers:  http://www.speff.com
9/11 United we Stand

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

At 09:02 AM 3/6/02 +1100, you wrote:
>"Rick C." wrote:
>
> > A no load condition and a drop in voltage on the input
> > of the78xx will blow it. I have seen some circuits with
> > a diode placed across the 78xx, anode to the output, cathode
> > to the input to protect it.
>
>I've never seen this approach with 78xx regs - interesting. I've only
>seen it with 317 types.
>
>Tony

Just ran across this in a app note a few days ago. I think it was on the
Fairchild or the Phillips site.
It also suggested a couple of caps.

Tried both and didn't notice any difference.

Dave

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

Yeah, 470 might be a little wimpy. I guess I usually keep my loads below 0.5a @
5v with the 7805 unless I want a combination power supply/space heater. ;-)

Another "condition" that can occur is a mutiple regulator power supply from one
source. +5, +12, +18 volt from the same rectifier (the +12 or +18 not short
circuit proof). Here, with a large cap on the output of the 5v reg, a heavy load
or short on another regulator could drop Vin under Vout.
Rick

Spehro Pefhany wrote:

{Quote hidden}

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

At 09:12 AM 3/6/02 +1300, Russell wrote:
><snip>
> > Looking at published plans, it seems that some people routinely specify 2
>x
> > 2200.  Others just put in a single 1000.  What's a guy to do?
>
>Depends largely on what peak ripple YOU wan't to tolerate and why.
>Larger caps generally never hurt performance. Smaller caps might.
><snip>

Too large a filter capacitor will result in too long a rise time on the
final regulated voltage.

PIC microprocessors have a maximum "come-up" time specification for
start-up reliability.

================================================================
Robert A. LaBudde, PhD, PAS, Dpl. ACAFS  e-mail: rallcfltd.com
Least Cost Formulations, Ltd.            URL: http://lcfltd.com/
824 Timberlake Drive                     Tel: 757-467-0954
Virginia Beach, VA 23464-3239            Fax: 757-467-2947

"Vere scire est per causas scire"
================================================================

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

'[PIC]: Software low pass filtering'
2002\06\13@195542 by
Hello All,

some months ago Olin posted the formula that changed DSP world: :)
Filt <-- Filt + (New - Filt)*FFrac

Saddly, my 8 bit implementation have a problem that I can't surpass:
filt = filt + ((sig16)new - (sig16)filt) / 2;

The value never goes to 255 because of integer roundings:
filt = 254 + (255 - 254) / 2;
filt = 254 + (1)/2;
filt = 254;

There's a way to change this? I've tried to raise the resolution making:
filt = filt + ((sig16)new*2 - (sig16)filt*2 + 1) / 4;

But got same results because:
filt = 254 + ((sig16)255*2 - (sig16)254*2 + 1) / 4;
filt = 254 + (510 - 508 + 1) / 4;
filt = 254 + (510 - 508 + 1) / 4;
filt = 254 + (1) / 4;

Best regards,

Brusque

-----------------------------------------------------------------
Edson Brusque                 C.I.Tronics Lighting Designers Ltda
Research and Development               Blumenau  -  SC  -  Brazil
Say NO to HTML mail                          http://www.citronics.com.br
-----------------------------------------------------------------

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

Brusque --

> some months ago Olin posted the formula that changed DSP world: :)
>     Filt <-- Filt + (New - Filt)*FFrac
>
> Saddly, my 8 bit implementation have a problem that I can't surpass:
>     filt = filt + ((sig16)new - (sig16)filt) / 2;
>
> The value never goes to 255 because of integer roundings:
>     filt = 254 + (255 - 254) / 2;
>     filt = 254 + (1)/2;
>     filt = 254;
>
> There's a way to change this? I've tried to raise the resolution making:
>     filt = filt + ((sig16)new*2 - (sig16)filt*2 + 1) / 4;
>
> But got same results because:
>     filt = 254 + ((sig16)255*2 - (sig16)254*2 + 1) / 4;
>     filt = 254 + (510 - 508 + 1) / 4;
>     filt = 254 + (510 - 508 + 1) / 4;
>     filt = 254 + (1) / 4;

I think you correctly recognized that you need to round rather than
truncate the result, but you only rounded one term instead of the total:

Original:
filt = filt + (new - filt) / 2;

Rounded:
filt = ((filt*2 + (new*2 - filt*2) / 2) + 1) / 2;
filt = ((254*2 + (255*2 - 254*2) / 2) + 1) / 2;
filt = ((508 + (510 - 508) / 2) + 1) / 2;
filt = ((508 + 2 / 2) + 1) / 2;
filt = (509 + 1) / 2;
filt = 510 / 2;
filt = 255;

I hope this helps.

-- Dave Tweed

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

Why do you care if it gets to 255 or just 254 ?

The error is pretty small.

Tal

{Quote hidden}

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

On Thu, 13 Jun 2002, Edson Brusque (listas) wrote:

> Hello All,
>
>
>     some months ago Olin posted the formula that changed DSP world: :)
>         Filt <-- Filt + (New - Filt)*FFrac
>
>     Saddly, my 8 bit implementation have a problem that I can't surpass:
>         filt = filt + ((sig16)new - (sig16)filt) / 2;

The filter can be written like so:

Filt' = Filt + (New - Filt)*FFrac
= Filt(1-FFrac) + New*FFrac

Often, the FFrac is the ratio of two integers such that:

FFrac = B/(A+B)
1-FFrac = A/(A+B)

The sum of FFrac and (1-FFrac) is  (A+B)/(A+B) or 1.

Using this nomenclature, the filter can be rewritten:

Filt' = (A*Filt  + B*New)/(A+B)

So far nothing new, just a rearrangement of terms.

Now to apply rounding, there are few tricks that you can perform.

Filt' = (A*Filt + B*New + A*New)/(A+B) - A*New/(A+B)

Filt' = New + (Filt-New) * A/(A+B)        ........... (1)

>
>     The value never goes to 255 because of integer roundings:
>         filt = 254 + (255 - 254) / 2;
>         filt = 254 + (1)/2;
>         filt = 254;

In this filter, A=B=1. If you use equation 1:

filt = 255 + (254 - 255) / 2
= 255 - 1/2
= 255

Whoopee!

This rounding also works for 0: New=0, Filt=1

Filt' = 0 + (1-0)/2
= 1/2
= 0

One way to implement this would be:

; W = New

subwf  Filt,W    ;W = Filt-New
subwf  Filt,F    ;Swap New and Filtered values

movwf  temp      ;Save the difference
rlf    temp,w    ;put sign bit into carry
rrf    temp,w    ;signed right shift
btfsc  temp,7    ;If the difference is negative
addlw 1         ;  then round down
subwf  Filt,F

This implementation does have a subtle bug. If the difference between the
new and filtered values is greater than 0x7f, then the filter has a
spurious response. To fix this, you need to check the signs of the
difference versus the sign of the filt or new value. It can be done in 4
more instructions.

BTW, an efficient implementation of this class of recursive, one-pole
digital filters can be found:

http://www.dattalo.com/technical/software/pic/twist.asm

Scott

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

On Thu, 13 Jun 2002, Edson Brusque (listas) wrote:

> Hello All,
>
>
>     some months ago Olin posted the formula that changed DSP world: :)
>         Filt <-- Filt + (New - Filt)*FFrac
>
>     Saddly, my 8 bit implementation have a problem that I can't surpass:
>         filt = filt + ((sig16)new - (sig16)filt) / 2;

This is because of the parity of 'filt' goes lost. I'd say filt should
inherit the parity of 'new'.

Regards,
Imre

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

Hi,

Edson Brusque wrote:
>    some months ago Olin posted the formula that changed DSP world: :)
>        Filt <-- Filt + (New - Filt)*FFrac
>
>    Saddly, my 8 bit implementation have a problem that I can't
surpass:
>        filt = filt + ((sig16)new - (sig16)filt) / 2;
>
>    The value never goes to 255 because of integer roundings:
>        filt = 254 + (255 - 254) / 2;
>        filt = 254 + (1)/2;
>        filt = 254;
<snip>

Well this is one of the drawbacks with (standard) IIR filters, you're
only
affecting 1/x part of the difference to the output each pass.
In this case it easy:

Change:        Filt <-- Filt + (New - Filt)*FFrac

to:         Filt <-- Filt + (New - Filt)+1*FFrac

Assuming you truncate the result.
If FFRac is of another magnitude then change the '1' to
( i.e. an 'halfbit' of the output ).

/Tony

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

Hi,
just to clarify I added parantheses:

Change:        Filt <-- Filt + (New - Filt)*FFrac

to:         Filt <-- Filt + ((New - Filt)+1)*FFrac

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

>     some months ago Olin posted the formula that changed DSP world: :)
>         Filt <-- Filt + (New - Filt)*FFrac
>
>     Saddly, my 8 bit implementation have a problem that I can't surpass:
>         filt = filt + ((sig16)new - (sig16)filt) / 2;
>
>     The value never goes to 255 because of integer roundings:
>         filt = 254 + (255 - 254) / 2;
>         filt = 254 + (1)/2;
>         filt = 254;
>
>     There's a way to change this? I've tried to raise the resolution
making:
>         filt = filt + ((sig16)new*2 - (sig16)filt*2 + 1) / 4;
>
>     But got same results because:
>         filt = 254 + ((sig16)255*2 - (sig16)254*2 + 1) / 4;
>         filt = 254 + (510 - 508 + 1) / 4;
>         filt = 254 + (510 - 508 + 1) / 4;
>         filt = 254 + (1) / 4;
>

It helps to have enough fraction bits so that 1/FFrac is not expressed as 0.

*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.com

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

Hello Dave,

> I think you correctly recognized that you need to round rather than
> truncate the result, but you only rounded one term instead of the total:
>
> Original:
>       filt = filt + (new - filt) / 2;
>
> Rounded:
>       filt = ((filt*2 + (new*2 - filt*2) / 2) + 1) / 2;
>       filt = ((254*2 + (255*2 - 254*2) / 2) + 1) / 2;
>       filt = ((508 + (510 - 508) / 2) + 1) / 2;
>       filt = ((508 + 2 / 2) + 1) / 2;
>       filt = (509 + 1) / 2;
>       filt = 510 / 2;
>       filt = 255;

you are right! Dumb me...

Saddly, your solution suffers from a problem I haven't seen when I wrote
the original post.

The filter don't go from 1 to 0:

filt = ((filt*2 + (new*2 - filt*2) / 2) + 1) / 2;
filt = ((1*2 + (0*2 - 1*2) / 2) + 1) / 2;
filt = ((2 + (0 - 2) / 2) + 1) / 2;
filt = ((2 + (-1)) + 1) / 2;
filt = (1 + 1) / 2;
filt = 2 / 2;
filt = 1;

Thank you,

Brusque

-----------------------------------------------------------------
Edson Brusque                 C.I.Tronics Lighting Designers Ltda
Research and Development               Blumenau  -  SC  -  Brazil
Say NO to HTML mail                          http://www.citronics.com.br
-----------------------------------------------------------------

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

Hello Tony,

>Change:     Filt <-- Filt + (New - Filt)*FFrac
>to:         Filt <-- Filt + ((New - Filt)+1)*FFrac
>Assuming you truncate the result.
>If FFRac is of another magnitude then change the '1' to
>( i.e. an 'halfbit' of the output ).

sorry but I don't get it. FFrac have to be between 0 and 1 right? (x/2)
is the same as (x*0.5). So I don't know what you mean with FFrac=4, maybe
(new-filt)/4?

Your formula is great. It overcomes the problem of having to cast New
and Filt variables to 16 bit, but it suffers from the same problem as
Dave's.

Filt <-- Filt + ((New - Filt)+1)/2
Filt <-- 1 + ((0 - 1)+1)/2
Filt <-- 1 + (0)/2
Filt <-- 1

My implementation solved this problem and don't have to deal with
negative numbers:

if (filt < new) filt = filt + ((new - filt)+1) / 2;
else filt = filt - ((filt - new)+1) / 2;

The only problem I've found if when going from 0 to 255 or from 255 to
0:

filt = filt + ((new - filt)+1) / 2
filt = 0 + ((255 - 0)+1) / 2    <--- 255+1=256, it will roll to 0
filt = 0 + (0) / 2
filt = 0 <--- should be 255

Anyway, I can solve this doing 16 bit operations or (easier) with a
couple of "if" clauses.

Thank you very much,

Brusque

-----------------------------------------------------------------
Edson Brusque                 C.I.Tronics Lighting Designers Ltda
Research and Development               Blumenau  -  SC  -  Brazil
Say NO to HTML mail                          http://www.citronics.com.br
-----------------------------------------------------------------

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

Brusque --

> Saddly, your solution suffers from a problem I haven't seen when I wrote
> the original post.
>
> The filter don't go from 1 to 0:

Yes, that's rounding for you -- it either biases toward 0 (truncation) or
toward +infinity (adding 0.5 and truncating). If you really need to go all
the way from 0 to 255, then you need something more sophisticated.

"Round to even", as used in some floating-point systems, won't work for
you; you'll still get stuck at 254 at the high end.

One approach would be to "dither" the rounding by simply adding 1 or adding
0 on alternate iterations.

-- Dave Tweed

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

>One approach would be to "dither" the rounding by simply adding 1 or adding
>0 on alternate iterations.

I think that there is no way to make that low pass function span the
entire output domain. Because the math specifies an asymptotical approach
of the output value to the input value and asymptotes do not exist in the
integer math world. I also think that the fiddling with conditional
clauses will introduce points of discontinuity into the mapping function
and if this is a part of a servo or some control loop it may react
strangely to those points.

Peter

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

> >One approach would be to "dither" the rounding by simply adding 1 or
> >0 on alternate iterations.
>
> I think that there is no way to make that low pass function span the
> entire output domain. Because the math specifies an asymptotical approach
> of the output value to the input value and asymptotes do not exist in the
> integer math world.

True, which is why a few fraction bits do allow the filter to span the
entire range.  I usually make the filter value fixed point with a few extra
bits on the right.  For example, a common case is filtering a 10 bit A/D
value.  I use 16 bits for this with the 10 bit A/D value in the high bits.
That leaves 6 fraction bits for filter roundoff.  It will work exactly as
long as the filter fraction is 2 ** -N, where N is from 0 to 6.

By the way 1/64 is a very heavy filter for most purposes because it has such
a slow response time.  It has a 50% step response time of 45 iterations and
90% in 147 iterations.  Splitting this into two poles of 1/8 each increases
the cycles to compute it but also the response time.  The 50% response drops
to 12 iterations, and the 90% response to 29 iterations.  Both filters have
the same 18dB attenuation of random noise.

> I also think that the fiddling with conditional
> clauses will introduce points of discontinuity into the mapping function
> and if this is a part of a servo or some control loop it may react
> strangely to those points.

I agree.  That kind of fiddling will only lead to trouble.

*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.com

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

On Sat, 15 Jun 2002, Olin Lathrop wrote:

> > >One approach would be to "dither" the rounding by simply adding 1 or
> > >0 on alternate iterations.
> >
> > I think that there is no way to make that low pass function span the
> > entire output domain. Because the math specifies an asymptotical approach
> > of the output value to the input value and asymptotes do not exist in the
> > integer math world.
>
> True, which is why a few fraction bits do allow the filter to span the
> entire range.  I usually make the filter value fixed point with a few extra
> bits on the right.  For example, a common case is filtering a 10 bit A/D
> value.  I use 16 bits for this with the 10 bit A/D value in the high bits.
> That leaves 6 fraction bits for filter roundoff.  It will work exactly as
> long as the filter fraction is 2 ** -N, where N is from 0 to 6.

Actually, not entirely true. As I showed in an earlier post, all one needs
to do is reconstruct the equation so that the asymptotes converge in
proper direction. Most of the time when these integer weighted filters are
presented, the new value of the filter is the old value of the filter plus
a term that is weight by an input:

filter = filter + (filter - input)*weight           ....... eq(1)

I agree when constructed this way that it's not possible using integer
arithmetic constrained to the dynamic range of the data to span the entire
dynamic range. However, if the equation is rearranged:

filter = input - (input - filter) * weight'         ....... eq(2)

it is. Mathematically these are identical (weight' is equal to 1-weight).
However, there are several subtle differences when integer arithmetic is
used. In both cases, if the difference the new input and the current state
of filter is less than the reciprocal of the weighting fraction then the
integer arithmetic truncates the result:

if( abs(filter - input) < 1/weight ) then
abs(filter - input) / weight is zero.

In eq(1), this means that the filter will not change states. In eq(2) this
means that the new filter state will become the same as the input. In
other words, if the input spans to the extremes of the dynamic range then
the filter output will too.

Round to Zero
-------------

Now, you don't get something for nothing. As I showed in the PIC assembly
implementation of this algorthm you do need to control the rounding.
Specifically, you need to monitor the sign of the difference and round
towards zero. If the difference is positive, then the integer division
automatically will round toward zero. If the difference is negative you
need to add 1 to the final result. In psuedo code:

; compute   (input - filter) / W
; where input, filter, and W are all integers.
; implement "rounding toward zero"

result = (input - filter) / W

if( result < 0)
result++;

{Quote hidden}

In the general case, this is true. However, the "rounding toward zero"
algorithm has a discontinuity at zero. Fortunately, this is also the point
where the input has no effect on the filter. It's kind of like sin(x)/x
for x equal to zero.

For a weight factor of 1/2, it's interesting to see how the two filter
constructions behave:

(A - B)/2

A-B  round to zero    floor
------------------------------------------
0          0          0
1          0          0
2          1          1
3          1          1
-1          0         -1
-2          0         -1
-3         -1         -2
-4         -1         -2

In other words, the two are the same when the difference is positive. When
the difference is negative, the "round to zero" algorithm is one greater.
The discontinuity is probably easier to see:

rtz      -1 -1  0  0  0  0  1  1  2
floor    -2 -2 -1 -1  0  0  1  1  2
diff     -4 -3 -2 -1  0  1  2  3  4

The round to zero algorithm results in zero for 4 values whereas the floor
algorithm results in zero for only two values. This behavior of the rtz
algorithm is clearly discontinuous. However, this dicontinuity works in
your favor when applied to eq(2).

Let's take an example:

weight = 1/2
filter = 8
input  = 10

eq(1):

1)    filter = 8 + (10 - 8)/2 = 8 + 1 ===> 9
2)           = 9 + (10 - 9)/2 = 9 + 0 ===> 9

eq(2):

1)    filter = 10 - (10 - 8)/2 = 10 - 1 ===> 9
2)           = 10 - (10 - 9)/2 = 10 - 0 ===> 10

Now let's go the other direction.

weight = 1/2
filter = 8
input  = 6

eq(1):

1)    filter = 8 + (6 - 8)/2 = 8 - 1 = 7
2)           = 7 + (6 - 7)/2 = 7 - 1 = 6

eq(2):

1)    filter = 6 - (6 - 8)/2 = 6 - 0 = 6

Here's another interesting test
weight = 1/2
filter = 8
input  = 7  (differ by 1)

eq(1):

1)    filter = 8 + (7 - 8)/2 = 8 - 1 = 7

eq(2):

1)    filter = 7 - (7 - 8)/2 = 7 - 0 = 7

Both filters converge, but the round to zero does so more quickly when the
difference between the input and filter is even.

So as far as non-linearities and discontinuities, I think it's clear to
see that the "frequency response" of both these filters is approximately
the same. In all cases, the number iterations required for the two filters
to reach their final states differ by at most one. The round to zero
implementation however has the benefit of always converging toward the
input value.

Scott

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

I wrote:
> One approach would be to "dither" the rounding by simply adding 1 or adding
> 0 on alternate iterations.

"Peter L. Peres" <plpACTCOM.CO.IL> wrote:
> I also think that the fiddling with conditional
> clauses will introduce points of discontinuity into the mapping function
> and if this is a part of a servo or some control loop it may react
> strangely to those points.

Olin Lathrop <olin_piclistEMBEDINC.COM> wrote:
> I agree.  That kind of fiddling will only lead to trouble.

Then you guys simply do not understand the concept of "dither", which
has a long tradition of application in both control systems and audio
applications for *linearizing* the response when dealing with quantization
effects.

A simple "square wave" dither of 1/2 LSB seems perfect for this
application, in terms of low computational cost. Random dither would be
more difficult to compute, and would probably have no net benefit for the
overall application.

Anyway, another approach would be to simply avoid the internal quantization
altogether by maintaining the filter state as a 16-bit variable to begin
with. Just take the high byte as the 8-bit output value when you need it.
Something like this:

filter is a 16-bit variable used to maintain the state of the filter
factor is an 8-bit constant whose value is 256 * FFrac

filter = filter + (new - filter>>8) * factor;

Where "filter>>8" is just C-style notation for "the high byte of filter".
This is an 8-bit subtract, an 8*8->16 multiply (which can be optimized to a
16-bit shift if factor is a power of 2), and a 16-bit addition. The only
cost is one more byte of data storage.

-- Dave Tweed

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

Hello Scott,

> The filter can be written like so:
>
> Filt' = Filt + (New - Filt)*FFrac
>       = Filt(1-FFrac) + New*FFrac
>
<snip>
> BTW, an efficient implementation of this class of recursive, one-pole
> digital filters can be found:
>
> http://www.dattalo.com/technical/software/pic/twist.asm

this is very interesting. I think now I have something to thought about
in the whole weekend. :)

I'll talk to you later when I got good understanding of your twist.asm.

Best regards,

Brusque

-----------------------------------------------------------------
Edson Brusque                 C.I.Tronics Lighting Designers Ltda
Research and Development               Blumenau  -  SC  -  Brazil
Say NO to HTML mail                          http://www.citronics.com.br
-----------------------------------------------------------------

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

Hi,
late reply, been out of the loop for a while,

anyway, Edson Brusque wrote:
<snip>
>    The only problem I've found if when going from 0 to 255 or from 255
to 0:
>
>    filt = filt + ((new - filt)+1) / 2
>    filt = 0 + ((255 - 0)+1) / 2    <--- 255+1=256, it will roll to 0
>    filt = 0 + (0) / 2
>    filt = 0 <--- should be 255
>
>    Anyway, I can solve this doing 16 bit operations or (easier) with a
>       couple of "if" clauses.
<snip>
Well remember that you actually have 9 bit's in the working register,
you can also use the carry, in this case, assuming the constants you use
and the flow, would give:

filt = filt + ((new - filt)+1) / 2
filt = 0 + ((255 - 0)+1) / 2    <--- 255+1=256, it will roll to 0 ** and
carry will be set **
filt = 0 + (0) / 2              <---- use RRF, it will roll in the carry
as top bit and produce
filt = 128 <--- should be 255 **nope** should be 128 ( ffrac is = 2 )

/Tony

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

2002\08\27@142659 by
Here is the code that I have written based on filter feedback.  I think the
straight average gives a better result. I am using a 877 and seem to get +/-
1.5bits of random noise without filtering (input is pot tied to +5V, also
Vref+ tied to +5V).  Is there a better way?  Are there any good sites
covering this subject?

ADC_FILT = 0;                   // Clear out previous count
for (i=0; i<64; i++)
{
while(!ADIF) continue;  // Wait for conversion complete

}

//                      ALTERNATIVE FILTER.  Change i to <255 in the for statement above
//                      Comment out 3 lines below and replace with 2 lines below.
//
//                      Software low pass filter to attenuate noise by -12dB
//                      }

else ;                  // All other channels un-scaled

Ian

------------------------------------------------------
http://mdm1.bravepages.com
Technical support for the Multifunction Display Module
------------------------------------------------------

> {Original Message removed}

'[EE] Filtering for a tec'
2003\04\01@120404 by
part 1 1583 bytes content-type:text/plainHi All,
I am a bit out of my league in designing this circuit and would appreciate
any assistance or any comments.  I am pwm-ing a thermoelectric cooler using
a PIC16F877 pwm module at 80khz via RC1.  The tec is sensitive to ripple
current (<10%).  The tec pulls about 3 amps when attached directly to the
battery.  I am trying to maximize the current at an 80% duty cycle and a
lower (power saving mode) duty cycle.

I used the filter tables and came up with a Butterworth N=2 filter with an
f3db at 4.5 KHz and an attenuation at -50db at 80 kHz.  I think the tec is
about 4 ohms but I wasn't sure how to calculate the input impedance.

Using only one cap 10uF (at the negative lead of the tec) and one inductor
100uH the current is pretty low (2.1A) at 80% duty so I tried moving the cap
to the drain of the MOSFET as this looked more like the examples that I had
seen.  I also added a second cap on the back as it appeared to help.  This
raised the current to 2.6A but the cap closest to the drain of the mosfet
either bakes or explodes.  This cap is circled red in the attached
schematic.

I have this circuit modeled in spice (SwitchCadIII) and it appears to do
exactly as I hoped but alas in practice it smokes.  As an aside using very
low esr caps really seem to help the overall operation in the simulation.

Any help would be greatly appreciated and excuse any serious mistakes as I
am just getting back into hardware after many years.

Gregory

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

part 2 8722 bytes content-type:image/gif; (decode)

part 3 2 bytes
-
On Tuesday 01 April 2003 09:02 am, Gregory A. Pruden wrote:
> I tried moving the cap
> to the drain of the MOSFET as this looked more like the examples
> that I had seen.  I also added a second cap on the back as it
> appeared to help.  This raised the current to 2.6A but the cap
> closest to the drain of the mosfet either bakes or explodes.  This
> cap is circled red in the attached schematic.
>
> I have this circuit modeled in spice (SwitchCadIII) and it appears
> to do exactly as I hoped but alas in practice it smokes.  As an
> aside using very low esr caps really seem to help the overall
> operation in the simulation.

You probably don't want a filter here. If you're using an inductor,
you should probably set it up as a buck DC-DC converter. This will be
much more efficient. Same components but arranged differently.

Anyway, if you look at the current through the capacitors, you'll see

--
Ned Konz
GPG key ID: BEEA7EFE

--
http://www.piclist.com hint: To leave the PICList
piclist-unsubscribe-requestmitvma.mit.edu>
Thanks Ned,
You are right I looked at the current in the cap and the simulation shows
between 12A and 42A depending on the ESR.

Could you point me to an example, or suggest the movement of the components,
for the buck DC-DC circuit?

Gregory

{Original Message removed}
On Tuesday 01 April 2003 10:00 am, Gregory A. Pruden wrote:
> Thanks Ned,
> You are right I looked at the current in the cap and the simulation
> shows between 12A and 42A depending on the ESR.
>
> Could you point me to an example, or suggest the movement of the
> components, for the buck DC-DC circuit?
>
> Gregory
>

A quick Google search for "buck converter" theory got:
http://www.ipes.ethz.ch/ipes/e_index.html

There are also a number of app notes at Linear Tech, ON Semi, and TI

> {Original Message removed}
Gregory,

Switching Power Supply Topology Review by LLoyd H. Dixon at:

http://www-s.ti.com/sc/psheets/slup067/slup067.pdf

Dave

"Gregory A. Pruden" wrote:
>
> Could you point me to an example, or suggest the movement of the components,
> for the buck DC-DC circuit?

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

'[EE]: filtering power onboard'
2003\06\12@134056 by
ok....ive seen where some designers will use a LC filter, while others use a
pi filter when feeding different sections of a board.  Generally, its used
when feeding a noise sensitive circuit such as a PLL, but I've seen it also
on just to different parts of a board when large ASIC's are used.

So, a LC is used when the impedance is different, while a pi used when the
impedances are more matched, granted that a pi is a LC with the additional
cap in front.

So, the couple of questions running around in my noggin are......does this
filter both ways...in that if you have a 3.3 rail, and feed 3 chips...each
off its own filter, do you actually gain anything by doing all three, or
would two suffice...meaning that will the filter also prevent noise from
coming back from the chips onto the rails.  Second is.....it seems there is
no rhyme or reason to some of the designs in that one might use the LC while
another a pi.  The source voltage is a small POL (point of load) module, no
specs on the output impedance but most suggest a pi filter on the output.

So, if I want to try and do the best job on keeping the power clean on the
pins of the chips...I'm leaning toward a LC  consisting of a ferrite bead, a
.1uF cap and a 1uF cap.

_________________________________________________________________
The new MSN 8: advanced junk mail protection and 2 months FREE*
http://join.msn.com/?page=features/junkmail

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics

'[PIC]: Filtering again'
2003\09\04@223840 by
Hi

I presume most of you get Embedded Systems Programming
but I remembered a post a while ago about nooise/filtering
and although the method is probably a bit strong for most
PIC applications it is a very neat one for any DSP
application:

http://www.embedded.com/showArticle.jhtml?articleID=14400097

jon

--

Hey guys,

I'm working on a rover. So far my rover has a rangefinder and a steering servo.
The problem is that the servro creates huge spikes on the +5V line. These spikes
make the rangefinder think it's hearing an echo :(

I was considering running the servos on their own power line and opto-isolating
the PWM but there has to be a better way.

If someone could give me a crash corse in ioslating devices that cause big
spikes I would be most greatful.

Thanks,
Steve

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

At 09:52 AM 9/6/2003 -0600, stesquibMINES.EDU wrote:

>Hey guys,
>
>I'm working on a rover. So far my rover has a rangefinder and a steering servo.
>The problem is that the servro creates huge spikes on the +5V line. These spikes
>make the rangefinder think it's hearing an echo :(
>
>I was considering running the servos on their own power line and opto-isolating
>the PWM but there has to be a better way.
>
>If someone could give me a crash corse in ioslating devices that cause big
>spikes I would be most greatful.

it's a short course
don't power motors from your logic supply.
use two batteries.
tie the grounds together at the batteries.

final exam tomorrow at 9.

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

On Saturday 06 Sep 2003 4:52 pm, you wrote:
> Hey guys,
>
> I'm working on a rover. So far my rover has a rangefinder and a steering
> servo. The problem is that the servro creates huge spikes on the +5V line.
> These spikes make the rangefinder think it's hearing an echo :(
>
> I was considering running the servos on their own power line and
> opto-isolating the PWM but there has to be a better way.
>
> If someone could give me a crash corse in ioslating devices that cause big
> spikes I would be most greatful.
>

First thing to do is separate the hi current carrying 0V and +5V from those
supplying the rest of the circuit.  Star connect these at the power supply.

Ian

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

stesquib@MINES.EDU wrote:

> If someone could give me a crash corse in ioslating devices that cause big
> spikes I would be most greatful.
>
> Thanks,
> Steve

Steve,

Bypass capacitors, huge ground lines and a wheeling diode (for inductive

Try a combination of an electrolytic cap and a tantalum cap on the power
supply to the servo. The tantalum is fast acting and the electrolytic is
a larger current buffer than the tantalum.

Large ground lines are going to minimize the current spikes: V=L(dI/dt)
where L is going to be really small.

The next thing is a resistor and a wheeling diode (in series) across the
servo's power and ground. The diode's arrow should point at the +ve.

When the power to the servo is shut off (instantaneously) the field
built up around the motor stator (a coil) collapses and forward-biases
the diode. The pulse is shorted out. The resistor connected in series
with the diode shortens the time constant (t=L/R) of the pulse.

Hope this helps.

John (hoping he has remembered EE properly)

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

General things about transients.  It is important to know where the spikes
originate.  For example, if an inductive device, say a compressor down the
line kicks on and sends a transient up the line, then a varistor (surge
suppressor) placed right at the source (the compressor motor) will usually
resolve the problem.  If the device is a DC relay on your PC, then, you need
a reverse biased diode across the relay, or perhaps a suitable varistor.  Do
not put a capacitor across the coil because it will change the picking and
release time according to the capacitor charge and discharge rate.  In some
cases the diode does not work because it is not placed exactly across the
coil but placed on the power traces to the coil..  In other cases the diode
does not work because it does not have a fast enough recovery time and a
schottky is required. Transients are usually difficult problems, some more
than others.   The important thing is to first characterize the transient
and determine the point of origin.  Then capturing or filtering it at that
point will usually work.  An o-scope is not the ideal device for transient
analysis, a spectrum analyzer is.  But often a spectrum analyzer is
unavailable.  If you could get your hands on one from a rental place or a
friend it will be very helpful.

If I understand your specific problem correctly it is the transient produced
by the servo motor inductance.  If the software does not accommodate a
suitable ramp up-ramp down (accel-decel curve) then you may want to try a
PTC inrush limiter in addition to the diode, as long as it does not
compromise timing.  If the motor is powered from the PC Card, or located on
the card, the you may wish to overlay the power traces with wires.  During
the design states, parallel traces are utilized in order to reduce the trace
inductance since 1/LT = 1/L1+1?L2+...1/Ln. Wider traces are of course
preferred.  I hope this information, though long winded, is of some use to
you in your future designs also.

Good luck,
Richard

{Original Message removed}
Sorry, Just fixing the subject tag.

{Quote hidden}

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

'[EE:] EMI Filtering for Linear Power Supply'
2004\05\11@162504 by
Hello all,

I am designing a 12V linear power supply and now in the final stage I
see I have some problems with the EMI (or so I guess). I have a circuit
powered from this supply and when the refrigerator in my room starts, it
resets the circuit.
In your oppinion, is the EMI the cause of this problem ? What could I do
to overcome it ?
I hope I have explained it clearly. Thank you in advance for your

Lucian

--

At 11:25 PM 5/11/2004 +0300, Lucian wrote:

>Hello all,
>
>I am designing a 12V linear power supply and now in the final stage I
>see I have some problems with the EMI (or so I guess). I have a circuit
>powered from this supply and when the refrigerator in my room starts, it
>resets the circuit.
>In your oppinion, is the EMI the cause of this problem ? What could I do
>to overcome it ?
>I hope I have explained it clearly. Thank you in advance for your

You might not have enough transient rejection on the supply side, but this isn't an EMI problem.

The question is, what happens on your 12V output, when the fridge switches, and what happens on the high side of the regulator at the same time.?

You may need a larger input cap, if the fridge causes the input voltage to sag.

I've always tried to design for an input range of 70 - 140VAC for a nominal 120V input.
Any tighter than that, and you start seeing problems in the field.

--

The input is of 220V, and I don't know for sure what happens when the
fridge switches, but I do know that there is also a problem with my
computer speakers - a short interruption in the sound playback - when
the fridge switches.
I will try with a larger input capacitor.

Lucian
{Original Message removed}
At 12:37 AM 5/12/2004 +0300, Lucian wrote:

>The input is of 220V,

Just scale the numbers then.

>and I don't know for sure what happens when the
>fridge switches, but I do know that there is also a problem with my
>computer speakers - a short interruption in the sound playback - when
>the fridge switches.
>I will try with a larger input capacitor.

It's probably a sag as the motor inductance is placed across the line.

--

Thank you for your reply. I will try with a larger capacitor.

Lucian
-----Original Message-----
From: pic microcontroller discussion list
[PICLISTMITVMA.MIT.EDU] On Behalf Of David VanHorn
Sent: 12 mai 2004 01:03
To: PICLISTMITVMA.MIT.EDU
Subject: Re: [EE:] EMI Filtering for Linear Power Supply

At 12:37 AM 5/12/2004 +0300, Lucian wrote:

>The input is of 220V,

Just scale the numbers then.

>and I don't know for sure what happens when the
>fridge switches, but I do know that there is also a problem with my
>computer speakers - a short interruption in the sound playback - when
>the fridge switches.
>I will try with a larger input capacitor.

It's probably a sag as the motor inductance is placed across the line.

--

--

Is it when the fridge switches on or off?

If when switching on, then it could be voltage sag as the motor starts, or
a voltage spike when the start windings are disconnected a few hundred mS
later.
If it happens when the fridge stops as well, then it is almost certainly a
spike as the run windings are disconnected.
But don't discount a spike at startup as the start  windings will draw more
current and the switch is near the motor, compared to the thermostat
mounted inside the fridge itself (for the turn off).

A larger cap will help fix a voltage sag and may change the spike
behaviour. If it is spikes on the mains, then it is better fixed at the
source - if you are prepared to attack your fridge , or try adding a spike
supressor between the wall socket and the fridge plug.

But regardless, you don't want your regulator upset by external events so I
guess if you can sort it out 100% at that end it may be desirable also! I
guess I'm suggesting you use the fridge to sort out the regulator problem &
then use the speakers to sort out the  fridge problem!

Richard P

At 12:37 AM 5/12/2004 +0300, Lucian wrote:

>The input is of 220V,

Just scale the numbers then.

>and I don't know for sure what happens when the
>fridge switches, but I do know that there is also a problem with my
>computer speakers - a short interruption in the sound playback - when
>the fridge switches.
>I will try with a larger input capacitor.

It's probably a sag as the motor inductance is placed across the line.

--

--

Do the lights in the room dim when the fridge kicks on? if you have a decent multimeter, check and see if the voltage sags when the fride kicks on. I'm not sure how to fix that, but finding the problem is the first part of the soluton.

Lucian <lucifferHOME.RO> wrote:Hello all,

I am designing a 12V linear power supply and now in the final stage I
see I have some problems with the EMI (or so I guess). I have a circuit
powered from this supply and when the refrigerator in my room starts, it
resets the circuit.
In your oppinion, is the EMI the cause of this problem ? What could I do
to overcome it ?
I hope I have explained it clearly. Thank you in advance for your

Lucian

--

---------------------------------
Do you Yahoo!?
Win a \$20,000 Career Makeover at Yahoo! HotJobs

--

Yes, you are right, but I woudn't like to risk that in other
environments, this source resets again and I want to know the cause of
this behaviour. It is a source for an alarm system and it is not allowed
to reset. I will try first with a larger capacitor, even if it is now of
3300uF and I consider it big enough...

Lucian
{Original Message removed}
What about running the circuit off a battery supply that is charged with
your typical supply.  Then you don't have to worry about spikes per se,
and you have a backup system.

Lucian wrote:

>Yes, you are right, but I woudn't like to risk that in other
>environments, this source resets again and I want to know the cause of
>this behaviour. It is a source for an alarm system and it is not allowed
>to reset. I will try first with a larger capacitor, even if it is now of
>3300uF and I consider it big enough...
>
>Lucian
>{Original Message removed}
This will be the case with the next supply I will be using, for the
moment I have one on a breadboard without a battery backup and was

Lucian

{Original Message removed}
> The input is of 220V, and I don't know for sure what happens when the
> fridge switches, but I do know that there is also a problem with my
> computer speakers - a short interruption in the sound playback - when
> the fridge switches. I will try with a larger input capacitor.

You need to filter the fridge. It takes >15A surge on start and puts a
~1kV spike on the mains when it switches off. There is nothing wrong with
your psu. Just the fridge imho ;-)

Peter

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics

When the frigde STARTS the line voltage DROPS.
When it STOPS it produce spike and EMI.

As other say, desing so it accept lower input voltage

/Morgan

Lucian 22:25 2004-05-11:
>Hello all,
>
>I am designing a 12V linear power supply and now in the final stage I
>see I have some problems with the EMI (or so I guess). I have a circuit
>powered from this supply and when the refrigerator in my room starts, it
>resets the circuit.

--
Morgan Olsson, Kivik, Sweden

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

Ok, I admit, my fridge has a problem :)
So this is not an EMI issue, but a spike one. Ok, the solution I found
is to insert an 100nF capacitor between VCC and GND, this will solve the
reset problem. I have 2 boards, one with an 100nF cap and one without.
The one without the capacitor was resetting, so I will take this as a
general rule with my microcontroller boards, inserting the capacitor.
As with the fridge, I'm too busy to fix his problem :)
Thank you for your kind support !

Lucian
{Original Message removed}

'[PIC:] filtering an 8 bit value'
2004\06\08@183748 by
Good day to all.

I'm having a 'mental midget' monent here and would like suggestions.

I'm trying to filter an 8 bit value.  A nice, slow filter is just fine, so
I thought I'd do the tried and true 256 times IIR filter:
filt = curr(H,L) - old + new
where filt is the high byte of curr(H,L).

Here's what I've got: filtered value is the high byte of PHASCAL1(H,L)

FiltPC1
movfw       PHASCAL1        ;first subtract old value (curr value >>8)
subwf       PHASCAL1L,F     ;F-W -> dest  C=0 if borrow
skpc                        ;borrow?
decf      PHASCAL1,F      ;yep
skpnc                       ;carry?
incf      PHASCAL1,F      ;yep - propogate C into hi byte
;done: filtered value is PHASCAL1

All of the above is pretty straight forward.

My problem is that the routine that determines NEWPHASCAL simply increments
or decrements by 1.  So:

movfw       PHASCAL1        ;get current value
movwf       NEWPHASCAL
some test
incf      NEWPHASCAL

some different test         ;tests are mutually exclusive
decf      NEWPHASCAL
goto        FiltPC1

This is a lot of messing about for a simple increment or decrement.

So:  can someone suggest a simpler way of filtering an 8 bit value that only
needs to be incremented or decremented by 1?

Thanks!

dwayne

--
Dwayne Reid   <dwaynerplanet.eon.net>
Trinity Electronics Systems Ltd    Edmonton, AB, CANADA
(780) 489-3199 voice          (780) 487-6397 fax

Celebrating 20 years of Engineering Innovation (1984 - 2004)
.-.   .-.   .-.   .-.   .-.   .-.   .-.   .-.   .-.   .-
`-'   `-'   `-'   `-'   `-'   `-'   `-'   `-'   `-'
Do NOT send unsolicited commercial email to this email address.
This message neither grants consent to receive unsolicited
commercial email nor is intended to solicit commercial email.

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

Dwayne Reid <PICLISTmitvma.mit.edu> wrote:

> movfw   PHASCAL1
> subwf   PHASCAL1L,F
> skpc
> decf    PHASCAL1,F
> movfw   NEWPHASCAL
> skpnc
> incf    PHASCAL1,F
> ....
> My problem is that the routine that determines NEWPHASCAL simply
> increments or decrements by 1.
> ....
> This is a lot of messing about for a simple increment or decrement.
>
> So:  can someone suggest a simpler way of filtering an 8 bit value
> that only needs to be incremented or decremented by 1?

Dwayne:

Eight cycles/lines of code doesn't seem like THAT much "messing
about"... But you could reduce it to seven:

MOVF    PHASCAL1,W
SUBWF   NEWPHASCAL,W
SKPC
DECF    PHASCAL1
SKPNC
INCF    PHASCAL1

What are you trying to filter out?  If you just want to remove
jitter, for instance, you might merely need to wait for the input to
take two consecutive steps in the same direction before allowing your
output to change.

-Andy

=== Andrew Warren -- aiwcypress.com
=== Principal Design Engineer
=== Cypress Semiconductor Corporation
===
=== Opinions expressed above do not
=== necessarily represent those of
=== Cypress Semiconductor Corporation

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

At 06:55 PM 6/8/2004, Andrew Warren wrote:
{Quote hidden}

Thanks, Andy.  I think you swapped the old & new values but I see what you
were getting at - just leave the intermediate low byte in W for the
addition part of the filter.  Cool!

But the "messing about" that I mentioned is the preamble to the filter
routine - I've got to get the current (filtered) value into a register just
so that I can inc or dec it - then filter the result.

I was hoping there was an easy way to inc or dec the filter directly and
save that 5 or 6 cycles.

>What are you trying to filter out?  If you just want to remove
>jitter, for instance, you might merely need to wait for the input to
>take two consecutive steps in the same direction before allowing your
>output to change.

I'm building a phase lock loop running at about 8 KHz.  Its on a small PIC
with internal 4 MHz oscillator - hence my desire for short and sweet.  My
current approach is to trim a register that gets added to TMR0 each period
but I'm getting a lot of jitter.

If this approach doesn't work out, then I'll try a phase accumulator and
see if I still get the frequency I want.

dwayne

--
Dwayne Reid   <dwaynerplanet.eon.net>
Trinity Electronics Systems Ltd    Edmonton, AB, CANADA
(780) 489-3199 voice          (780) 487-6397 fax

Celebrating 20 years of Engineering Innovation (1984 - 2004)
.-.   .-.   .-.   .-.   .-.   .-.   .-.   .-.   .-.   .-
`-'   `-'   `-'   `-'   `-'   `-'   `-'   `-'   `-'
Do NOT send unsolicited commercial email to this email address.
This message neither grants consent to receive unsolicited
commercial email nor is intended to solicit commercial email.

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

At 09:21 PM 6/8/2004, Dwayne Reid wrote:

>>     MOVF    PHASCAL1,W
>>     SUBWF   NEWPHASCAL,W
>>     SKPC
>>     DECF    PHASCAL1
>>     SKPNC
>>     INCF    PHASCAL1
>
>Thanks, Andy.  I think you swapped the old & new values   <snip>

I take back what I wrote above - you had it right!  Obvious in hindsight -
but I didn't see it.

Thanks!

dwayne

--
Dwayne Reid   <dwaynerplanet.eon.net>
Trinity Electronics Systems Ltd    Edmonton, AB, CANADA
(780) 489-3199 voice          (780) 487-6397 fax

Celebrating 20 years of Engineering Innovation (1984 - 2004)
.-.   .-.   .-.   .-.   .-.   .-.   .-.   .-.   .-.   .-
`-'   `-'   `-'   `-'   `-'   `-'   `-'   `-'   `-'
Do NOT send unsolicited commercial email to this email address.
This message neither grants consent to receive unsolicited
commercial email nor is intended to solicit commercial email.

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

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