Contacts

Clock resonator. AVR. Training course. Asynchronous timer mode. Pros of quartz generators

It would seem that a banal deal, to launch a watch quartz. What problems may be? There is a microcontroller and two of its legs, which are specifically designed to connect quartz. There is a watch quartz. Sold quartz is a matter of two seconds. A minute is needed in order to add a couple of timer initialization lines to the program. That's it seems to be all. But, after I launched this rolled hour quartz, I realized that the question was not as simple as I thought.

And the prehistory was like that. A friend asked me to make him simple oats, without frills, on 7-segment indicators. Plevoe business. The microcontroller was taken by ATMEGA48 (able to work with the watch quartz), the program is quickly written, the sealing is rushed. After assembling the clock and debugging the program (dynamic display, buttons, etc.) it has a queue to hours quartz. Before these hours, I have already applied a couple of times in my projects a couple of times and there was nothing foreshadowed trouble :), but an unforeseen-hour quarter happened flatly refused to be launched. At all!
In attempts to figure out, it prevents my watch quartz to earn my watch quartz, I first turned to the datashet on the microcontroller (ATMEGA48). Information on the asynchronous regime and the connection of the timer was very small there. Then I began to look for a solution to the problem in the forums. Here it was a variety of decisions and councils up to ritual dances with tambourines, which also did not really help me. I had to deal with samples and errors (not to be confused with the "tyk method"!) It is very possible to understand what. As a result of heroic sweats, the advancing on which only you can rake and killed three days have been born a practical experience of connecting the hourly quartz, with which I will share here.

So, what rakes are waiting for us when launching watch quartz?

1 scheme engineering.
1.1 Capacitors.
In the datashitis, the microcontroller is quite exemptently mentioned that the capacitors must be connected to the hour quarters, and it is difficult to find out about their container. The hourly quartz, most likely, will earn and without capacitors, but better to put it will improve frequency stability and help quartz quickly run.
Capacitance of capacitors should be within 12-22 PF.

1.2 Wiring tracks for quartz.
Here datasheet and apnounces give us clear instructions. The tracks from the legs of the microcontroller before the quartz should be minimal length, an earthy "track for capacitors must be separate, that is, it should not be processed through it (this does not have the high-speed and high-frequency chains).

1.3 hour quartz housing.
The iron housing of the hour quartz must necessarily roll to the ground (to the one to which condensers are soldered). An ungrounded building will work as an antenna, making distortions to the work of quartz, worsening the accuracy of your watch.

1.4 Dirt on the board.
A clock quartz is a rather tender thing and resistance to a couple of mega between the legs are quite enough to stop. As practice has shown, liquid flux, if it is bad, it gives sufficient resistance, so that the quartz does not work. After soldering, worry carefully. Very often in fluxes, the acid is contained, which gives the conductivity between the legs. To neutralize the acid, rinse the feet with a weak solution of soda (food) and thoroughly flush with clean water.

2 programming.
2.1 Initialization of the asynchronous timer mode.

In order for the timer to work from a time quartz, it (timer) must be translated into asynchronous mode. To transfer the timer (almost all microcontrollers, it is timer 2) to this mode you need to write 1 in the AS2 bit. But not everything is so simple, you need to comply with a certain launch algorithm. By datashet, the procedure for incorporating an asynchronous mode for timer 2 is as follows:
1. To prohibit interrupts from the timer / counter 2 - OCIE2X, TOIE2;
2. Switch it to asynchronous mode 1 -\u003e AS2;
3. Record new values \u200b\u200bin the TCNT2, OCR2X and TCCR2X registers;
4. Wait for the discharge of TCN2UB, OCR2XUB and TCR2XUB flags;
5. Reset Timer / Counter 2 Interrupt Flags;
6. Allow interrupts (if required).

Be sure to follow such a sequence. Here is the listing of proper initialization of the asynchronous Timer mode2.

