i will use matlab code just for convenience, i get the same behavior using a C++ code.
I have two signals:
Fp=5;
A=0.00025;
Phi=0;
Off=0.5;
KADC_5VOLT=5.0/32768.0;
tc=250e-6;
tmax=30;
t=0:tc:tmax;
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));
Buf1=double(Buf1);
Buf2=double(Buf2);
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?