Alternating current frequency calculation method, device, computer equipment and storage medium

Through the steps of periodic sampling, inverse cosine calculation, top-cut bottoming and least squares normal linear fitting, the problem of low frequency calculation accuracy when AC waveform distortion is solved, and high-precision AC frequency calculation is achieved.

CN118962234BActive Publication Date: 2025-04-01HANGZHOU SHENGHANG TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202411464060.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-10-21
Publication Date
2025-04-01
Estimated Expiration
2044-10-21

AI Technical Summary

Technical Problem

The existing AC frequency calculation method is difficult to accurately measure the zero crossing point when AC waveform distortion (high noise or harmonic content), resulting in a decrease in frequency calculation accuracy.

Method used

By obtaining the alternating current signal, periodically sampling is performed to obtain the sampling sequence, then perform inverse cosine calculation and top-cut bottom processing, search the interval between the preset minimum value and the maximum value, perform linear fitting of the least squares method, calculate the horizontal coordinate difference when the straight line crosses zero point, calculate the sine wave period based on the sampling period and finally obtain the frequency.

Benefits of technology

Even if the AC waveform is distorted, the frequency can still be accurately calculated through this method. The accuracy of measuring the zero crossing point is not affected by the initial phase and the number of samples, and the frequency calculation accuracy is high.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118962234B_ABST
    Figure CN118962234B_ABST
Patent Text Reader

Abstract

The present invention belongs to the field of alternating current, and relates to an alternating current frequency calculation method, device, computer equipment and storage medium. The method comprises obtaining an alternating current signal; periodically sampling the alternating current signal to obtain a sampling sequence; performing arccosine calculation on the sampling sequence to obtain an arccosine value; clipping the arccosine value to obtain a clipped value; searching for two intervals with the same direction of change between a preset minimum value and a preset maximum value in the clipped value; performing least squares linear fitting on the two intervals to obtain two straight lines; calculating the horizontal coordinates of the two straight lines when they cross zero points, calculating the difference between the horizontal coordinates, and then calculating the sine wave period according to the sampling period, and then calculating the frequency according to the sine wave period. Even when the alternating current waveform has a certain distortion, the zero-crossing point measurement is still not affected, the accuracy of measuring the zero-crossing point is not affected by the initial phase and the number of samples, and the frequency calculation accuracy is high.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of alternating current technology, and in particular to an alternating current frequency calculation method, device, computer equipment, and storage medium. Background Art

[0002] As a core parameter in the electrical field, alternating current (AC) frequency is widely calculated and applied in all aspects of our daily life and industrial production.

[0003] AC frequency, typically measured in Hertz (Hz), represents the number of periodic changes per unit time. Its calculation formula is frequency (f) = 1 / T, where f represents the frequency and T represents the signal's period. This formula reveals the inverse relationship between frequency and period, providing a theoretical basis for accurately calculating AC frequency.

[0004] The calculation and application of AC frequency holds broad application prospects and plays an important role in power systems, electrical equipment, communications, and information technology. With the continuous advancement of technology and the rapid development of the power industry, the calculation and application of AC frequency will become more accurate and efficient, bringing greater convenience and benefits to our lives and work.

[0005] Traditional AC frequency calculation methods generally use the voltage comparison method to measure the zero-crossing time interval. This method has two shortcomings: First, when the AC waveform has a certain degree of distortion (high noise or harmonic content), the zero-crossing point is difficult to measure; second, even if the AC waveform is not highly distorted, the accuracy of the zero-crossing point measurement will be affected by the initial phase and the number of samples, which ultimately affects the frequency calculation accuracy. Summary of the Invention

[0006] The purpose of the embodiments of the present invention is to provide a method, apparatus, computer device, and storage medium for calculating AC frequency to solve the problem in existing AC frequency calculation methods that the zero-crossing point is difficult to measure when the AC waveform has a certain degree of distortion (high noise or harmonic content).

[0007] In order to solve the above technical problems, the present invention provides a method for calculating the frequency of alternating current, which adopts the following technical solution, including:

[0008] Acquire AC power signal;

[0009] Perform periodic sampling on the AC signal to obtain a sampling sequence S1, S2, S3, ..., Sn, where n is the number of sampling points;

[0010] Performing arc cosine calculation on the sampling sequences S1, S2, S3, ..., Sn to obtain arc cosine values ​​Cn;

[0011] performing top- and bottom-chopping on the arc cosine value Cn to obtain a top- and bottom-clipped value Dn;