/ * forbid interrupts * / CLi (); / * 1. Forbid interrupts of Timer / Counter2 resetting OCIE2X and TOIE2. * / Timsk2 & \u003d ~ ((1<< OCIE2A) | (1 << OCIE2B) | (1 << TOIE2) ) ; / * 2. Transfer Timer / Counter2 to asynchronous mode by installing AS2. * / ASSR \u003d (1<< AS2) ; / * Give some time to stabilize the generator operation (you can omit). * / _delay_ms (1000); / * 3. Record new TCNT2, OCR2X, and TCCR2B values. * / TCNT2 \u003d 0; / * Install the collector \u003d 128 32.768 KHz / 128/256 \u003d overflow once in a second. * / TCCR2B | \u003d (1<< CS22) | (1 << CS20) ; / * 4. To be sure that the clock earned waiting until the bits are reset: TCN2UB, OCR2AUB, OCR2BUB, TCR2AUB and TCR2BUB. * / While (Assr & 0x1f); / * 5. Remove the Timer / Counter2 interrupt flags. * / TIFR2 | \u003d ((1<< OCF2A) | (1 << OCF2B) | (1 << TOV2) ) ; / * 6. Allow the interruption overflowing Timer 2 * / Timsk2 | \u003d (1<< TOIE2) ; / * Allow interrupts * / SEI ();

