About crystals: when and why they are needed - Page 1
Forum section: electronics / beginners

author: Moriambar
author_rank: Unknown
timestamp: April 08, 2019, 11:03:53 am
content: 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,whena 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!

author: Kleinstein
author_rank: Super Contributor
timestamp: April 08, 2019, 11:34:46 am
content: 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.

author: golden_labels
author_rank: Super Contributor
timestamp: April 08, 2019, 11:37:30 am
content: Uncomparably better accuracy.Greater stability. In particular wrt temperature.Prrety much independent of supply voltage and its fluctuations.Usually lower power consumptionThe 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.

author: Fraser
author_rank: Super Contributor
timestamp: April 08, 2019, 11:46:57 am
content: 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