[0012] Searching for two intervals with the same direction of change between the preset minimum value and the preset maximum value in the truncated value Dn, namely Di~Di+kk and Dj~Dj+k;

[0013] Perform the least squares linear fitting on the two intervals to obtain two straight lines and , and ;

[0014] Calculate two straight lines separately and The horizontal coordinate when crossing zero and , calculate the horizontal coordinate and The difference between them is used to calculate the sine wave period according to the sampling period, that is, , and then calculate the frequency based on the sine wave period, .

[0015] Preferably, the step of periodically sampling the AC signal to obtain a sampling sequence S1, S2, S3, ..., Sn specifically includes:

[0016] Select the sampling frequency;

[0017] Determine the sampling period;

[0018] Synchronous trigger sampling;

[0019] Select sampling points to obtain the sampling sequence S1, S2, S3, ..., Sn;

[0020] Store sampling sequence S1, S2, S3, ..., Sn.

[0021] Preferably, the step of performing arc cosine calculation on the sampling sequences S1, S2, S3, ..., Sn to obtain the arc cosine value Cn specifically includes:

[0022] calculate , where A is the AC signal amplitude, that is .

[0023] Preferably, the step of clipping the arc cosine value Cn to obtain the clipped value Dn specifically includes:

[0024] calculate .

[0025] Preferably, the step of searching for two intervals between a preset minimum value and a preset maximum value, i.e., Di to Di+k and Dj to Dj+k, which change in the same direction in the truncated value Dn specifically includes:

[0026] Set specific values ​​for the preset minimum and maximum values;

[0027] Traverse the clipped value Dn, search for two intervals between the preset minimum value and the preset maximum value that change in the same direction, and obtain Di~Di+k, Dj~Dj+k.

[0028] Preferably, the least squares linear fitting is performed on the two intervals to obtain two straight lines. and , and The steps specifically include:

[0029] Determine the fitting interval and ;

[0030] Setting up a linear model ;

[0031] In the fitting interval, according to the set linear model, determine 、 、 and The value of , two straight lines are obtained by least squares linear fitting and ,

[0032] .

[0033] Preferably, the two straight lines are calculated separately and The horizontal coordinate when crossing zero and , calculate the horizontal coordinate and The difference between them is used to calculate the sine wave period according to the sampling period, that is, , and then calculate the frequency based on the sine wave period, The steps specifically include:

[0034] make ;

[0035] make ;

[0036] The sine wave period is calculated based on the sampling period, that is, ;

[0037] Calculate the frequency based on the sine wave period, .

[0038] In order to solve the above technical problems, the present invention further provides an AC frequency calculation device, which adopts the following technical solution, including:

[0039] An acquisition module, used for acquiring an AC signal;

[0040] A sampling module is used to periodically sample the AC signal to obtain a sampling sequence S1, S2, S3, ..., Sn, where n is the number of sampling points;

[0041] An arccosine calculation module, configured to perform arccosine calculation on the sampling sequences S1, S2, S3, ..., Sn to obtain an arccosine value Cn;

[0042] a clipping module, configured to clip the arc cosine value Cn to obtain a clipped value Dn;

[0043] A search module is used to search for two intervals with the same change direction between a preset minimum value and a preset maximum value in the truncated value Dn, namely Di~Di+k and Dj~Dj+k;

[0044] The linear fitting module is used to perform the least squares linear fitting on two intervals to obtain two straight lines. and , and ;

[0045] Frequency calculation module, used to calculate two straight lines separately and The horizontal coordinate when crossing zero and , calculate the horizontal coordinate and The difference between them is used to calculate the sine wave period according to the sampling period, that is, , and then calculate the frequency based on the sine wave period, .

[0046] In order to solve the above technical problems, the present invention also provides a computer device, which adopts the technical solution described below, including a memory and a processor, wherein the memory stores computer-readable instructions, and when the processor executes the computer-readable instructions, it implements the steps of the above-mentioned AC frequency calculation method.

[0047] In order to solve the above technical problems, the present invention also provides a computer-readable storage medium, which adopts the technical solution described below, wherein the computer-readable storage medium stores computer-readable instructions, and when the computer-readable instructions are executed by a processor, the steps of the above-mentioned AC frequency calculation method are implemented.

