Summary of the invention
The invention provides a kind of frequency tracking method for Fourier transform, the problem that can impact the computational accuracy of Fourier transform with the deviation that solves the prior art medium frequency.
A kind of frequency tracking method for Fourier transform is characterized in that, comprising:
According to current a-c cycle calculating sampling time interval △ t;
In a cycle, ac analog is sampled N time N=2 according to the sampling time interval △ t that calculates
M, M is integer;
According to the data that sampling obtains, directly calculate the first a-c cycle f
1, adopt Fast Fourier Transform (FFT) to calculate the second a-c cycle f
2
Compare the first a-c cycle f
1With the second a-c cycle f
2Difference, whether judge described difference less than preset value, if, then with the second a-c cycle f
2Be current a-c cycle, otherwise, with the first a-c cycle f
1Be current a-c cycle.
A kind of frequency-tracking device for Fourier transform is characterized in that, comprising:
The first computing module is used for according to current a-c cycle calculating sampling time interval △ t;
Sampling module is used for ac analog being sampled N time N=2 in a cycle according to the sampling time interval △ t that calculates
M, M is integer;
The second computing module, the data for obtaining according to sampling directly calculate the first a-c cycle f
1
The 3rd computing module for the data that obtain according to sampling, adopts Fast Fourier Transform (FFT) to calculate the second a-c cycle f
2
Comparison module is used for relatively the first a-c cycle f
1With the second a-c cycle f
2Difference, judge that whether described difference is less than preset value;
A-c cycle arranges module, if be used for described difference less than preset value, then with the second a-c cycle f
2Be current a-c cycle, otherwise, with the first a-c cycle f
1Be current a-c cycle.
Technical solution of the present invention adopts with the constant duration image data, the data that gather are obtained two a-c cycles by direct calculating and Fourier transform respectively, whether the difference according to these two a-c cycles is determined take one of them as current a-c cycle above preset value, and according to the definite technical scheme that adopts the time interval of current a-c cycle, frequency that can the real-time follow-up ac analog, make the sampling period consistent with the cycle of ac analog, accomplish that a cycle namely finishes frequency-tracking, thereby make measurement data not be subjected to the impact of frequency change, can correct when frequency departure is large, the problem that the Fourier transform measuring error is large, the measuring accuracy of technical solution of the present invention is high, calculated amount is little, applied widely, every cycle only need to carry out one time Fourier transform, and common not with 51 of DSP function, the chips such as ARM just can be realized.
Embodiment
The invention will be further described below in conjunction with accompanying drawing, and following examples only are used for technical scheme of the present invention more clearly is described, and can not limit protection scope of the present invention with this.
The embodiment of the invention provides a kind of frequency tracking method for Fourier transform, the method be according to Fourier transform in the situation of frequency departure less than 1Hz, frequency measurement more accurately characteristics proposes.
Please refer to Fig. 1, embodiment of the invention method comprises:
110, according to current a-c cycle calculating sampling time interval △ t, in a cycle, ac analog is sampled N time N=2 according to the sampling time interval △ t that calculates
M, M is integer.
Suppose that described ac analog is
Wherein, U
mBe voltage magnitude, f is a-c cycle,
Be initial phase angle, t is time variable, and the initial value of a-c cycle f is 50Hz.
Described sampling time interval is
Present embodiment adopts timer regularly, and constant duration △ t samples, and employing obtains discrete signal and is designated as
K is sampling number, and adopting k for the first time is 1, and the k that samples for the second time is 2, the like.
120, the data that obtain according to sampling directly calculate the first a-c cycle f
1, adopt Fast Fourier Transform (FFT) to calculate the second a-c cycle f
2
Present embodiment can adopt half-wave to calculate the first a-c cycle, specifically comprises:
Calculate the mean value of N the data that sampling obtains in the cycle, a described N data are compared with this mean value respectively, find out two adjacent zero crossing data, calculate the difference △ N of these two multi-zero data, then, the first a-c cycle is
The second a-c cycle f
2Computing method comprise:
Adopt Fast Fourier Transform (FFT), calculate respectively the first-harmonic real part U that exchanges phasor
aWith first-harmonic imaginary part U
b, wherein,
U
kBe k point sampling value, K is natural number;
Calculate the initial phase angle of first-harmonic according to first-harmonic real part and imaginary part
Then the second a-c cycle is
Φ
nAnd Φ
N-1It is respectively the initial phase angle of first-harmonic in adjacent two sampling periods.
130, compare the first a-c cycle f
1With the second a-c cycle f
2Difference, whether judge described difference less than preset value, if, then with the second a-c cycle f
2Be current a-c cycle, otherwise, with the first a-c cycle f
1Be current a-c cycle.
Described preset value can be 0.5Hz.If f
1With f
2Differ<0.5Hz, then with f
2Be current a-c cycle, otherwise with f
1Be current a-c cycle.The present embodiment method can be accomplished each cycle tracking and be upgraded a-c cycle one time.Point out in 110 that the a-c cycle calculating sampling time interval △ t according to current after having redefined current a-c cycle, need to recomputate sampling time interval △ t.
In the situation of frequency departure less than 1Hz, frequency measurement is characteristics more accurately, have proposed said method according to Fourier transform for the embodiment of the invention.The method adopts sampled value directly to ask the method for frequency when frequency departure is large, and the frequency that Fourier transform is calculated is corrected.And be implemented in each sampling period sampling time interval is recomputated, to reach sample frequency tracking measurement a-c cycle.
Technical solution of the present invention adopts with the constant duration image data, the data that gather are obtained two a-c cycles by direct calculating and Fourier transform respectively, whether the difference according to these two a-c cycles is determined take one of them as current a-c cycle above preset value, and according to the definite technical scheme that adopts the time interval of current a-c cycle, frequency that can the real-time follow-up ac analog, make the sampling period consistent with the cycle of ac analog, accomplish that a cycle namely finishes frequency-tracking, thereby make measurement data not be subjected to the impact of frequency change, can correct when frequency departure is large, the problem that the Fourier transform measuring error is large, the measuring accuracy of technical solution of the present invention is high, calculated amount is little, applied widely, every cycle only need to carry out one time Fourier transform, and common not with 51 of DSP function, the chips such as ARM just can be realized, simply, reliably, low to hardware requirement, it is convenient to realize, practical.
Please refer to Fig. 2, the embodiment of the invention also provides a kind of frequency-tracking device for Fourier transform, comprising:
The first computing module 201 is used for according to current a-c cycle calculating sampling time interval △ t;
Sampling module 202 is used for ac analog being sampled N time N=2 in a cycle according to the sampling time interval △ t that calculates
M, M is integer;
The second computing module 203, the data for obtaining according to sampling directly calculate the first a-c cycle f
1
The 3rd computing module 204 for the data that obtain according to sampling, adopts Fast Fourier Transform (FFT) to calculate the second a-c cycle f
2
Comparison module 205 is used for relatively the first a-c cycle f
1With the second a-c cycle f
2Difference, judge that whether described difference is less than preset value;
A-c cycle arranges module 206, if be used for described difference less than preset value, then with the second a-c cycle f
2Be current a-c cycle, otherwise, with the first a-c cycle f
1Be current a-c cycle.
Suppose that described ac analog is
Wherein, U
mBe voltage magnitude, f is a-c cycle,
Be initial phase angle, t is time variable, and the initial value of a-c cycle f is 50Hz.
Described the
first computing module 201 specifically can be used for according to formula
The calculating sampling time interval.
Described the
second computing module 203, specifically can be used for adopting half-wave to calculate the first a-c cycle, comprise: the mean value that calculates N the data that sampling obtains in the cycle, a described N data are compared with this mean value respectively, find out two adjacent zero crossing data, calculate the difference △ N of these two multi-zero data, then, the first a-c cycle is
Described the 3rd computing module 204 specifically can comprise:
The first computing unit is used for calculating the first-harmonic real part U that exchanges phasor
aWith first-harmonic imaginary part U
b, wherein,
U
kBe k point sampling value, K is natural number;
The second computing unit is used for calculating the initial phase angle of first-harmonic according to first-harmonic real part and imaginary part
The 3rd computing unit is used for according to formula
Calculate the second a-c cycle, Φ
nAnd Φ
N-1It is respectively the initial phase angle of first-harmonic in adjacent two sampling periods.
To sum up, the frequency-tracking device that is used for Fourier transform that the embodiment of the invention provides, employing is with the constant duration image data, the data that gather are obtained two a-c cycles by direct calculating and Fourier transform respectively, whether the difference according to these two a-c cycles is determined take one of them as current a-c cycle above preset value, and according to the definite technical scheme that adopts the time interval of current a-c cycle, frequency that can the real-time follow-up ac analog, make the sampling period consistent with the cycle of ac analog, accomplish that a cycle namely finishes frequency-tracking, thereby make measurement data not be subjected to the impact of frequency change, can correct when frequency departure is large, the problem that the Fourier transform measuring error is large, the measuring accuracy of technical solution of the present invention is high, calculated amount is little, applied widely, every cycle only need to carry out one time Fourier transform, and common not with 51 of DSP function, the chips such as ARM just can be realized, simply, reliably, low to hardware requirement, it is convenient to realize, practical.
The below does further detailed description with a concrete application examples to technical solution of the present invention:
In should use-case, the frequency-tracking device be take ARM cortex-M3 chip as master control IC, and hardware connection as shown in Figure 3.
During actual motion, 220V ac phase voltage access frequency-tracking device, behind electric resistance partial pressure, voltage rising, filtering circuit, be converted to 3V with interior voltage signal, be input to again modulus (AD) switched pins of master control IC, convert digital quantity to through AD, finish by embodiment of the invention method again and calculate and frequency-tracking.
As shown in Figure 4, should may further comprise the steps by use-case:
1, chip initial configuration
A, the per cycle sampling number N=32 of setting, the initial default frequency is 50Hz,
B, each variable of initialization, configuration AD, timer.
2, sampled data
Adopt timer regularly, the constant duration △ t AC signal of sampling obtains u
k
3, algorithm calculates
A, obtain the mean value of sampled data first
Pass through again
Compare with each sampled data, obtain the poor △ N of adjacent two zero crossing data and two zero crossing data.Obtain a-c cycle according to △ N
B, employing Fast Fourier Transform (FFT) calculate the first-harmonic real part, the imaginary part that exchange phasor, calculate the initial phase angle of first-harmonic according to first-harmonic real part and imaginary part
With the initial phase angle calculated rate of the first-harmonic in adjacent two sampling periods,
C, judgement alternating voltage data if voltage magnitude less than 40V, is not then done frequency-tracking, are no longer carried out following step, otherwise are calculated below continuing.
D, two frequency f of comparison
1And f
2, as: f
1With f
2Differ<0.5Hz, then with f
2Be a-c cycle, sampling time interval is recomputated; Otherwise with f
1Be a-c cycle, sampling time interval is recomputated.And carry out sample frequency and follow the tracks of.
Technical solution of the present invention has preferably frequency-tracking ability, and is less in frequency jitter, can accomplish during for example less than 1Hz that a cycle just finishes sample frequency and follow the tracks of, and when frequency jitter was large, two cycles just can be finished frequency-tracking.
More than the frequency tracking method and the device that are used for Fourier transform that the embodiment of the invention is provided be described in detail, but the explanation of above embodiment just is used for helping to understand method of the present invention and core concept thereof, should not be construed as limitation of the present invention.Those skilled in the art are in the technical scope that the present invention discloses, and the variation that can expect easily or replacement all should be encompassed within protection scope of the present invention.