The electronic clock of the single-chip microcomputer makes the clever use of the clock control system to calibrate the electronic clock.

Introduction: This article proposes a solution for the situation where the time of the calibrated electronic clock appears to be faster or slower when the electronic clock is used to make an electronic clock or a control system that is controlled according to the clock.  

In the application of single-chip microcomputers, this kind of situation is often encountered. When using an MCU to make an electronic clock or a control system that requires clock-based control, it will suddenly find that the time of the originally calibrated electronic clock has become faster or slower.

So, try to adjust its travel time accuracy in various ways, but the final effect is still unsatisfactory, so I have to manually adjust it once in a while. So, can you make the clock more accurate? Now explore the following:

First, the analysis of the cause of error

1. The timing pulse reference of the electronic clock of the single chip microcomputer is provided by the frequency of the external crystal oscillator after being divided by 12, and the timing is realized by the internal timing and counter. Therefore, the accuracy of the external crystal frequency directly affects the accuracy of the electronic clock timing.

2. The electronic clock of the single-chip microcomputer uses the internal timing, the counter overflow generates an interrupt (the 12MHz crystal oscillator is generally 50ms) and multiplies the corresponding multiplier to realize the conversion of the second, minute and time. As we all know, from timing, the counter generates an interrupt request to the response interrupt, which takes 3_8 machine cycles. The data stack and reload timing in the timer interrupt subroutine, the initial value of the counter also takes several machine cycles. Also. It takes a certain machine cycle to shift from the interrupted population to the interrupt subroutine. E.g:

As can be seen from the above procedure, the loading of the lower 8 bits from the interrupted population to the initial value of the timer/counter requires 2+2+2=6 machine cycles. Therefore, these 6 machine cycles are generally added to the initial value of the timer/counter during programming. However, from timing, it takes several machine cycles (3~8 machine cycles) for the counter to overflow the interrupt request to execute the interrupt. It is difficult to determine the exact value, which is why the electronic clock timing is not accurate.

Second, the solution

1, using high-precision crystal vibration scheme

Although the use of a high-precision crystal oscillator can slightly improve the accuracy of the electronic clock timing, the crystal oscillator is not the main factor that causes the timing of the electronic clock to be inaccurate, and the high-precision crystal oscillator is expensive, so it is not necessary to adopt this scheme.

2. Dynamic synchronization correction scheme

From the programmer's hand, the dynamic synchronization correction method is used to give timing, and the counter is given an initial value. The dynamic synchronization correction method is as follows: due to timing, after the counter overflows, it will automatically increment from O, so before the timer/counter is assigned again, the timing, the value in the counter low (TLO) and the initial value are added. Then send the timing, the counter, at this time, the value in the counter is the accurate value after the dynamic synchronization correction. The specific procedures are as follows:

With this method, it is believed that the accuracy of the electronic clock produced has been improved.

3. Automatic adjustment plan

After using the synchronous correction scheme, the accuracy of the electronic clock is improved a lot, but due to the deviation of the crystal frequency and some other unknown factors (the same circuit board, the same program changed after a single-chip microcomputer, the travel time error is not the same, I do not know What is the reason? There will still be accumulation errors over time. To this end, an automatic adjustment scheme can be employed. It is actually a fault tolerant technology. The principle of automatic adjustment is: the time required for the error Is is actually measured, and then the second is adjusted by "1" or minus "1" after such a period of time. For example, the electronic clock is 1 second slower every 50 hours, and its automatic adjustment procedure is as follows:

The following is a complete example:

Conclusion

Using this method is more time consuming, but the effect is very good. After the experiment, one adjustment can be used to control the monthly error to about Is. If the number of days required for the error Is is measured again according to this method and the second adjustment is performed, the accuracy will be higher.

Bear Ear Headphones

Bear ear headphone is a patented headphone designed exclusively by LINX Headphone Factory, which has Chinese and EU patents. On the basis of ordinary headphones, plus bear ears, it is more lovely. The earphones emit LED lights, and the lights can be freely controlled. There are 4 ways: flash with the rhythm of music, flash, steady and light off.

Advantages:

1. Bear ears, exclusive private model patent, cute shape.

2. LED colorful light.

3. Multiple colors, can be mixed batch.

4. Stock, 24 hours delivery.

5. Colors can be customized freely.

6. Wired bear ear headphones and Bluetooth bear ear headphones are optional.

Bear Ear Headphone


Bear Ear Headphones,Bear Headphones,Bear Earphones,Bear Ear LED Headphones

Shenzhen Linx Technology Co., Ltd. , https://www.linxheadphone.com