REAL-TIME CLOCKS IN IoT

Why Real-Time Clocks are important in embedded system

Have you ever missed a planned event due to a lack of awareness of time? The same thing can happen with IoT devices if time is not automatically tracked. Real-time clocks (RTCs) are essential components in IoT devices that help track time accurately, which is critical for time-related activities. In this write-up, we will explore the importance of RTCs in embedded systems and discuss best practices to avoid common mistakes.

What is RTC?

Real-time clocks (RTCs) are integrated circuits that keep track of the current time based on a set time standard, such as UTC or GMT+0. They are designed to continue running even after the main system is shut down, making them essential in data-driven embedded systems that require accurate time data to perform specific tasks. For example, have you ever wondered how your laptop or phone shows accurate time even when it has been off for a while? RTCs?? That's right. That is another basic use case for RTC.

Dr. Monk's DIY Electronics Blog: Review: 4-digit 7-segment LED and RTC from  Adafruit

Best Practices for RTCs:

Accurate timekeeping is crucial in IoT devices, and RTCs play a significant role in achieving it. However, poor placement of RTC components can result in mismatched expected results. In a prior work experience, a batch of standalone payment controllers, designed for a parking electronic system, encountered a malfunction with their clock software. It caused the program's timer to progressively slow down compared to the real-time, leading to the failure of transmitting the expected data packs on a regular basis. Thus, it is vital to be diligent in avoiding any errors related to RTC, as discussed below.

Common Mistakes to Avoid in Real-Time Clocks

Designing real-time clock circuitry may seem like a simple task because it only involves 5 components: A dedicated RTC chip or built-in RTC on a microcontroller, a crystal, a couple of capacitors, and a coin cell battery. However, I will say this once more, poor placement of RTC components can result in mismatched expected results. Therefore, you need to be keen and:

  1. Keep the crystal as close as possible to the RTC and keep the trace as short as you can. It will reduce the possibility of noise coupling.

  2. Do not route any other trace in between or under the trace between RTC and the crystal. This will prevent unwanted interference from being coupled to the clocking signal.

Instead, it is recommended to:-

  1. Not route any high-speed signals within the vicinity of real-time clocks circuitry. It is recommended to keep a distance of 200 milliseconds in between.

  2. Place a ground plane beneath and surrounding the RTC circuitry and keep it isolated from other ground planes for at least 40 milliseconds.

  3. Make sure that you are using the correct value for the crystal load capacitors as specified in the datasheet for the crystal.

While one can be keen on the developmental process, it's also easy to leave some issues unattended. In the next section, I bring to your attention reasons why it can be easy for some RTC design mistakes to escape lab testing.

Post-Deployment RTC Problems:

Why Some RTC Design Mistakes Escape Lab Testing

RTC design errors that are not addressed can lead to undesirable outcomes such as the clock ticking at a different rate than intended. Such discrepancies can have a direct impact on the reliability and functionality of devices that depend on RTC functionality, as demonstrated by the payment controllers. In the laboratory environment where the controllers were developed, the electrical setup was nearly flawless, with minimal interference. However, when deployed to real-world contexts, the controllers experienced variations in clock speed, which sometimes caused problems.

What Can You Do If You Have Post-Deployment Real-Time Clock Problems?

Unfortunately, there are no elegant quick fixes when you have messed up your real-time clock design, and the products are already deployed on the field. One potential remedy is to create a small RTC module and manually rewire the controller to work with the new module. However, in instances where your devices are tightly packed in enclosures or are being mass-produced for end-users, these reworks may not be feasible. In such circumstances, you may need to produce a new batch of replacement products that incorporate fully functional real-time clocks.

Conclusion

In summary, RTCs are crucial components in IoT devices that help accurately track time and guide time-related activities. To ensure the proper functioning of RTCs, it is essential to follow best practices and avoid common mistakes during the developmental process.