[0048] Compared with the prior art, the present invention mainly has the following beneficial effects: first, an alternating current signal is acquired; periodic sampling is performed on the alternating current signal to obtain a sampling sequence; arccosine calculation is performed on the sampling sequence to obtain an arccosine value; the arccosine value is clipped to obtain a clipped value; two intervals with the same direction of change between a preset minimum value and a preset maximum value are retrieved from the clipped value; the two intervals are linearly fitted using the least squares method to obtain two straight lines; the horizontal coordinates of the two straight lines when they cross zero points are calculated respectively, the difference between the horizontal coordinates is calculated, and then the sine wave period is calculated according to the sampling period, and then the frequency is calculated according to the sine wave period; even when the alternating current waveform has a certain degree of distortion (high noise or harmonic content), the zero-crossing point measurement is still not affected, the accuracy of the zero-crossing point measurement is not affected by the initial phase and the number of samples, and the frequency calculation accuracy is high. BRIEF DESCRIPTION OF THE DRAWINGS

[0049] In order to more clearly illustrate the solutions in the present invention, a brief introduction is given below to the drawings required for use in describing the embodiments of the present invention. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0050] Figure 1 is a flow chart of an embodiment of a method for calculating the frequency of alternating current according to the present invention;

[0051] Figure 2 This is a schematic diagram of a sampling sequence generated by periodically sampling an AC signal in the AC frequency calculation method of the present invention;

[0052] Figure 3 Schematic diagram of the method for calculating the alternating current frequency of the present invention after performing arc cosine calculation on the sampling sequence;

[0053] Figure 4 Schematic diagram of the inverse cosine calculation result after truncating the top and bottom of the result in the AC frequency calculation method of the present invention;

[0054] Figure 5 Schematic diagram of two intervals used in the AC frequency calculation method of the present invention;

[0055] Figure 6 1 is a schematic structural diagram of an embodiment of an AC frequency calculation device of the present invention;

[0056] Figure 7 It is a structural diagram of an embodiment of a computer device of the present invention. DETAILED DESCRIPTION

[0057] Unless otherwise defined, all technical and scientific terms used herein have the same meanings as commonly understood by those skilled in the art to which this invention belongs. The terms used in the specification of the application are for the purpose of describing specific embodiments only and are not intended to limit the present invention. The terms "including" and "having" and any variations thereof in the specification and claims of the present invention and the accompanying drawings are intended to cover non-exclusive inclusions. The terms "first" and "second" in the specification and claims of the present invention and the accompanying drawings are used to distinguish different objects, not to describe a specific order.

[0058] References herein to "embodiments" mean that a particular feature, structure, or characteristic described in connection with the embodiments may be included in at least one embodiment of the present invention. The appearance of this phrase in various places in the specification does not necessarily refer to the same embodiment, nor does it constitute a separate or alternative embodiment that is mutually exclusive of other embodiments. It is understood, both explicitly and implicitly, by those skilled in the art that the embodiments described herein may be combined with other embodiments.

[0059] In order to enable those skilled in the art to better understand the solutions of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings.

[0060] It should be noted that the AC frequency calculation method provided in the embodiment of the present invention is generally executed by a server / terminal device. Accordingly, the AC frequency calculation device is generally provided in the server / terminal device.

[0061] It should be understood that the number of terminal devices, networks and servers is merely illustrative and any number of terminal devices, networks and servers may be provided as required.

[0062] Example 1

[0063] Please refer to Figure 1 , shows a flow chart of an embodiment of the method for calculating the frequency of alternating current of the present invention. The method for calculating the frequency of alternating current comprises the following steps:

[0064] Step S1: Acquire an alternating current signal.

[0065] In this embodiment, the electronic device (e.g., a server / terminal device) on which the AC frequency calculation method is executed can receive the AC frequency calculation request via a wired connection or a wireless connection. It should be noted that the wireless connection method may include, but is not limited to, 3G / 4G / 5G connection, WiFi connection, Bluetooth connection, WiMAXX connection, Zigbee connection, UWB (ultra wideband) connection, and other wireless connection methods currently known or to be developed in the future.

[0066] Acquiring AC signals is the prerequisite and foundation for frequency calculation. Depending on the application scenario, there are various methods for obtaining AC signals, including generators, oscillators, power inverters, and grid power supply.

[0067] Generators are a traditional and common method for generating AC signals. Their basic principle is to convert mechanical energy into electrical energy, generating AC power through electromagnetic induction. Generators can be designed and adjusted as needed to produce sinusoidal AC signals with specific frequency, amplitude, and phase.

[0068] As one of the main sources of AC signals, generators are flexible and highly adjustable. By adjusting their parameters, AC signals of different frequencies, amplitudes, and phases can be easily obtained to meet various application requirements.

[0069] An oscillator is a circuit device specifically designed to generate a stable sinusoidal alternating current signal. Its basic principle is to create a sinusoidal waveform by using a positive feedback mechanism to create a self-oscillating circuit through an amplifier and feedback circuit.

