low pass digital filter on a fixed point microcontroller

On Sat, 18 Oct 2008 12:50:57 -0700, Tim Wescott wrote (in article ):

You state in your own paper that sampling at the Nyquist rate is meaningless without phase (and how can you have phase if you sample at the Nyquist rate?). So I respectfully submit that your premise is incorrect. In theory, you need to sample at least greater than twice the highest frequency component.

Just change your into from

"The Nyquist theorem states that if you have a signal that is perfectly band limited to a bandwidth of f0 then you can collect all the information there is in that signal by sampling, as long as your sample rate is 2f0 or more."

to ---sample rate > 2f0 or more.

The form of the theorem you are using is for analytical functions of infinite extent. Thus the misconception. If you can not sample for an infinite length of time (and who has the time for that?), you must exclude the equality.

Your intro should say function instead of signal and remove the other references to bandwidth and signals, then relate it to the Fourier Transform to define bandlimiting. Note the FT is also from -infinity to infinity.

Or you can just say >2f0.

-- Charlie Springer

Reply to
Charlie Springer
Loading thread data ...

On Sat, 18 Oct 2008 14:06:15 -0700, Jerry Avins wrote (in article ):

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

Reply to
Charlie Springer

e

...

...

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

Reply to
robert bristow-johnson

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.
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Reply to
Jerry Avins

On Sat, 18 Oct 2008 20:21:50 -0700, Jerry Avins wrote (in article ):

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

Reply to
Charlie Springer

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!

Reply to
Philip Martel

" ... 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.
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Reply to
Jerry Avins

On Sun, 19 Oct 2008 06:07:01 -0700, Philip Martel wrote (in article ):

">>It can be as low as

-- Charlie

Reply to
Charlie Springer

On Sun, 19 Oct 2008 06:17:05 -0700, Jerry Avins wrote (in article ):

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

Reply to
Charlie Springer

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.
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Reply to
Jerry Avins

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.
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Reply to
Jerry Avins

IIRC I make the point that the theorem, as stated, requires an infinite observation interval. One of the main points of the paper is to get folks to realize that the Nyquist limit isn't a wall that you can comfortably lean against -- it's more like an electric fence that you want to distance yourself from by a healthy margin.

I intentionally avoided mention of the Fourier transform; the intended audience for that article doesn't necessarily understand the FT, and I didn't want to throw it at them.

It does make for significantly more hand waving instead of hard math -- but if someone can understand the hard math, they don't need a whole article, they just need to think a bit.

--
Tim Wescott
Wescott Design Services
 Click to see the full signature
Reply to
Tim Wescott

I was reading "at least twice" and getting fs (is strictly) > f/2.

But now that you've all smacked me upside the head, I'm not sure why I was thinking that.

Habit, I suppose.

--
Tim Wescott
Wescott Design Services
 Click to see the full signature
Reply to
Tim Wescott

While it isn't "aliasing" according to the accepted definition of that term, I would consider a system that reproduces the original signal at full amplitude one time, but outputs zero volts (AC or DC) after cycling the power to be a failure to "capture the essence" of the original signal. That, of course, is what happens when the signal is a sine wave and the sample rate is exactly twice the sampled frequency; one time the samples hit the peaks, the next time they always hit the zero crossings.

--
Guy Macon
Reply to
Guy Macon

Did I or anyone else talk about capturing an essence? Do you think that a signal's essence can be captured by sampling it at a millihertz above the theoretical 2x for ten seconds? Do you know any practical system that samples less than ten percent above? Even that pushes the edge.

You can sample the cosine component, but not the sine. If there were a way to sample at *precisely* 2x, it would also be possible to get the phase right. Otherwise, margin is needed.

Jerry

--
Engineering is the art of making what you want from things you can get.
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Reply to
Jerry Avins

okay, well independent of what Jerry said (dunno if i agree), i thought the only problem with sampling something at Nyquist was phase vs. amplitude is ambiguous. you cannot know both the phase and the amplitude of any component at Nyquist. consider:

x(t) = (1/cos(theta)) * cos(w0*t+theta)

if w0 = 2*pi*(Fs/2) or Hyquist, then the samples are

x[n] = x(n/Fs) = -(-1)^n

doesn't matter what the phase (with the corresponding amplitude) is, you cannot tell from the samples because of aliasing. aliasing at higher frequencies results in frequency components (with determined phase and amplitude) below Nyquist masquerading as the originally there at that sub-Nyquist frequency. but it was originally above Nyquist, hence aliasing. in both cases of aliasing, it's just that you don't have sufficient information to discriminate between the different cases that happen to have identical samples.

that's the only thing i think is wrong with sampling something with a component at the Nyquist frequency.

r b-j

Reply to
robert bristow-johnson

I'm probably being a bit thick, but how? (Unless of course the signal generator and the sampling device are syncronised)

Rocky

Reply to
Rocky

If they aren't synchronized or derived from a single source, how would a precise 2:1 frequency ratio be maintained?

Jerry

--
Engineering is the art of making what you want from things you can get.
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Reply to
Jerry Avins

Mathematically, the probability of any specific value in a continuous distribution is zero. In sampling an analog signal, one would need a PLL to keep the sampling frequency right on twice a sine input. In that case, it is up to the designer of the PLL to select the appropriate phase.

For real sampling of real analog signals the spectrum should tend to zero approaching half the sampling frequency. Filters with infinitely sharp cutoff aren't physically realizable.

Except for signals specifically hand generated to prove one way or the other, there are no cases where the difference should be visible.

-- glen

Reply to
glen herrmannsfeldt

Tim Wescott wrote: (snip)

or a perfectly periodic signal, such that the Fourier series is used instead of the continuous Fourier transform. Otherwise, yes.

For a finite interval, it approximately works not too far from the end points, good enough for most of us.

Otherwise, it seems to me that if you have N+1 points over an interval of N times the Nyquist rate you have enough. (Subtract a line with the slope of the line going through the first and last points that crosses the axis half way between the two end points. Now connect the first and last point (which are now equal) and use periodic boundary conditions. The +1 is for the slope of the needed line.) That tells how close you can come with a finite interval.

-- glen

Reply to
glen herrmannsfeldt

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.