A Harmonic Analysis Method Based on Multi-Cycle Equivalent Sampling
Through multi-period equivalent sampling and accurate uniform sampling triggered by microcontroller timer, combined with FFT transformation, the problem of efficient and accurate harmonic analysis of high-frequency periodic signals is solved, and simple and efficient signal frequency range expansion and accuracy improvement is achieved.
Patent Information
- Application Number
- CN202210906869.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-29
- Publication Date
- 2025-07-08
- Estimated Expiration
- 2042-07-29
AI Technical Summary
The prior art is difficult to realize efficient and accurate harmonic analysis of high-frequency periodic signals without introducing high hardware costs and complex calculations. In particular, the synchronous sampling method and spectrum interpolation method have problems with high hardware costs and high computational complexity. The equivalent sampling method lacks theoretical guidance and large synchronization errors.
The multi-period equivalent sampling method is adopted to calculate the mutual quality of the signal cycle number L and the sampling point number N, and the equivalent sampling is triggered by using a microcontroller timer to dynamically adjust the sampling interval to achieve quasi-uniform sampling of the signal cycle, and harmonic analysis is performed through FFT fast Fourier transform.
It realizes simple, efficient and high-precision harmonic analysis of high-frequency periodic signals, breaks through the limitation of ADC conversion time, broadens the frequency range, reduces hardware cost and calculation complexity, and improves the accuracy of harmonic analysis.
Smart Images

