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: James Hayek
Subject: Re: Nyquist Rate & Distortion, A Visual Example: Issues
Date: Sun, 25 Apr 2021 16:26:33 -0400

It definitely helps, thank you. One thing I noticed, and don't know how to address is why the ""Correctly Sampled Signal"" Time Sink shows the amplitude on the nanoscale.My signal source has an amplitude of one and the Time Sink should be displaying a range from -1 to 1. 

I placed a rational resampler like you mentioned. I placed it after the throttle block and before the Time Sink. I used an interpolation of 5 for the signal that uses a variable sampling rate (2*freq) and see a nice sine wave now. I am unsure how to do that for the signal source where I keep the sample rate constant since a constant value of 5 distorts the signal. Is there a way to tie this parameter to another?

Yes, that's a good example. I see when freq is greater than samp_rate/2 that the frequency sink displays an incorrect frequency. Maybe that's the way to go about showing aliasing in GRC.  



On Sun, Apr 25, 2021 at 2:55 PM Daniel Estévez <daniel@destevez.net> wrote:
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.



--
Thanks,
James G Hayek
Youtube.com/JamesHayek

Attachment: SampleRate.grc
Description: Binary data


reply via email to

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