[0070] You can also use a power inverter to get an AC signal. A power inverter is a device that converts DC power to AC power.

[0071] Step S2, periodically sampling the AC signal to obtain a sampling sequence S1, S2, S3, ..., Sn, where n is the number of sampling points.

[0072] Periodic sampling is a method that samples an AC signal multiple times within a complete cycle to obtain the signal's amplitude and phase information, which is then used to calculate the frequency. During the sampling process, it is necessary to ensure that the sampling frequency satisfies the sampling theorem, which states that the sampling frequency should be greater than or equal to twice the signal's highest frequency to ensure signal integrity and accuracy.

[0073] Figure 2 FIG. 1 is a schematic diagram of a sampling sequence generated by periodically sampling an AC signal in the AC frequency calculation method of the present invention. Figure 2 As shown, in this embodiment, step S2 may further include the following steps:

[0074] S21, select sampling frequency.

[0075] Selecting the sampling frequency is the first step in periodic sampling. According to the sampling theorem, the sampling frequency should be greater than or equal to twice the highest frequency of the signal. In practical applications, higher sampling frequencies are often chosen to achieve higher sampling precision and accuracy. The selection of the sampling frequency requires consideration of factors such as signal characteristics, measurement accuracy requirements, and the performance of the sampling equipment.

[0076] S22, determining the sampling period.

[0077] The sampling period is the reciprocal of the sampling frequency and represents the time interval between each sample. When determining the sampling period, it's important to ensure that it's small enough to capture a sufficient number of samples within a complete cycle, accurately reflecting the signal's waveform and frequency characteristics. The sampling period also needs to consider factors such as the rate of change of the signal and the response speed of the sampling device.

[0078] S23, synchronous trigger sampling.

[0079] Synchronous trigger sampling is a key step in periodic sampling. To ensure accurate and synchronized sampling, a synchronous trigger signal is often used to control the sampling process. The synchronous trigger signal should have the same frequency and phase as the AC signal to be measured, so that sampling occurs at a fixed time within each cycle. This synchronous trigger signal can be implemented using circuits such as a phase-locked loop (PLL) to ensure synchronization between the sampling signal and the signal.

[0080] S24, select sampling points to obtain a sampling sequence S1, S2, S3, ..., Sn.

[0081] Based on synchronously triggered sampling, appropriate sampling points must be selected for sampling. The selection of sampling points should meet certain requirements, such as equal-interval sampling and equal-phase sampling. Equal-interval sampling refers to sampling at fixed intervals within each sampling cycle; equal-phase sampling, based on the signal's phase information, samples at fixed phase points within each cycle. The selection of sampling points depends on factors such as signal characteristics, sampling objectives, and the performance of the sampling equipment.

[0082] S25, store the sampling sequence S1, S2, S3, ..., Sn.

[0083] During the sampling process, the sampled data sequence S1, S2, S3, ..., Sn needs to be stored. The sampled data is typically represented digitally and can be stored in computer memory, a hard drive, or other storage devices. To facilitate subsequent data processing and analysis, the sampled data must be formatted and stored, including information such as the data format, storage location, and timestamp.

[0084] Step S3, performing arc cosine calculation on the sampling sequences S1, S2, S3, ..., Sn to obtain arc cosine value Cn.

[0085] Figure 3 FIG. 1 is a schematic diagram of the method for calculating the AC frequency of the present invention after performing arc cosine calculation on the sampling sequence. Figure 3 As shown, in this embodiment, step S3 specifically includes:

[0086] calculate , where A is the AC signal amplitude, that is .

[0087] As a mathematical tool with high computational accuracy, arccosine calculation can be used to improve the accuracy and reliability of AC frequency calculations, providing a strong guarantee for the stable operation of power systems.

[0088] Step S4: clipping the arc cosine value Cn to obtain a clipped value Dn.

[0089] The arccosine value Cn is clipped at the top and bottom, that is, the top and bottom of the arccosine value Cn are flattened.

[0090] Figure 4 Schematic diagram of the AC frequency calculation method of the present invention after the arc cosine calculation result is truncated. Figure 4 As shown, in this embodiment, step S4 specifically includes:

[0091] calculate .

[0092] Step S5 , searching the value Dn after truncating the top and bottom, for two intervals with the same direction of change between the preset minimum value and the preset maximum value, namely Di to Di+k and Dj to Dj+k.

[0093] In this embodiment, step S5 specifically includes:

[0094] S51, setting specific values ​​of the preset minimum value and the preset maximum value.

