We measured the voltage output of a rotating machine (generator) which base frequency is 60 Hz. The acquisition sampling is 20 kHz. The generator frequency is varying in time (can be 60.1, 59.9, etc). My recording length is several minutes and I would like to trace the output frequency of the voltage over the time.
I made a sliding windows where I calculate an FFT over 2*334=668 samples, corresponding to 33.4 msec of approximately 2 cycles at 60 Hz.
With the FFT function, I am not able to acheive the precision of 1/10 Hz.
The frequency bins are 29.94 Hz, 59.88 Hz, 89.82 Hz, for a windows 2 cycles. In order to refine the bins, I will have to enlarge the windows, but it becomes so large that a fluctuation is no longer visible.
Am I missing something?
Is there another method that could be more suitable for the application?
load Va.mat %Contains the variable which is the generator output voltage
T = 50e-6; % Sampling period
Fs = 1/T; % Sampling frequency
L = 2*334; % Length of signal
t = (0:L-1)*T; % Time vector
iter = 5000; %Number of windows
sig = zeros(iter,3);
for i = 1:1:iter
S = Gen_volt_output(i:L+i-1,1); %Sample to be analysed
f = Fs*(0:(L/2))/L; %Freq. bins
Y = fft(S);
P2 = abs(Y/L);
P1 = P2(1:L/2+1);
P1(2:end-1) = 2*P1(2:end-1);
[max_val,index] = max(P1);
frequence = f(index);
sig(i,1) = i;
sig(i,2) = frequence;
sig(i,3) = max_val/sqrt(2);
end
subplot(2,1,1)
plot(sig(:,2))
subplot(2,1,2)
hold on
plot(sig(:,3))
plot(Gen_volt_output(1:iter))
hold off

 Respuesta aceptada

William Rose
William Rose el 28 de Mzo. de 2021

2 votos

When you do a standard FFT, the output frequency spacing is df=1/T where T is the duration of the sample. To get resolution of 0.1 Hz, you need a 10 second long sample. You would need even longer, if you use Welch's method, pwelch(). (Read the help for more on pwelch() is desired.) Since you have sampled the signal at a high rate, I recommend measuring the time between successive upward-sloping zero crossings, and taking the reciprocal of that interval to estimate the frequency of each cycle. Or find T2cross=time between every second positive-sloped zero crossing. Then f=2/(T2cross).
Of course this will not be exactly correct if the baseline is drifting or if the signal is not centered on zero, so adjust accordingly, if needed.

3 comentarios

William Rose
William Rose el 28 de Mzo. de 2021
For finding when the zero crossings occur, you can make your own function, or you can see what others have done by entering "zero crossing" in the Matlab Answers search bar. It has been discussed at length. If you dive into the comments here, you will find a function crossing_V6(), posted by @Mathieu NOE. He really knows a lot, so I trust what he posts. I have not tried crossing_V6(), but it looks good. It allows the user to specifiy a level other than zero. It returns times (if a time vector is provided), or the indices, of exact level crossings, and it interpolates, if the sampled values cross but do not exactly equal the level. I think it returns crossings with + and - slope. Therefore you can take every second or every fourth crossing, in order to estimate frequency every one or every two cycles. If you do not pass a time vector, then multiply index differences by the samping interval, to get cycle durations in seconds.
Yannick Pratte
Yannick Pratte el 28 de Mzo. de 2021
Thanks! That works!
William Rose
William Rose el 29 de Mzo. de 2021
You're welcome @Yannick Pratte

Iniciar sesión para comentar.

Más respuestas (0)

Productos

Versión

R2020b

Etiquetas

Preguntada:

el 28 de Mzo. de 2021

Comentada:

el 29 de Mzo. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by