Author Topic: About crystals: when and why they are needed  (Read 941 times)

0 Members and 1 Guest are viewing this topic.

Offline MoriambarTopic starter

  • Supporter
  • ****
  • Posts: 502
  • Country: it
About crystals: when and why they are needed
« on: April 08, 2019, 11:03:53 am »
Hi there.
One of my greatest challenges as a beginner is the user of crystals with an MCU.
I mean, I'm mostly an AVR user and when I use an at tiny or something, I use the internal oscillator. I never found the use of an external crystal.
So this got me wondering: what purpose does an external crystal serve? Is it just to run the mcu faster? Also, when a crystal would be beneficial?

I know that my question is kind of broad, but I'm willing to browse through documents if you can point me the right way too.

cheers!
 

Offline Kleinstein

  • Super Contributor
  • ***
  • Posts: 14749
  • Country: de
Re: About crystals: when and why they are needed
« Reply #1 on: April 08, 2019, 11:34:46 am »
The crystal based clock is much more stable and accurate than the µC internal RC type oscillator. It already starts with the UART: here the internal clock often works, but not always, especially if there are additional temperature variations. So a reliable UART kind of needs a crystal (or ceramic resonator of good accuracy).

It's more obvious with a clock. With the RC clock the time could be off by some 10 minutes a day, with a reasonable crystal it's more like a few seconds.

With many of the AVRs a crystal also allows a higher speed, as the internal RC clock is often limited to some 8 MHz.
 
The following users thanked this post: Moriambar

Offline golden_labels

  • Super Contributor
  • ***
  • Posts: 1340
  • Country: pl
Re: About crystals: when and why they are needed
« Reply #2 on: April 08, 2019, 11:37:30 am »
  • Uncomparably better accuracy.
  • Greater stability. In particular wrt temperature.
  • Prrety much independent of supply voltage and its fluctuations.
  • Usually lower power consumption
The drawback is the cost and size.

Try implementing a clock on AVR8 with the internal RC oscillator. Run it for a day. Compare the results with even the cheapest quartz clock. Compare with the exactly same chip running at different temperature or considerably different supply voltage.

---edit:
Umm, the common sense warning: while testing across different temperatures, keep in mind to have your power source in the safe temperature and protected from shorts. Overheating a microcontroller in a sun or shorting its pins in a fridge will cost you a few bucks. Batteries catching fire or a short damaging USB port will cost you much more. This is important, since the test will be running unattended.
« Last Edit: April 08, 2019, 12:06:25 pm by golden_labels »
People imagine AI as T1000. What we got so far is glorified T9.
 
The following users thanked this post: Moriambar

Online Fraser

  • Super Contributor
  • ***
  • Posts: 13323
  • Country: gb
Re: About crystals: when and why they are needed
« Reply #3 on: April 08, 2019, 11:46:57 am »
You need to consider what a crystal in terms of electronics actually does. It oscillates at a frequency that is both known and remains relatively stable. The oscillation is at a frequency that may be relied upon as a master reference for accurate timing of events. By comparison RC and LC based reference oscillators can drift with temperature and are not normally considered an accurate reference where exact frequency is concerned.

In a microprocessor system where only one master oscillator is used and exact frequency is not critical, a simple reference oscillator is adequate. But where a microprocessor is generating signals that need to be compatible or synchronised with other sub systems that demand frequency accuracy, the crystal oscillator provides that required accuracy. Phase locked loop systems often use an accurate master oscillator to create other frequencies and these then have the same accuracy as the master oscillator. Consider baud rate generation, this can be referenced to a simple RC or crystal oscillator. To provide a known accurate baud rate, a crystal is normally used. A simple oscillator may be adequate but there is the element of doubt that is unacceptable in mission critical applications.

Where a reference oscillator needs to be of known reliable and relatively stable frequency, a crystal oscillator remains a relatively cheap solution that delivers excellent performance. If a drift prone LC or RC oscillator is acceptable in an application there is that option that is simpler and cheaper. The designer needs to consider the oscillator accuracy requirements of the system, including its interaction with other systems that may require accurately timed signals.

Fraser
« Last Edit: April 08, 2019, 11:49:44 am by Fraser »
If I have helped you please consider a donation : https://gofund.me/c86b0a2c
 
The following users thanked this post: Moriambar


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf