![Types of RTC modules](https://upload.wikimedia.org/wikipedia/commons/7/7e/Types_of_RTC_modules.jpg)
A real-time clock (RTC) is an electronic device (most often in the form of an
integrated circuit
An integrated circuit or monolithic integrated circuit (also referred to as an IC, a chip, or a microchip) is a set of electronic circuits on one small flat piece (or "chip") of semiconductor material, usually silicon. Large numbers of tiny ...
) that measures the passage of time.
Although the term often refers to the devices in
personal computer
A personal computer (PC) is a multi-purpose microcomputer whose size, capabilities, and price make it feasible for individual use. Personal computers are intended to be operated directly by an end user, rather than by a computer expert or tec ...
s,
server
Server may refer to:
Computing
*Server (computing), a computer program or a device that provides functionality for other programs or devices, called clients
Role
* Waiting staff, those who work at a restaurant or a bar attending customers and su ...
s and
embedded system
An embedded system is a computer system—a combination of a computer processor, computer memory, and input/output peripheral devices—that has a dedicated function within a larger mechanical or electronic system. It is ''embedded'' as ...
s, RTCs are present in almost any electronic device which needs to keep accurate
time of day
Time is the continued sequence of existence and events that occurs in an apparently irreversible succession from the past, through the present, into the future. It is a component quantity of various measurements used to sequence events, to co ...
.
Terminology
The term ''real-time clock'' is used to avoid confusion with ordinary
hardware clocks which are only
signals
In signal processing, a signal is a function that conveys information about a phenomenon. Any quantity that can vary over space or time can be used as a signal to share messages between observers. The ''IEEE Transactions on Signal Processing'' ...
that govern
digital electronics
Digital electronics is a field of electronics involving the study of digital signals and the engineering of devices that use or produce them. This is in contrast to analog electronics and analog signals.
Digital electronic circuits are usual ...
, and do not count time in human units. RTC should not be confused with
real-time computing
Real-time computing (RTC) is the computer science term for hardware and software systems subject to a "real-time constraint", for example from event to system response. Real-time programs must guarantee response within specified time constrai ...
, which shares its
three-letter acronym
A three-letter acronym (TLA), or three-letter abbreviation, is an abbreviation consisting of three letters. These are usually the initial letters of the words of the phrase abbreviated, and are written in capital letters (upper case); three-lette ...
but does not directly relate to time of day.
Purpose
Although keeping time can be done without an RTC,
using one has benefits:
* Low power consumption
(important when running from alternate power)
* Frees the main system for time-critical tasks
* Sometimes more accurate than other methods
A
GPS
The Global Positioning System (GPS), originally Navstar GPS, is a Radionavigation-satellite service, satellite-based radionavigation system owned by the United States government and operated by the United States Space Force. It is one of t ...
receiver can shorten its startup time by comparing the current time, according to its RTC, with the time at which it last had a valid signal.
If it has been less than a few hours, then the previous
ephemeris
In astronomy and celestial navigation, an ephemeris (pl. ephemerides; ) is a book with tables that gives the trajectory of naturally occurring astronomical objects as well as artificial satellites in the sky, i.e., the position (and possibly vel ...
is still usable.
Some motherboards are made without real time clocks. The real time clock is omitted either out of the desire to save money (as in the
Raspberry Pi
Raspberry Pi () is a series of small single-board computers (SBCs) developed in the United Kingdom by the Raspberry Pi Foundation in association with Broadcom. The Raspberry Pi project originally leaned towards the promotion of teaching basic ...
system architecture) or because real time clocks may not be needed at all (as in the
Arduino
Arduino () is an open-source hardware and software company, project, and user community that designs and manufactures single-board microcontrollers and microcontroller kits for building digital devices. Its hardware products are licensed unde ...
system architecture
[However, note that many Arduino software suites include an optional software RTC run from a low precision timer as described.]).
Power source
![Inside the Real-time clock IC vnutri u nei neonka](https://upload.wikimedia.org/wikipedia/commons/7/7d/Inside_the_Real-time_clock_IC_vnutri_u_nei_neonka.jpg)
RTCs often have an alternate source of power, so they can continue to keep time while the primary source of power is off or unavailable. This alternate source of power is normally a
lithium battery
Lithium battery may refer to:
* Lithium metal battery, a non-rechargeable battery with lithium as an anode
** Rechargeable lithium metal battery, a rechargeable counterpart to the lithium metal battery
* Lithium-ion battery, a rechargeable batte ...
in older systems, but some newer systems use a
supercapacitor
A supercapacitor (SC), also called an ultracapacitor, is a high-capacity capacitor, with a capacitance value much higher than other capacitors but with lower voltage limits. It bridges the gap between electrolytic capacitors and rechargeable ba ...
,
because they are rechargeable and can be
soldered
Solder (; NA: ) is a fusible metal alloy used to create a permanent bond between metal workpieces. Solder is melted in order to wet the parts of the joint, where it adheres to and connects the pieces after cooling. Metals or alloys suitable ...
. The alternate power source can also supply power to
battery backed RAM.
Timing
Most RTCs use a
crystal oscillator
A crystal oscillator is an electronic oscillator circuit that uses a piezoelectric crystal as a frequency-selective element. The oscillator frequency is often used to keep track of time, as in quartz wristwatches, to provide a stable cloc ...
,
but some have the option of using the
power line frequency.
The crystal frequency is usually 32.768 kHz,
the same frequency used in
quartz clocks and watches. Being exactly 2
15 cycles per second, it is a convenient rate to use with simple binary counter circuits. The low frequency saves power, while remaining above human
hearing range
Hearing range describes the range of frequencies that can be heard by humans or other animals, though it can also refer to the range of levels. The human range is commonly given as 20 to 20,000 Hz, although there is considerable variati ...
. The quartz
tuning fork
A tuning fork is an acoustic resonator in the form of a two-pronged fork with the prongs (tines) formed from a U-shaped bar of elastic metal (usually steel). It resonates at a specific constant pitch when set vibrating by striking it against ...
of these crystals does not change size much from temperature, so temperature does not change its frequency much.
Some RTCs use a
micromechanical resonator on the silicon chip of the RTC. This reduces the size and cost of an RTC by reducing its parts count. Micromechanical resonators are much more sensitive to temperature than quartz resonators. So, these compensate for temperature changes using an electronic thermometer and electronic logic.
Typical crystal RTC accuracy specifications are from ±100 to ±20 parts per million (8.6 to 1.7 seconds per day), but temperature-compensated RTC ICs are available accurate to less than 5 parts per million.
In practical terms, this is good enough to perform
celestial navigation
Celestial navigation, also known as astronavigation, is the practice of position fixing using stars and other celestial bodies that enables a navigator to accurately determine their actual current physical position in space (or on the surface of ...
, the classic task of a
chronometer
A clock or a timepiece is a device used to measure and indicate time. The clock is one of the oldest human inventions, meeting the need to measure intervals of time shorter than the natural units such as the day, the lunar month and th ...
. In 2011,
chip-scale atomic clock
A chip scale atomic clock (CSAC) is a compact, low-power atomic clock fabricated using techniques of microelectromechanical systems (MEMS) and incorporating a low-power semiconductor laser as the light source. The first CSAC physics package was d ...
s became available. Although vastly more expensive and power-hungry (120 mW vs. <1 μW), they keep time within 50 parts per trillion ().
Examples
![DS1307 1438A4 +102BN](https://upload.wikimedia.org/wikipedia/commons/6/62/DS1307_1438A4_%2B102BN.jpeg)
Many
integrated circuit
An integrated circuit or monolithic integrated circuit (also referred to as an IC, a chip, or a microchip) is a set of electronic circuits on one small flat piece (or "chip") of semiconductor material, usually silicon. Large numbers of tiny ...
manufacturers make RTCs, including
Epson
Seiko Epson Corporation, or simply known as Epson, is a Japanese multinational electronics company and one of the world's largest manufacturers of computer printers and information- and imaging-related equipment. Headquartered in Suwa, Nagano, ...
,
Intersil
Intersil is an American semiconductor company headquartered in Milpitas, California. As of February 24, 2017, Intersil is a subsidiary of Renesas. The previous Intersil was formed in August 1999 through the acquisition of the semiconductor busin ...
,
IDT,
Maxim
Maxim or Maksim may refer to:
Entertainment
* ''Maxim'' (magazine), an international men's magazine
** ''Maxim'' (Australia), the Australian edition
** ''Maxim'' (India), the Indian edition
*Maxim Radio, ''Maxim'' magazine's radio channel on Sir ...
,
NXP Semiconductors
NXP Semiconductors N.V. (NXP) is a Dutch semiconductor designer and manufacturer with headquarters in Eindhoven, Netherlands. The company employs approximately 31,000 people in more than 30 countries. NXP reported revenue of $11.06 billion in 2 ...
,
Texas Instruments
Texas Instruments Incorporated (TI) is an American technology company headquartered in Dallas, Texas, that designs and manufactures semiconductors and various integrated circuits, which it sells to electronics designers and manufacturers globall ...
,
STMicroelectronics
STMicroelectronics N.V. commonly referred as ST or STMicro is a Dutch multinational corporation and technology company of French-Italian origin headquartered in Plan-les-Ouates near Geneva, Switzerland and listed on the French stock market. ST ...
and
Ricoh
is a Japanese multinational imaging and electronics company (law), company. It was founded by the now-defunct commercial division of the Riken, Institute of Physical and Chemical Research (Riken) known as the ''Riken concern (business), Concer ...
. A common RTC used in
single-board computer
A single-board computer (SBC) is a complete computer built on a single circuit board, with microprocessor(s), memory, input/output (I/O) and other features required of a functional computer. Single-board computers are commonly made as demonstrati ...
s is the
Maxim Integrated
Maxim Integrated, a subsidiary of Analog Devices, designs, manufactures, and sells analog and mixed-signal integrated circuits for the automotive, industrial, communications, consumer, and computing markets. Maxim's product portfolio includes p ...
DS1307.
The RTC was introduced to PC compatibles by the
IBM PC/AT
The IBM Personal Computer/AT (model 5170, abbreviated as IBM AT or PC/AT) was released in 1984 as the fourth model in the IBM Personal Computer line, following the IBM PC/XT and its IBM Portable PC variant. It was designed around the Intel 80 ...
in 1984, which used a
Motorola
Motorola, Inc. () was an American Multinational corporation, multinational telecommunications company based in Schaumburg, Illinois, United States. After having lost $4.3 billion from 2007 to 2009, the company split into two independent p ...
MC146818 RTC.
Later,
Dallas Semiconductor
Dallas Semiconductor, acquired by Maxim Integrated in 2002 for $2.5 billion, was a company that designed and manufactured analog, digital, and mixed-signal semiconductors (integrated circuits, or ICs). Its specialties included communications pro ...
made compatible RTCs, which were often used in older
personal computer
A personal computer (PC) is a multi-purpose microcomputer whose size, capabilities, and price make it feasible for individual use. Personal computers are intended to be operated directly by an end user, rather than by a computer expert or tec ...
s, and are easily found on
motherboard
A motherboard (also called mainboard, main circuit board, mb, mboard, backplane board, base board, system board, logic board (only in Apple computers) or mobo) is the main printed circuit board (PCB) in general-purpose computers and other expand ...
s because of their distinctive black battery cap and
silkscreen
Screen printing is a printing technique where a mesh is used to transfer ink (or dye) onto a substrate, except in areas made impermeable to the ink by a blocking stencil. A blade or squeegee is moved across the screen to fill the open mesh ...
ed logo.
In newer computer systems, the RTC is integrated into the
southbridge chip.
[https://www.intel.com/Assets/PDF/datasheet/290562.pdf ]
Some
microcontroller
A microcontroller (MCU for ''microcontroller unit'', often also MC, UC, or μC) is a small computer on a single VLSI integrated circuit (IC) chip. A microcontroller contains one or more CPUs (processor cores) along with memory and programmable i ...
s have a real-time clock built in, generally only the ones with many other features and
peripheral
A peripheral or peripheral device is an auxiliary device used to put information into and get information out of a computer. The term ''peripheral device'' refers to all hardware components that are attached to a computer and are controlled by the ...
s.
Radio-based RTCs
Some modern computers receive clock information by digital radio and use it to promote time-standards. There are two common methods: Most cell phone protocols (e.g.
LTE) directly provide the current local time. If an internet radio is available, a computer may use the
network time protocol
The Network Time Protocol (NTP) is a networking protocol for clock synchronization between computer systems over packet-switched, variable- latency data networks. In operation since before 1985, NTP is one of the oldest Internet protocols in c ...
. Computers used as local time servers occasionally use
GPS
The Global Positioning System (GPS), originally Navstar GPS, is a Radionavigation-satellite service, satellite-based radionavigation system owned by the United States government and operated by the United States Space Force. It is one of t ...
or ultra-low frequency radio transmissions broadcast by a national standards organization (i.e. a
radio clock
A radio clock or radio-controlled clock (RCC), and often (incorrectly) referred to as an atomic clock is a type of quartz clock or watch that is automatically synchronized to a time code transmitted by a radio transmitter connected to a time st ...
).
Software-based RTCs
The following system is well-known to
embedded system
An embedded system is a computer system—a combination of a computer processor, computer memory, and input/output peripheral devices—that has a dedicated function within a larger mechanical or electronic system. It is ''embedded'' as ...
s programmers, who sometimes must construct RTCs in systems that lack them. Most computers have one or more hardware timers that use timing signals from
quartz crystal
Quartz is a hard, crystalline mineral composed of silica (silicon dioxide). The atoms are linked in a continuous framework of SiO4 silicon-oxygen tetrahedra, with each oxygen being shared between two tetrahedra, giving an overall chemical form ...
s or
ceramic resonators. These have inaccurate absolute timing (more than 100 parts per million) that is yet very repeatable (often less than 1 ppm). Software can do the math to make these into accurate RTCs. The hardware timer can produce a periodic interrupt, e.g. 50
Hz, to mimic a historic RTC (see below). However, it uses math to adjust the timing chain for accuracy:
time = time + rate.
When the "time" variable exceeds a constant, usually a power of two, the nominal, calculated clock time (say, for 1/50 of a second) is subtracted from "time", and the clock's timing-chain software is invoked to count fractions of seconds, seconds, etc. With 32-
bit
The bit is the most basic unit of information in computing and digital communications. The name is a portmanteau of binary digit. The bit represents a logical state with one of two possible values. These values are most commonly represente ...
variables for time and rate, the mathematical resolution of "rate" can exceed one part per billion. The clock remains accurate because it will occasionally skip a fraction of a second, or increment by two fractions. The tiny skip ("
jitter
In electronics and telecommunications, jitter is the deviation from true periodicity of a presumably periodic signal, often in relation to a reference clock signal. In clock recovery applications it is called timing jitter. Jitter is a significa ...
") is imperceptible for almost all real uses of an RTC.
The complexity with this system is determining the instantaneous corrected value for the variable "rate". The simplest system tracks RTC time and reference time between two settings of the clock, and divides reference time by RTC time to find "rate". Internet time is often accurate to less than 20 milliseconds, so 8000 or more seconds (2.2 or more hours) of separation between settings can usually divide the forty milliseconds (or less) of error to less than 5 parts per million to get chronometer-like accuracy. The main complexity with this system is converting dates and times to counts of seconds, but methods are well known.
If the RTC runs when a unit is off, usually the RTC will run at two rates, one when the unit is on and another when off. This is because the temperature and power-supply voltage in each state is consistent. To adjust for these states, the software calculates two rates. First, software records the RTC time, reference time, on seconds and off seconds for the two intervals between the last three times that the clock is set. Using this, it can measure the accuracy of the two intervals, with each interval having a different distribution of on and off seconds. The rate math solves two
linear equation
In mathematics, a linear equation is an equation that may be put in the form
a_1x_1+\ldots+a_nx_n+b=0, where x_1,\ldots,x_n are the variables (or unknowns), and b,a_1,\ldots,a_n are the coefficients, which are often real numbers. The coefficien ...
s to calculate two rates, one for on and the other for off.
Another approach measures the temperature of the oscillator with an electronic thermometer, (e.g. a
thermistor
A thermistor is a type of resistor whose resistance is strongly dependent on temperature, more so than in standard resistors. The word thermistor is a portmanteau of ''thermal'' and ''resistor''.
Thermistors are divided based on their conduction ...
and
analog-to-digital converter
In electronics, an analog-to-digital converter (ADC, A/D, or A-to-D) is a system that converts an analog signal, such as a sound picked up by a microphone or light entering a digital camera, into a digital signal. An ADC may also provide ...
) and uses a
polynomial
In mathematics, a polynomial is an expression consisting of indeterminates (also called variables) and coefficients, that involves only the operations of addition, subtraction, multiplication, and positive-integer powers of variables. An exa ...
to calculate "rate" about once per minute. These require a calibration that measures the frequency at several temperatures, and then a
linear regression
In statistics, linear regression is a linear approach for modelling the relationship between a scalar response and one or more explanatory variables (also known as dependent and independent variables). The case of one explanatory variable is call ...
to find the equation of temperature. The most common quartz crystals in a system are SC-cut crystals, and their rates over temperature can be characterized with a 3rd-degree polynomial. So, to calibrate these, the frequency is measured at four temperatures. The common tuning-fork-style crystals used in watches and many RTC components have parabolic (2nd-degree) equations of temperature, and can be calibrated with only 3 measurements.
MEMS
Microelectromechanical systems (MEMS), also written as micro-electro-mechanical systems (or microelectronic and microelectromechanical systems) and the related micromechatronics and microsystems constitute the technology of microscopic devices, ...
oscillators vary, from 3rd degree to fifth degree polynomials, depending on their mechanical design, and so need from four to six calibration measurements. Something like this approach might be used in commercial RTC ICs, but the actual methods of efficient high-speed manufacturing are proprietary.
Historic RTCs
Some
computer
A computer is a machine that can be programmed to Execution (computing), carry out sequences of arithmetic or logical operations (computation) automatically. Modern digital electronic computers can perform generic sets of operations known as C ...
designs such as smaller
IBM System/360
The IBM System/360 (S/360) is a family of mainframe computer systems that was announced by IBM on April 7, 1964, and delivered between 1965 and 1978. It was the first family of computers designed to cover both commercial and scientific applica ...
s,
[ Revised by and ]
PDP-8
The PDP-8 is a 12-bit computing, 12-bit minicomputer that was produced by Digital Equipment Corporation, Digital Equipment Corporation (DEC). It was the first commercially successful minicomputer, with over 50,000 units being sold over the model's ...
s
and
Nova
A nova (plural novae or novas) is a transient astronomical event that causes the sudden appearance of a bright, apparently "new" star (hence the name "nova", which is Latin for "new") that slowly fades over weeks or months. Causes of the dramati ...
s used a real-time clock that was accurate, simple and low cost. In Europe, North America and some other grids, the frequency of the AC mains is adjusted to the long-term frequency accuracy of the national standards. In those grids, clocks using AC mains can keep perfect time without adjustment. Such clocks are not practical in portable computers or grids (e.g. in South Asia) that do not regulate the frequency of AC mains.
These computers' power supplies use a transformer or resistor divider to produce a sine wave at logic voltages. This signal is conditioned by a zero crossing detector, either using a
linear amplifier
A linear amplifier is an electronic circuit whose output is proportional to its input, but capable of delivering more power into a load. The term usually refers to a type of radio-frequency (RF) power amplifier, some of which have output power mea ...
, or a
schmitt trigger
In electronics, a Schmitt trigger is a comparator circuit with hysteresis implemented by applying positive feedback to the noninverting input of a comparator or differential amplifier. It is an active circuit which converts an analog input si ...
. The result is a square wave with single, fast edges at the mains frequency. This logic signal triggers an interrupt. The interrupt handler software usually counts cycles, seconds, etc. In this way, it can provide an entire clock and calendar. In the IBM 360, the interrupt updates a 64-bit count of microseconds utilized by standardized systems software. The clock's jitter error is half if the clock interrupts for each zero crossing, instead of each cycle.
The clock also usually formed the basis of computers' software timing chains; e.g. it was usually the timer used to switch tasks in an operating system. Counting timers used in modern computers provide similar features at lower precision, and may trace their requirements to this type of clock. (e.g. in the PDP-8, the mains-based clock, model DK8EA, came first, and was later followed by a crystal-based clock, DK8EC.)
A software-based clock must be set each time its computer is turned on. Originally this was done by computer operators. When the Internet became commonplace,
network time protocol
The Network Time Protocol (NTP) is a networking protocol for clock synchronization between computer systems over packet-switched, variable- latency data networks. In operation since before 1985, NTP is one of the oldest Internet protocols in c ...
s were used to automatically set clocks of this type.
See also
*
Crystal oscillator frequencies
*
High Precision Event Timer
The High Precision Event Timer (HPET) is a hardware timer available in modern x86-compatible personal computers. Compared to older types of timers available in the x86 architecture, HPET allows more efficient processing of highly timing-sensitiv ...
*
IRQ 8
*
Real-time clock alarm
*
System time
In computer science and computer programming, system time represents a computer system's notion of the passage of time. In this sense, ''time'' also includes the passing of days on the calendar.
System time is measured by a ''system clock'', w ...
*
Timer
A timer is a specialized type of clock used for measuring specific time intervals.
Timers can be categorized into two main types.
The word "timer" is usually reserved for devices that counts down from a specified time interval, while devices th ...
*
Wall-clock time Elapsed real time, real time, wall-clock time, wall time, or walltime is the actual time taken from the start of a computer program to the end. In other words, it is the difference between the time at which a task finishes and the time at which the ...
*
Time formatting and storage bugs
In computer science, time formatting and storage bugs are a class of software bugs that may cause time and date calculation or display to be improperly handled. These are most commonly manifestations of arithmetic overflow, but can also be the re ...
References
External links
*
{{Authority control
Clocks
Integrated circuits