/ * Prohibit interrupts * / CLI (); / * 1. Forbid interrupts of Timer / Counter2 resetting OCIE2X and TOIE2. * / Timsk2 & \u003d ~ ((1<

2.2 Beron timer 2.
In order for interruptions to overflow Timer2 occurred once per second, the value of the collector must be 128. (128 per unit * 256Production \u003d 32768 particle quartz).

2.3 Work hours in sleep mode Powersave.
Very tempting in pauses between second interruptions to translate the microcontroller into sleep mode, in this case the current of the microcontroller will fall to 6-7 m. For such a case, there is a low consumption of Powersave, in it Timer2 continues to work from time quartz and awakens a microcontroller with interrupt. The algorithm for such a mode of operation is simple, after exiting the sleep mode to interrupt from the timer in the procedure for processing the "Tick" clock interrupt procedure, we leave the interrupt and again give the command to fall asleep (SLEEP). Here there is a very important nuance. Again, we look at the datashitte on the microcontroller in the section of low consumption and the operation of the asynchronous mode. In order for the timer after awakening, it began to function normally and was able to withdraw a microcontroller from sleep when the next interruption is needed to the fallup team to wait a certain time. In order to make sure that the generator works normally, it is necessary to record into any timer register, from those that do not break the work hours (for example, in OCR2X) and wait for the discharge of the readiness flags of this Register (OCR2XUB). After the flag has dropped, you can safely translate the microcontroller into sleep mode.

/ * Output point from interrupt overflow Timer2 * / / * Written any value in OCR2A. * / OCR2A \u003d 0; / * We wait until OCR2AUB is reset. * / While (Assr & (1<

3 Miscellaneous.
3.1 Do not use cheap chinese quarters(especially quenched with old broken spear hours). Even if they earn, they will have accuracy.

3.2 Well, finally, Have some different quartz at hand, perhaps your quartz is not launched because it is bedrooms. Try to replace it.

Here, it seems, and all the rakes for which I swung while I launched a watch quartz. Or something else to add?


(Visited 9 508 Times, 1 Visits Today)

In this article, let's talk about the device of quartz watches and a quartz resonator. Perhaps it will be a rather complicated topic for understanding. Please note that the article discusses the principle of operation of quartz clocks is not an example of an existing mechanism A on a primitive abstract and coarse model showing only the essence of most electronic and quartz hours.
In this article, I want to dispel inaccuracy regarding the device of the quartz clock scheme that I met on other resources, but about it is slightly lower.

Consider for example the simplest quartz mechanism, it consists of:

  1. Electronic unit with controller and quartz resonator
  2. Power element (no photo)
  3. Stepper electric motor (coil stator and rotor with permanent magnet)
  4. Six gear arrows

It seems that everything is simple, the electronic unit gives an electrical pulse on the coil of the stator and the rotor makes the turnover equal to one second. But how the electronic block "understands", which passed time to turn the rotor.

Consider more detail the scheme of the simplest electronic block of quartz o'clock, it consists of a quartz resonator (green rectangle) and a microcontroller (red square).

Now let's stay in more detail on the principle of operation and the device of a quartz resonator.

On the photo, the open quartz resonator, unfortunately I could not open, without damaging the quartz, which is most often used in the wrist clock.

The operation of the quartz resonator is based on a piezoelectric effect.

The essence of the piezoelectric effect is the generation of EDC with a piezoelectric when squeezing or stretching (vibration) of a solid (piezoelectric) and vice versa when the tension is supplied, the piezoelectric will be squeezed or expanding. It is important to notice, this effect occurs only at the time of compression or stretching.

Any quartz resonator consists of a quartz single crystal cut in a certain way and with the metal plates fixed on it to which contacts are summarized. Specifically, in hours, resonators are used with a flat crystal in the form of a tape (in the form of the letter "Y" or "u") with metal plates attached on the planes to which conclusions are connected. Quartz Dielectric itself - that is, it does not spend the electric current.

And now we turn to the essence of this component. It makes it possible that the quartz resonator itself generates a constant frequency when the DC is applied. This is not the case, in fact, everything is more complicated.

As mentioned above, the piezoelectric effect occurs only at the time of compression or stretching of the piezoelectric. For example, if you briefly submit an electrical charge to the conclusions on a quartz resonator, the quartz crystal will be squeaked (EMF). But at that moment, how quartz will turn back it will create the opposite of the polarity (anti-EDS) charge on the conclusions, of course much smaller than was in the initial one. Ie will happen one oscillation. The oscillations may be somewhat, it is important that it is in this case (if there is no fuel supply from outside) they will be harmoniously decaying. All this happens at a very short moment of time. It is about the same as the strike on the Tam. Quartz crystal can only fluctuate with one frequency, regardless of amplitude.

Resonance

Whatever quartz fluctuations were permanent and not decaying, it is necessary to ensure a constant external feeding of these oscillations, such as the electrical current of a certain frequency.

And now we go to why the resonator is called a resonator. The quartz crystal itself has its own frequency of mechanical oscillations. As I already led an example above with the toton. He also has its own mechanical frequency, that is, it doesn't matter how it was hit, it will give the sound on the same note (frequency). With quartz, the same thing. If you submit an electrical current of any frequency (within reasonable limits), the quartz will mechanically fluctuate (this time already constantly unlike a short charge) only with its own (resonant) frequency, generating EMF and anti-EDS. But if the quartz conclusions to submit a current of the frequency on which quartz resonates, the consumption of electricity that turns into work (in quartz oscillations) will be minimally unlike other frequencies. Roughly speaking quartz will miss all frequencies other than its resonant, in which resistance will dramatically increase. All this reminds us the work of the oscillatory circuit, but the quartz differs much better quality.

Microcontroller

One of the tasks of the frequency maintenance microcontroller at the conclusions of quartz at which it resonates based on resistance at a certain frequency.

Those, the microcontroller is synchronized with quartz, and since the frequency of quartz is known, it is known how much time has passed for a certain amount of quartz oscillations. Most often, the frequency of quartz used in the clock is 32,768 Hz. With such a frequency, you can provide good performance indicators.

We tell about the basic principles of the quartz mechanism in wrist hours


Image: Multi-master.ru.

It seems that all the more or less understandable concept of mechanical clock. Of course, rather less than more, but the basis is clear: the source of energy - the spring - acts on the wheel, the frequency of oscillations of the latter is determined by the helix, the oscillations are transmitted to the node, and the transmission should be transmitted, it should be transmitted, it is gear wheels (gear) arrows.

In fact, everything is incredibly difficult, but the principle is that such. The main thing is that all this can be seen through the eyes. And even swell their hands. Well, at least virtually.

But the quartz watch - how are they built? There, after all, it is not possible to see and even more so sweeping. However, if you figure it out, then they are all easier. So, in order.


Scheme of the simple quartz mechanism (with a second arrow at the mark "6 hours"). Image: Encyclopedia Britannica

Battery


Battery (on the example of the ETA Flatline 210.001 mechanism). Image: Eta.ch.

Energy source - battery. Energy is not mechanical, as in the case of a spring, and electric. Nevertheless, the energy is still. The battery may be a "tablet", and maybe, for example, solar. These are just the details.

Quartz


A quartz resonator generator (on the example of the ETA Flatline 210.001 mechanism). Image: Eta.ch.

The oscillatory system is a generator with a quartz resonator, or abbreviated quartz.

The current generated by the battery makes the quartz crystal fluctuate (piezoelectric effect). This crystal is an analogue of the spiral - set to a certain frequency of oscillations, most often 32 768 Hertz It is about ten thousand times more than the number of balance fluctuations in ordinary mechanical clock. With this frequency, the impulses of the generator - an analogue of the balance.


Microprocessor / binary meter (on the example of the ETA Flatline 210.001 mechanism). Image: Eta.ch.

32 768 - this is 2 in the 15th degree, which is important because the simplest binary counter is also present in the scheme, it is also a divider, at the exit of which the frequency will fall up to 1 heza - until a second tact.

Electric motor


Step-by-step electric motor (on the example of the mechanism of ETA FlatLine 210.001). Image: Eta.ch.

With this frequency of 32,768 hertz - once per second - pulses are fed by a stepper motor, which is an analogue of the descent.

An hour quartz is the term used to designate a special battery for quartz clocks. From the technical point of the watch quartz is a quartz generator for transmission of energy, which is necessary for turning the arrows of the clock. When you press on a clock quartz, an electrical impulse appears, when the current is applied to it. It is due to the technical characteristics of the applicable hour quarters, the clock based on quartz generators is famous for the striking accuracy of the testimony.

Features of the choice and operation of watch quartz

In our online store, you can purchase high-quality modern optional quartz and retails of the best world and domestic producers at competitive prices. For residents of Moscow, preferential delivery conditions are provided. When used in the hourly mechanism of a high-quality quartz generator, the clock almost does not require additional charging. They are enough to start 1 time a few years. The main parameter of the selection of hourly quartz is the enemosphere of application, compliance with the hourly mechanism. Watch quartz of new generations are maximally adapted to the most different modifications of quartz watches.

What is the generator? The generator is essentially a device that converts one type of energy into another. In electronics, it is very often possible to hear the phrase "generator of electrical energy, frequency generator," and so on.

The quartz generator is a frequency generator and has in its composition. Mostly quartz generators are two species:

those that can produce a sinusoidal signal

and those that give a rectangular signal


Most often in electronics uses a rectangular signal

Pierce scheme

In order to excite quartz at the resonance frequency, we need to collect the scheme. The simplest scheme for the excitation of quartz is classic pierce Generatorwhich consists of only one field transistor and a small strapping of four radio elements:


A few words about how the scheme works. The scheme has positive feedback and self-oscillations begin in it. But what is a positive feedback?

In school, all of you put vaccinations to the reaction of Mantu to determine if you have a tube or not. After some time, nurses came and the ruler measured your skin reaction to this vaccination


When they put this vaccination, it was impossible to scroll the place of the injection. But I, then I was still slander, was on the drum. As soon as I started to quickly scroll the place of the injection, I wanted to scratch even more)) And here is the speed of the hand, which Chesled the vaccination, I froze on some peak, because I had a maximum of hand to the hand with a frequency of hertz in 15. Vigol I swell on the floor of my hand)) And even once I was drove me to donate blood in suspicion of tuberculosis, but as it turned out, did not find it. It is not surprising ;-).

