i will use matlab code just for convenience, i get the same behavior using a C++ code.

I have two signals:



Buf1= int32 ((A*cos(2.0*pi*t*Fp+ Phi*pi/180.0)+Off)/(KADC_5VOLT));
Buf2= int32 ((A*cos(2.0*pi*t*Fp+ Phi*pi/180.0)+0)/(KADC_5VOLT));


performing a FFT on Buf1 i get amplitude 2.4246e-04 for the 5 Hz component ((this values seems to change randomly as a function of A, while A is small); while for Buf2 i get amplitude 2.6287e-04 for the 5 Hz component. If i set A > 0.0015, performing a FFT on Buf1 and Buf2 i get amplitude 0.0015 for the 5 Hz component;

if i use just:

Buf1= ((A*cos(2.0*pi*t*Fp+ Phi*pi/180.0)+Off)/(KADC_5VOLT));
Buf2= ((A*cos(2.0*pi*t*Fp+ Phi*pi/180.0)+0)/(KADC_5VOLT));

performing a FFT on Buf1 and Buf2 i get amplitude 2.5000e-04 for the 5 Hz component.

What is the reason of that? is seems that the problem is related to a quantization error, but why is the offset so important? Also: how can i get rid of it?


Since your offset is 3/5ths (plus some integer), the truncation fractions will be different, resulting in a different sum of quantization noise. You can get rid of this difference by using an integer offset (including/after scaling) before truncation or rounding. (e.g. not (2^N)/5)

Also, if your signal is not exactly periodic in your FFT aperture, then the result magnitude of very low frequencies will have a small dependence on phase, relative to the window (edge or center), and thus not exactly match the input amplitude.

| improve this answer | |

Firstly you didn't mention your sample rate and how your time vector is defined.

Yes, this is a quantization problem. The maximum amplitude in Buf2 is 1.6. If you quantize that to integers you only end up with the values -2,-1,0,1,2 so you have massive amounts of quantization noise. You are only quantizing this two 2 or 3 bits. The correct way to turn this into fixed point would be the apply proper scaling, i.e using fractionals, Q notation or some reasonable normalization scheme.

Adding the offset just shifts the problem around. The only numbers that you get will be 3275, 3276, 3277 and 3278.

The bigger amplitude in Buf1 is simply just quantization noise from the very large added DC component.

| improve this answer | |
  • $\begingroup$ edited with the information that i didn't mentioned. What surprises me is that Buf2 does not have a large DC component. Its offset is set to zero. $\endgroup$ – BiA Jul 22 '13 at 13:51
  • $\begingroup$ Sorry, my bad. Buf1 has the large DC offset. Again, you have enormous amounts of quantization noise, so all bets are off. $\endgroup$ – Hilmar Jul 22 '13 at 15:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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