Categories: Microcontroller circuits
Number of views: 3195
Comments on the article: 0

RTC Real-Time Clock Chips - Purpose, Types and Examples of Use

 

To perform any tasks related to automation, you often need to count certain time intervals. Sometimes this is done by counting a certain number of periods of the clock or machine cycles.

However, although they follow at a given frequency and most often depend on the quartz resonator, when performing operations in real time, and especially if they are tied to the time of day, they shift in time. To solve this problem, use real-time clock or RTC chips.


What it is

RTC (real time clock, Russian real-time clock) is a type of microcircuit designed to count time in "real" units (seconds, minutes, hours, etc.).

They are dependent on the power source, which can be either external, in the form of a replaceable battery or a lithium battery, or integrated into the microcircuit housing (see photo below). Clock signals for time reporting can be obtained from an external quartz resonator, and less often - from the power supply network.

The reading accuracy depends on the quality and tuning accuracy of the internal oscillator or external crystal oscillator. At the same time, the accuracy of quartz and RTC, respectively, is indicated not in hertz and not in percentage, but in "ppm", for example ± 12 ppm, ± 50 ppm. This stands for Parts Per Million, that is, the number of parts per million of some average value.

RTC Real Time Clock Chip

Real-time clocks can be implemented on the basis of microcontrollers, however, the use of special chips can reduce power consumption, since most microcontrollers even in sleep mode (or low power mode) consume more power than special integrated circuits (ICs). RTCs can also be integrated into the microcontroller itself (as in STM32).

It is thanks to the real-time clock on your computer that the time and date after it is disconnected from the network does not get off, in this case they work from the CR2032 battery installed in the connector on the motherboard, it also feeds the BIOS chip so that the settings set in it do not get lost.

RTC chip with built-in battery

Classification

The classification of RTC chips may vary from manufacturer to manufacturer. The most common real-time clocks of such manufacturers as: Maxim Integrated and STMicroelectronics. There are microchips on the market from other companies:

  • Intersil Corporation (DC Renesas Electronics);

  • Cymbet (EnerChip ™ RTC line, distinctive feature - built-in solid state battery);

  • NXP (RTC with calendar, supporting I2C or SPI protocols)

  • Zilog;

  • Epson

  • ON semiconductor.

Real-time clock module with DS1307 chip

Maxim Integrated uses the type of control interface as the main criterion for the classification of RTC chips, namely:

1. RTC chips with a serial control interface: I2C, 3-wire, SPI.

2. With a parallel control interface:

  • with multiplexed address / data bus;

  • with shared address and data buses;

  • with 1-wire single-wire interface.

Real Time Clock Module

You can also classify by data presentation format:

  • Calendar In the form of a template YY-MM-DD for date and HH-MM-SS for time, time and their other formats;

  • Binary. In the form of a continuous binary counter of time units (seconds or their fractions).

Depending on the purpose of the microcircuit in the device’s circuit and its type is selected, if the IC with a calendar representation, it will function as a normal clock, and in the case of a binary one, for applications such as reports of time periods, for example, license validity period, warranty period or devices for recording something (for example, electric meters), for example, in the Maxim Integrated catalog they are called “Elapsed Time Counter” - the elapsed time counter, an example of such an IC is DS1683.

In other cases, real-time clock microcircuits can be classified by functionality or other characteristics:

  • The presence of a built-in generator or it is necessary to use an external generator (quartz).

  • By the presence of a built-in power source or the possibility of using an external battery.

  • By the type and size of internal memory and communication protocols with the "external" world (described above).

  • By the presence of a phantom (phantom) interface for accessing the internal registers of the microcircuit (for setting, setting modes or reading values).

  • Other functions: watchdog, alarm, second exit, power control, the ability to charge an external battery, etc.

And finally, many manufacturers classify their devices according to the level of energy consumption, on average, the current consumption ranges from 200 to 1500 nA, but may also go out of this range depending on the specific IC and manufacturer.


Amateur radio practice

Real-time clocks are often used in conjunction with such popular development and prototyping platforms as the Arduino family, and when developing devices on any other microcontrollers, as well as Raspberry Pi family microcomputers and the like.

The use of RTC chips in amateur radio practice

Today, the industry produces modules with RTC, in the form of a separate circuit board or shield. The advantage of this type of modules is that there is no need to spread the board and unsolder the microcircuit, the harness, the battery holder and so on.

They are convenient to use both for ready-made devices and in mock-ups - you can use jumpers with plugs and Dupont-type connectors, if you install a comb on the module to connect them, or solder the wires directly to the nickles on the board (see - Tips for quickly assembling circuit boards on breadboards).

Modules with RTC

Among the arduino and modern homemade manufacturers, the most widely used are Maxim Integrated real-time clock microcircuits and modules based on them, namely:

  • DS1302;

  • DS1307;

  • DS3231.

Their differences are shown in the table below.

Features of the DS1302, DS1307, and DS3231 Chips

As you can see, all of them communicate with the microcontroller via the I2C bus, and the DS1302 via SPI, although the datasheet says "a simple 3-wire serial interface suitable for most microcontrollers." And it can connect not only to 10-13 pins of Arduinoon which the pins are assigned are SPI, but to the others installed in the sketch, the circuits will be lower. Datashits for these ICs with all technical data are attached to the article.

Datasheets for real-time chips:

Arduino UNO supports both of these protocols, which you can see in the diagram below (marked in purple and gray for SPI and I2C, respectively).

Arduino uno

Like the Raspberry pi.

Raspberry pi

This means that you can use any of these modules from each platform. You can see the external differences of the modules in the illustration below, but the layout of the board may differ, look at the IC marking.

In order for Arduino to work with RTC, you need a library, but since it is not in the standard Arduino IDE package, you need to download it. There are libraries on the network for each of the considered ICs, and there are universal libraries that you should choose and which one will be more convenient.

Universal library attached - iarduino_rtc.zip. Note that the IC type is manually set in it, and for the DS1302 the conclusions to which it is connected:

include // Connect the library
iarduino_RTC time (RTC_DS3231); // Create a time object for the DS3231 IC
iarduino_RTC time (RTC_DS1307); // FOR DS1307
iarduino_RTC time (RTC_DS1302, RST, CLK, DAT); // for DS1302.
// Instead of RST, CLK and DAT, the numbers of the arduino pins,
// to which the corresponding pins of the clock module are connected

Diagram for DS1302, once again recall that the conclusions may be different:

Connection diagram DS1302 to Arduino

But the data line DS1307 and DS3231 only connects to the A5 and A4 pins of the Arduino UNO (for other revisions and versions of the board, see the pinout).

RTC to Arduino Connection Diagram
RTC to Arduino Connection Diagram

Conclusion

Real-time clocks allow you to make projects in which any processes must start on a schedule. In almost any relatively complex project for practical use there is such a need; it doesn’t matter whether it is an automatic watering system for plants or a process control system in production.

Due to the low cost of parts and the simplicity of connecting and programming, anyone can now implement such systems, even without in-depth knowledge of electronics and microcontrollers. But this does not mean that since there is arduino with its inherent simplicity, then there is no need to study the software and hardware. On the contrary, knowledge of iron and code structure will allow you to make faster and more complex programs, which at the same time take up less space.

See also at i.electricianexp.com:

  • What are Nextion displays and how to work with them?
  • PIC microcontrollers for beginners
  • Types and arrangement of AVR microcontrollers
  • Programmable microcontrollers in JavaScript: which one to choose, characteristics ...
  • Measuring temperature and humidity on Arduino - a selection of methods

  •