I sampled a 50Hz sine wave (its not perfectly a sine wave, it's a data coming from current sensor using Arduino).
Using real time graphing technique by sending the data from Arduino to the PC I managed to reconstruct the signal as attached here
The second experiment I logged my data into an SD card, my sampling rate was 5000 and when I tried to reconstruct the signal in MATLAB, I got this graph which doesn't construct the original signal back, but rather its strange as bellow:
Notice the maximum values for the both graphs.
Why the signal is not correctly reconstructed? I sampled it at 5000 Hz which is almost 10 times the original signal frequency and it meets Nyquist criteria ... And as a result of wrongly constructed signal the FFT is indicating the frequency of zero not 50 Hz.
The MATLAB code
filename = 'C:\Users\Sabir\Desktop\internship Sri Wawasan\testFFT.csv'; % thee file fid = fopen(filename,'rt'); [data]=textscan(fid, ' %f',...%the values of the sensors as cell array 'delimiter',',') ; fclose(fid); sensorMatrix=cell2mat(data); % the values of the sensors as matrix %taking some point from the sensors matrix y=sensorMatrix(1:3000,1);% array of one chanel plot (y) L=length(y) Fs = 5000; % Sampling frequency T = 1/Fs; % Sample time % Length of signal t = (0:L-1)*T; % Time vector plot(Fs*t,y)
and finally here is the FFT, it has 100 Hz and 150 Hz components