Forum Discussion
Altera_Forum
Honored Contributor
14 years ago --- Quote Start --- 1. why is NCO signal and filter datapath 2-bit longer than ADC input? was it randomly assigned? --- Quote End --- You have the code, change it and see what happens :) NCOs have spurious harmonics. If you look at the example figures in the slides I sent a link to, you will see how the harmonics create spurious images in the demodulated response. By adding a couple more bits, you push the level of the images below the quantization noise floor of the demodulated output. This is why you requantize the demodulated signal; the full bit-width product is corrupted by harmonic content, so there is no point in keeping it, and wasting logic processing the extra bits. --- Quote Start --- 2. The incoherent mean is the power of the window, right? it is a normalization factor in computing spectrum. --- Quote End --- When you window a coherent signal like a sinewave, you attenuate the signal at the ends, and its power is lowered by the coherent signal gain. When you window a noise-like signal, you attenuate the RMS (the standard deviation) of the signal at the ends, and its power is lowered by the incoherent signal gain. The paper on using windows with the DFT by Harris (1978) has more details. --- Quote Start --- 3. why should I use multirate processing? i mean, the decimation. I had this question when I saw your diagram of the lock-in amplifier. is it necessary to downsample? so I should build a CIC filter instead of a FIR? --- Quote End --- When you have a sample rate that is orders-of-magnitude higher than the signal bandwidth of interest, then you are 'wasting' processing resources by processing every sample. A more efficient solution is to cascade a series of digital filters that first eliminate noise and then resample to a 'new' sample rate. Eventually the decimated signal is 'sampled' at a rate consistent with the bandwidth of the signal. The best solution is design dependent, but in your case, a CIC filter followed by a FIR or half-band FIR, would probably work nicely. --- Quote Start --- 4. why need h(max) as an extra normalization factor? --- Quote End --- An ideal low pass filter is a rect function in the frequency domain, eg. rect(f/B ), which has an inverse Fourier transform B*sinc(B*t), where f is in normalized frequency units (-0.5 to 0.5) and hence B < 1. The filter coefficients are essentially B*sinc(B*t), so the maximum coefficient is about the size B. If you scale your coefficients into fractional integer format, then since B < 1, you never use the MSBs of your coefficients. To minimize quantization errors in the filter coefficients, you 'normalize' the coefficients by 1/B > 1. This acts like gain in your signal path, so you need to account for it. --- Quote Start --- 5. Ns=Na*Nt+Nh, why? why do we need the extra samples from the window? --- Quote End --- Plot the data from the filtered signal that includes the Nh samples. You'll see that the filtered response looks 'funky' (FIR filter technical term). The first samples out of the filter were calculated while the filter was not completely full. Its easier just to discard those output samples, so they don't produce artifacts in the spectrum. --- Quote Start --- 6. in the quantization of NCO signals, instead of 2^(B_noc-1), you used 2^(B_nco)-1, is it supposed to prevent overflowing? but it is only for NCO signals... --- Quote End --- Read the code again. The amplitude was set to 2^(B_nco-1)-1, because the sinusoid can only take on values -2^(B_nco-1) to +2^(B_nco-1)-1, so you cannot use 2^(B_nco-1), as the sinusoid positive peak cannot be represented. --- Quote Start --- 7.The way you quantized z_q(z_q = filter(h_q,1,y_q), then times 2^(B_out-1), round the number, divided by 2^(B_out-1)). in the hardware case, we just cut off LSB and MSB to keep the signed bit and B_out-1 bits, right? --- Quote End --- No. You need to 'convergent' round. Look at the slides and paper I sent links to. --- Quote Start --- 8. The quantization noise floor I have always been confused, never understood it in the slides... can you explain to me more clearly? --- Quote End --- When you take a continuous signal x(t) and quantize it to y(t), you can consider y(t) to have been 'created' by adding noise to it, eg. y(t) = x(t) + q(t), where q(t) = y(t) - x(t). If you go and perform this calculation for say Gaussian noise in MATLAB, eg., x(t) = 0.25*randn(1,Nt)*2^(B-1), and then create the quantized version via y(t) = round(x(t)) and set any codes outside the range -2^(B-1) to 2^(B-1)-1 to their respective limits. Now plot q(t). You will see that the error is between -0.5 and +0.5. If you plot a histogram, hist(q), you will see that the noise is fairly uniform. The Fourier transform of a uniform noise signal is N*sigma^2, where sigma is the variance of the noise, i.e., 1/sqrt(12). When you calculate the spectrum of a quantized signal, this 'noise' determines the noise floor. When you normalize the signal to fractional integer format, the noise RMS is 1/sqrt(12)*1/2^(B-1). When you calculate the power level of this noise, its 10*log10( 1/12 * 1/2^(2*B-2) ) = 10*log10( 1/3 * 1/2^(2*B ) ) = -4.77dB - 6.02*B. The highest level sinusoid you can represent in fractional integer format has an amplitude of 1.0, which is an RMS of -3dB, so the signal to noise of a quantized sinusoid is -3dB - (-4.77dB - 6.02*B ) = 6.02*B + 1.76dB, and viola, you have the 'rule of thumb' you'll see in many references (but usually without explanation). In the figures my m-file produces, the expected 'noise floor' is drawn at -(6.02*B + 4.77dB ). The peak of an input sinusoid with -3dB power (an amplitude of ~1.0) actually lies above the -3dB point on the power spectrum plot due to the coherent gain of the FFT; if you increase the number of samples used per FFT, the peak will go up. This coherent gain is due to the fact that the power spectrum is normalized so that the power level of incoherent noise signals is fixed relative to the y-axis, i.e., given Nt-samples of noise with standard deviation sigma in the time domain, we expect a variance Nt*sigma^2 in the frequency domain, and hence normalize by Nt, so that we can plot the expected power at 10*log10(sigma^2). The expected peak of a sinusoid is (Nt/2), which in power is (Nt/2)^2, which once normalized by Nt is (Nt/4), and 10*log10(Nt/4) = 10*log10(Nt/2) - 3dB, where the -3dB is the sinusoid power, and the 10*log10(Nt/2) is the coherent gain of the FFT. --- Quote Start --- 9. in the figure(1) plot(fn,10*log10(Rxx+10^(-10))); why adding 10^(-10)? --- Quote End --- log10() does not like to see zeros. Adding a small value sets the noise floor at -100dB. Cheers, Dave