[0095] Figure 5 Schematic diagram of two intervals used in the AC frequency calculation method of the present invention. Figure 5 As shown, in a specific implementation, the preset minimum value can be 0.4 to 0.6, and the preset maximum value can be 2.34 to 2.94. In this embodiment, the preset minimum value is 0.5, and the preset maximum value can be 2.64.

[0096] S52, traverse the clipped value Dn, search for two intervals between the preset minimum value and the preset maximum value with the same direction of change, and obtain Di~Di+k, Dj~Dj+k.

[0097] Step S6: perform least squares linear fitting on the two intervals to obtain two straight lines and , and .

[0098] In this embodiment, step S6 specifically includes:

[0099] S61, determine the fitting interval and .

[0100] Select two representative time periods and These two intervals should fully reflect the frequency characteristics of AC power while avoiding excessive noise or abnormal data.

[0101] Selecting an appropriate fitting interval can ensure that the fitting results are more accurate and reflect the actual frequency characteristics of the AC power.

[0102] S62, Setting the Linear Model .

[0103] In the selected interval, a linear model is set to describe the relationship between voltage or current and time. The linear model is expressed as ,in Represents the instantaneous value of voltage or current, Represents time, and are the slope and intercept of the model, respectively.

[0104] The linear model provides a mathematical basis for the subsequent fitting process, making it possible to use mathematical methods to solve the parameter values ​​that best reflect the characteristics of the data.

[0105] S63, within the fitting interval, according to the set linear model, determine 、 、 and The value of , two straight lines are obtained by least squares linear fitting and , and .

[0106] In order to find the best 、 、 and The objective function is usually defined as the sum of squares of the differences between the observed values ​​and the values ​​predicted by the model, i.e. the residual sum of squares (RSS).

[0107] The objective function is used to quantify the difference between the model prediction value and the true observation value. By minimizing this objective function, the optimal model parameters can be found.

[0108] Using the least squares method, the objective function is solved to find the values ​​of (k) and (b) that minimize the sum of squared residuals. This involves taking the derivative of the objective function and setting it to zero, then solving for (k) and (b) analytically or numerically.

[0109] Solving the model parameters is the core step of linear fitting, which determines the shape and position of the fitting line, and thus determines the estimation of the AC frequency characteristics.

[0110] After obtaining the fitted line, you can also evaluate its fitting effect. This can be achieved by calculating statistics such as the residual sum of squares and the coefficient of determination (R²).

[0111] Evaluating the fitting effect helps to understand the accuracy and reliability of the fitted line, and thus determine whether its estimation of the AC frequency characteristics is accurate.

[0112] After confirming that the fitted straight line can well reflect the frequency characteristics of the AC power, the frequency information of the AC power can also be extracted through the slope of the fitted straight line or other related parameters.

[0113] Using the least squares method to linearly fit an interval to obtain a straight line involves determining the fitting interval, setting the linear model, constructing the objective function, solving the model parameters, evaluating the fitting results, and extracting frequency information. These steps together constitute a complete data processing workflow, providing strong support for accurately estimating the frequency of AC power.

[0114] Step S7, calculate two straight lines respectively and The horizontal coordinate when crossing zero and , calculate the horizontal coordinate and The difference between them is used to calculate the sine wave period according to the sampling period, that is, , and then calculate the frequency based on the sine wave period, .

[0115] In specific implementation, step S7 may further include the following steps:

[0116] S71, order .

[0117] S72, order .

[0118] S73, calculate the sine wave period according to the sampling period, that is, .

[0119] S74, calculate the frequency based on the sine wave period, .

[0120] For example, when 128 points of 50Hz AC power are sampled, the sampling period is τ = 156.25us.

[0121] In specific implementation, it has been verified that when a 50Hz AC signal (without harmonic components) is sampled at 128 points per cycle using a 12-bit ADC, the calculated frequency error is less than 0.02Hz. When a 5% harmonic is applied to the AC signal, the final calculation accuracy can still reach 0.1Hz.

[0122] The beneficial effects of implementing this embodiment are as follows: first, an alternating current signal is acquired; periodically samples the alternating current signal to obtain a sampling sequence; arccosine calculation is performed on the sampling sequence to obtain arccosine values; the arccosine values ​​are clipped to obtain clipped values; two intervals with the same direction of change between a preset minimum value and a preset maximum value are retrieved from the clipped values; the two intervals are linearly fitted using the least squares method to obtain two straight lines; the horizontal coordinates of the two straight lines when they cross zero are calculated, the difference between the horizontal coordinates is calculated, and then the sine wave period is calculated based on the sampling period, and then the frequency is calculated based on the sine wave period; even when the alternating current waveform has a certain degree of distortion (high noise or harmonic content), the zero-crossing point measurement is still not affected, the accuracy of the zero-crossing point measurement is not affected by the initial phase and the number of samples, and the frequency calculation accuracy is high.

