Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

External RTC or not?

Status
Not open for further replies.

600V3Phase

Junior Member level 3
Junior Member level 3
Joined
Mar 24, 2010
Messages
26
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,578
Hello,

I am using a PIC32 uC and on board space is critical. I have created a timer Interupt routine which constantly increments an extern variable. The count this variable holds is the number of 4 ms time slices.

Therefore I am able to count the time slices and decern seconds, minutes, hours etc...

My question is, I now need to make a calendar time clock. In other words for example lets say that I need something to turn on at 10:00am and turns off at 5pm on Mondays, Wednesday's and Sunday's.

So I am thinking that I can simply tick off 24 hours per day and x amount of days per month at 12 months a year and then compare my values to the desired time schedule described above. And for the day light savings time I check for (October/April) months to adjust the time 1 hour back/front. And for the leap year I add a day every 4 years for the month of February.

Now I am thinking of programming this myself from scratch in the uC as I don't think this will be too difficult. What do you guys think? Is there much more to this? Do you guys think its worth the trouble to do it myself or go with one of em external RTC chips that hold the calendar data (but in consequence will take up room on my board)?

Thanks all for your feedback !
 
Last edited:

Which PIC32 are you using ? PIC32MX795F512L has internal RTCC.
 

RTC is first of all the power safe backup register, which can work without external power.
 

Seriously!!! That's the one I'm using....

Let me look into that....

Thanks Okada

- - - Updated - - -

Okada, are you familiar with Mikroelektronika?

- - - Updated - - -

Ok thanks Easyrider83.
 

Yes, I use mikroElektronika Softwares and Hardwares. I have mikroC PRO PIC32 and EasyPIC Fusion v7 with PIC32MX795F512L.
 

Hi,

I don't know about PIC 32 and it's internal periferals...

Counting pulses is just a relative time measurement from power up.
But in your post you say about absolute alarm times, so you need to set the absolute time somehow.
And you need to do the every time after power up...or does the internal RTC has separate battery power supply?

I fend to use seperate RTCs. They have separate battery connection, have alarm registers and have alarm outputs. Easy to use. No continous processing power needed.

Klaus
 
  • Like
Reactions: Alloy

    Alloy

    Points: 2
    Helpful Answer Positive Rating
Using buttons to set date and time for many alarms is tedious. Instead use microSD Card with PIC32.

Create afile like time.txt and alarm.txt on the SD Card.

If you want to update RTC time then remove SD Card and connect it to a PC and then put new data like

TIME:10:30 PM
DATE:20/04/2016 Thursday

in time.txt and reinser SD Card into PIC32 circuit and press a button and it will update the time.

For alarms a similar thing is done.

Put data like

10:20 PM - 10/04/2017
03:45 AM - 05/03/2018

in alarm.txt

The PIC32 will read the alarm times and execute it by comparing the alarm times with RTC time.

Buttons and LCD will make the circuit complex. Add a buzzer. if SD Card is removed then it will make a sound.

I have done a similar project using PIC18F. it was a school bell project. It even had USB connectivity. The school bell could be connected to PC and the file on SD Card could be modified.

Small Circuit, just a PIC32 with crystal and associsated capacitors, a few resistors, a transistor, a relay, a bell, a microSD Card holder and Card.
 

PIC32 and most other microprocessor don't have a separate RTC power supply, so the battery consumption will be much higher than with a dedicated RTC. The internal RTC isn't suitable for longer backup periods with a small battery.
 

Then let him go for DS1307 with a good quality crystal. If he uses SMD version of the components then it will take less space on the PCB. PIC32 has 5V tolerant I2C pins and so DS1307 can be easily interfaced to it. He needs two voltages. 3.3V for PIC32 and 5V for DS1307. Ofcourse there are other 3.3V RTC Chips.
 

Ok thank you very much for your help.... All valid points here! All I need is a simple way to track calendar time and the internal RTCC in the Pic32 seems to appeal to me. But on the other hand an external DD RTC chip would handle the battery switchover operations. Hummmm ! I'm undecided!

Okada, I looked into the one page RTCC help for the MKE timer library.

Can I use the timer library to do what I want to achieve.

https://www.mikroe.com/mikroc/pic32/libraries/

Scroll down under under "Miscelaneous libraries" and then "timer"

Thanks all
 
Last edited:

No, you can't use that library. mikroMedia Plus for PIC32 example project contains RTCC project. Check that.
 

Ok Okada,

Let me think about this.... The RTCC2 click board also looks interesting....

?

Thanks for your help
 

I have used all the RTCx Clicks from mikroE. I can help you with any RTCx Click.
 

Hi Okada,

Thank you for offering your generous help.

So this is the way I see it. Using the internal RTCC of the pic is good but I will still need an external battery chip/hardware to do the transfer of battery power in the event of power loss.

So I may as well go with an external RTCx click board which also has the battery and the capability to hold the its data when upon a power fail.

Another thing is that I don't know if I should go with the RTC2 or RTC3. I think the RTC2 needs an interchangeable battery but the RTC3 has a capacitor which in both cases is used to memorize the part's data.

What is the advantage/disadvantage of having a capacitor vs a battery ?

Also what hardware do I need to test the RTC2/3 click boards?

Thanks for your help. It's really nice of you!
?
 

I have completed a pair of projects which have RTC requirements, and can tell you from hard earned experience that power interruptions happen.

The don't have to be blackouts... a thunderstorm going thru your area may have substation lightning hits which interrupt the power briefly, but enough to reset the micro.
Dedicated RTC circuits will continue running happily from its own battery or supercapacitor.

I can vouch for the DS1307...Low cost, very simple to use, I2C communication, and since it already provides the seconds, minutes, hours, date, day, month and year with leap year correction, it greatly simplifies your firmware requirements. In a SMT package with a 32Khz SMT crystal, its footprint is even smaller than the backup battery.

You also get for free 56 bytes of battery-backed RAM, which you can use at your leisure for any variables you don't want to loose. I use them for running time registers. Since a running time register is constantly being updated, you would put large stress on an EEPROM used for that purpose.
 

Hi Schmitt Trigger,

Ok well good points.... I guess will go with MKE RTC2 which has the same DS chip that you mentioned.

One thing though, although the DS1307 has real time and takes care of months, days and leap years, does it take into account the day light savings time.... For example days in winter are shorter than days in summer in the northern hemisphere. But the opposite is true in the Southern Hemisphere? Also day light lasts longer in Quebec than it lasts in say Florida since they are in different latitudes. Does the DS1307 take all this into consideration?

Other than that, I would have no problem using the DS1307.

Thanks

- - - Updated - - -

Hello Okada,

I have another question. If I decide to use the RTC chip in the RTC2 click board from MKE, do I have to buy the RTC2 click board or can I just buy theDS1307 chip and connect it to my uC (with corresponding pins of course) and use their library to access the data in the DS1307?

Thanks
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top