DSPRelated.com
Forums
Online · Live + on demand
February 9-11, 2027
Price goes up Jan 1: register now to lock in today's rate
Register Now →

low pass digital filter on a fixed point microcontroller

Started by Johnny Chang ●August 5, 2008
On Sat, 18 Oct 2008 14:06:15 -0700, Jerry Avins wrote
(in article <edsKk.1549$Zd.527@newsfe10.iad>):

> There will always be some violation of the >2x requirement because > filters aren't perfect. The need is to keep the violation small enough > so that aliases are tolerable. > > Just as it takes a long time to resolve frequencies near DC, it takes > just as long to resolve frequencies just below fs/2. Just think about > detecting a signal at 999.999 Hz when sampling at 2 KHz. How long before > a full cycle is acquired? Exactly as long as for a .001 Hz signal. so > another good reason for moderate oversampling is the accurate capture of > frequencies a bit below Myquist's limit.
True enough Jerry. In fact, the "sampling period" is the beat which is the difference between the Nyqist freq and the frequency in question. That's why I dig plenty-o-oversampling, that and the option to do some delta-sigma tricks if the need arises for higher resolution. I also approve of adding a dithering signal to the input. Either a sine or pink noise with an amplitude of a couple of LSBs. -- Charlie Springer
On Oct 18, 3:50&#4294967295;pm, Tim Wescott <t...@justseemywebsite.com> wrote:
> On Fri, 17 Oct 2008 23:05:42 -0700, Charlie Springer wrote: > > On Wed, 6 Aug 2008 14:25:22 -0700, dkel...@hotmail.com wrote (in article > > <838644c2-e573-48d6-9f44-f86719777...@27g2000hsf.googlegroups.com>): > > >> &#4294967295;If the frequencies that you are trying to get rid of are more than > >> half your sample frequency, once sampled, they are not separable from > >> any other signal in band. > > > Just a common nit. That is greater than or equal to half the sampling > > rate. People (and DSP book authors among them) tend to say you have to > > sample at least twice as fast as your greatest frequency then call it > > the Nyquist frequency. They should say you need to sample at greater > > than twice the highest frequency.
...
> > In theory it needs to be at least twice the highest frequency component;
... no, Tim, i think the theory is that it needs to (strictly) exceed twice the highest frequency component. a frequency component at precisely Nyquist cannot get both phase and magnitude represented in the samples. there actually is aliasing at that frequency which doesn't create a new frequency component like the other aliasing does, but it potentially screws up the phase and/or amplitude of that frequency component at Nyquist. r b-j
robert bristow-johnson wrote:
> On Oct 18, 3:50 pm, Tim Wescott <t...@justseemywebsite.com> wrote: >> On Fri, 17 Oct 2008 23:05:42 -0700, Charlie Springer wrote: >>> On Wed, 6 Aug 2008 14:25:22 -0700, dkel...@hotmail.com wrote (in article >>> <838644c2-e573-48d6-9f44-f86719777...@27g2000hsf.googlegroups.com>): >>>> If the frequencies that you are trying to get rid of are more than >>>> half your sample frequency, once sampled, they are not separable from >>>> any other signal in band. >>> Just a common nit. That is greater than or equal to half the sampling >>> rate. People (and DSP book authors among them) tend to say you have to >>> sample at least twice as fast as your greatest frequency then call it >>> the Nyquist frequency. They should say you need to sample at greater >>> than twice the highest frequency. > ... >> In theory it needs to be at least twice the highest frequency component; > ... > > no, Tim, i think the theory is that it needs to (strictly) exceed > twice the highest frequency component. a frequency component at > precisely Nyquist cannot get both phase and magnitude represented in > the samples. there actually is aliasing at that frequency which > doesn't create a new frequency component like the other aliasing does, > but it potentially screws up the phase and/or amplitude of that > frequency component at Nyquist.
This argument is getting tired. Or maybe I'm just getting tired of it. Assuming more-or-less steady state signal and plenty of sampling time. the sample rate needs to be a little (how little?) faster than twice the highest component* in order to capture its essence. It can be as low as exactly twice if the aim is simply avoiding aliasing and DC doesn't count. If the signal isn't more-or-less steady, then sampling needs to be a good deal faster than 2x. Borderline considerations are very rarely relevant to the real world. Jerry ____________________________ * For the sake of argument, perfect bandlimiting. -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
On Sat, 18 Oct 2008 20:21:50 -0700, Jerry Avins wrote
(in article <iJxKk.1692$JT3.575@newsfe03.iad>):