[0123] The present invention can be used in a wide variety of general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, and the like. The present invention can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present invention can also be practiced in distributed computing environments in which tasks are performed by remote processing devices connected via a communications network. In a distributed computing environment, program modules can be located in local and remote computer storage media, including storage devices.

[0124] Those skilled in the art will appreciate that all or part of the processes in the above-described method embodiments can be implemented by instructing related hardware using computer-readable instructions. The computer-readable instructions can be stored in a computer-readable storage medium. When executed, the program can include the processes in the above-described method embodiments. The aforementioned storage medium can be a non-volatile storage medium such as a magnetic disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).

[0125] It should be understood that although the steps in the flowcharts of the accompanying drawings are shown in sequence as indicated by the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some of the steps in the flowcharts of the accompanying drawings may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be executed in turn or alternately with other steps or at least a portion of the sub-steps or stages of other steps.

[0126] Example 2

[0127] Further references Figure 6 , as a response to the above Figure 1 The present invention provides an embodiment of an AC frequency calculation device, which is similar to the embodiment of the present invention. Figure 1 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.

[0128] like Figure 6 As shown, the AC frequency calculation device 80 of this embodiment includes: an acquisition module 81, a sampling module 82, an arc cosine calculation module 83, a clipping module 84, a retrieval module 85, a linear fitting module 86 and a frequency calculation module 87. Among them:

[0129] An acquisition module 81 is used to acquire an AC signal;

[0130] The sampling module 82 is used to periodically sample the AC signal to obtain a sampling sequence S1, S2, S3, ..., Sn, where n is the number of sampling points;

[0131] An arccosine calculation module 83 is used to perform arccosine calculation on the sampling sequences S1, S2, S3, ..., Sn to obtain an arccosine value Cn;

[0132] a clipping module 84 for clipping the arccosine value Cn to obtain a clipped value Dn;

[0133] A search module 85 is configured to search for two intervals, namely, Di to Di+k and Dj to Dj+k, between a preset minimum value and a preset maximum value in the truncated value Dn, which change in the same direction.

[0134] The linear fitting module 86 is used to perform the least squares linear fitting on the two intervals to obtain two straight lines. and , and ;

[0135] Frequency calculation module 87, used to calculate the frequency of two straight lines and The horizontal coordinate when crossing zero and , calculate the horizontal coordinate and The difference between them is used to calculate the sine wave period according to the sampling period, that is, , and then calculate the frequency based on the sine wave period, .

[0136] The beneficial effects of implementing this embodiment are as follows: first, an alternating current signal is acquired; periodically samples the alternating current signal to obtain a sampling sequence; arccosine calculation is performed on the sampling sequence to obtain arccosine values; the arccosine values ​​are clipped to obtain clipped values; two intervals with the same direction of change between a preset minimum value and a preset maximum value are retrieved from the clipped values; the two intervals are linearly fitted using the least squares method to obtain two straight lines; the horizontal coordinates of the two straight lines when they cross zero are calculated, the difference between the horizontal coordinates is calculated, and then the sine wave period is calculated based on the sampling period, and then the frequency is calculated based on the sine wave period; even when the alternating current waveform has a certain degree of distortion (high noise or harmonic content), the zero-crossing point measurement is still not affected, the accuracy of the zero-crossing point measurement is not affected by the initial phase and the number of samples, and the frequency calculation accuracy is high.

[0137] Example 3

[0138] To solve the above technical problems, the embodiment of the present invention also provides a computer device. Figure 7 , Figure 7 This is a basic structural block diagram of the computer device in this embodiment.

[0139] The computer device 9 includes a memory 91, a processor 92, and a network interface 93 that are interconnected through a system bus. It should be noted that the figure only shows a computer device 9 having components of a memory 91, a processor 92, and a network interface 93, but it should be understood that it is not required to implement all the components shown, and more or fewer components may be implemented instead. Among them, those skilled in the art can understand that the computer device here is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to a microprocessor, an application specific integrated circuit (ASIC), a field-programmable gate array (FPGA), a digital signal processor (DSP), an embedded device, etc.

[0140] The computer device may be a desktop computer, notebook computer, PDA, cloud server, etc. The computer device may interact with the user via a keyboard, mouse, remote control, touchpad, or voice control device.

