-1
$\begingroup$

Imagine I have a 1 kHz sine wave with very low noise. (Assume a signal generator output with 1v peak to peak clean signal). I am using an ADC to sample this signal. Take the following cases:

  1. Sample for 100 ms at 1 MHz
  2. Sample for 10 ms at 1 MHz
  3. Sample for 1 ms at 1 MHz
  4. Sample for 500 µs at 10 MHz

And I take the resulting output and FFT using 1024 window size.

My mental model is such that

  1. Will have a fantastic SNR a well defined peak at 1 kHz.
  2. Same as 1. The SNR will not reduce substantially.
  3. No peak can be observed since the signal didn’t even cycle one round in time domain, even though the sampling rate is well above the required minimum resolution. (Nyquist)
  4. Same as 3.

Could you please help me verify? Also how does the period of the signal vs ADC sampling duration comes in to play? What is the theory behind it?

$\endgroup$
  • $\begingroup$ The reasoning also depends on the amplitude quantization $\endgroup$ – Laurent Duval Jan 24 '18 at 8:27
  • $\begingroup$ @LaurentDuval amplitude is not an issue let’s assume. My signal is p2p 1v And adc can be 10bit. $\endgroup$ – Ktuncer Jan 24 '18 at 8:29
  • $\begingroup$ @Ktuncer well, with exactly that number of bits, amplitude quantization does become an issue, because none of your cases actually put a "bin center frequency" right atop of your tone's frequency. And especially for 3. and 4., the question of whether you can still detect something depends on the SNR being better than $1024 = 2^{10}$, so Laurent is on-point here. $\endgroup$ – Marcus Müller Jan 24 '18 at 12:17
  • $\begingroup$ @MarcusMüller I don’t get it. 10 bit is depending on your reference voltage will be dividing the reference voltage to 1024. The 1v signal will definitely show up in adc and in the bins. So again amplitude doesn’t come in the picture. We are not trying to sample a signal that at the noise floor. We sample a very clean and visible signal with high snr. We just do it for a short time. $\endgroup$ – Ktuncer Jan 24 '18 at 12:47
  • $\begingroup$ Have you tried simulating the experiment using Matlab/Octave/Python ? $\endgroup$ – Fat32 Jan 24 '18 at 13:32
2
$\begingroup$

I think that what you are hinting at is the concept of resolution of the Discrete Fourier Transform. This will determine how much SNR will drop in-band.

The standard DFT will break some $x[n]$ down to a complex sum of sinusoids. But if you notice, the variable changes from $n$ to $k$, with $k$ being the index to $X$. As an index, it cannot be a Real number. It has to be an integer. You probably have heard $k$ being referred to as the "bin".

Again, if you notice that formula, knowing that $k,n \in \mathbb{Z}$, you will see that $x[n]$ is broken down to a set of sinusoids whose (physical) frequencies depend on $N$.

The mapping between physical frequencies and "bins" is straightforward: $f_k = k \cdot \frac{Fs}{N}$

So, if you obtained a 128 point DFT of the output of a CD player, the distance between bins would be $\frac{44100}{128} = 343.75$ Hz.

BUT, in reality, this is like setting up a filter bank of band pass filters (or, resonators) every $\frac{Fs}{N}$ Hz. The "bin" resonator will peak at the centre and fall off gradually around it. Consequently, how much noise will be in-band to the resonator, depends on its "width".

Now:

Will have a fantastic snr a well defined peak at 1KHz.

$\frac{1000000}{1024}=976.525$ Hz. Your spectrum will be divided in 1024 bins of 976.525 Hz each. Your first two bins will be higher than zero. The first bin considerably more than the second. In the absence of any further information about the SNR and assuming that the noise affects all bands equally, the first bin will receive $\frac{1}{1024}$th of the SNR.

Same as 1. The snr will not reduce substantially.

If the SNR was the same as #1 then reducing your integration time they will scale proportionally (remember that power is energy over time).

No peak can be observed since the signal didn’t even cycle one round in time domain, even though the sampling rate is well above the required minimum resolution. (Nyquist)

It depends on the SNR. If signal power is below noise power then all 1024 windows will be "dancing" randomly as each band will be receiving some random portion of the total noise power. If the signal power is above the noise power then your lower windows will still register higher sums because multiplied with the 1kHz sinusoid will still generate larger sums than multiplying them with the 900kHz sinusoids.