So what am I telling you Hochma here? The fact is that this scab's vaccination is the most positive feedback. That is, while I did not touch her, I did not want to scratch. But as soon as quietly scratched, it became more and I began to scratch more, and it became even more and so on. If there were no physical restrictions on my hand, then surely the place of vaccination would already be worn until meat. But I could wave my hand only with some maximum frequency. So, the same principle also has a quartz generator ;-). I slightly filed momentum, and it begins to accelerate and already stops only at the frequency of parallel resonance ;-). For example, "physical limitation".

First of all, we need to pick up the inductor inductance. I took a toroidal core and wound several turns from the wires of MGTF


The whole process was controlled using an LC meter, achieving a nominal, as a diagram - 2.5 mp. If I did not take it, I added the turns if I dug the face value, it was outpost. As a result, it achieved such inductance:


Its correct name :.

Pickup From the left-topoint: stock - source - shutter


Small lyrical retreat.

So, we collected a quartz generator, the voltage filed, it remains only to remove the signal from the output of our self-made generator. Digital oscilloscope is taken for business


First of all, I took quartz for the greatest frequency that I have: 32,768 megahertz. Do not confuse it with the watch quartz (it will be discussed below).


At the bottom of the left corner of the oscilloscope shows us the frequency:


As you see 32.77 megahertz. The main thing is that our quartz is alive and the scheme works!

Let's take quartz with a frequency of 27 megahertz:


I read the testimony. Skilled that he managed:


The frequency also more or less showed correctly.

Well, and similarly check all other quartz, which I have.

Here is the Quartz oscillogram on 16 megahertz:


The oscilloscope showed the frequency of Rovenko 16 megahertz.

Here I set quartz for 6 megahertz:


Exactly 6 megahertz

On 4 megahertz:


All OK.

Well, let's take another Soviet for 1 megahertz. That's how it looks like:


1000 kilohertz \u003d 1 Meghertz is written on top ;-)


We look at the oscillogram:


Working!

With a great desire, you can even measure the frequency by the Chinese frequency meter:


400 Hertz Error for an old Soviet quartz is not very many. But it is better, of course, take advantage of a normal professional frequency meter ;-)

Hour quartz

With watch quartz, a quartz generator according to the pier scheme refused to work.


"What in the hour quartz?" - you ask. An hour quartz is quartz with a frequency of 32,768 Hertz. Why is there such a strange frequency on it? The thing is that 32,768 is 2 15. Such quartz works in a pair with a 15-bit counter-meter. This is our chip K176IA5.

The principle of operation of this chip is: nthe donkey, as it counts 32,768 pulses, on one of the legs it gives the pulse. This impulse on the leg with a quartz resonator by 32,768 Hertz appears exactly once per second. And how do you remember, the oscillation once per second is 1 hertz. That is, on this leg, the impulse will be issued with a frequency of 1 hertz. And since it is so, why not use it in hours? Hence the name goes.

Currently, in wrist hours and other mobile gadgets, this meter and quartz resonator are built into one chip and provide not only the score of seconds, but also a number of other functions, such as alarm clock, calendar, and so on. Such microcircuits are called RTC (R.eAL T.iME C.lock) or translated from the Bourgeois Watch of Real Time.

Pierce Scheme for Rectangular Signal

So, back to the pier scheme. Previous pier diagram generates sinusoidal signal

But also there is a modified pier diagram for a rectangular signal

And here she is:

Some radio elements can be changed in a rather wide range. For example, C1 and C2 capacitors can be in the range of 10 and to 100 PF. Here the rule is: the less the frequency of quartz, the less the capacitor capacity should be. For time quarters, capacitors can be put in front of 15-18 PF. If quartz with a frequency of 1 to 10 megahertz, then you can put 22-56 PF. If you do not want to bother, then simply put capacitors with a capacity of 22 PF. Definitely do not lose.

Also a small chip note: changing the value of C1 capacitor, you can adjust the resonance frequency in very subtle limits.

R1 resistor can be changed from 1 to 20 minutes, and R2 from zero and up to 100 com. Here, too, there is a rule: the smaller the frequency of quartz, the greater the significance of these resistors and on the contrary.

The maximum frequency of quartz, which can be inserted into the scheme depends on the speed of the CMOS inverter. I took the 74HC04 chip. It is not too fast. Consists of six inverters, but we will use only one inverter:


Here is its pinout:

By connecting the time quartz to this scheme, the oscilloscope issued this oscillogram here:


By the way, do you remind anything part of the scheme?

Is this part of the scheme used to clutter the AVR microcontrollers?

She is the most! Just the missing elements of the scheme is already in the MK itself ;-)

Pros of quartz generators

Pluses of quartz frequency generators are high frequency stability. Basically, it is 10 -5 - 10 -6 from the nominal or, as they often say, PPM (from the English. pARTS PER MILLION) - parts per million, that is, one millionic or number of 10 -6. The deviation of the frequency in one direction or another in the quartz generator is mainly due to the change in the ambient temperature, as well as the aging of quartz. When the quartz aging, the frequency of the quartz generator becomes a bit less every year about 1.8x10 -7 from the nominal. If, say, I took quartz with a frequency of 10 megahertz (10,000,000 hertz) and put it in the scheme, then for the year its frequency will go about 2 Hertz in minus ;-) I think it's completely tolerant.

Currently, quartz generators are produced in the form of complete modules. Some firms producing such generators reach frequency stability up to 10 -11 from the nominal! Ready modules look like this:


or so

Such modules of quartz generators mainly have 4 outputs. Here is the sprinkle of the square quartz generator:

Let's check out one of them. It is written on it 1 MHz


Here is his rear view:


Here is his pinout:

Feeding a constant voltage of 3.3 and up to 5 volts plus at 8, and a minus to 4, from the output 5, I got a clean even beautiful meander with a frequency written on a quartz generator, then you mean 1 megahertz, with very minid emissions.


Well, just a look!

Yes, and the Chinese frequency generator showed the exact frequency:


From here we conclude: it is better to buy a ready-made quartz generator than to kill a bunch of time and nerves to adjust the pier's scheme. The pier circuit will be suitable for checking the resonators and for your various homemade.



Did you like the article? Share it