[0141] The memory 91 includes at least one type of readable storage medium, including flash memory, a hard disk, a multimedia card, card-type memory (e.g., SD or DX memory), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic storage, a magnetic disk, an optical disk, etc. In some embodiments, the memory 91 may be an internal storage unit of the computer device 9, such as the hard disk or internal memory of the computer device 9. In other embodiments, the memory 91 may also be an external storage device of the computer device 9, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash memory card, etc. Of course, the memory 91 may also include both the internal storage unit of the computer device 9 and its external storage device. In this embodiment, the memory 91 is generally used to store the operating system and various application software installed on the computer device 9, such as computer-readable instructions for the AC frequency calculation method. In addition, the memory 91 can also be used to temporarily store various types of data that have been output or are about to be output.

[0142] In some embodiments, the processor 92 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chip. The processor 92 is generally used to control the overall operation of the computer device 9. In this embodiment, the processor 92 is used to execute computer-readable instructions or process data stored in the memory 91, such as computer-readable instructions for executing the AC frequency calculation method.

[0143] The network interface 93 may include a wireless network interface or a wired network interface. The network interface 93 is generally used to establish a communication connection between the computer device 9 and other electronic devices.

[0144] The beneficial effects of implementing this embodiment are as follows: first, an alternating current signal is acquired; periodically samples the alternating current signal to obtain a sampling sequence; arccosine calculation is performed on the sampling sequence to obtain arccosine values; the arccosine values ​​are clipped to obtain clipped values; two intervals with the same direction of change between a preset minimum value and a preset maximum value are retrieved from the clipped values; the two intervals are linearly fitted using the least squares method to obtain two straight lines; the horizontal coordinates of the two straight lines when they cross zero are calculated, the difference between the horizontal coordinates is calculated, and then the sine wave period is calculated based on the sampling period, and then the frequency is calculated based on the sine wave period; even when the alternating current waveform has a certain degree of distortion (high noise or harmonic content), the zero-crossing point measurement is still not affected, the accuracy of the zero-crossing point measurement is not affected by the initial phase and the number of samples, and the frequency calculation accuracy is high.

[0145] Example 4

[0146] The present invention also provides another embodiment, namely, providing a computer-readable storage medium, which stores computer-readable instructions. The computer-readable instructions can be executed by at least one processor to enable the at least one processor to perform the steps of the AC frequency calculation method as described above.

[0147] The beneficial effects of implementing this embodiment are as follows: first, an alternating current signal is acquired; periodically samples the alternating current signal to obtain a sampling sequence; arccosine calculation is performed on the sampling sequence to obtain arccosine values; the arccosine values ​​are clipped to obtain clipped values; two intervals with the same direction of change between a preset minimum value and a preset maximum value are retrieved from the clipped values; the two intervals are linearly fitted using the least squares method to obtain two straight lines; the horizontal coordinates of the two straight lines when they cross zero are calculated, the difference between the horizontal coordinates is calculated, and then the sine wave period is calculated based on the sampling period, and then the frequency is calculated based on the sine wave period; even when the alternating current waveform has a certain degree of distortion (high noise or harmonic content), the zero-crossing point measurement is still not affected, the accuracy of the zero-crossing point measurement is not affected by the initial phase and the number of samples, and the frequency calculation accuracy is high.

[0148] Through the above description of the embodiments, those skilled in the art will clearly understand that the above-mentioned embodiments and methods can be implemented using software and a necessary general-purpose hardware platform. Of course, hardware can also be used, but in many cases, the former is a more preferred embodiment. Based on this understanding, the technical solution of the present invention, or the portion that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk) and includes a number of instructions for enabling a terminal device (such as a mobile phone, computer, server, air conditioner, or network device) to execute the various embodiments and methods of the present invention.

[0149] Obviously, the embodiments described above are only some embodiments of the present invention, rather than all embodiments. The preferred embodiments of the present invention are given in the accompanying drawings, but they do not limit the patent scope of the present invention. The present invention can be implemented in many different forms. On the contrary, the purpose of providing these embodiments is to make the understanding of the disclosure of the present invention more thorough and comprehensive. Although the present invention has been described in detail with reference to the aforementioned embodiments, for those skilled in the art, it is still possible to modify the technical solutions described in the aforementioned specific embodiments, or to make equivalent replacements for some of the technical features therein. Any equivalent structure made using the contents of the present invention specification and drawings, directly or indirectly used in other related technical fields, is also within the scope of patent protection of the present invention.

Claims

