In a single of my jobs, knowledge captured from several sensors experienced to generally be time stamped within the YearYear/DayDay/MonthMonth, HoursHours:MinutesMinutes:SecondsSeconds structure. My preliminary believed was since there was already a GPRS modem within the procedure, I could basically configure it to implement the community time sent by the foundation station when it fired up. As soon as the GPRS module commenced up and retrieved the right time, I could then invoke a straightforward AT command to read through enough time stamp into the microcontroller. After the microcontroller was in a very placement to ask for the time stamp as and when desired, I could then produce this data across the method to all the sub-system factors such as the data logger.
After the plan was set up, I reviewed the entire AT command checklist of the modem. There was in truth a command named AT+CCLK which might be made use of as follows:
AT+CCLK? (to study the existing time stamp during the required format)
AT+CCLK=yyddmmhhmmss (to write the current time stamp)
I’d personally only be using the ?¡ãread?¡À command considering that the modem would routinely have the network time on get started up and compose it into its memory. Nevertheless, upon begin up, the modem would generally provide the manufacturing unit default time stamp which happens to be 03/01/01, 00:00:00. Even soon after registering for the mobile network, this time would never ever get up to date.
Soon after undertaking some investigation on why this was the case, I discovered out that since the cellular tariff I used to be on only supported facts interaction and not voice, the operator would not allow me to access the network time, which intended which i might have to use the manufacturing facility default time location of my bad minimal GPRS modem unless I came up by having an alternate alternative. The answer was to bring in a true time clock (RTC) in hardware which would become the only level of time reference for my procedure. Simply because these clever tiny equipment also have a battery back again up, the time reference could be dependable without external programming for 3 to five several years. So I started to examine which actual time clock could well be well suited for my reasons.
There are several points to remember even though seeking to find a appropriate RTC. A person in the most significant feature is definitely the availability of ?¡ãautomatic back again up switching circuitry?¡À that can simplify battery maintenance. What this generally implies may be the RTC employs the procedure power when it is accessible alternatively than draining the coin mobile battery set up. Each time the procedure energy goes down, the RTC quickly (and promptly) switches on the back again up battery without losing keep track of of time. Take into account that not the entire RTCs will arrive using this type of aspect. The majority of the ones I came across just run from your back up battery only.
If you’re by now using I2C within your system, then integrating an RTC that supports I2C (a.k.a two-wire interface, TWI) is likely to make perception. Most I2C devices will assist speeds of up to 400 kbps, that’s greater than enough for looking through and programming an RTC. Be aware that as a way to assistance speeds of 400 kbps around the I2C, your MCU frequency ought to be superior plenty of. If you are employing an MCU using an inadequate clock level, you will require to work at a decrease I2C bus velocity. In my procedure, I could only go up to one hundred fifteen kbps, which labored perfectly great (my MCU was an AtMega2560 managing at one.8 MHz).
Definitely, other than a little footprint on the PCB, small external circuitry is likewise preferred when choosing an RTC system. A normal external circuitry will require, a crystal oscillator, a coin mobile battery, a handful of capacitors and resistors. Possessing these types of number of exterior components can even minimise the chance of your RTC not doing the job whenever you initially build it!
Acquisition and programming of time and date is probably going to require Binary Coded Decimal (BCD) format. For anyone of you who’re not common while using the BCD structure, please have got a consider the code snippet I have furnished in this article. You’ll be able to instantly plug this code in the info encoder and also the decoder portion of one’s RTC implementation. It has been examined and will work as anticipated.
A few of the RTC products occur with external interrupt functions that allow for back up battery voltage measurement too as many timing features. If these types of extra functions on an RTC gadget does not raise the price within your style and design way too substantially, I think they are worthy of owning just in case you will need them at some phase.
Discover our Real Time Clocks. At Heisener, we guarantee top quality standards, pioneering and innovative products in addition to a real-time quote service.
Right after hunting for an RTC system, I decided to implement PCF8523T from NXP Semiconductor. You can access the datasheet for this RTC here. I bought this section from DigiKey for $0.fifty two a chunk. I utilized the SO8 offer which wasn’t way too challenging to solder on to a prototype board. Building was fairly straight forward. I merely adopted the application data in Figure 36 on the datasheet to construct the circuit. You may see the fully useful RTC board I created and use right here for getting an idea of the ultimate merchandise.
Even though the datasheet will supply many of the information and facts the builders will require, I’d personally love to conclude by briefly speaking about a lot of the important functions and also the benefits of PCF8523T.
Allow me initial start out by talking with regard to the energy necessities of the unit. This machine draws battery back up latest of one hundred fifty nA at 3.0V. The again up battery I exploit is CR1225. The common ability of the battery is 48 mAh. If you want to know how these numbers translate into battery daily life with regards to a long time, enable us do a fast calculation as follows.
48 mAh / one hundred fifty nA = 320 000 hrs of daily life less than continual operation
320000 hours / 24 hours = 13333 days
13333 times / one year = 36.five several years of battery everyday living!
I have to issue out the over calculations are dependent on assumptions these kinds of as being the ambient temperature of twenty five levels C and that the battery is totally billed when set up (i.e. you can find no leakage owing to shelf storage). Be sure to begin to see the CR1225 datasheet for further more data. Even so, even though this battery lasts for your third of its everyday living expectancy, this means it is going to not must get replaced for twelve several years! I assume which will do nicely in our process. I need to also take note which the again up battery will only be desired quickly in my software as being the technique will expend almost all of its existence managing on rechargeable batteries, which can even be feeding the RTC chip.
PCF8523T also arrives which has a number of alarm capabilities. The unit can be programmed to fireplace an exterior interrupt over a supplied working day on the week, at a particular date, hour and moment, which happens to be handy for monitoring events.
The unit also will come with two unbiased timers that may be configured being a countdown timer with interrupt. Also, a single of those people timers could be configured like a watchdog that generates an interrupt on timing out. These types of exterior timing functions are fantastic should the MCU you are using has pretty several timers in-built.
An additional amazing attribute of this product is the fact it may possibly create a clock sign as large as 32768 Hz and as little as 1 Hz besides 5 other frequencies between. This clock sign is available by way of an external pin that could be linked to the microcontroller input. This characteristic can be utilized for synchronising discrete method parts using RTC as the frequent clock supply.
Eventually, the RTC is often programmed to generate an interrupt when the again up battery is working very low, this really is a terrific element to acquire for battery upkeep. As an example, as my method also contains a GPRS modem, I can build an SMS alarm to program a battery improve prior to the battery goes flat just after which the technique loses the actual time data.
1 detail I have to point out here’s that after i initial crafted this RTC board, I permit it run for over 50 several hours just after which I found spurious time and day corruptions. I then changed the device on my board which has a new a person and this trouble disappeared. Even immediately after steady operation of one hundred twenty hrs, I did not observe any data corruptions. I believe throughout the very first assessments the device may have been exposed to electrostatic discharge which can have triggered this inside fault. Thus, I counsel you’re taking care though dealing with this RTC product while developing your board. Also, make certain to not overheat the system though soldering it in order to avoid any danger of failure.
Authentic Time Clocks (RTCs) in Microcontroller Timers
Actual Time Clock (RTC) Vs. Clock: What On Earth Is The Primary Difference?