The sense of time

How does a micro controller “understand” time ? This question is frequently asked. Here is the answer….

We humans, have the sense of time mainly due to sunrise and sunset. Accordingly we have adjusted our lives. The terms – “memory”, “now” and “then” have meaning if we have the sense of time. Same is true for micro controllers! But how does a micro controller “understand” time?

Well, let us know more about the sunrise and the sunset. Our perception of sunrise and sunset is not simply about light and dark. Sunrise and sunset is a repetitive process. The day and the night together form a cycle of an oscillator. These cycles give us the sense of time. When you say I read a book yesterday, it means, you read it one sun-cycle before the current sun-cycle.

Now apply this principle to micro controllers. If micro controller is connected to an electrical oscillator of fixed frequency, the smallest action of a micro controller can be related to a cycle of the oscillator.

Every micro controller has an oscillator connected to it. Most of the times, it is a crystal oscillator. A piezo crystal oscillates with very high frequency (in KHz and MHz) and provides the micro controller the sense of time. Crystal oscillators produce very stable frequency. They are stable especially for a wide range of temperature.

High frequency oscillators have period in micro or nano seconds. Usually, micro controllers execute instructions in one or more oscillator cycles. Thus micro controllers work in synchronism with the oscillator pulses and have the “sense of time”. The oscillator is like a “clock” to the micro controller which goes ahead micro second by micro second.