Using Pic as a digital clock/timer. How accurate?


Closed Thread
Results 1 to 19 of 19

Hybrid View

  1. #1
    Join Date
    May 2006
    Location
    Del Rio, TX, USA
    Posts
    343


    Did you find this post helpful? Yes | No

    Default

    Bad wording on my part. What I ment was that I have used one of the temperature compensated oscillators (the DS32kHz, not the DS3232 RTC) with other RTCs and as an input to the PIC timers, and they worked well. I'll have a glance at you code and the Datasheet to see if I can spot anything.

    With other DSXXXX RTCs, I have seen the need to set some of the registers to appropriate setting before things work correctly. So that is one place to start.

    I'll get back if I see anything.

    SteveB

  2. #2
    Join Date
    Sep 2004
    Location
    Mentor, Ohio
    Posts
    352


    Did you find this post helpful? Yes | No

    Smile

    Hi Rocky,

    I think your code is missing the clock register constants. I use the DS1337 RTC from Maxim. The code for this chip was posted here either in 2004 or 2005 by Tonigalea. This chip also has two alarms. The key to an accurate clock is as was mentioned before. But you must also use the correct crystal. The DS1337, for example, must have a crystal with a 12.5pf capacitance load. When you look in a parts catalog, DigiKey for example, look for the capacitance load for 32,768 crystals. They are around $.50 or less.

    We also just covered RTC's with jcleaver using a DS1307. It looked like he also didn't list the RTC register constants. I sent him a copy of a program for that RTC and he got that going.

    I would give a serious look at Paul Borgmeier's Easy Accurate Clock programs as they are very easy to work with and setting up user interface for alarms should be very easy also.

    You asked a questions about the timing that no one seemed to answer. The PIC generates an internal time base which is derived from the Oscillator of the PIC divided by 4 so if you are using a 4mHz crystal then you PIC clock runs at 1mHz. Then there are programmable timers in the PIC that can be set up to count pulses then interrupt the PIC program to advance the clock program and/or do tasks at a specified time.

    Hope this helps.

    BobK

  3. #3
    Join Date
    Aug 2005
    Location
    Los angeles
    Posts
    39


    Did you find this post helpful? Yes | No

    Default

    Bob,
    Can you specify what register constant i am missing? i look it up and i didn't see anything else i need to specify.Remember its the DS3232 i aim using so it might be slightly different than the other rtc's
    Please let me know

    thanks

  4. #4
    Join Date
    Aug 2005
    Location
    Los angeles
    Posts
    39


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by SteveB View Post
    Bad wording on my part. What I ment was that I have used one of the temperature compensated oscillators (the DS32kHz, not the DS3232 RTC) with other RTCs and as an input to the PIC timers, and they worked well. I'll have a glance at you code and the Datasheet to see if I can spot anything.

    With other DSXXXX RTCs, I have seen the need to set some of the registers to appropriate setting before things work correctly. So that is one place to start.

    I'll get back if I see anything.

    SteveB
    Thanks steve! let me know if you find anything unusual or wrong i n my code...Thanks again

  5. #5
    Join Date
    Sep 2004
    Location
    Mentor, Ohio
    Posts
    352


    Did you find this post helpful? Yes | No

    Smile

    Hi Rocky,

    Look on page 11 of the datasheet. The addresses in Hex and the register name under the function column are what you need. I have attached a listing example from a DS1337 program for an example. The datasheet had the same type of setup as this chip. You can't write any data to the RTC if it doesn't know where to put it.

    Boy if I'm wrong here I really apologize but I think I'm right. Please let me know.

    BobK
    Attached Files Attached Files
    Last edited by BobK; - 12th February 2007 at 19:26. Reason: Correct some errors.

  6. #6
    Join Date
    Aug 2005
    Location
    Los angeles
    Posts
    39


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by BobK View Post
    Hi Rocky,

    Look on page 11 of the datasheet. The addresses in Hex and the register name under the function column are what you need. I have attached a listing example from a DS1337 program for an example. The datasheet had the same type of setup as this chip. You can't write any data to the RTC if it doesn't know where to put it.

    Boy if I'm wrong here I really apologize but I think I'm right. Please let me know.

    BobK
    Bob,

    That's what i have on my code if you look back. Here is a sample take the minutes sample for example:
    'Set the time
    I2cwrite PORTC.2,PORTC.1,CONTL,$01,[rtcmin] 'minutes
    the CONTL is the address of the RTC the $01 is the minutes register and the rtcmin is the value to be put in the register.
    I hope you find my mistake.

    Thanks

  7. #7
    Join Date
    Sep 2004
    Location
    Mentor, Ohio
    Posts
    352


    Did you find this post helpful? Yes | No

    Smile

    Hi Rocky,

    Click on SEARCH and enter DS1337. Look at the post :example code for DS1337, dated 28Oct2004. The program shows the register addresses. If you don't have the addresses setup then the clock can't be set and it will not work properly.

    All of the addresses on page 11 of the datasheet need to be setup as constants. Take the list of addresses on the example code I attached on my last reply. Put them into your program and try them. I do understand you also may possibly have other issues with your setup but these constants need to be a part of your program.

    BobK

  8. #8
    Join Date
    Aug 2005
    Location
    Los angeles
    Posts
    39


    Did you find this post helpful? Yes | No

    Wink HorrAY! it works

    Thanks Bob and all of you who replied to this post. My mistake was simple like usual. The RTC slave address is 7 bits so I added an extra zero to the left to make it 8 but i was wrong the zero should be to the right!

Similar Threads

  1. Digital clock thermometer Calendar PIC 16F628
    By valdirdf in forum Code Examples
    Replies: 0
    Last Post: - 31st May 2009, 01:52
  2. PIC 18f4680 DIGITAL INPUTS
    By MegaADY in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 30th July 2008, 07:34
  3. Digital Holter with PIC ?!
    By Eugeniu in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 28th November 2007, 10:37
  4. Pic driven digital audio delay
    By skimask in forum Off Topic
    Replies: 12
    Last Post: - 19th April 2007, 20:42
  5. Serial Pic to Pic using HSER
    By Chadhammer in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 11th March 2005, 23:14

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts