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 solving prior art medium frequency.
For a frequency tracking method for Fourier transform, it is characterized in that, comprising:
According to current a-c cycle calculating sampling time interval △ t;
Ac analog is sampled N time in a cycle according to the sampling time interval △ t calculated, N=2
m, M is integer;
According to the data obtained of sampling, directly calculate the first a-c cycle f
1, adopt Fast Fourier Transform (FFT) to calculate the second a-c cycle f
2;
Relatively the first a-c cycle f
1with the second a-c cycle f
2difference, judge whether described difference is less than preset value, if so, then with the second a-c cycle f
2for current a-c cycle, otherwise, with the first a-c cycle f
1for current a-c cycle.
For a frequency tracking apparatus for Fourier transform, it is characterized in that, comprising:
First computing module, for according to current a-c cycle calculating sampling time interval △ t;
Sampling module, for sampling N time to ac analog in a cycle according to the sampling time interval △ t calculated, N=2
m, M is integer;
Second computing module, for according to the data obtained of sampling, directly calculates the first a-c cycle f
1;
3rd computing module, for according to the data obtained of sampling, adopts Fast Fourier Transform (FFT) to calculate the second a-c cycle f
2;
Comparison module, for comparing the first a-c cycle f
1with the second a-c cycle f
2difference, judge whether described difference is less than preset value;
A-c cycle arranges module, if be less than preset value for described difference, then with the second a-c cycle f
2for current a-c cycle, otherwise, with the first a-c cycle f
1for current a-c cycle.
Technical solution of the present invention adopts with constant duration image data, to the data gathered respectively by directly calculating and Fourier transform obtain two a-c cycles, whether exceed preset value to determine with one of them for current a-c cycle according to the difference of these two a-c cycles, and determine according to current a-c cycle the technical scheme adopting the time interval, can the frequency of real-time follow-up ac analog, make the sampling period consistent with the cycle of ac analog, accomplish that namely a cycle completes frequency-tracking, thus make measurement data not by the impact of frequency change, can correct when frequency departure is large, the problem that 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 needs to carry out a Fourier transform, and it is common not with 51 of DSP function, the chips such as ARM just can realize.
Embodiment
Below in conjunction with accompanying drawing, the invention will be further described, and following examples only for technical scheme of the present invention is clearly described, and can not limit the scope of the invention with this.
The embodiment of the present invention provides a kind of frequency tracking method for Fourier transform, and the method is according to Fourier transform when frequency departure is less than 1Hz, frequency measurement feature proposition more accurately.
Please refer to Fig. 1, embodiment of the present invention method comprises:
110, according to current a-c cycle calculating sampling time interval △ t, ac analog is sampled N time in a cycle according to the sampling time interval △ t calculated, N=2
m, M is integer.
Suppose that described ac analog is
wherein, U
mfor voltage magnitude, f is a-c cycle,
for initial phase angle, t is time variable, and the initial value of a-c cycle f is 50Hz.
Described sampling time interval is
The present embodiment adopts timer timing, and constant duration △ t samples, and employing obtains discrete signal and is designated as
k is sampling number, and first time adopts k to be 1, and second time sampling k is 2, the like.
120, according to the data obtained of sampling, the first a-c cycle f is directly calculated
1, adopt Fast Fourier Transform (FFT) to calculate the second a-c cycle f
2.
The present embodiment can adopt half-wave to calculate the first a-c cycle, specifically comprises:
Calculate in a cycle mean value of the N number of data obtained of sampling, described N number of data 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
Second a-c cycle f
2computing method comprise:
Adopt Fast Fourier Transform (FFT), calculate the first-harmonic real part U exchanging phasor respectively
awith first-harmonic imaginary part U
b, wherein,
U
kfor kth point sampling value, k is natural number;
The initial phase angle of first-harmonic is calculated according to first-harmonic real part and imaginary part
Then the second a-c cycle is
Φ
nand Φ
n-1the initial phase angle of first-harmonic in adjacent two sampling periods respectively.
130, the first a-c cycle f is compared
1with the second a-c cycle f
2difference, judge whether described difference is less than preset value, if so, then with the second a-c cycle f
2for current a-c cycle, otherwise, with the first a-c cycle f
1for current a-c cycle.
Described preset value can be 0.5Hz.If f
1with f
2difference <0.5Hz, then with f
2for current a-c cycle, otherwise with f
1for current a-c cycle.The present embodiment method can accomplish that each cycle is followed the tracks of and upgrades an a-c cycle.Point out in 110, according to current a-c cycle calculating sampling time interval △ t, after having redefined current a-c cycle, need to recalculate sampling time interval △ t.
The embodiment of the present invention is according to Fourier transform when frequency departure is less than 1Hz, and frequency measurement is feature more accurately, proposes said method.The method, when frequency departure is large, adopts sampled value directly to ask the method for frequency, corrects the frequency that Fourier transform calculates.And realize recalculating sampling time interval in each sampling period, to reach sample frequency tracking measurement a-c cycle.
Technical solution of the present invention adopts with constant duration image data, to the data gathered respectively by directly calculating and Fourier transform obtain two a-c cycles, whether exceed preset value to determine with one of them for current a-c cycle according to the difference of these two a-c cycles, and determine according to current a-c cycle the technical scheme adopting the time interval, can the frequency of real-time follow-up ac analog, make the sampling period consistent with the cycle of ac analog, accomplish that namely a cycle completes frequency-tracking, thus make measurement data not by the impact of frequency change, can correct when frequency departure is large, the problem that 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 needs to carry out a Fourier transform, and it is common not with 51 of DSP function, the chips such as ARM just can realize, simply, reliably, low to hardware requirement, it is convenient to realize, practical.
Please refer to Fig. 2, the embodiment of the present invention also provides a kind of frequency tracking apparatus for Fourier transform, comprising:
First computing module 201, for according to current a-c cycle calculating sampling time interval △ t;
Sampling module 202, for sampling N time to ac analog in a cycle according to the sampling time interval △ t calculated, N=2
m, M is integer;
Second computing module 203, for according to the data obtained of sampling, directly calculates the first a-c cycle f
1;
3rd computing module 204, for according to the data obtained of sampling, adopts Fast Fourier Transform (FFT) to calculate the second a-c cycle f
2;
Comparison module 205, for comparing the first a-c cycle f
1with the second a-c cycle f
2difference, judge whether described difference is less than preset value;
A-c cycle arranges module 206, if be less than preset value for described difference, then with the second a-c cycle f
2for current a-c cycle, otherwise, with the first a-c cycle f
1for current a-c cycle.
Suppose that described ac analog is
wherein, U
mfor voltage magnitude, f is a-c cycle,
for initial phase angle, t is time variable, and the initial value of a-c cycle f is 50Hz.
Described first computing module 201, specifically may be used for according to formula
the calculating sampling time interval.
Described second computing module 203, specifically may be used for adopting half-wave to calculate the first a-c cycle, comprise: the mean value calculating in a cycle the N number of data obtained of sampling, described N number of 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 3rd computing module 204 specifically can comprise:
First computing unit, for calculating the first-harmonic real part U exchanging phasor
awith first-harmonic imaginary part U
b, wherein,
U
kfor kth point sampling value, k is natural number;
Second computing unit, for calculating the initial phase angle of first-harmonic according to first-harmonic real part and imaginary part
3rd computing unit, for according to formula
calculate the second a-c cycle, Φ
nand Φ
n-1the initial phase angle of first-harmonic in adjacent two sampling periods respectively.
To sum up, the frequency tracking apparatus for Fourier transform that the embodiment of the present invention provides, adopt with constant duration image data, to the data gathered respectively by directly calculating and Fourier transform obtain two a-c cycles, whether exceed preset value to determine with one of them for current a-c cycle according to the difference of these two a-c cycles, and determine according to current a-c cycle the technical scheme adopting the time interval, can the frequency of real-time follow-up ac analog, make the sampling period consistent with the cycle of ac analog, accomplish that namely a cycle completes frequency-tracking, thus make measurement data not by the impact of frequency change, can correct when frequency departure is large, the problem that 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 needs to carry out a Fourier transform, and it is common not with 51 of DSP function, the chips such as ARM just can realize, simply, reliably, low to hardware requirement, it is convenient to realize, practical.
With an embody rule example, further detailed description is done to technical solution of the present invention below:
Should in use-case, frequency tracking apparatus is with ARMcortex-M3 chip for master control IC, and hardware connection is as shown in Figure 3.
During actual motion, 220V ac phase voltage access frequency tracking apparatus, after electric resistance partial pressure, voltage rising, filtering circuit, be converted to the voltage signal within 3V, be input to modulus (AD) switched pins of master control IC again, become digital quantity through AD conversion, then complete calculating and frequency-tracking by embodiment of the present invention method.
As shown in Figure 4, should comprise the following steps by use-case:
1, chip initial configuration
A, setting each cycle sampling number N=32, initial default frequency is 50Hz,
B, each variable of initialization, configuration AD, timer.
2, sampled data
Adopt timer timing, constant duration △ t Sample AC signal, obtains u
k.
3, algorithm calculates
A, first obtain the mean value of sampled data
pass through again
compare with each sampled data, obtain two adjacent zero crossing data and the poor △ N of two zero crossing data.A-c cycle is obtained 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, judge alternating voltage data, if voltage magnitude is less than 40V, then do not do frequency-tracking, no longer carry out step below, otherwise calculate below continuing.
D, compare two frequency f
1and f
2, as: f
1with f
2difference <0.5Hz, then with f
2for a-c cycle, sampling time interval is recalculated; Otherwise with f
1for a-c cycle, sampling time interval is recalculated.And carry out sample frequency tracking.
Technical solution of the present invention has good frequency-tracking ability, less in frequency jitter, and such as, can accomplish when being less than 1Hz that a cycle just completes sample frequency and follows the tracks of, when frequency jitter is large, two cycles just can complete frequency-tracking.
The frequency tracking method for Fourier transform provided the embodiment of the present invention above and device are described in detail, but the explanation of above embodiment just understands method of the present invention and core concept thereof for helping, and 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 change that can expect easily or replacement, all should be encompassed within protection scope of the present invention.