> This argument is getting tired. Or maybe I'm just getting tired of it. > Assuming more-or-less steady state signal and plenty of sampling time. > the sample rate needs to be a little (how little?) faster than twice the > highest component* in order to capture its essence. It can be as low as > exactly twice if the aim is simply avoiding aliasing and DC doesn't count.
Jerry (don't get tired!), what if you sample a10 volt 1 KHz sine at 2 KHz with all the samples falling at pi/8 and 9pi/8 ? What will you get for amplitude? -- Charlie Springer
"Charlie Springer" <RAM@regnirps.com> wrote in message 
news:0001HW.C5202B4900B66E61F02845B0@news.nw.centurytel.net...
> On Sat, 18 Oct 2008 20:21:50 -0700, Jerry Avins wrote > (in article <iJxKk.1692$JT3.575@newsfe03.iad>): > >> This argument is getting tired. Or maybe I'm just getting tired of it. >> Assuming more-or-less steady state signal and plenty of sampling time. >> the sample rate needs to be a little (how little?) faster than twice the >> highest component* in order to capture its essence. It can be as low as >> exactly twice if the aim is simply avoiding aliasing and DC doesn't >> count. > > Jerry (don't get tired!), what if you sample a10 volt 1 KHz sine at 2 KHz > with all the samples falling at pi/8 and 9pi/8 ? What will you get for > amplitude?
Charlie, Jerry is saying that the sample rate has to be faster than twice the highest component. It's right there in black and white a few lines above. You come back and ask him to sample a 1 KHz sine wave at 2 KHz. That violates the "faster than". Stop beating a dead horse!
> > -- Charlie Springer >
Charlie Springer wrote:
> On Sat, 18 Oct 2008 20:21:50 -0700, Jerry Avins wrote > (in article <iJxKk.1692$JT3.575@newsfe03.iad>): > >> This argument is getting tired. Or maybe I'm just getting tired of it. >> Assuming more-or-less steady state signal and plenty of sampling time. >> the sample rate needs to be a little (how little?) faster than twice the >> highest component* in order to capture its essence. It can be as low as >> exactly twice if the aim is simply avoiding aliasing and DC doesn't count. > > Jerry (don't get tired!), what if you sample a10 volt 1 KHz sine at 2 KHz > with all the samples falling at pi/8 and 9pi/8 ? What will you get for > amplitude?
" ... and DC doesn't count." That alias won't get through my headphones. :-) Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
On Sun, 19 Oct 2008 06:07:01 -0700, Philip Martel wrote
(in article <3ZednQOig-WcrGbVnZ2dnUVZ_jSdnZ2d@comcast.com>):

> "Charlie Springer" <RAM@regnirps.com> wrote in message > news:0001HW.C5202B4900B66E61F02845B0@news.nw.centurytel.net... >> On Sat, 18 Oct 2008 20:21:50 -0700, Jerry Avins wrote >> (in article <iJxKk.1692$JT3.575@newsfe03.iad>): >> >>> This argument is getting tired. Or maybe I'm just getting tired of it. >>> Assuming more-or-less steady state signal and plenty of sampling time. >>> the sample rate needs to be a little (how little?) faster than twice the >>> highest component* in order to capture its essence. It can be as low as >>> exactly twice if the aim is simply avoiding aliasing and DC doesn't >>> count. >> >> Jerry (don't get tired!), what if you sample a10 volt 1 KHz sine at 2 KHz >> with all the samples falling at pi/8 and 9pi/8 ? What will you get for >> amplitude? > Charlie, > Jerry is saying that the sample rate has to be faster than twice the highest > component. It's right there in black and white a few lines above. You come > back and ask him to sample a 1 KHz sine wave at 2 KHz. That violates the > "faster than". Stop beating a dead horse!
">>It can be as low as
>> exactly twice if the aim is simply avoiding aliasing and DC doesn't >> count."
-- Charlie
On Sun, 19 Oct 2008 06:17:05 -0700, Jerry Avins wrote
(in article <lrGKk.5348$TX6.877@newsfe06.iad>):

>> Jerry (don't get tired!), what if you sample a10 volt 1 KHz sine at 2 KHz >> with all the samples falling at pi/8 and 9pi/8 ? What will you get for >> amplitude? > > " ... and DC doesn't count." That alias won't get through my headphones. :-)
Ya, you betcha! I'm really aiming at the folks using the functional definition for a finite time situation. I see it all the time. All you folks who know the truth should consider pointing out the error every time it pops up. Maybe we can really kill that horse. -- Charlie Springer
Philip Martel wrote:
> "Charlie Springer" <RAM@regnirps.com> wrote in message > news:0001HW.C5202B4900B66E61F02845B0@news.nw.centurytel.net... >> On Sat, 18 Oct 2008 20:21:50 -0700, Jerry Avins wrote >> (in article <iJxKk.1692$JT3.575@newsfe03.iad>): >> >>> This argument is getting tired. Or maybe I'm just getting tired of it. >>> Assuming more-or-less steady state signal and plenty of sampling time. >>> the sample rate needs to be a little (how little?) faster than twice the >>> highest component* in order to capture its essence. It can be as low as >>> exactly twice if the aim is simply avoiding aliasing and DC doesn't >>> count. >> Jerry (don't get tired!), what if you sample a10 volt 1 KHz sine at 2 KHz >> with all the samples falling at pi/8 and 9pi/8 ? What will you get for >> amplitude? > Charlie, > Jerry is saying that the sample rate has to be faster than twice the highest > component. It's right there in black and white a few lines above. You come > back and ask him to sample a 1 KHz sine wave at 2 KHz. That violates the > "faster than". Stop beating a dead horse!
What I sad was that if the sample rate is exactly twice the sampled frequency, you get no aliasing, provided that DC doesn't matter. Charlie pointed our that DC can arise in the case I described, so we're -- all of us -- in effective agreement. Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
Charlie Springer wrote:
> On Sun, 19 Oct 2008 06:17:05 -0700, Jerry Avins wrote > (in article <lrGKk.5348$TX6.877@newsfe06.iad>): > >>> Jerry (don't get tired!), what if you sample a10 volt 1 KHz sine at 2 KHz >>> with all the samples falling at pi/8 and 9pi/8 ? What will you get for >>> amplitude? >> " ... and DC doesn't count." That alias won't get through my headphones. :-) > > Ya, you betcha! I'm really aiming at the folks using the functional > definition for a finite time situation. I see it all the time. All you folks > who know the truth should consider pointing out the error every time it pops > up. Maybe we can really kill that horse.
We've tried. Many times. I try to stay polite, but I find it really tiring. I'll say again, with Tim's support I'm sure, that in a practical case not limited to quasi-stationary signals, the sample rate should be substantially greater than 2x, not just some vanishingly small epsilon. Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;