Clock with timer interrupt0


Closed Thread
Results 1 to 7 of 7

Hybrid View

  1. #1
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    Looks like you have a good xtal... wait until you find a bad one...

    Most xtals are 4.0 MHz... their accuracy isn't 4.000000000 MHz, some could even be 4.09 or 3.90 MHz.

    You want to spend $20 on a xtal, you'll get better accuracy, but what are you asking from a 20 cent device? Put in a 30pF trmmer capacitor and trim for exactly 4.0000000MHz with a 10-digit Frequency Counter phase-locked to a 10MHz Atomic Standard. Oh... don't forget to enclose the xtal and PIC in a temperature controlled oven +/- 0.1C as well... and then, and only then, you can start getting accuracy to better than 10 seconds per DAY.

    Lets face it, I've used a Dallas/maxim DS1307 (which costs a fortune) and a quality EPSON 32kHz xtal, and I whoop for joy if I get an accuracy better than 15 minutes in a YEAR.

    All this timekeeping using microprocessors is complete rubbish. You need to lock it to a high quality, high stability clock source for any kind of accuracy even approaching your cheap 99 cent Laser-Trimmed, digital wristwatch.

  2. #2
    Join Date
    Jul 2005
    Posts
    78


    Did you find this post helpful? Yes | No

    Default

    7 seconds a minute is 11.6% error, probably not a crystal error but the code.

    Changing timer zero's count is very funky to do as there is a built-in two instruction cycle delay before it starts counting again. The last timer I built (2% accuracy using a resonator) uses a Timer 2 as the time beat. Timer 2 is preferable as it has a compare value; I have the same clock (1MHz) and load PR2 with 250 so I get a steady evenly spaced interupt every .25 miliseconds without having to reload any registers.

    That's kind of fast for once a sec updating but you also have pre and post scaler to work with.


    BTW, what processor are you using? Microchip says "your search 12F625 did not match any documents. please refine your search."

  3. #3
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    If you are running from AC, You can get good accuracy by timing the 50 or 60Hz from the power transformer. If the AC goes away, you can turn on your
    timer interrupt.
    Just like the little alarm clocks with battery backup.
    Charles Linquist

  4. #4


    Did you find this post helpful? Yes | No

    Default

    The comment about using the AC line frequency is pretty sharp - The Hammond Clock company used to sell AC powered clocks with synchronous motors, and they would make gifts of these clocks to operators of the power utilities. The power plant operators would then have an incentive to regulate the AC line frequency.

    I think in your case, you should look into a real-time clock IC. There are many of these to choose from, and you can interface to them using a variety of techniques. As has been stated in this thread, trying to use the counter in a PIC to keep accurate time in the long term is a waste of, um, time.

  5. #5
    Join Date
    Apr 2006
    Location
    New Hampshire USA
    Posts
    298


    Did you find this post helpful? Yes | No

    Smile Search and Research

    Darrel Taylor's
    A better Search tool for the Forum
    http://www.picbasic.co.uk/forum/showthread.php?t=4751

    Finds:

    Paul Borgmeier's
    Easy and Accurate Clocks without RTC IC
    http://www.picbasic.co.uk/forum/showthread.php?t=2129
    Ohm it's not just a good idea... it's the LAW !

Similar Threads

  1. Single digit 7 Seg LED clock - PIC16F88
    By thirsty in forum Code Examples
    Replies: 4
    Last Post: - 17th July 2009, 08:42
  2. Clock using Instant Interrupts
    By PICpocket in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 16th February 2009, 21:43
  3. clock and date without using real timer
    By eepro in forum Off Topic
    Replies: 1
    Last Post: - 21st September 2008, 02:38
  4. Help with sound command in 2 programs
    By hyperboarder in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 5th July 2007, 20:36
  5. Help with realtime clock and timer
    By geselaw in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 8th October 2005, 09:56

Members who have read this thread : 0

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

Tags for this Thread

Posting Permissions

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