7/13/2023 0 Comments Real time clock timer![]() I simply followed the application information in Figure 36 of the datasheet to build the circuit. I used the SO8 package which was not too hard to solder onto a prototype board. I bought this part from DigiKey for $0.52 a piece. You can access the datasheet for this RTC here. If such additional features on an RTC device does not increase the cost of your design too much, I think they are worth having in case you need them at some stage.Īfter searching for an RTC device, I decided to use PCF8523T from NXP Semiconductor. Some of the RTC devices come with external interrupt functions that allow back up battery voltage measurement as well as various timing functions. It has been tested and works as expected. You can directly plug this code into the data encoder and the decoder section of your RTC implementation. For those of you who are not familiar with the BCD format, please have a look at the code snippet I have provided here. Having such few external components will also minimise the risk of your RTC not working when you first build it!Īcquisition and programming of time and date is likely to involve Binary Coded Decimal (BCD) format. A typical external circuitry will involve, a crystal oscillator, a coin cell battery, a couple of capacitors and resistors. Obviously, besides a small footprint on a PCB, minimal external circuitry is also preferred when choosing an RTC device. In my system, I could only go up to 115 kbps, which worked perfectly fine (my MCU was an AtMega2560 running at 1.8 MHz). If you are using an MCU with an insufficient clock rate, you will need to operate at a lower I2C bus speed. Note that in order to support speeds of 400 kbps on the I2C, your MCU frequency must be high enough. Most I2C devices will support speeds of up to 400 kbps, which is more than enough for reading and programming an RTC. If you are already using I2C in your system, then integrating an RTC that supports I2C (a.k.a two-wire interface, TWI) will make sense. Most of the ones I came across simply operate from the back up battery only. Remember that not all of the RTCs will come with this feature. Whenever the system power goes down, the RTC automatically (and quickly) switches to the back up battery without losing track of time. What this basically means is the RTC uses the system power when it is available rather than draining the coin cell battery installed. One of the most important feature is the availability of “automatic back up switching circuitry” which will simplify battery maintenance. There are a few points to keep in mind while trying to find a suitable RTC. So I started to investigate which real time clock would be suitable for my purposes. Because these clever little devices also have a battery back up, the time reference could be trusted with no external programming for 3 to 5 years. The solution was to bring in a real time clock (RTC) in hardware which would become the single point of time reference for my system. Even after registering to the mobile network, this time would never get updated.Īfter doing some investigation on why this was the case, I found out that because the mobile tariff I was on only supported data communication and not voice, the operator would not allow me to access the network time, which meant that I would have to use the factory default time setting of my poor little GPRS modem unless I came up with an alternative solution. ![]() However, upon start up, the modem would always give the factory default time stamp which is 03/01/01, 00:00:00. ![]() I would only be using the “read” command since the modem would automatically get the network time on start up and write it into its memory. There was indeed a command called AT+CCLK which could be used as follows:ĪT+CCLK? (to read the current time stamp in the required format)ĪT+CCLK=yyddmmhhmmss (to write the current time stamp) Once the plan was in place, I reviewed the full AT command list of the modem. Once the microcontroller was in a position to request the time stamp as and when needed, I could then deliver this information across the system to all the sub-system components including the data logger. Once the GPRS module started up and retrieved the correct time, I could then invoke a simple AT command to read the time stamp into the microcontroller. My initial thought was because there was already a GPRS modem in the system, I could simply configure it to use the network time delivered by the base station when it fired up. In one of my projects, data captured from various sensors had to be time stamped in the YearYear/DayDay/MonthMonth, HoursHours:MinutesMinutes:SecondsSeconds format. ![]()
0 Comments
Leave a Reply. |