Same as 3.

Worse than three. Your separation now is $\frac{10000000}{1024}=9765.625$ Hz of which 1kHz is approximately 1 tenth of. The rest is "measuring" (or summing) noise.

Hope this helps.

EDIT:

... If you do observe only a fraction of a period of a given signal. In this case a sine. Does it still show up in fft ?

Yes.

import scipy
import matplotlib.pyplot as plt

signalDuration = 1 #In Seconds
Fs = 100 #In Hz
f = 0.2 #Sinusoid frequency, in Hz

t = scipy.linspace(0,signalDuration, signalDuration * Fs) #Time vector
p = 2.0*scipy.pi*t #Phase vector.

s = scipy.sin(f*p)

plt.plot(s);plt.show()

The signal (s):

enter image description here

S = scipy.fft(s)
plt.semilogy(abs(S))

Its spectrum:

enter image description here

Three things:

  1. Vary the 'f' around 1.0to observe the "shape" of the first bandpass filter. You will notice that the amplitude peaks at 1.0 but decreases in between the bins.

  2. To understand why the sums work out:

abs(complex(scipy.sum(s*scipy.cos(1*p)), -scipy.sum(s*scipy.sin(1*p)))) evaluates to 9.351789426245258

abs(complex(scipy.sum(s*scipy.cos(30*p)), -scipy.sum(s*scipy.sin(30*p)))) evaluates to 0.36042210522410306

The first case is for k=1 the second is for k=30.

  1. Whether you are going to observe a robust value or not is up to the SNR. You are right to observe the "fraction" but a fraction with respect to what? So what if the input signal is a fraction of a full period? A full period will give you a sum of $A$, a fraction of the period will give you a fraction of $A$. Now if this fraction of $A$ happens to be below SNR, you still get a sum but with very high variability over time that it makes it unreliable.
$\endgroup$
  • $\begingroup$ There was a downvote – which is democratically very fine – but as this is a nice (in both the modern and the old meaning of "nice") and extensive answer, I'd really be interested in why this question did not meet someone's expectation; I think a comment would probably help understanding what might be wrong. $\endgroup$ – Marcus Müller Jan 24 '18 at 12:13
  • $\begingroup$ Only thing I'd be willing to criticize: OP speaks of a a "sine wave", implying a real-valued signal. So we're not even only talking about leakage of a single complex sinusoids, but two with half the power. $\endgroup$ – Marcus Müller Jan 24 '18 at 12:16
  • $\begingroup$ You guys are missing the real question. If you do observe only a fraction of a period of a given signal. In this case a sine. Does it still show up in fft ? I just cannot believe it and I am trying to get theoretical basis. $\endgroup$ – Ktuncer Jan 24 '18 at 12:35
  • $\begingroup$ @Ktuncer please see updated answer. $\endgroup$ – A_A Jan 24 '18 at 13:34
  • 1
    $\begingroup$ Thanks for a good answer. The big revelation for me was that even if you observe the fraction of a period of a periodic signal, the FFT still contains relevant information regarding the period or frequency of that signal, it is just smaller. My mental model was completely wrong, I was thinking that we need several cycles of signal to be digitized and FFT'ed before we observe the signal clearly. $\endgroup$ – Ktuncer Jan 28 '18 at 5:58
-1
$\begingroup$

"You guys are missing the real question. If you do observe only a fraction of a period of a given signal. In this case a sine. Does it still show up in fft ? "

I'm going to assume you used a 1000 point DFT instead of 1024 to avoid a little muddling that occurs. In your first two cases, there are a whole number of cycles within your DFT frame (or really close) so the signal is centered on a bin and there is no leakage (minimal leakage with 1024). Had you had 1.1 cycles in your frame, there would have been some leakage around the 1 bin. In your example 3, you have 0.1 cycles per frame, so most of your value is going to be in the 0 bin (DC bin) with leakage into the other bins. In your example 4, you only have .005 cycles so your signal will show up in the DC bin with hardly any leakage. Since you used a sine wave instead of a cosine wave it will be very close to zero as well.

Ced

P.S. I don't like the term "leakage", but that is what is used and understood.

$\endgroup$

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.