Design Con 2015
Breaking News
Comments
Newest First | Oldest First | Threaded View
Max The Magnificent
User Rank
Blogger
Re: Noise Filtering
Max The Magnificent   8/5/2014 2:48:32 PM
NO RATINGS
@Elizabeth: I've used averaging to reduce the noise on an anlog signal but the way I usually do it is to capture sets of samples 2 or 4 times as fast as you need them...

I can't wait to get the main display up and running, and to hen start playing with differenmt filtering techniques to see which works and looks best on the display.

 

Wnderer
User Rank
CEO
Re: Noise Filtering
Wnderer   8/5/2014 7:11:20 AM
NO RATINGS
@elizabethsimon:

Okay, I see what you're doing now. Thanks.

elizabethsimon
User Rank
CEO
Re: Noise Filtering
elizabethsimon   8/5/2014 12:15:58 AM
NO RATINGS
Yes you are right about the first example I gave being a moving average FIR filter of order two. And it would be mroe efficient to do it using a circular buffer..


In the second example I was trying to show an IIR filter. I think it would work as written but might be clearer if it was broken into steps like this

...

   newSpectrumLeft[i] = analogRead(channelLeft) / 4; // new sample

   spectrumLeft[i] = (spectrumLeft[i] + newSpectrumLeft[i]) / 2; average

...

The difference between this example and the first one is that it's always influenced by ALL previous samples although the older samples have much less influence.


As an example, say you had the following values for newSpectrumLeft and you started with everything at zero

32 32 0 0 0 0 0

with the first example that I gave you would have

16 32 16 0 0 0 0

the second example should give

16 24 12 6 3 1

At least that's the idea I was trying to get across

 

Wnderer
User Rank
CEO
Re: Noise Filtering
Wnderer   8/4/2014 6:46:32 PM
NO RATINGS
@elizabethsimon

I don't think that's exactly right. I believe your first example is a moving average filter of order 2 which is an FIR filter. I think your second example keeps getting bigger.  See the Wiki page.

http://en.wikipedia.org/wiki/Finite_impulse_response

I'm not sure the way he is averaging now is doing anything beneficial since he just averages short bursts of values. Implementing a moving average filter might improve the signal, but Max would need to implement a circular buffer for the spectrum values in between channel reads.

 

Some Notes on moving average filters, that seem to be missing from the Wiki.


A moving average filter implements a sinc function

H[f] = |sin(pi *f *M)/(M*sin(pi*f))| where M is the order of the filter. 

The full sampling frequency is divided into M humps.

The peak at the center of sampling frequency has an amplitude of 1/M for odd M. The peaks near the center will be close to this value for even M.

The amplitude of the second hump that occurs at 1.5/M approaches 1/1.5pi as M gets large.

 

 

elizabethsimon
User Rank
CEO
Noise Filtering
elizabethsimon   8/4/2014 4:44:17 PM
NO RATINGS
I've used averaging to reduce the noise on an anlog signal but the way I usually do it is to capture sets of samples 2 or 4 times as fast as you need them.


so in main you would have

...

   delayMicroseconds(sampleTime/2);

   readMSGEQ7s();

...

while in your subroutine you would have

...

   oldSpectrumLeft[i] = newSpectrumLeft[i];

   newSpectrumLeft[i] = analogRead(channelLeft) / 4;

   spectrumLeft[i] = (oldSpectrumLeft[i] + newSpectrumLeft[i]) / 2;

...

This is the simplest form of FIR (Finite Impulse Response) filter

 

Or if you wanted a "running average" you could use something like

...

   spectrumLeft[i] = (spectrumLeft[i] + (analogRead(channelLeft) / 4)) / 2;

...

If you do this though, you need to make sure that you initialize spectrumLeft[i] to zero in your startup code. This is the simplest form of IIR (Infinite Impulse Response) filter.

The averaging technique your friend Steve showed you is most useful if you have a lot of noise on the analog signal which might occur if you had long wires or you were using adjacent signals to run PWM to a motor or something similar.

 

Sheepdoll
User Rank
Blogger
waveform hardware
Sheepdoll   8/4/2014 2:59:11 PM
NO RATINGS
Max;

Your timing diagrams look similar to the ones I have for my pipe organ playback and paper roll conversions.  May be some similarity here as music is recorded as discreet 'events' which relate to frequency (pitch) and duration.

My preference on the Arduinos when dealing with sample and hold type shift registers, is to cascade the hardware timers.  This is how the USB scanner I showed at EELive! works.

One timer is set to the width of the clock pulse.  This toggles the clock line through the output compare. The cascaded timer (which can be done through the timer configuration) counts the clock pulses and can toggle the output compare pin automatically to generate the strobe.  This keeps the ISR routines small.  The overhead plus a shift of the bit in or out. 

For really tight constraints, Unrolled loops work well.  This is a code space/clock speed tradeoff.  AVRs have a lot of code space.

 

 

 



Most Recent Comments
resistion
 
resistion
 
David Ashton
 
Susan Rambo
 
AZskibum
 
AZskibum
 
alex_m1
 
alex_m1
 
AZskibum
Top Comments of the Week
Flash Poll
Like Us on Facebook

Datasheets.com Parts Search

185 million searchable parts
(please enter a part number or hit search to begin)
EE Life
Frankenstein's Fix, Teardowns, Sideshows, Design Contests, Reader Content & More
<b><a href=Betajet">

The Circle – The Future's Imperfect in the Present Tense
Betajet
5 comments
The Circle, a satirical, dystopian novel published in 2013 by San Francisco-based writer Dave Eggers, is about a large, very powerful technology company that combines aspects of Google, ...

Max Maxfield

Recommended Reads From the Engineer's Bookshelf
Max Maxfield
27 comments
I'm not sure if I read more than most folks or not, but I do I know that I spend quite a lot of time reading. I hate to be idle, so I always have a book or two somewhere about my person -- ...

Martin Rowe

Make This Engineering Museum a Reality
Martin Rowe
Post a comment
Vincent Valentine is a man on a mission. He wants to make the first house to ever have a telephone into a telephone museum. Without help, it may not happen.

Rich Quinnell

Making the Grade in Industrial Design
Rich Quinnell
16 comments
As every developer knows, there are the paper specifications for a product design, and then there are the real requirements. The paper specs are dry, bland, and rigidly numeric, making ...

Special Video Section
The LT8640 is a 42V, 5A synchronous step-down regulator ...
The LTC2000 high-speed DAC has low noise and excellent ...
How do you protect the load and ensure output continues to ...
General-purpose DACs have applications in instrumentation, ...
Linear Technology demonstrates its latest measurement ...
10:29
Demos from Maxim Integrated at Electronica 2014 show ...
Bosch CEO Stefan Finkbeiner shows off latest combo and ...
STMicroelectronics demoed this simple gesture control ...
Keysight shows you what signals lurk in real-time at 510MHz ...
TE Connectivity's clear-plastic, full-size model car shows ...
Why culture makes Linear Tech a winner.
Recently formed Architects of Modern Power consortium ...
Specially modified Corvette C7 Stingray responds to ex Indy ...
Avago’s ACPL-K30T is the first solid-state driver qualified ...
NXP launches its line of multi-gate, multifunction, ...
Doug Bailey, VP of marketing at Power Integrations, gives a ...
See how to ease software bring-up with DesignWare IP ...
DesignWare IP Prototyping Kits enable fast software ...
This video explores the LT3086, a new member of our LDO+ ...
In today’s modern electronic systems, the need for power ...