CN102289194B - Method and device for operating clock - Google Patents

Method and device for operating clock Download PDF

Info

Publication number
CN102289194B
CN102289194B CN 201110239994 CN201110239994A CN102289194B CN 102289194 B CN102289194 B CN 102289194B CN 201110239994 CN201110239994 CN 201110239994 CN 201110239994 A CN201110239994 A CN 201110239994A CN 102289194 B CN102289194 B CN 102289194B
Authority
CN
China
Prior art keywords
square
wave signal
frequency
cycle length
module
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.)
Expired - Fee Related
Application number
CN 201110239994
Other languages
Chinese (zh)
Other versions
CN102289194A (en
Inventor
周健
杨小宝
冯磊
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen H&T Intelligent Control Co Ltd
Original Assignee
Shenzhen H&T Intelligent Control Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Shenzhen H&T Intelligent Control Co Ltd filed Critical Shenzhen H&T Intelligent Control Co Ltd
Priority to CN 201110239994 priority Critical patent/CN102289194B/en
Publication of CN102289194A publication Critical patent/CN102289194A/en
Application granted granted Critical
Publication of CN102289194B publication Critical patent/CN102289194B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Electric Clocks (AREA)
  • Measuring Frequencies, Analyzing Spectra (AREA)

Abstract

The invention provides a method and device for operating a clock. The method provided by the invention comprises the following steps: converting alternating current signals of a power grid into square wave signals; detecting the cycle time of the square wave signals; determining the frequency of the square wave signals according to the detected cycle time; counting the pulses of the square wave signals; and operating the clock according to the frequency and pulse number of the square wave signals. The method and device for operating the clock provided by the invention do not need an oscillator or timer with high accuracy, can improve the accuracy for operating the clock and do not excessively increase the cost of a product.

Description

Method and the device of operation clock
Technical field
The present invention relates to move the clock field, relate in particular to a kind of method and device that moves clock.
Background technology
Along with the development of science and technology, all have the function of operation clock in the general electronic product, and the precision that the operation clock need to be higher, the precision of minimum timing is moved the precision of clock often in the general electronic products.But the accuracy requirement to timer in the present electronic product is usually not high, if in order to move clock, and adopts high-precision oscillator or timer, just can increase the cost of electronic product.
Summary of the invention
The present invention needs high-precision oscillator or timer to improve the precision of operation clock for solving in the prior art, can increase greatly the technical matters of cost of products, a kind of method and apparatus that moves clock is provided, do not need high-precision oscillator or timer, just can improve the precision of operation clock, and the cost of increase product that can be not too much.
The invention provides a kind of method of moving clock, said method comprising the steps of,
Convert the grid alternating current signal to square-wave signal;
Detect the cycle length of square-wave signal, according to the cycle length of the square-wave signal that detects, confirm the frequency of square-wave signal;
To the step-by-step counting of square-wave signal, according to frequency and the step-by-step counting of square-wave signal, the operation clock.
Preferably, detect the cycle length of square-wave signal, according to the cycle length of the square-wave signal that detects, confirm the step of the frequency of square-wave signal, be specially:
Detect the cycle length of square-wave signal, according to the cycle length of the square-wave signal that detects, obtain the calculated rate of square-wave signal;
According to the calculated rate of described square-wave signal, the choice criteria frequency is the frequency of square-wave signal.
Preferably, at the calculated rate according to described square-wave signal, the frequency of square-wave signal is chosen as after the step of standard frequency, further comprising the steps of:
Detect the cycle length of a N continuous square-wave signal;
Whether in the Preset Time zone that obtains according to time normal period and poorly be not more than the preset ratio value cycle length of each square-wave signal, if so, confirm that the frequency of square-wave signal is selected standard frequency the cycle length of judging each square-wave signal.
Preferably, in the cycle length of detecting square-wave signal, according to the cycle length of the square-wave signal that detects, confirm after the frequency of square-wave signal, further comprising the steps of:
The unit interval that produces according to the frequency of square-wave signal is set to standard unit's time of timer;
Move described timer the time according to standard unit, obtain the count parameter of standard unit's time;
According to the count parameter of standard unit's time, described timer is calibrated.
Preferably, in the step-by-step counting to square-wave signal, according to frequency and the step-by-step counting of square-wave signal, before the step of operation clock, further comprising the steps of:
Obtain the cycle length of square-wave signal, whether deviation between time normal period of the cycle length that relatively gets access to and square-wave signal in the first Preset Time, if so, carries out the step-by-step counting to square-wave signal, according to frequency and the step-by-step counting of square-wave signal, the step of operation clock.
Preferably, obtain the step of the cycle length of square-wave signal, be specially:
Obtain the mistiming between the zero crossing of adjacent square-wave signal.
Preferably, when getting access to the zero crossing of square-wave signal, further comprising the steps of at every turn:
Timer is resetted.
Preferably, when the deviation between time normal period of the cycle length that gets access to and square-wave signal is not in the first Preset Time, further comprising the steps of:
Be set to the preset multiple of time normal period the time-count cycle of timer;
According to the time-count cycle of described timer, the operation clock also adds up the cycle of operation number of times of timer;
Judge whether cycle of operation number of times reaches default cycle of operation number of times, if so, carry out the step of the cycle length of obtaining square-wave signal.
Preferably, when cycle of operation number of times reaches default cycle of operation during number of times, further comprising the steps of:
The operation variable i is set, and variable i is from adding one, and wherein the initial value of i is that 0, i is positive integer;
Judge whether the operation variable i reaches default number of run value, if not, preserves current operation variable i, carries out the step of the cycle length of obtaining square-wave signal, if so, clock count is carried out correction process, and the operation variable i is carried out zero clearing.
The present invention also provides a kind of device that moves clock, and described device comprises modular converter, confirms module and operation module;
Modular converter is used for converting the grid alternating current signal to square-wave signal;
Confirm module, for detection of the cycle length of square-wave signal, according to the cycle length of the square-wave signal that detects, confirm the frequency of square-wave signal;
The operation module is used for the step-by-step counting to square-wave signal, according to frequency and the step-by-step counting of confirming that module is confirmed, and the operation clock.
Preferably, described modular converter comprises that an end is the first resistance of the receiving end of grid alternating current signal, the other end of described the first resistance is electrically connected with the anode of the first backward dioded, the negative electrode of the second backward dioded and an end of the second resistance respectively, the negative electrode of described the first backward dioded is electrically connected with power supply, the anode of the second backward dioded is connected with ground, and the other end of the second resistance is the output terminal of square-wave signal.
Preferably, described affirmation module comprises the first detecting unit, computing unit and selected cell;
The first detecting unit is for detection of the cycle length of square-wave signal;
Computing unit for the cycle length that detects according to the first detecting unit, obtains the calculated rate of square-wave signal;
Selected cell is used for the calculated rate that obtains according to computing unit, and the choice criteria frequency also is made as the frequency of square-wave signal.
Preferably, described affirmation module also comprises the second detecting unit, judging unit and confirmation unit;
The second detecting unit is used for detecting the cycle length of detecting a N continuous square-wave signal cycle length of a N continuous square-wave signal after selecting unit choice criteria frequency;
Judging unit, be used for judging that cycle length that the second detecting unit detects is whether in the time normal period resulting Preset Time zone of selecting according to selected cell and differ from the cycle length of each square-wave signal and be not more than the preset ratio value, if so, signal is judged in output first;
Confirmation unit is used for judging signal according to first of judging unit output, confirms that the frequency of square-wave signal is selected standard frequency.
Preferably, described device comprises that also first arranges module, computing module and calibration module;
First arranges module, is used for confirming that unit interval that the frequency of module affirmation produces is set to standard unit's time of timer;
Computing module is used for moving described timer the time according to the first standard unit that the module setting is set, and obtains the count parameter of standard unit's time;
Calibration module according to the count parameter that computing module obtains, is calibrated described timer.
Preferably, described device also comprises acquisition module and comparison module;
Acquisition module is used for the cycle length of obtaining square-wave signal;
Comparison module is used for deviation between time normal period of cycle length that acquisition module relatively gets access to and square-wave signal whether in the first Preset Time, if so, exports the first comparison signal, if not, exports the second comparison signal;
The operation module also is used for when receiving the first comparison signal of comparison module, to the step-by-step counting of square-wave signal, and according to frequency and the step-by-step counting of square-wave signal, the operation clock.
Preferably, described device comprises that also second arranges module, timing module and the first judge module;
First arranges module, is used for being set to the preset multiple of time normal period the time-count cycle of timer when receiving the second comparison signal of comparison module;
Timing module is used for being set, operation one-period calculating clock the time-count cycle that module arranges according to described first;
The first judge module is used for judging whether the clock timing of timing module one-period finishes, if so, and the output first signal;
Acquisition module also is used for obtaining the cycle length of square-wave signal when receiving the first signal of the first judge module.
Preferably, described device comprises that also second arranges module, the second judge module, preservation module and correction module;
Second arranges module, is used for when receiving the first signal of the first judge module the operation variable i being set, and variable i is from adding one, and wherein the initial value of i is that 0, i is positive integer;
The second judge module is used for judging whether the second operation variable i that the module setting is set reaches default number of run value, if so, exports the first consequential signal, if not, exports the second consequential signal;
Correction module is used for when receiving the first consequential signal of the second judge module clock timing being carried out correction process, and the operation variable i is carried out zero clearing;
Preserve module, when receiving the second consequential signal of the second judge module, preserve current operation variable i;
Acquisition module also is used for after the preservation module is preserved the operation variable i cycle length of obtaining square-wave signal.Be used for simultaneously after correction module is carried out correction process to clock timing the cycle length of acquisition methods signal.
Can find out from the scheme of operation clock, by converting high-precision grid alternating current signal to square-wave signal, then according to high-precision square-wave signal operation clock, therefore do not need high-precision oscillator or timer, just can improve the precision of operation clock, and the cost of increase product that can be not too much.
Description of drawings
Fig. 1 is the process flow diagram that the present invention moves method the first embodiment of clock;
Fig. 2 is the process flow diagram of a kind of embodiment of frequency confirmation method of square-wave signal of the present invention;
Fig. 3 is the process flow diagram that the present invention moves method the second embodiment of clock;
Fig. 4 is the process flow diagram that the present invention moves the third embodiment of method of clock;
Fig. 5 is the process flow diagram that the present invention moves the 4th kind of embodiment of method of clock;
Fig. 6 is the structural representation that the present invention moves device the first embodiment of clock;
Fig. 7 is the circuit diagram of a kind of embodiment of modular converter of the present invention;
Fig. 8 is the structural representation that the present invention confirms a kind of embodiment of module;
Fig. 9 is the structural representation that the present invention moves device the second embodiment of clock;
Figure 10 is the structural representation that the present invention moves the third embodiment of device of clock.
Embodiment
In order to make technical matters solved by the invention, technical scheme and beneficial effect clearer, below in conjunction with drawings and Examples, the present invention is further elaborated.Should be appreciated that specific embodiment described herein only in order to explain the present invention, is not intended to limit the present invention.
The invention provides the method for the operation clock of the first embodiment, as shown in Figure 1, said method comprising the steps of,
Step S01 converts the grid alternating current signal to square-wave signal;
Step S02, according to the cycle length that detects, confirms the frequency of square-wave signal at the cycle length of detection square-wave signal;
Step S03, to the step-by-step counting of square-wave signal, according to frequency and the step-by-step counting of square-wave signal, the operation clock.
In step S02, because the frequency of grid alternating current signal is that the electrical network power frequency is 50Hz or 60Hz, the standard frequency of square-wave signal should be 50Hz or 60Hz so, and the cycle length of the square-wave signal that therefore detects, the frequency of confirming square-wave signal should be 50Hz or 60Hz.
In step S01, according to China's present electrical network power frequency standard-required under normal circumstances precision need be higher than 40PPM, and along with the continuous progress of power supply technique, power supply grid is increasingly stable, electrical network power frequency precision also can constantly improve.
In step S03, for example the frequency of square-wave signal is defined as 50Hz, and the step-by-step counting of square-wave signal is counted from zero, and when meter full 50, assert that then clock has moved 1S.
Can find out from such scheme, by converting high-precision grid alternating current signal to square-wave signal, then according to high-precision square-wave signal operation clock, therefore do not need high-precision oscillator or timer, just can improve the precision of operation clock, and the cost of increase product that can be not too much.
In implementation, as shown in Figure 2, described step S02 is specially:
Step S021, according to the cycle length that detects, obtains the calculated rate of square-wave signal at the cycle length of detection square-wave signal;
Step S022, according to the calculated rate of described square-wave signal, the choice criteria frequency also is made as the frequency of square-wave signal.
In step S022, when being 50.2Hz such as the calculated rate of described square-wave signal, the frequency of square-wave signal is chosen as the standard frequency of 50Hz so, when being 60.9Hz such as the calculated rate of described square-wave signal, the frequency of square-wave signal is chosen as the standard frequency of 60Hz so, whether the calculated rate that therefore can pass through to judge described square-wave signal determines the frequency of square-wave signal be chosen as which standard frequency less than the predeterminated frequency value, just gives unnecessary details no longer one by one herein.
Further, in order to prevent because power supply electrifying disturbs the error that causes, as shown in Figure 2, further comprising the steps of after step S022;
Step S023, the cycle length of a detection N continuous square-wave signal;
Step S024, the cycle length of judging each square-wave signal whether in the Preset Time zone that obtains according to time normal period and the cycle length of each square-wave signal the poor preset ratio value that is not more than, if, enter step S025, the frequency of confirming square-wave signal is selected frequency, if not, enter step S023;
Step S025 confirms that the frequency of square-wave signal is selected standard frequency.
In step S024, be the frequency that 50Hz is made as square-wave signal such as the choice criteria frequency, time normal period of square-wave signal is 0.02s, the Preset Time zone can be 0.019-0.021s so; Be the frequency that 60Hz is made as square-wave signal such as the choice criteria frequency, time normal period of square-wave signal is 1/60s, and the Preset Time zone can be 0.016-0.018s so.Described preset ratio value is specially 1%-1.5%.
In implementation, can be after step S02 or step S022 or step S025, further comprising the steps of:
The unit interval that produces according to the frequency of square-wave signal is set to standard unit's time of timer;
Move described timer the time according to standard unit, obtain the count parameter of standard unit's time;
According to the count parameter of standard unit's time, described timer is calibrated.Row calibration during to timer makes timer can produce identical time reference by the square-wave signal that is converted to through the grid alternating current signal, thereby so that the precision of timer promoted greatly.
As shown in Figure 3, the present invention also provides the method for the operation clock of the second embodiment, and is after step S02, further comprising the steps of:
Step S04, the unit interval that produces according to the frequency of square-wave signal is set to standard unit's time of timer;
Step S05 moves described timer the time according to standard unit, obtains the count parameter of standard unit's time;
Step S06 according to the count parameter of standard unit's time, calibrates described timer, enters step S03.
In step S04, the unit interval can be 1-2S, when the unit interval is 1S, take 1S time that the frequency of square-wave signal produces as the standard 1S time.
In step S05 and step S06, with standard 1S time run timing device, if establishing with the 0.2ms interrupt timing unit count standard 1S time, its theoretical count parameter should be 5000, but because the error of oscillator in the reality, the count parameter that its actual count parameter is standard unit's time is W, if according to 0.2ms interrupt timing unit the Interruption parameter being set is N, and the Interruption parameter after the calibration is M, then formerly do not consider in the situation of power frequency error, Interruption parameter M after the calibration is by 5000/W=N/M, derive M=W*N/5000, consider that actual count parameter W has decimal, round off meter then M value has the error of maximum 0.5 unit, so total error is 40PPM (power frequency error)+1/5000 (counting error)+1/2*N, front two errors can be ignored for calibration timer error, so error approximates greatly 1/2*N, for 8 bit timing devices, the theoretical settings scope of N is 0-FF, the reasonable settings of N are about 200 so, actual error is 1/2*200=0.25% so, this error is less than the specification error of Tao Zhen (the general error of ceramic crystal oscillator is 0.5%), if for 16 bit timing devices, then the theoretical span of N is 0-FFFF, can get N is 2000 even larger, can further reduce error so, thereby improves the precision of timer.
In implementation, unstable in order to prevent the clock that causes because of interference, can be before step S03, further comprising the steps of: obtain the cycle length of square-wave signal, whether the deviation between time normal period of the cycle length that relatively gets access to and square-wave signal is in the first Preset Time, if, execution according to frequency and the step-by-step counting of square-wave signal, moves the step of clock to the step-by-step counting of square-wave signal, if not, do not move clock.Because the deviation between time normal period of accessed cycle length and square-wave signal is not in the first Preset Time the time, can think that this cycle length corresponding square-wave signal is asynchronous, assert that this signal is undesired signal, do not do the processing of operation clock.
In implementation, as shown in Figure 4, the method for the operation clock of the third embodiment of the present invention, after step S06, further comprising the steps of:
Step S07, the cycle length of obtaining square-wave signal;
Step S08, whether the deviation between time normal period of the cycle length that relatively gets access to and square-wave signal in the first Preset Time, if so, enters step S03, if not, enters step S09;
Step S09 is set to the preset multiple of time normal period the time-count cycle of timer;
Step S010, according to the time-count cycle of described timer, the operation one-period calculates clock;
Step S011 judges whether the clock timing of operation one-period finishes, and if so, returns step S07, if not, returns step S010.
In step S08, the span of described the first Preset Time is: time normal period * (4%-5%).When being 50Hz such as the standard frequency of square-wave signal, time normal period of square-wave signal is 0.02s, and the span of described the first Preset Time is 0.0008-0.001s.
In step S09, described preset multiple is specially: 1.04-1.05.Deviation between time normal period of the cycle length that gets access to and square-wave signal illustrates the verification of synchronization failure of square-wave signal not in the first Preset Time the time, and need to move clock this moment by timer.In order to make timer in timing, can pick up as early as possible again the zero passage synchronous point of square-wave signal, therefore arrange larger time-count cycle with timer.
In step S011, because generally all being the interference by electric network source, the zero crossing synchronization failure of square-wave signal causes, can again find the zero passage synchronous point of square-wave signal after power supply disturbs and removes within several time-count cycles, the clock operation returns to again by the square-wave signal running status.
In implementation, step S07 is specially: obtain the mistiming between the zero crossing of adjacent square-wave signal.Be mistiming between first square-wave signal and second 's the zero crossing to be cycle length of first square-wave signal.
In implementation, when getting access to the zero crossing of square-wave signal, further comprising the steps of: as timer to be resetted, thereby timer is arranged synchronously, remove some undesired signals at every turn.
In implementation, as shown in Figure 5, the method for the operation clock of the 4th kind of embodiment of the present invention.When in step S011, judge that obtain cycle of operation number of times reaches default cycle of operation during number of times, further comprising the steps of:
Step S012 arranges the operation variable i, and variable i is from adding 1, and wherein the initial value of i is that 0, i is positive integer;
Step S013 judges whether the operation variable i reaches default number of run value, if not, enters step S015, returns step S07, if so, enters step S014;
Step S014 carries out correction process to clock timing, and the operation variable i is carried out zero clearing, returns step S07;
Step S015 preserves current operation variable i, returns step S07.
In step S012, when timer did not move clock, variable i equaled 0, and by timer operation clock, and cycle of operation number of times reaches default cycle of operation during number of times when at every turn, and variable i just can add 1 certainly.
In the present embodiment, because during the zero crossing synchronization failure of square-wave signal, move clock by timer, and time normal period of the numeric ratio square-wave signal that arrange the time-count cycle of timer is larger, in the process of operation clock, can there be some errors so, when reaching certain number of times by timer operation clock, error will be come obviously, therefore error appears in order to prevent from moving clock, improve the precision of operation clock, when the operation variable i reaches default number of run value, clock timing is carried out correction process.
In step S013, the value of default number of run value is 10-20, is 20 such as the value of presetting the number of run value, namely when reaching 20 times by timer operation clock, clock timing is carried out correction process.
In implementation, in order to realize moving clock, as shown in Figure 6, the present invention also provides the device of the operation clock of the first embodiment, and described device comprises modular converter 1, confirms module 2 and operation module 3;
Modular converter 1 is used for converting the grid alternating current signal to square-wave signal;
Confirm module 2, for detection of the cycle length of the square-wave signal of modular converter 1 output, according to the cycle length that detects, confirm the frequency of square-wave signal;
Operation module 3 is used for the step-by-step counting to square-wave signal, according to frequency and the step-by-step counting of confirming that module 2 is confirmed, and the operation clock.
Can find out from such scheme, by converting high-precision grid alternating current signal to square-wave signal, then according to high-precision square-wave signal operation clock, therefore do not need high-precision oscillator or timer, just can improve the precision of operation clock, and the cost of increase product that can be not too much.
In implementation, as shown in Figure 7, the circuit diagram of a kind of embodiment of modular converter of the present invention.Described modular converter 1 comprises that an end is the receiving end U of grid alternating current signal oThe first resistance R 1, the other end of described the first resistance R 1 is electrically connected with the anode of the first backward dioded D1, the negative electrode of the second backward dioded D2 and an end of the second resistance R 2 respectively, the negative electrode of described the first backward dioded D1 is electrically connected with power supply VCC, the anode of the second backward dioded D2 is connected with ground GND, and the other end of the second resistance R 2 is the output terminal I of square-wave signal o
In the present embodiment, as long as just can convert the grid alternating current signal to square-wave signal by two resistance and two backward diodeds, so modular converter is simple in structure, with low cost, the cost of increase product that can be not too much.
In implementation, as shown in Figure 8, the present invention confirms the structural representation of a kind of embodiment of module.Described affirmation module 2 comprises the first detecting unit 21, computing unit 22 and selected cell 23;
The first detecting unit 21 is for detection of the cycle length of square-wave signal;
Computing unit 22 for the cycle length that detects according to the first detecting unit, obtains the calculated rate of square-wave signal;
Selected cell 23 is used for the calculated rate that obtains according to computing unit 22, and the choice criteria frequency also is made as the frequency of square-wave signal.
In the present embodiment, in order to prevent that described affirmation module 2 also comprises the second detecting unit 24, judging unit 25 and confirmation unit 26 because power supply electrifying disturbs the error that causes;
The second detecting unit 24 is used for detecting the cycle length of a N continuous square-wave signal after selecting unit 23 choice criteria frequencies;
Judging unit 25, be used for judging that cycle length that the second detecting unit 24 detects is whether in the time normal period resulting Preset Time zone of selecting according to selected cell 23 and differ from the cycle length of each square-wave signal and be not more than the preset ratio value, if so, signal is judged in output first;
Confirmation unit 26 is used for judging signal according to first of judging unit 25 outputs, confirms that the frequency of square-wave signal is selected standard frequency.
In the present embodiment, be 50Hz such as selected cell 23 choice criteria frequencies, and 50Hz is made as the frequency of square-wave signal that time normal period of square-wave signal is 0.02s, the Preset Time zone can be 0.019-0.021s so; Be 60Hz such as selected cell 23 choice criteria frequencies, and will be made as the frequency of square-wave signal, time normal period of square-wave signal is 1/60s, and the Preset Time zone can be 0.016-0.018s so.
In implementation, in order to improve the precision of timer, as shown in Figure 9, the present invention also provides the device of the operation clock of the second embodiment, and described device comprises that also first arranges module 4, computing module 5 and calibration module 6;
First arranges module 4, is used for confirming that unit interval that the frequency of module 2 affirmations produces is set to standard unit's time of timer;
Computing module 5 is used for being set according to first standard unit's time that module 4 arranges, and moves described timer, obtains the count parameter of standard unit's time;
Calibration module 6 according to the count parameter that computing module 5 obtains, is calibrated described timer.
In implementation, unstable in order to prevent the clock that causes because of interference, the device of the operation clock of the second embodiment of the present invention also comprises acquisition module 7 and comparison module 8;
Acquisition module 7 is used for the cycle length of obtaining square-wave signal;
Comparison module 8 is used for deviation between time normal period of cycle length that acquisition module 7 relatively gets access to and square-wave signal whether in the first Preset Time, if so, exports the first comparison signal, if not, exports the second comparison signal;
Operation module 3 also is used for when receiving the first comparison signal of comparison module 8, to the step-by-step counting of square-wave signal, and according to frequency and the step-by-step counting of square-wave signal, the operation clock.
Wherein, acquisition module 7 can be used for after confirming that module 2 is confirmed the frequency of square-wave signal, the cycle length of obtaining square-wave signal.In the present embodiment, described acquisition module 7 is used for after 6 pairs of described timers of calibration module are calibrated the cycle length of obtaining square-wave signal.
In the present embodiment, whether the deviation between the cycle length that gets access to by acquisition module 7 relatively and time normal period of square-wave signal in the first Preset Time, is come the zero crossing of square-wave signal is carried out verification synchronously.When the deviation between time normal period of the cycle length that gets access to and square-wave signal during at the first Preset Time, the zero crossing that square-wave signal is described is synchronous, and the deviation between time normal period of cycle length and square-wave signal is not in the first Preset Time, can think that this cycle length corresponding square-wave signal is asynchronous, assert that this signal is undesired signal, do not do the processing of operation clock.
For so that clock normally moves, in the present embodiment, described device comprises that also second arranges module 9, timing module 10 and the first judge module 11;
Second arranges module 9, is used for being set to the preset multiple of time normal period the time-count cycle of timer when receiving the second comparison signal of comparison module 8;
Timing module 10 is used for being set, operation one-period calculating clock the time-count cycle that module 9 arranges according to described second;
The first judge module 11 is used for judging whether the clock timing of timing module 10 operation one-periods finishes, if so, and the output first signal;
Acquisition module 7 also is used for when receiving the first signal of the first judge module 11 cycle length of obtaining square-wave signal.
In the present embodiment, when receiving the second comparison signal of comparison module 8, the verification of synchronization failure of square-wave signal is described, and for the normal operation of clock, move clock by timer this moment.But in order to make timer in timing, can pick up as early as possible again the zero passage synchronous point of square-wave signal, therefore arrange larger time-count cycle with timer, and the clock timing of timing module 10 operation one-periods is not when finishing, the first judge module 11 output secondary signals are to timing module 10, timing module 10 continuation arrange the time-count cycle that module 9 arranges according to described second, and operation is until the one-period timing finishes to calculate also clock.
In implementation, as shown in figure 10, the present invention also provides the device of the operation clock of the third embodiment, is with the difference of the device of the second embodiment: described device also comprises and second module 12, the second judge module 13 is set, preserves module 15 and correction module 14;
Second arranges module 12, is used for when receiving the first signal of the first judge module 11 the operation variable i being set, and variable i is from adding one, and wherein the initial value of i is that 0, i is positive integer;
The second judge module 13 is used for judging whether the second operation variable i that module 12 settings are set reaches default number of run value, if so, exports the first consequential signal, if not, exports the second consequential signal;
Correction module 14 is used for when receiving the first consequential signal of the second judge module 13 clock count being carried out correction process;
Preserve module 15, when receiving the second consequential signal of the second judge module 13, preserve current operation variable i;
Acquisition module 7 also is used for after preservation 15 pairs of operations of module variable i is preserved the cycle length of obtaining square-wave signal.
In the present embodiment, because during the zero crossing synchronization failure of square-wave signal, move clock by timer, and the time that arrange the time-count cycle of timer is larger than time normal period of square wave signal, can have some errors so in the process of operation clock.When reaching certain number of times by timer operation clock, therefore error will be come obviously, error occurs in order to prevent from moving clock, improves the precision of operation clock, when the operation variable i reaches default number of run value, clock timing is carried out correction process.When the first judge module 11 output first signal, be that timer is when having run to default predetermined period number of times, need so the second judge module 13 to judge when whether the number of times of timer operation clock reaches default number of run value, when namely only having number of times when timer operation clock not reach default number of run value, acquisition module 7 just can continue to obtain the cycle length of square-wave signal, zero crossing with the check square-wave signal is synchronous, otherwise need to carry out correction process by 14 pairs of clock counts of correction module.
The above only is preferred embodiment of the present invention, not in order to limiting the present invention, all any modifications of doing within the spirit and principles in the present invention, is equal to and replaces and improvement etc., all should be included within protection scope of the present invention.

Claims (5)

1. method of moving clock is characterized in that: said method comprising the steps of,
Convert the grid alternating current signal to square-wave signal;
Detect the cycle length of square-wave signal, according to the cycle length that detects, confirm the frequency of square-wave signal;
To the step-by-step counting of square-wave signal, according to frequency and the step-by-step counting of square-wave signal, the operation clock;
Detect the cycle length of a N continuous square-wave signal;
Whether in the Preset Time zone that obtains according to time normal period and poorly be not more than the preset ratio value cycle length of each square-wave signal, if so, confirm that the frequency of square-wave signal is selected standard frequency the cycle length of judging each square-wave signal;
The cycle length of described detection square-wave signal, according to the cycle length of the square-wave signal that detects, confirm the step of the frequency of square-wave signal, be specially:
Detect the cycle length of square-wave signal, according to the cycle length of the square-wave signal that detects, obtain the calculated rate of square-wave signal;
According to the calculated rate of described square-wave signal, the choice criteria frequency is the frequency of square-wave signal.
2. the method for claim 1 is characterized in that: in the cycle length of detecting square-wave signal, according to the cycle length of the square-wave signal that detects, confirms after the frequency of square-wave signal, further comprising the steps of:
The unit interval that produces according to the frequency of square-wave signal is set to standard unit's time of timer;
Move described timer the time according to standard unit, obtain the count parameter of standard unit's time;
According to the count parameter of standard unit's time, described timer is calibrated.
3. method as claimed in claim 2 is characterized in that: in the step-by-step counting to square-wave signal, according to frequency and the step-by-step counting of square-wave signal, before the step of operation clock, further comprising the steps of:
Obtain the cycle length of square-wave signal, whether deviation between time normal period of the cycle length that relatively gets access to and square-wave signal in the first Preset Time, if so, carries out the step-by-step counting to square-wave signal, according to frequency and the step-by-step counting of square-wave signal, the step of operation clock.
4. device that moves clock is characterized in that: described device comprises modular converter, confirms module and operation module;
Modular converter is used for converting the grid alternating current signal to square-wave signal;
Confirm module, for detection of the cycle length of the square-wave signal of modular converter output, according to the cycle length that detects, confirm the frequency of square-wave signal;
The operation module is used for the step-by-step counting to square-wave signal, according to frequency and the step-by-step counting of confirming that module is confirmed, and the operation clock; Described modular converter comprises that an end is the first resistance of the receiving end of grid alternating current signal, the other end of described the first resistance is electrically connected with the anode of the first backward dioded, the negative electrode of the second backward dioded and an end of the second resistance respectively, the negative electrode of described the first backward dioded is electrically connected with power supply, the anode of the second backward dioded is connected with ground, and the other end of the second resistance is the output terminal of square-wave signal; Described affirmation module comprises the first detecting unit, computing unit and selected cell;
The first detecting unit is for detection of the cycle length of square-wave signal;
Computing unit for the cycle length that detects according to the first detecting unit, obtains the calculated rate of square-wave signal;
Selected cell is used for the calculated rate that obtains according to computing unit, and the choice criteria frequency also is made as the frequency of square-wave signal; Described affirmation module also comprises the second detecting unit, judging unit and confirmation unit;
The second detecting unit is used for detecting the cycle length of detecting a N continuous square-wave signal cycle length of a N continuous square-wave signal after selecting unit choice criteria frequency;
Judging unit, be used for judging that cycle length that the second detecting unit detects is whether in the time normal period resulting Preset Time zone of selecting according to selected cell and differ from the cycle length of each square-wave signal and be not more than the preset ratio value, if so, signal is judged in output first;
Confirmation unit is used for judging signal according to first of judging unit output, confirms that the frequency of square-wave signal is selected standard frequency.
5. device as claimed in claim 4, it is characterized in that: described device comprises that also first arranges module, computing module and calibration module;
First arranges module, is used for confirming that unit interval that the frequency of module affirmation produces is set to standard unit's time of timer;
Computing module is used for moving described timer the time according to the first standard unit that the module setting is set, and obtains the count parameter of standard unit's time;
Calibration module according to the count parameter that computing module obtains, is calibrated described timer.
CN 201110239994 2011-08-19 2011-08-19 Method and device for operating clock Expired - Fee Related CN102289194B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN 201110239994 CN102289194B (en) 2011-08-19 2011-08-19 Method and device for operating clock

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN 201110239994 CN102289194B (en) 2011-08-19 2011-08-19 Method and device for operating clock

Publications (2)

Publication Number Publication Date
CN102289194A CN102289194A (en) 2011-12-21
CN102289194B true CN102289194B (en) 2013-03-13

Family

ID=45335686

Family Applications (1)

Application Number Title Priority Date Filing Date
CN 201110239994 Expired - Fee Related CN102289194B (en) 2011-08-19 2011-08-19 Method and device for operating clock

Country Status (1)

Country Link
CN (1) CN102289194B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103853081B (en) * 2012-12-06 2018-01-30 海尔集团公司 MCU internal clockings calibration system and method and printed circuit board (PCB)
CN105301947B (en) * 2015-11-17 2017-09-26 中国联合网络通信集团有限公司 A kind of clocking method and time set
CN106102227B (en) * 2016-06-20 2017-08-25 福州台江区超人电子有限公司 Building roof control system of lamp decoration

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US4068465A (en) * 1975-07-14 1978-01-17 Bernard M. Licata Clock using alternating current cycle counting
JPH0285792A (en) * 1988-09-22 1990-03-27 Toshiba Corp Ac period watch
JP3383437B2 (en) * 1994-09-29 2003-03-04 株式会社デノン Time measurement method and clock
CN2724298Y (en) * 2004-08-16 2005-09-07 Tcl国际电工(惠州)有限公司 Precisely timed delay switch
CN201479089U (en) * 2009-05-27 2010-05-19 无锡和晶科技股份有限公司 Adaptive timer

Also Published As

Publication number Publication date
CN102289194A (en) 2011-12-21

Similar Documents

Publication Publication Date Title
CN101582732B (en) Clock detection method and device
EP3420371B1 (en) Processing apparatus and method for detecting partial discharge pulses in the presence of noise signals
CN103618588B (en) A kind of auto-baud-detect method and detection module
CN103257569B (en) Time measuring circuit, method and system
EP3217590B1 (en) In-system global clock providing method and device
CN102289194B (en) Method and device for operating clock
US10944133B2 (en) Method of monitoring a battery, monitoring system and monitoring circuit
CN105245203B (en) High-precision low-speed clock duty ratio detecting system and method
CN104991167A (en) Power line fault positioning system and method thereof based on over-voltage online monitoring
CN106645952B (en) A kind of detection method and system of signal phase difference
CN107231225A (en) A kind of leading character sequence detecting method and device
JP2011035473A (en) Baud rate error detection circuit and baud rate error detection method
CN102539975B (en) Method for carrying out synchronous on-line detection on data of 10kV merging units (MUs) based on voltage-phase comparison
KR101665903B1 (en) Signal processing apparatus
CN103595588A (en) Method for accurately measuring asynchronous Ethernet circuit time delay
CN101719858B (en) Synchronous processing method of bit timing of control area network (CAN) controller
CN102854374B (en) Device and method for detecting direct-current voltage of power unit element
CN108061564B (en) Single-wire transmission identification and synchronization method for incremental encoder phase signals
JP6838532B2 (en) Sensor device and measurement method
JP5153693B2 (en) Data collection system
CN112134593B (en) Zero crossing point signal output and power line data sending method and equipment
CN106209090A (en) A kind of combining unit pulse per second (PPS) synchronism output system and method based on FPGA
CN113759166B (en) Method for detecting power factor in power system
CN202837415U (en) Amplitude frequency characteristic testing system
CN102749509A (en) Signal sampling test method

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
CF01 Termination of patent right due to non-payment of annual fee
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20130313