is my fft code is correct ?

4 views (last 30 days)
tomer polsky
tomer polsky on 1 Jan 2020
I am trying to find the dominent ferquincy of my current data .
so this is the plot of my current via time :
clc;clear all;
ADC_data_lim17_GAIN25=load('Data_Lim_17_GAIN_25');
dec_limit=17 %% decimal limit
f_RD_not=892.858e3; %% ferquincy of the RD_not
normalization_coffient=(19.6e-3)/(25*15e-3) %% normalization coffient ,that is used to transfer from decimal limit to real current.
real_data_ADC=ADC_data_lim17_GAIN25.real_data_ADC; %% dicmal value of the I_1 current (ADC data).
I_real=real_data_ADC*normalization_coffient; %%real current after considartion of the normalization_coffient.
real_data_comperator_output=ADC_data_lim17_GAIN25.real_data_IN_driver; %% output of the comperator in the FPGA .
t=(1/f_RD_not)*(1:length(real_data_comperator_output)); %% time after normalization using the normalization_coffient.
figure(52);
plot(t,I_real,' red -- d ','linewidth',1); %% plot--> of I_real
hold on ;
plot(t,1*dec_limit*normalization_coffient*ones(size(t)),' black ','linewidth',3); %% plot--> of boundery limit
hold on ;
min_y_of_switch=min(real_data_ADC(length(t)/2:end)); %% used to normal the switch in the steady state.
max_y_of_switch=max(real_data_ADC(length(t)/2:end));%% used to normal the switch in the steady state.
line=(max_y_of_switch-min_y_of_switch); %% coffient for the normlaztion of the comperator output.
% plot(t,min(I_real(length(t)/2:end))+line*normalization_coffient*real_data_comperator_output,' blue -- O ','linewidth',1);%% plot--> comperator output
title([' I_1(t) from ADC , Boundery Limit Current=' num2str(dec_limit*normalization_coffient) '[A]']);
ylabel('I[A]');xlabel('time[ mSec]');grid on;grid minor;
legend_1=legend ('I_{real}','boundery limit','comperator output'); %% legend
set(legend_1,'FontSize',16); %% set the font size of the legend xlim([ 0 t(end)]); %% limits of the x axis
xticks([0:0.0002:t(end)]); %% jumps of X axis
ylim([ 0 max(I_real)]); %% limits of the y axis
yticks([ 0:0.1:max(I_real)]); %% jumps of Y axis
I_real_6=I_real;
and this is my fft of this current code :
figure(2);
Fs = f_RD_not; % Sampling frequency
T = 1/Fs; % Sampling period
L = 2040; % Length of signal
t_fft = (0:L-1)*T; % Time vector
Y = fft(I_real_6);
P2 = abs(Y/L);
P1 = P2(1:L/2+1);
P1(2:end-1) = 2*P1(2:end-1);
f = Fs*(0:(L/2))/L;
plot(f,P1);
title('Single-Sided Amplitude Spectrum of I_1(t) from ADC ')
xlabel('f (K Hz)');
ylabel('|P1(f)|') ;
set(gca,'FontSize',12);grid on; %% font size of the lablels
ax = gca; %% used to make xlabel as 10^-3
ax.XAxis.Exponent = +3; %% used to make xlabel as 10^-3
xticks([0:10e3:f(end)]); %% jumps of X axis
down belew I attached pics of the current in time domain and the same current in ferquncy domain, also I attached the data file .
Is my FFT code is right ? and my domiment ferquncy is 87.97[K Hz] ?
  1 Comment
David Goodmanson
David Goodmanson on 4 Jan 2020
Hi tomer,
by eye, 17 cycles / 0.2 ms = 85 kHz ok
and the amplitude in the frequency domain also looks good.

Sign in to comment.

Answers (0)

Categories

Find more on Fourier Analysis and Filtering in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!