1. A method for calculating the frequency of alternating current, characterized in that: The steps include: Acquire AC power signal; The alternating current signal is periodically sampled to obtain a sampling sequence S1, S2, S3, ..., Sn, where n is the number of sampling points; Perform arccosine calculation on the sampling sequence S1, S2, S3, ..., Sn to obtain an arccosine value Cn, wherein the arccosine value Cn is a time series value corresponding to each sampling point number; The arccosine value Cn is clipped to obtain a clipped value Dn; Searching for two adjacent intervals with the same change direction between the preset minimum value and the preset maximum value in the value Dn after the top and bottom are cut, namely Di~Di+k, Dj~Dj+k; Perform the least squares linear fitting on the two intervals to obtain two straight lines and , and ; Calculate two straight lines separately and The horizontal coordinate when it crosses zero and , calculate the horizontal coordinate and The difference between them is used to calculate the sine wave period according to the sampling period, that is, Then the frequency is calculated based on the sine wave period, ,in is the sampling period.

2. The method for calculating the frequency of alternating current according to claim 1, characterized in that: The step of periodically sampling the AC signal to obtain a sampling sequence S1, S2, S3, ..., Sn specifically includes: Select the sampling frequency; Determine the sampling period; Synchronous trigger sampling; Select sampling points to obtain a sampling sequence S1, S2, S3, ..., Sn; Store sampling sequence S1, S2, S3, ..., Sn.

3. The method for calculating the frequency of alternating current according to claim 1, characterized in that: The step of performing arccosine calculation on the sampling sequences S1, S2, S3, ..., Sn to obtain the arccosine value Cn specifically includes: calculate , where A is the AC signal amplitude, that is .

4. The method for calculating the frequency of alternating current according to claim 1, characterized in that: The step of searching for two intervals with the same direction of change between the preset minimum value and the preset maximum value in the value Dn after the top and bottom are cut, namely Di~Di+k, Dj~Dj+k, specifically includes: Set specific values ​​for the preset minimum value and the preset maximum value; Traverse the clipped value Dn, search for two intervals with the same direction of change between the preset minimum value and the preset maximum value, and obtain Di~Di+k, Dj~Dj+k.

5. The method for calculating the frequency of alternating current according to claim 1, characterized in that: The least squares linear fitting is performed on the two intervals to obtain two straight lines. and , and The steps specifically include: Determine the fitting interval and ; Setting up the linear model , linear model It is a linear function of the number of sampling points; In the fitting interval, according to the set linear model, determine , , and The value of , through the least squares linear fitting method, two straight lines are obtained and , and .

6. The method for calculating the frequency of alternating current according to claim 1, characterized in that: The two straight lines are calculated separately and The horizontal coordinate when it crosses zero and , calculate the horizontal coordinate and The difference between them is used to calculate the sine wave period according to the sampling period, that is, Then the frequency is calculated based on the sine wave period, The steps specifically include: make ; make ; The sine wave period is calculated according to the sampling period, that is, ; Calculate the frequency based on the sine wave period, .

7. An alternating current frequency calculation device, characterized in that: include: An acquisition module, used for acquiring an alternating current signal; A sampling module, used for periodically sampling the AC signal to obtain a sampling sequence S1, S2, S3, ..., Sn, where n is the number of sampling points; An arccosine calculation module, used for performing arccosine calculation on the sampling sequences S1, S2, S3, ..., Sn to obtain an arccosine value Cn, wherein the arccosine value Cn is a time series value corresponding to each sampling point number; A clipping module, used for clipping the arccosine value Cn to obtain a clipped value Dn; A search module is used to search for two adjacent intervals with the same direction of change between a preset minimum value and a preset maximum value in the value Dn after being clipped, namely Di~Di+k, Dj~Dj+k; The linear fitting module is used to perform the least squares linear fitting on two intervals to obtain two straight lines. and , and ; Frequency calculation module, used to calculate two straight lines separately and The horizontal coordinate when it crosses zero and , calculate the horizontal coordinate and The difference between them is used to calculate the sine wave period according to the sampling period, that is, Then the frequency is calculated based on the sine wave period, ,in is the sampling period.

8. A computer device, comprising a memory and a processor, wherein the memory stores computer-readable instructions, and the processor implements the steps of the method for calculating the frequency of alternating current according to any one of claims 1 to 6 when executing the computer-readable instructions.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-readable instructions, and when the computer-readable instructions are executed by a processor, the steps of the method for calculating the frequency of alternating current according to any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Unitary regression frequency measurement method, electronic equipment and storage medium

    CN110069984A