Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
Tools
Old 29th March 2009, 03:40 AM   #1
Default Real Time Clock

Hi,
I am using 89S52 in a traffic controller. I need a real time clock also. I can do it with the same uC. But I need the clock to run even when there is a power failure. What is the best method suggested?
premkumar9 is offline  
Old 29th March 2009, 04:22 AM   #2
Default

I like to use real time clock calendar chips. When there is no system power they run off a battery. The often communicate by SPI or I2C.

The one I use is the M41T00.
__________________
Please post questions to the forums. PM's are for personal communication.

BCHS/3v0's Tutorials
Junebug USB PIC programmer kit., USB Bit Whacker,
The 15 Minute Printed Circuit Board! (+drill time)
3v0 is online now  
Old 29th March 2009, 06:58 AM   #3
Default

I used DS1307 with backup battery support.
__________________
The Loosers Now Might Be Later To win
For The Time's They're a Changing
theo92 is offline  
Old 29th March 2009, 07:28 AM   #4
Default

Quote:
Originally Posted by theo92 View Post
I used DS1307 with backup battery support.
I also used DS1307 in some cases. But I noticed difficulty in staring the counting . The same program which worked in one case doesn't start the oscillator (with DS1307) in another board. This type of problems take lot of my time. That is why I thought of adding the clock in the uC itself provided there is a method to make the clock work even during supply failure.
premkumar9 is offline  
Old 29th March 2009, 08:11 AM   #5
Default

Quote:
Originally Posted by premkumar9 View Post
I also used DS1307 in some cases. But I noticed difficulty in staring the counting . The same program which worked in one case doesn't start the oscillator (with DS1307) in another board. This type of problems take lot of my time. That is why I thought of adding the clock in the uC itself provided there is a method to make the clock work even during supply failure.
I too noticed the same problem.
But I think,never tested,a good quality oscillator with ringed ground plane under the oscillator PCB pad can overcome the problem, it's just my thinking, I never tested.
I like the IC DS1307 pretty much, and I think a good quality PCB with ground plane is required for accurate and reliable timing.
__________________
The Loosers Now Might Be Later To win
For The Time's They're a Changing
theo92 is offline  
Old 29th March 2009, 03:55 PM   #6
Default

The M41T00 datasheet has this about starting the clock. I do not know if it will work for others but there is no harm in trying. ST is the active low clock enable bit.

Quote:
Note: In order to guarantee oscillator start-up after the initial power-up, set the ST bit to a '1,' then
reset this bit to a '0.' This sequence enables a “kick start” circuit which aids the oscillator start-up during worst case conditions of voltage and temperature.
__________________
Please post questions to the forums. PM's are for personal communication.

BCHS/3v0's Tutorials
Junebug USB PIC programmer kit., USB Bit Whacker,
The 15 Minute Printed Circuit Board! (+drill time)
3v0 is online now  
Old 29th March 2009, 04:27 PM   #7
Default

DS1307 is a 5V supply only part, which makes it unusable to me. M41T00 takes 2.0V to 5.5V supply. That means I can use the M41T00 in all my projects, not just ones with 5V rails and don't need to write multiple libraries.

If you are going to pick a chip to use right now and you can carry on to later projects, you want something that you can use with 3.3V projects, as 5V is getting outdated with uC's.
__________________
Mark Higgins
DirtyLude is offline  
Old 30th March 2009, 03:14 AM   #8
Default

Quote:
Originally Posted by theo92 View Post
I too noticed the same problem.
But I think,never tested,a good quality oscillator with ringed ground plane under the oscillator PCB pad can overcome the problem, it's just my thinking, I never tested.
I like the IC DS1307 pretty much, and I think a good quality PCB with ground plane is required for accurate and reliable timing.
Do you think that it is a must to initialize the control register?
premkumar9 is offline  
Old 30th March 2009, 04:33 AM   #9
Default

Quote:
Originally Posted by premkumar9 View Post
Do you think that it is a must to initialize the control register?
really I made it very simple.
I used a user library from swordfish site.
It's very very simple to use Swordfish Wiki | SwordfishUser / DS1307 browse

I think they intialize all the control resistors.
Code:
dim 
   I2CWriteByte as WriteByte,
   I2CReadByte as ReadByte,
   I2CInitialize as Initialize,
   I2CStart as Start,
   I2CStop as Stop,
   I2CRestart as Restart
.......
{
****************************************************************************
* Name    : RTCStartWrite (PRIVATE)                                        *
* Purpose : Starts a RTC write                                             *
****************************************************************************
}
sub RTCStartWrite(Address as byte) 
   I2CStart
   I2CWriteByte(RTC_DEV_ADDR)
   I2CWriteByte(Address)        
end sub
{
****************************************************************************
* Name    : RTCStartRead (PRIVATE)                                         *
* Purpose : Starts a RTC read                                              *
****************************************************************************
}
sub RTCStartRead(Address as byte)
   RTCStartWrite(Address)
   I2CRestart
   I2CWriteByte(RTC_DEV_ADDR + 1)
end sub
{
****************************************************************************
* Name    : RTCStop (PRIVATE)                                              *
* Purpose : Stops RTC read or write                                        *
****************************************************************************
}
sub RTCStop()
   Acknowledge(I2C_NOT_ACKNOWLEDGE)
   Stop
end sub
{
****************************************************************************
* Name    : ReadRegister (PRIVATE)                                         *
* Purpose : Read DS1307 register ($00..$3F)                                *
****************************************************************************
}         
function ReadRegister(pAddress as byte) as byte
   RTCStartRead(pAddress)
   Result = I2CReadByte(I2C_NOT_ACKNOWLEDGE)
   RTCStop
end function
{
****************************************************************************
* Name    : WriteRegister (PRIVATE)                                        *
* Purpose : Write to DS1307 register ($00..$3F)                            *
****************************************************************************
}         
sub WriteRegister(pAddress as byte, pData as byte)
   RTCStartWrite(pAddress)
   I2CWriteByte(pData)
   RTCStop
end sub
{
****************************************************************************
* Name    : ReadControl                                                    *
* Purpose : Returns the RTC control byte ($07)                             *
*         : See the control constants RTC_SQWXXXX above                    *
****************************************************************************
}
__________________
The Loosers Now Might Be Later To win
For The Time's They're a Changing
theo92 is offline  
Old 5th April 2009, 12:57 PM   #10
Default

It worked. There is no need to initialize the control register. My problem was due to some mistake in the wiring.
premkumar9 is offline  
Reply

Tags
clock, real, time

Thread Tools
Display Modes


Similar
Title Starter Forum Replies Latest
Real Time Clock Help for PICAXE 18x johnjohn Micro Controllers 0 3rd December 2007 06:59 AM
Interfacing real time clock goodpickles General Electronics Chat 1 13th February 2005 10:36 AM
Real Time Clock on LPT l30 Electronic Projects Design/Ideas/Reviews 1 5th May 2004 07:50 AM
real time clock finst Micro Controllers 4 17th January 2004 01:11 AM
list of Real Time Clock thendo Micro Controllers 2 8th November 2003 06:41 PM



All times are GMT. The time now is 08:43 PM.


Electronic Circuits  |  Learning Electronics
eXTReMe Tracker