Figure CN115267329B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of harmonic analysis, and particularly relates to a harmonic analysis method based on multi-period equivalent sampling. Background Art
[0002] Periodic signals are a type of signals that widely exist and are widely used in human activities. The harmonic analysis of periodic signals is the basic content of signal analysis and is the basis for the identification, state analysis, and fault diagnosis of various signal source devices. Theoretically, if it is possible to synchronously (equally divide) and uniformly (equally spaced) sample the signal within an integer number of periods, error-free harmonic analysis of the periodic signal can be achieved through discrete Fourier transform (DFT). However, due to the change of signal frequency and the fact that the sampling interval can only be an integer multiple of the clock period, it is difficult to achieve uniform sampling synchronized with an integer number of signal periods in practice. In addition, limited by the analog-to-digital conversion time (ADC time) during sampling, the sampling frequency of the signal cannot be too high, thus greatly limiting the frequency range of the analyzed signal.
[0003] There are mainly various methods for harmonic analysis based on signal sampling, such as dual-rate sampling [1], synchronous sampling [2], quasi-synchronous sampling [3], spectrum interpolation [4], and equivalent sampling [5]. The synchronous sampling method requires the introduction of a hardware frequency doubling circuit, with high hardware costs, and there will also be a lock loss phenomenon when interference occurs; the dual-rate sampling method can eliminate the error accumulation of the sampling time during the sampling process, but the number of sampling points within one period varies with the change of signal frequency and cannot directly utilize the fast Fourier transform (FFT) of an integer power of 2 sampling points for fast analysis. Quasi-synchronous sampling does not require accurate acquisition of the signal frequency, but a window function needs to be used to weight the sampling data of multiple periods to suppress the leakage interference between harmonics caused by asynchronous sampling, and there are also errors introduced by the fence effect during harmonic analysis; the spectrum interpolation method requires solving complex equations, with high computational complexity.
[0004] Since different window functions correspond to different degrees of harmonic leakage, many excellent window functions have been designed for the harmonic analysis of periodic signals [6 - 10]. There is also a fence effect in the harmonic analysis based on quasi-synchronous sampling. Even if spectral line interpolation compensation is performed [11 - 14], due to the non-uniform distribution of leakage at each harmonic, small-amplitude harmonics are easily submerged by stronger harmonic leakage. The method based on equivalent sampling can break through the limitation of the ADC time on the sampling frequency, effectively broaden the frequency range of the analyzed signal, but the number of signal periods required for harmonic analysis of a specific periodic signal and the uniqueness of each equivalent sampling point are not clear, and there is a lack of theoretical guidance for the number of signal periods and the total number of sampling points of the used signal. It fails to achieve synchronous sampling and directly utilize FFT for fast calculation, and also does not well solve the synchronous error introduced by the discontinuity of the sampling interval. Summary of the Invention
[0005] Aiming at the deficiencies of the existing technology, the purpose of the present invention is to provide a harmonic analysis method based on multi-cycle equivalent sampling, so as to realize simple, efficient and high-precision harmonic analysis of high-frequency periodic signals.
[0006] In order to achieve the above purpose, the present invention is implemented by the following technical solutions:
[0007] A harmonic analysis method based on multi-cycle equivalent sampling includes the following steps:
[0008] Step 1: Calculate the number of signal cycles used for one harmonic analysis:
[0009] Given the frequency f of the analysis signal r and the period T r and perform continuous sampling on it. The number of sampling points N is taken as an integer power of 2. Then the minimum odd number of cycles L used for N times of equivalent sampling is:
[0010]
[0011] In the formula, ceil() is the ceiling function, t ADC is the sampling hold and conversion time of the signal, T r is the signal period;
[0012] Step 2: Trigger an ADC conversion once, save the sampling result of this time, and obtain the time sequence number n of N equivalent sampling points within 1 cycle;
[0013] n = (m L) % N
[0014] In the formula, () % is to take the remainder of mL with respect to N, m is the original sampling sequence number within L cycles, m = 0, 1, 2, 3..., (N - 1);
[0015] Furthermore, obtain the equivalent sampling sequence x[n] within 1 signal cycle;
[0016] Step 3: Repeat sampling multiple times, and map the original sampling sequence x s [m] within L signal cycles to the equivalent sampling sequence x p [n] within 1 signal cycle;
[0017] x p [n] = x s [m]
[0018] L and N are relatively prime. The equivalent sampling sequence consists of N non-repeating samplings in time, n = 0, 1, 2,..., N - 1;
[0019] Step 4: Use the FFT fast Fourier transform to calculate x p[n]Perform an N-point DFT conversion to calculate the amplitude and phase of each harmonic of the periodic signal.
[0020] The present invention also has the following technical features:
[0021] Preferably, the sampling interval t used for the first harmonic analysis in step one s is greater than the ADC conversion time t ADC , and the number of cycles spanned by N samplings is odd.
[0022] Furthermore, in step one, the number of sampling points N takes a fixed value that is an integer power of 2, and N is greater than twice the highest harmonic order M of the signal.
[0023] Furthermore, in step two, the sampling time of equivalent sampling is triggered and controlled by the timer of the single-chip microcomputer. Specifically, set the sampling time cumulative increment:
[0024]
[0025] where int() is the truncation function, t c is the working clock cycle, and T add is the sampling time cumulative increment;
[0026] Set the count value for the next trigger sampling of the timer:
[0027] T acc = T acc + T add
[0028]
[0029] Wait for the next sampling start time:
[0030] T cnt = T ov
[0031] where round() is the rounding function, Tacc is the sampling time cumulative sum, T cnt is the timing counter, T ov is the preset value for triggering sampling, m cnt , m acc are the binary digit lengths of T cnt and T acc respectively; m f is the length of the fractional part of t add / t s / t c in T
[0032] Usually, the integer bit length of the sampling time cumulative sum T acc is the same as that of Tcnt has the same length, and the number of decimal places of Tacc is the same as that of T add has the same number of decimal places, and there is a relationship m acc = m cnt + m f .
[0033] Preferably, in the second step, N samplings are performed within L periods, and the actual sampling interval is t s = LT r / N;
[0034] Equivalent N sampling points to 1 signal period, then the equivalent sampling interval is t p = T r / N, then t s = Lt p .
[0035] Preferably, in the third step, the original sampling sequence is x s [m],
[0036] x s [m] = x(t m )
[0037] where the sampling time is t m ;
[0038] t m = t c round(mLt p / t c )
[0039] where m = 0, 1, 2,..., N - 1.
[0040] Furthermore, in the third step, when the number of repeated sampling points is less than N times, return to the second step.
[0041] Preferably, before triggering the first ADC conversion in the second step, initialize the working counter and variables.
[0042] Preferably, the method for initializing the working counter and variables in the second step is:
[0043] Reset the sampling time accumulation sum: T acc = 0;
[0044] Reset the sampling sequence number: m = 0;
[0045] Reset the working counter: T cnt = 0;
[0046] Start the working counter.
[0047] Compared with the prior art, the present invention has the following technical effects:
[0048] In the harmonic analysis method based on multi-period equivalent sampling of the present invention, since the number of signal periods L used for one analysis and the total number of sampling points N are relatively prime, the equivalent sampling times within 1 period are different from each other, and there is no need for interpolation to fill in the gaps, so that the sampling sequences within multiple periods are mapped to the equivalent sampling sequences within 1 period without repetition in time, and at the same time, the FFT algorithm can be fully utilized;
[0049] The present invention realizes the harmonic analysis of high-frequency periodic signals by performing equivalent sampling on the signal within multiple periods without the need for high-speed analog-to-digital conversion; by equivalenting the sampling sequences within multiple periods to the sampling sequences within 1 period, the limitation of the ADC conversion time on the sampling rate is broken through, and the frequency range of the measured signal is effectively broadened;
[0050] The number of equivalent sampling points within 1 period of the present invention can always be an integer power of 2, and the FFT can be directly used to realize the fast harmonic analysis of periodic signals;
[0051] The present invention dynamically adjusts the sampling interval to ensure that the sampling process is as synchronous as possible with the signal period. The sampling time is very close to the ideal uniform sampling time, and the sampling process is almost synchronous with the signal period, effectively suppressing the synchronous error and having high harmonic analysis accuracy; by controlling that all variables of the sampling time take long integer variables, the sampling process is simple and efficient;
[0052] The equivalent sampling harmonic analysis method proposed by the present invention is particularly suitable for being embedded and implemented in a single-chip microcomputer with built-in analog-to-digital conversion, has no high requirements for the quantization accuracy of the ADC, and does not require other hardware overhead. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] Figure 1 is a flowchart of the present invention. DETAILED DESCRIPTION OF THE INVENTION
[0054] The following further elaborates and explains the specific content of the present invention in detail in conjunction with embodiments.
[0055] Referring to Figure 1 as shown, this embodiment provides a harmonic analysis method based on multi-period equivalent sampling.
[0056] Step 1. Calculate the number of signal periods used for one harmonic analysis:
[0057] Given the frequency f r of the analyzed signal and the period T r and continuously sampling it. In order to directly utilize the FFT for fast calculation in the calculation, the number of sampling points N is taken as an integer power of 2, generally taking a fixed value with a margin and not changing during the harmonic analysis process. Based on the signal period Tr and the sample-and-hold and conversion time t of the signal ADC , the minimum number of odd cycles L required for N equivalent samplings is calculated by the following formula:
[0058]
[0059] where ceil() is the ceiling function;
[0060] Step 2: Trigger an ADC conversion, save the sampling result of this time, and obtain the time sequence number n of N equivalent sampling points within 1 cycle:
[0061] S1. Initialize the working counter and variables:
[0062] Reset the sampling time accumulation sum: T acc = 0;
[0063] Set the sampling time accumulation increment: where int() is the truncation function, and t c is the working clock cycle;
[0064] Reset the sampling sequence number: m = 0; reset the working counter: T cnt = 0; Start the working counter;
[0065] S2. Trigger an ADC conversion;
[0066] In the equivalent sampling of the signal, the sampling time is triggered and controlled by the timer of the single-chip microcomputer. In order to make the discrete sampling time as accurate as possible and the calculation simple in the rolling update, long integer variables are used to represent the sampling time accumulation sum, sampling interval, etc. in the program. As long as the binary digits of the integer variable representing the sampling interval are long enough, the time accumulation error after N samplings can be ignored, and the actual sampling can be regarded as synchronized with the signal cycle. In the common working modes of the single-chip microcomputer timer counter, modes such as automatic reload increment, automatic reload decrement, and cyclic increment can all be used to trigger quasi-uniform sampling. Assume that the working counter T cnt in the used timer consists of m cnt binary digits, and the working clock cycle is t c . Here, the continuous counting mode of cyclic increment is adopted, and when T cnt continuously increments to the preset value, a sampling will be automatically triggered. For convenience, the main long integer variables used in the algorithm are: the sampling time accumulation sum T acc consisting of m acc binary digits, which is used to record the rolling update sampling time; the sampling time accumulation increment T add ; the preset value T ov for triggering sampling.
[0067] S3. Set the sampling time accumulation increment: The calculation formula for the sampling time accumulation increment corresponding to the sampling interval is
[0068]
[0069] In the formula, int() is the truncation function, t c is the working clock cycle, T add is the sampling time accumulation increment;
[0070] Set the count value for the next trigger of the timer for sampling:
[0071] T acc = T acc + T add
[0072]
[0073] Here, round() is the rounding function; T ov is the preset value for triggering sampling. Usually, the integer bit length of the sampling time accumulation sum T acc is the same as that of T cnt and the decimal bit length is the same as that of T add There is a relationship m acc = m cnt + m f ; T cnt is the timer counter; Tacc is the sampling time accumulation sum; Tadd is the sampling time accumulation increment; m cnt and m acc are the binary digit lengths of T cnt and T acc respectively; m f is the length of the fractional part of t add / t s / t c in T
[0074] T add is the integer obtained by magnifying and rounding t s / t c , and its lower m f bits are the binary decimal corresponding to t s / t c . As long as m f is selected large enough, the T add accumulated to obtain T acc will be accurate enough. The preset value T ov for sampling trigger is taken from the high m acc bits of T cnt . Whenever T cnt increases to be the same as T ovTrigger a sampling immediately when they are equal.
[0075] The working counter of most single-chip microcomputer timers is 16 bits (m cnt = 16). If T add and T acc are both selected as 32-bit (m acc = 32) integer variables, and let m f = 16, then the sampling interval can be accurate to the order of magnitude of 1.5×10 -5 t c . The time accumulation error of N consecutive samplings can be ignored. To make the calculation simple and efficient, integer variables are used for the variables controlling the sampling time in the algorithm. In addition, the value of the equivalent sampling points N per cycle is taken as an integer power of 2 to facilitate direct use of FFT for fast calculation.
[0076] S4. Wait for the end of the sampling hold and ADC conversion time, save the current sampling result, and the time sequence number n of N equivalent sampling points in one cycle can be obtained by taking the remainder of mL divided by N:
[0077] n = (mL) % N;
[0078] Furthermore, the equivalent sampling sequence in one cycle is obtained as:
[0079] x p [n] = ADC sampling result;
[0080] m = 0, 1, 2, 3…, (N - 1), m is the original sampling sequence number in L cycles, n is the equivalent sampling sequence number in 1 cycle, and x p [n] is the equivalent sampling sequence in 1 signal cycle;
[0081] For N samplings in L cycles, the actual sampling interval is t s = LT r / N;
[0082] Equivalent N sampling points to 1 signal cycle, then the equivalent sampling interval is t p = T r / N, then t s = Lt p .
[0083] Step 3. Repeat sampling multiple times, and map the original sampling sequence x s [m] sampled in L signal cycles to the equivalent sampling sequence x p [n] in 1 signal cycle;
[0084] x p [n] = x s [m]
[0085] L and N are relatively prime, and the equivalent sampling sequence consists of N non-repeating samples in time, where n = 0, 1, 2, …, N - 1;
[0086] The original sampling sequence is x s [m],
[0087] x s [m] = x(t m )
[0088] where the sampling time is t m ;
[0089] t m = t c round(mLt p / t c )
[0090] where m = 0, 1, 2, …, N - 1.
[0091] Wait for the next sampling time to arrive: T cnt = T ov ; When the number of repeated samples is less than N, return to step two;
[0092] As long as N > 2M, the complex harmonic coefficients of the signal can be strictly given by the DFT of x p [n]
[0093]
[0094] The amplitude and phase of the k-th harmonic of the signal are respectively
[0095]
[0096] For the above-mentioned time-discrete process of the signal, it is required that the sampling is uniform sampling (equi-spaced sampling) that equally divides L signal periods. In fact, if it is directly difficult to precisely control the sampling time using the timer of the single-chip microcomputer, it will bring errors to the harmonic analysis. This is because the clock cycle t c of the timer cannot be infinitely small, and the sampling interval cannot be continuously regulated and can only take integer multiples of tc.
[0097] If uniform sampling is performed based on a biased but fixed sampling interval, the continuous accumulation of sampling time errors will make the time of N samplings not equal to L signal periods, resulting in non-synchronous sampling. Non-synchronous sampling will bring harmonic leakage errors and frequency point fence effect errors to the harmonic analysis. Although window functions can be selected to weight the signal and interpolation compensation in the frequency domain can be used to suppress harmonic leakage and the fence effect, more sampling data is required and the calculation is relatively complex. In addition, the spectral leakage after signal windowing is unevenly distributed among the harmonics, which is not conducive to the analysis of small-amplitude harmonics.
[0098] To eliminate the accumulation of sampling time errors, the sampling interval is dynamically adjusted during the sampling process so that the time for N samplings is equal to L signal cycles, corresponding to synchronous sampling. Obviously, the sampling intervals in this method are not equal, so it does not belong to uniform sampling. However, due to the very small timing clock cycle of the single-chip microcomputer, the sampling intervals are very close to the values in uniform sampling, so this sampling is called quasi-uniform sampling. The quasi-uniform sampling scheme is simpler, and the harmonic analysis error is evenly distributed among the harmonics, which is especially suitable for the analysis of small-amplitude harmonics.
[0099] Adopt the multi-period equivalent sampling period signal harmonic analysis method combined with quasi-uniform sampling. Under the condition that the signal frequency and the timing clock cycle are known, the actual sampling time triggered by the single-chip microcomputer timer for N (an integer power of 2) samplings in L (odd) cycles is
[0100]
[0101] where m = 0, 1,..., N - 1, and round(·) is rounding to the nearest integer. The resulting actual sampling time has a time offset within ±t c / 2 with respect to the ideal sampling time, and the sampling is not strictly uniform sampling. However, the error of the actual sampling time will not accumulate with continuous sampling (always within ±t c / 2).
[0102] Based on the calculated trigger signals for sampling at each discrete time point, and then substituting the sampling results into the formula x p [n] = x s [m] to obtain the equivalent sampling sequence within one period.
[0103] Step 4: Use the FFT fast Fourier transform to calculate the N-point DFT conversion of the equivalent sampling sequence x p [n], and calculate the amplitudes and phases of the 1st to Mth harmonics of the periodic signal to obtain the harmonic analysis result.
[0104] Based on the above equivalent sampling method, for a periodic signal with a frequency f r of 100 kHz (period T r of 10 μs), and the fundamental wave, 3rd harmonic, and 5th harmonic are 1200 mV, 235 mV, and 180 mV respectively, perform harmonic analysis. Use a single-chip microcomputer with a 12-bit ADC, the sampling interval is not less than the sampling hold and conversion time (set to 5 μs), the number of sampling points N is taken as 64, and the minimum odd number of cycle numbers L for equivalent sampling is 33. The actual harmonic analysis results are as follows:
[0105] Table Harmonic analysis results of the test signal with a frequency f r of 100 kHz
[0106] Harmonic order 1 2 3 4 5 6 7 8 9 10 Theoretical value / mV 1200 0 235 0 180 0 0 0 0 0 Measured value / mV 1199 2 238 1 182 2 0 1 3 1
[0107] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail and related explanations have been made with reference to the above embodiments, those of ordinary skill in the art should understand that: modifications or equivalent substitutions can still be made to the specific implementation manners of the present invention, and any modification or equivalent substitution that does not depart from the spirit and scope of the present invention shall be covered by the scope of these claims.
Claims
1. A harmonic analysis method based on multi-cycle equivalent sampling, characterized in that, It includes the following steps: Step 1: Calculate the number of signal cycles used for a harmonic analysis: Known frequency of the analysis signal f r and the period T r are continuously sampled, and the number of sampling points N is taken as an integer power of 2, then N the minimum number of odd-periods used for the equivalent sampling L is: where ceil( ) is the ceiling function, t ADC is the sampling hold and conversion time of the signal, T r is the signal period; Step 2: Trigger an ADC conversion once, save the current sampling result, and obtain the time sequence numbers of N equivalent sampling points within one cycle N n : n = (m L) % N Where, (%) is the remainder obtained by mL dividing N and taking the remainder, m is the original sampling sequence number within L periods, m = 0, 1, 2, 3…, ( N - 1); Further obtain an equivalent sampling sequence within one signal period x n ; Step 3. Repeat sampling multiple times, and map the original sampling sequence obtained within L signal periods to the equivalent sampling sequence within 1 signal period x s m ; x p n ; x p [ n ] = x s [ m ] L and N are relatively prime, and the equivalent sampling sequence consists of N samples that do not repeat each other in time, n = 0, 1, 2, …, N −1; Step 4. Use the FFT (Fast Fourier Transform) to calculate the x p n for N point DFT conversion to calculate the amplitudes and phases of the harmonics of the periodic signal; In Step 2, the sampling time of equivalent sampling is triggered and controlled by the timer of the single-chip microcomputer. Specifically, set the sampling time cumulative increment: where int( ) is the truncation function, t c is the working clock period, T add is the cumulative increment of the sampling time; Set the count value for the timer to trigger the next sampling: Wait for the next sampling start time: T cnt = T ov where round( ) is the rounding function, and Tacc is the cumulative sum of sampling time, T cnt is the timer counter, T ov is the preset value for triggering sampling, m cnt 、 m acc are respectively T cnt and T acc the lengths of the binary digits; m f is T add in t s / t c the length of the fractional part; Usually the integer bit length of the sum of sampling times T acc is the same as that of T cnt ; the fractional bit length of acc is the same as that of T and there is a relationship T add as follows m acc = m cnt + m f ; The original sampling sequence in step 3 described above is x s m x s [ m ] = x ( t m ) where the sampling time is t m ; t m = t c round( mLt p / t c ) where m = 0, 1, 2, …, N -1.
2. The harmonic analysis method based on multi-cycle equivalent sampling according to claim 1, wherein The sampling interval used for the fundamental harmonic analysis in the first step t s is greater than the ADC conversion time t ADC , and N the number of periods spanned by the sampling is odd.
3. The harmonic analysis method based on multi-cycle equivalent sampling according to claim 2, wherein The number of sampling points described in Step 1 N Take a fixed value that is an integer power of 2, and N is greater than twice the highest harmonic order of the signal M .
4. The harmonic analysis method based on multi-cycle equivalent sampling according to claim 1, characterized in that In the second step described above, L sampling is performed within N cycles, and the actual sampling interval is t s = LT r / N ; If N the sampling points are equivalent to one signal period, the equivalent sampling interval is t p = T r / N , then t s = Lt p .
5. The harmonic analysis method based on multi-cycle equivalent sampling according to claim 1, wherein In the third step described above, when the number of repeated sampling points is less than N times, return to the second step.
6. The harmonic analysis method based on multi-cycle equivalent sampling according to claim 1, wherein Before triggering the first ADC conversion in Step 2, initialize the working counter and variables.
7. The harmonic analysis method based on multi-period equivalent sampling according to claim 1, wherein The method for initializing the working counter and variables in Step 2 is as follows: Reset sampling time sum: T acc = 0; Reset sampling sequence number: m = 0; Reset the working counter: T cnt = 0; Start the working counter.
Citation Information
Patent Citations
Harmonic analysis method
CN105044459A
Method and apparatus for spectral estimations adapted to non-uniformities of sampling
WO2007009558A1