Learning in general starts with two questions; How? and Why?, how makes the learner as an imitator or one of a million, why enable your creativity, improve your experiences and make you unique. As a newbie in electronics Arduino is very good in terms of prototyping and making projects in an easy manner. Actually all websites that I read to learn Arduino and electronics focus on how to make this project and HOW to solve that problem. I was looking for more details about the physical components on Arduino, not finding much information about them encourage me write this series: we will start with
Arduino Crystal oscillator:
(The crystal inside the red square)
Arduino crystal helps Arduino dealing with time issues, for example if we build a project that turns a switch A off after 15 minutes on and turn on switch B, C & D one after another with a 20 minutes step. We can use Arduino software to program Arduino to do that, but how Arduino calculate the time? The answer is by using crystal, the number on the top of Arduino crystal is 16.000H9H this gives us information about the frequency which is 16,000,000 Hertz or 16 Mhz, this small component can make 16 millions cycles per second so using this concept Arduino can calculate time.
Furthermore, using this crystal is important in other applications such as microprocessors, webcams, computers, inside my computer motherboard there are two crystals; here is a photo:
Before knowing how crystals works, I thought that computer calculate time using algorithms (Now I understand that computer uses algorithms with crystals to detect time).
Still two questions, why Arduino team select a 16 Mhz crystal and do not use a 32Mhz or more? We have to look in the datasheet of (Arduino brain), ATmega328P: http://www.atmel.com/dyn/resources/prod_documents/8271S.pdf in the first page under "Speed Grade" it has been Clearfield that the maximum frequency should not exceed 20 Mhz, so the 16 Mhz is suitable.
The second question is; What about the crystal accuracy? This depends on the crystal specifications'. Arduino crystal have a 100ppm accuracy, in other words these crystals have an error margin 100 cycles – or + in each one million cycles, this means that the maximum – or + error in time calculated by Arduino is 30 seconds per a year.
3600 x 24 x 365 = 31,536,000 seconds.
ReplyDelete16,000,000 Hz x 31,536,000 s = 5.0458e14 cycles per year.
divided by 1,000,000 x 100 = 50.458e9 cycles error per year
divided by 16,000,000 = 3154 seconds per year which is 53 minutes (give or take).