discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Nyquist Rate & Distortion, A Visual Example: Issues


From: Daniel Estévez
Subject: Re: Nyquist Rate & Distortion, A Visual Example: Issues
Date: Sun, 25 Apr 2021 20:54:36 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.9.0

El 25/4/21 a las 18:42, James Hayek escribió:
Apologies if I missed any response from my prior thread.
I wanted to elaborate more here, on what I am attempting to do.

The goal is to create a GRC file to show how sampling rates affect a generated signal. Knowing, for real samples, fs (sampling rate, "samp_rate) would be greater than twice that of the highest bandwidth (f, "freq"), I created a flow graph where one can adjust
the
frequency whilst keeping the sampling rate constant.

I would have imagined (since fs > 2B) for any frequency I set past 1/2*fs, I would see distortion, and anything less would yield accurate results.

I created two sine wave Signal Sources. One where the _sample rate_ was

set to freq*2 and the _frequency_ was set to an adjustable variable, freq.

The other where the _sample rate_ was set to a fixed samp_rate and the _frequency_ was set to the same adjustable variable, freq.

Both signals output to a QT GUI Time SInk. When I run the program, I see the signal using a sampling rate of freq*2 is distorted (triangular waveform) and the signal with the fixed sampling rate distorts past a frequency of 1K Hz. I have the sampling rate to 32KSps.

Wouldn't it distort around 16KHz? What have I set up incorrectly?

Hi James,

Your results are perfectly fine. Nyquist theorem tells us that if we sample at a rate higher than 2*freq, then _it is possible_ to recover the original waveform. That's it. A key ingredient that sometimes is forgotten is the _it is possible_.

What Nyquist doesn't say is that if you sample at a rate higher than 2*freq and join your samples with straight lines, then the result will look like a sine wave. Think about it, if you have very few samples per cycle of the sine wave, then you'll get something just like the triangular-ish wave you see. In order to have a very nice sine wave you need to have many, many points per cycle. And even so, if you zoom all the way in, the fact that you have a bunch of samples joined with straight lines will be visible. That always happens with discrete time sampling.

The interesting question is then, how is it possible to recover the original waveform? This is basically done with sinc interpolation. You can try it yourself in GNU Radio by using the "Rational Resampler" block (for example) to interpolate your ugly triangular-ish waveform so that you get many points per cycle. You'll see a pretty sine wave of the correct frequency.

Now the interesting part comes when you set your frequency higher than samp_rate/2. As long as you're generating a sine wave, you'll also get a pretty sine wave when you interpolate. However, the frequency of this sine wave will no longer be the "expected" one. In this way you can demonstrate aliasing.

Hope this helps.

Best,

Dani.

Attachment: OpenPGP_signature
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]