CN112181047A - Self-adaptive method based on power grid power frequency clock source - Google Patents
Self-adaptive method based on power grid power frequency clock source Download PDFInfo
- Publication number
- CN112181047A CN112181047A CN202010915119.7A CN202010915119A CN112181047A CN 112181047 A CN112181047 A CN 112181047A CN 202010915119 A CN202010915119 A CN 202010915119A CN 112181047 A CN112181047 A CN 112181047A
- Authority
- CN
- China
- Prior art keywords
- power grid
- power
- power frequency
- clock source
- timer
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
- 238000000034 method Methods 0.000 title claims abstract description 23
- 230000003044 adaptive effect Effects 0.000 claims description 10
- 230000002159 abnormal effect Effects 0.000 claims description 3
- 230000010355 oscillation Effects 0.000 description 4
- 230000006978 adaptation Effects 0.000 description 1
- 239000013078 crystal Substances 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F1/00—Details not covered by groups G06F3/00 - G06F13/00 and G06F21/00
- G06F1/04—Generating or distributing clock signals or signals derived directly therefrom
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F1/00—Details not covered by groups G06F3/00 - G06F13/00 and G06F21/00
- G06F1/04—Generating or distributing clock signals or signals derived directly therefrom
- G06F1/08—Clock generators with changeable or programmable clock frequency
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F1/00—Details not covered by groups G06F3/00 - G06F13/00 and G06F21/00
- G06F1/04—Generating or distributing clock signals or signals derived directly therefrom
- G06F1/14—Time supervision arrangements, e.g. real time clock
Abstract
The invention discloses a self-adaptive method based on a power frequency clock source of a power grid, which comprises the following steps: the system is powered on and initialized; determining a power frequency value of the power grid; and switching the clock source of the system to a corresponding timing program according to the power frequency value of the power grid to adapt. According to the self-adaptive method based on the power frequency clock source of the power grid, the power frequency value of the power grid is determined, and then the clock source of the system is switched to the corresponding timing program to adapt according to the power frequency value of the power grid, so that the clock source of the system is used as a timing tool, and the stability and accurate control of the system are ensured.
Description
Technical Field
The invention belongs to the technical field of power supply of a power grid, and particularly relates to a self-adaptive method based on a power frequency clock source of the power grid.
Background
At present, in the application process of a power frequency system of a power grid, in order to save the device cost of a control system, an external crystal oscillator of an MCU (micro control unit) is usually saved, and internal RC oscillation is adopted.
However, the RC oscillation frequency is greatly affected by the working environment and is sensitive to temperature, which may cause the cycle time of the RC oscillation to be inconsistent. Therefore, if the internal RC oscillation is used as a clock reference, a deviation is caused, and the control system cannot control accurately.
Disclosure of Invention
In order to solve the problems, the invention provides a self-adaptive method based on a power frequency clock source of a power grid, which ensures the stability and accurate control of the system.
The technical scheme adopted by the invention is as follows:
a self-adaptive method based on a power frequency clock source of a power grid comprises the following steps:
s1, carrying out system power-on initialization;
s2, determining the power frequency value of the power grid;
and S3, switching the clock source of the system to a corresponding timing program to adapt according to the power frequency value of the power grid.
Preferably, the S2 is specifically:
s21, setting a first timer to receive a fixed number of pulse signals and then generating interruption;
s22, starting a second timer to count time in an accumulated mode after the first timer is interrupted once;
s23, when the first timer generates two continuous interrupts, the second timer calculates the total duration of the two interrupts;
and S24, determining the power frequency value of the power grid according to the total duration of the two interruption intervals.
Preferably, in S22, the second timer counts time in a minimum count unit.
Preferably, the minimum time unit is freely set by a user.
Preferably, the S24 is specifically:
s241, comparing the total time length of the two-time interruption interval with the product of the period time length corresponding to the corresponding power grid power frequency prestored in the system and the fixed number;
and S242, when the error range of the comparison of the total duration and the corresponding product is smaller than or equal to a preset value, determining the current power grid power frequency value as a power grid power frequency value correspondingly prestored in the system.
Preferably, the power frequency values of the power grid prestored in the system comprise 50Hz and 60 Hz.
Preferably, the fixed number is 100.
Preferably, the preset value of the error range is ± 10%.
Preferably, in S242, when an error range of the comparison between the total duration and the corresponding product is greater than a preset value, it is determined that the current power supply of the power grid is abnormal, and an alarm is given.
Compared with the prior art, the self-adaptive method based on the power frequency clock source of the power grid firstly determines the power frequency value of the power grid, and then switches the clock source of the system to the corresponding timing program for adaptation according to the power frequency value of the power grid, so that the clock source of the system is used as a timing tool, and the stability and the accurate control of the system are ensured.
Drawings
Fig. 1 is a flowchart of an adaptive method based on a power frequency clock source of a power grid according to an embodiment of the present invention;
fig. 2 is a specific flowchart of an adaptive method based on a power frequency clock source of a power grid according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
Examples
The embodiment of the invention provides a self-adaptive method based on a power frequency clock source of a power grid, which comprises the following steps as shown in figures 1-2:
s1, carrying out system power-on initialization;
s2, determining the power frequency value of the power grid;
and S3, switching the clock source of the system to a corresponding timing program to adapt according to the power frequency value of the power grid.
Therefore, the power frequency value of the power grid is determined at first, and then the clock source of the system is switched to the corresponding timing program to adapt according to the power frequency value of the power grid, so that the clock source of the system is used as a timing tool, and the system is ensured to be stably and accurately controlled.
The S2 specifically includes:
s21, setting a first timer to receive a fixed number of pulse signals and then generating interruption;
s22, starting a second timer to count time in an accumulated mode after the first timer is interrupted once;
s23, when the first timer generates two continuous interrupts, the second timer calculates the total duration of the two interrupts;
and S24, determining the power frequency value of the power grid according to the total duration of the two interruption intervals.
In this way, the first timer is set to interrupt after receiving a fixed number of pulse signals, and the first timer is used for the validity of the current numerical value and representing the completion of initialization; starting a second timer to accumulate and time after the first timer is interrupted once; when the first timer generates two continuous interrupts, the second timer calculates the total time length of the two interrupt intervals, namely the product of the period time length and the fixed number; and determining the power frequency value of the power grid according to the total time length of the two interruption intervals, so that the timing tool in the system is adaptive to the power frequency clock source of the power grid.
In S22, the second timer counts time in a minimum count unit. The minimum time unit is freely set by the user.
In this way, the second timer counts time in a minimum timing unit that is freely set by the user according to the actual situation, for example, 100mS or 10mS or the like.
The S24 specifically includes:
s241, comparing the total time length of the two-time interruption interval with the product of the period time length corresponding to the corresponding power grid power frequency prestored in the system and the fixed number;
and S242, when the error range of the comparison of the total duration and the corresponding product is smaller than or equal to a preset value, determining the current power grid power frequency value as a power grid power frequency value correspondingly prestored in the system.
Comparing the total time length of the two interruption intervals with the product of the period time length corresponding to the power frequency of the corresponding power grid prestored in the system and the fixed number; when the error range of the comparison of the total duration and the corresponding product is smaller than or equal to a preset value, determining that the current power grid power frequency value is a power grid power frequency value which is prestored in the system correspondingly, and further enabling a timing tool in the system to be adaptive to a power grid power frequency clock source; and when the error range of the comparison of the total duration and the corresponding product is larger than a preset value, determining that the current power supply of the power grid is abnormal, and giving an alarm.
The power frequency values of the power grid prestored in the system comprise 50HZ and 60 HZ.
Therefore, the power grid power frequency values pre-stored in the system comprise 50HZ and 60HZ, and are power grid power frequency values commonly used in the international world at present.
The fixed number is 100.
Thus, the fixed number is 100, which is convenient for calculating the product value of the period duration and the fixed number and comparing the product value with the total duration.
The preset value of the error range is +/-10%.
Thus, the error range is set to be ± 10%, which allows the total duration to be compared with the corresponding product within a certain error range.
The method comprises the following specific implementation steps:
the first step is as follows: electrifying and initializing, and setting a data valid flag as follows: flay _ Start is False (invalid value), which ensures that the level signal is reliably acquired. Configuration-related register description:
a first Timer (Timer0) using external power frequency as a clock source is used as an interrupt flag bit: and Flay _ ExInt is False (invalid value) and is used for recording whether the generation of the fixed interrupt clock reference by the power frequency pulse signal is finished or not.
Clocking out the value using a second Timer (Timer1) of the internal clock source: the timer _ Pulse is equal to Null, and provides a time basis for judging the power frequency of the power grid;
the second step is that: s21, setting a first Timer (Timer0) to be interrupted when 100 pulse signals are fixedly received, and after the interruption is started, firstly setting a data valid flag as: fly _ Start ═ True; fly _ ext ═ True.
Data initialization flag: fly _ Start ═ True for the validity of the current value, True representing that register initialization is complete.
S22, when detecting that fly _ ex ═ True, the second Timer (Timer1) is interrupted once in 100 microseconds, let Timer _ Pulse start timing, and let fly _ ex ═ False (reset to an invalid value).
And S23, when the first Timer (Timer0) fixedly receives 100 pulse signals for the second time, timing interruption occurs again to obtain timing data.
S24, through the timer _ Pulse timing data, the power frequency of the current power grid can be judged to be 60Hz or 50 Hz. For example:
when the power frequency of the power grid is detected to be 50Hz, the corresponding 100 cycle times are as follows: 100 pulse periods 20 ms 2000 ms.
When the power frequency of the power grid is detected to be 60Hz, the corresponding 100 cycle times are as follows: 100 pulse periods 16.66 ms 1666 ms.
Since the second Timer (Timer1) is interrupted once in 100 microseconds, and let the Timer _ Pulse count once, when the power frequency is 50Hz, theoretically the Timer _ Pulse is 2000 milliseconds; the power frequency is 60Hz, and the theoretical time _ Pulse is about 1666 milliseconds.
And thirdly, switching a clock source of the system to a corresponding timing program to adapt according to the power frequency value of the power grid, thereby ensuring the stability and accurate control of the system.
According to the self-adaptive method based on the power frequency clock source of the power grid, the power frequency value of the power grid is determined, and then the clock source of the system is switched to the corresponding timing program to adapt according to the power frequency value of the power grid, so that the clock source of the system is used as a timing tool, and the stability and accurate control of the system are ensured.
The above description is only for the preferred embodiment of the present invention, but the scope of the present invention is not limited thereto, and any changes or substitutions that can be easily conceived by those skilled in the art within the technical scope of the present invention are included in the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.
Claims (9)
1. An adaptive method based on a power frequency clock source of a power grid is characterized by comprising the following steps:
s1, carrying out system power-on initialization;
s2, determining the power frequency value of the power grid;
and S3, switching the clock source of the system to a corresponding timing program to adapt according to the power frequency value of the power grid.
2. The self-adaptation method based on the power frequency clock source of the power grid according to claim 1, wherein the S2 specifically is:
s21, setting a first timer to receive a fixed number of pulse signals and then generating interruption;
s22, starting a second timer to count time in an accumulated mode after the first timer is interrupted once;
s23, when the first timer generates two continuous interrupts, the second timer calculates the total duration of the two interrupts;
and S24, determining the power frequency value of the power grid according to the total duration of the two interruption intervals.
3. The adaptive method according to claim 2, wherein in S22, the second timer counts time with a minimum timing unit.
4. The adaptive method according to claim 3, wherein the minimum timing unit is freely set by a user.
5. The self-adaptation method based on the power frequency clock source of the power grid according to claim 2, wherein the S24 specifically is:
s241, comparing the total time length of the two-time interruption interval with the product of the period time length corresponding to the corresponding power grid power frequency prestored in the system and the fixed number;
and S242, when the error range of the comparison of the total duration and the corresponding product is smaller than or equal to a preset value, determining the current power grid power frequency value as a power grid power frequency value correspondingly prestored in the system.
6. The adaptive method according to claim 5, wherein the pre-stored grid power frequency values in the system comprise 50HZ and 60 HZ.
7. The grid power frequency clock source-based adaptive method according to claim 5, wherein the fixed number is 100.
8. The adaptive method according to claim 5, wherein the predetermined error range is ± 10%.
9. The self-adaptive method according to claim 5, wherein in step S242, when an error range of comparison between the total duration and the corresponding product is greater than a preset value, it is determined that the current power supply of the power grid is abnormal, and an alarm is given.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010915119.7A CN112181047B (en) | 2020-09-03 | 2020-09-03 | Self-adaptive method based on power frequency clock source of power grid |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010915119.7A CN112181047B (en) | 2020-09-03 | 2020-09-03 | Self-adaptive method based on power frequency clock source of power grid |
Publications (2)
Publication Number | Publication Date |
---|---|
CN112181047A true CN112181047A (en) | 2021-01-05 |
CN112181047B CN112181047B (en) | 2023-08-11 |
Family
ID=73924979
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010915119.7A Active CN112181047B (en) | 2020-09-03 | 2020-09-03 | Self-adaptive method based on power frequency clock source of power grid |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112181047B (en) |
Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN202133875U (en) * | 2011-05-25 | 2012-02-01 | 广州卓易电子科技有限公司 | Timing circuit |
CN102841247A (en) * | 2012-08-30 | 2012-12-26 | 惠州三华工业有限公司 | Detection method for grid frequency |
US20160218721A1 (en) * | 2015-01-28 | 2016-07-28 | Apple Inc. | Closed loop clock signal generator with multiple reference clocks |
CN206311665U (en) * | 2016-11-15 | 2017-07-07 | 江苏林洋能源股份有限公司 | A kind of intelligent electric energy meter doubleclocking source sampling device |
CN107783864A (en) * | 2017-10-20 | 2018-03-09 | 郑州云海信息技术有限公司 | A kind of server clock redundant apparatus and switching method |
CN110568750A (en) * | 2019-09-04 | 2019-12-13 | 西安矽力杰半导体技术有限公司 | Timing circuit and timing method |
CN110690894A (en) * | 2019-09-20 | 2020-01-14 | 上海励驰半导体有限公司 | Clock failure safety protection method and circuit |
-
2020
- 2020-09-03 CN CN202010915119.7A patent/CN112181047B/en active Active
Patent Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN202133875U (en) * | 2011-05-25 | 2012-02-01 | 广州卓易电子科技有限公司 | Timing circuit |
CN102841247A (en) * | 2012-08-30 | 2012-12-26 | 惠州三华工业有限公司 | Detection method for grid frequency |
US20160218721A1 (en) * | 2015-01-28 | 2016-07-28 | Apple Inc. | Closed loop clock signal generator with multiple reference clocks |
CN206311665U (en) * | 2016-11-15 | 2017-07-07 | 江苏林洋能源股份有限公司 | A kind of intelligent electric energy meter doubleclocking source sampling device |
CN107783864A (en) * | 2017-10-20 | 2018-03-09 | 郑州云海信息技术有限公司 | A kind of server clock redundant apparatus and switching method |
CN110568750A (en) * | 2019-09-04 | 2019-12-13 | 西安矽力杰半导体技术有限公司 | Timing circuit and timing method |
CN110690894A (en) * | 2019-09-20 | 2020-01-14 | 上海励驰半导体有限公司 | Clock failure safety protection method and circuit |
Also Published As
Publication number | Publication date |
---|---|
CN112181047B (en) | 2023-08-11 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US6971036B2 (en) | Methods and apparatus for low power delay control | |
KR20100017389A (en) | Interrupt/wake-up of an electronic device in a low power sleep mode detecting a sensor or frequency source activated frequency change | |
EP2057748A1 (en) | System frame number (sfn) evaluator | |
US6084441A (en) | Apparatus for and method of processing data | |
CA1168371A (en) | Dual deadman timer circuit | |
CN112181047A (en) | Self-adaptive method based on power grid power frequency clock source | |
JP2002368670A (en) | Radio communication equipment and method for estimating reception timing therefor | |
CN108230660B (en) | Control method and control device, storage medium and remote controller | |
JPH08125674A (en) | Communication controller | |
US5978318A (en) | Timepiece device mechanism for indicating restart after recharging | |
CN112104341A (en) | System clock calibration method based on self-adaptive power grid power frequency | |
CN113406992B (en) | System clock control method, processing device and readable storage medium | |
JPH1073683A (en) | Electronic time piece | |
US5546363A (en) | Clock apparatus for forming time information for use in computer system | |
JP2002202830A (en) | Microcomputer | |
CN105167345A (en) | Automatic alarm method and intelligent walking stick | |
US6449217B1 (en) | Low cost clock | |
CN112235876B (en) | Internet of things communication anti-collision control method based on power grid power frequency | |
JP2002008178A (en) | Variable measuring period type measurement control system | |
JPS62145440A (en) | Runaway detection circuit | |
KR940007805B1 (en) | Automatic checking method for 50/60hz power frequency | |
JP2002286877A (en) | Method and apparatus of deciding start timing of time frame, time information detector and radio-controlled clock | |
JP2906254B2 (en) | Programmable controller | |
JPH0792772B2 (en) | Watchdog timer device | |
JPH0784666A (en) | Control device for intermittent operation of cpu |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |