A Operating True Time Clock (RTC)

In a single of my tasks, information captured from a variety of sensors had for being time stamped while in the YearYear/DayDay/MonthMonth, HoursHours:MinutesMinutes:SecondsSeconds structure. My preliminary assumed was due to the fact there was previously a GPRS modem inside the technique, I could merely configure it to implement the network time delivered via the base station when it fired up. When the GPRS module begun up and retrieved the correct time, I could then invoke a simple AT command to browse the time stamp into the microcontroller. When the microcontroller was inside of a position to ask for enough time stamp as and when wanted, I could then provide this facts across the technique to each of the sub-system components such as the data logger.

The moment the program was set up, I reviewed the full AT command list from the modem. There was in fact a command known as AT+CCLK which could be made use of as follows:

AT+CCLK? (to read through the current time stamp in the required format)

AT+CCLK=yyddmmhhmmss (to put in writing the existing time stamp)

I might only be using the ?¡ãread?¡À command considering that the modem would instantly get the community time on get started up and write it into its memory. Nevertheless, upon start out up, the modem would usually provide the manufacturing unit default time stamp which happens to be 03/01/01, 00:00:00. Even following registering on the cellular community, this time would in no way get up to date.

Immediately after carrying out some investigation on why this was the case, I found out that as the cellular tariff I was on only supported data communication and not voice, the operator wouldn't allow me to entry the network time, which meant which i might have to employ the manufacturing unit default time placing of my very poor little GPRS modem except I arrived up with the different remedy. The answer was to herald a true time clock (RTC) in components which might turn out to be the single position of your time reference for my method. Due to the fact these clever tiny equipment even have a battery back again up, the time reference can be trustworthy with no exterior programming for three to 5 yrs. So I started to look into which serious time clock can be ideal for my reasons.

There are several factors to keep in mind while hoping to locate a appropriate RTC. A person with the most vital element is definitely the availability of ?¡ãautomatic back up switching circuitry?¡À that can simplify battery servicing. What this fundamentally usually means is the RTC uses the method power when it can be accessible somewhat than draining the coin mobile battery put in. Each time the process power goes down, the RTC automatically (and speedily) switches towards the back up battery with out losing track of your time. Bear in mind not every one of the RTCs will occur using this type of attribute. A lot of the kinds I found just function from your back up battery only.

In case you are presently working with I2C within your process, then integrating an RTC that supports I2C (a.k.a two-wire interface, TWI) could make feeling. Most I2C gadgets will aid speeds of as many as four hundred kbps, and that is over ample for looking through and programming an RTC. Take note that so as to guidance speeds of 400 kbps about the I2C, your MCU frequency should be large more than enough. If you are utilizing an MCU having an inadequate clock fee, you may need to work at a reduced I2C bus velocity. In my system, I could only go as much as 115 kbps, which labored properly fantastic (my MCU was an AtMega2560 managing at one.eight MHz).

Naturally, moreover a little footprint on a PCB, minimum external circuitry is usually favored when picking an RTC unit. A standard exterior circuitry will require, a crystal oscillator, a coin mobile battery, a couple of capacitors and resistors. Getting this kind of number of exterior components may even minimise the risk within your RTC not doing work once you initially develop it!

Acquisition and programming of time and day is likely to entail Binary Coded Decimal (BCD) format. For people of you that are not common with the BCD structure, you should use a think about the code snippet I've furnished here. You can directly plug this code to the info encoder plus the decoder portion within your RTC implementation. It has been analyzed and performs as envisioned.

Many of the RTC equipment arrive with external interrupt capabilities that make it possible for again up battery voltage measurement in addition as various timing features. If these added attributes on an RTC system does not enhance the cost of the design and style too substantially, I feel they are really worth acquiring in case you'll need them at some stage.

After browsing for an RTC machine, I decided to employ PCF8523T from NXP Semiconductor. You could entry the datasheet for this RTC here. I bought this component from DigiKey for $0.52 a piece. I utilised the SO8 package deal which wasn't much too really hard to solder on to a prototype board. Building was really simple. I merely adopted the appliance information in Determine 36 of the datasheet to develop the circuit. You are able to see the fully functional RTC board I designed and use listed here for getting an notion of the ultimate merchandise.

Even though the datasheet will offer the many info the developers would require, I'd love to conclude by briefly chatting about a lot of the critical characteristics along with the pros of PCF8523T.

Allow me to start with commence by talking about the power necessities of this gadget. This product draws battery back again up latest of one hundred fifty nA at three.0V. The again up battery I take advantage of is CR1225. The typical potential of this battery is 48 mAh. To be able to be familiar with how these numbers translate into battery lifestyle in terms of decades, allow us do a quick calculation as follows.

forty eight mAh / 150 nA = 320 000 hours of lifetime under constant operation

320000 hours / 24 hours = 13333 times

13333 days / one year = 36.5 decades of battery life!

I need to level out the above calculations are based on assumptions these kinds of because the ambient temperature of 25 degrees C and that the battery is completely billed when mounted (i.e. there is certainly no leakage owing to shelf storage). You should begin to see the CR1225 datasheet for even further information. Nonetheless, even when this battery lasts for your third of its life expectancy, this means it's going to not really need to get replaced for 12 decades! I guess that may do nicely inside our procedure. I have to also note which the again up battery will only be wanted temporarily in my software since the program will invest a lot of its lifestyle operating on rechargeable batteries, that can also be feeding the RTC chip.

PCF8523T also arrives using a range of alarm capabilities. The device could be programmed to fireside an external interrupt on a presented working day of your 7 days, in a specific date, hour and moment, which can be useful for tracking events.

Discover our Real Time Clocks. At Heisener, we guarantee top quality standards, pioneering and innovative products in addition to a real-time quote service.

The system also will come with two unbiased timers that could be configured to be a countdown timer with interrupt. Furthermore, just one of people timers could be configured for a watchdog that generates an interrupt upon timing out. These types of external timing functions are excellent in the event the MCU you might be working with has incredibly few timers built-in.

A further cool function of the product is that it can make a clock signal as higher as 32768 Hz and as little as 1 Hz as well as 5 other frequencies between. This clock sign is accessible by using an exterior pin that can be connected to your microcontroller input. This element can be utilized for synchronising discrete program factors employing RTC as the widespread clock resource.

Eventually, the RTC can be programmed to crank out an interrupt if the back again up battery is managing minimal, this is certainly a great aspect to have for battery routine maintenance. Such as, as my procedure also contains a GPRS modem, I am able to create an SMS alarm to routine a battery transform ahead of the battery goes flat following which the process loses the real time facts.

1 matter I need to point out here is that after i very first created this RTC board, I let it run for more than 50 hours following which I discovered spurious time and date corruptions. I then transformed the machine on my board by using a new just one which challenge disappeared. Even soon after steady procedure of one hundred twenty several hours, I did not notice any info corruptions. I think throughout the initial tests the device could happen to be subjected to electrostatic discharge which can have prompted this interior fault. As a result, I advise you are taking treatment when dealing with this RTC machine when constructing your board. Also, be certain to not overheat the system while soldering it to prevent any danger of failure.

Related links:

Real Time Clocks (RTCs) in Microcontroller Timers

Security in RTCs

Authentic Time Clock (RTC)

Ways to Make a Real-time Clock Circuit that has a DS1307 Chip

Serious time clock (RTC) vs. clock: What's the difference?