"inaccurate timing"

Discussion in 'Embedded Systems and Microcontrollers' started by folorunsoa, Aug 12, 2014.

  1. folorunsoa

    Thread Starter New Member

    Aug 11, 2014
    3
    0
    Thank you, Bob for your prompt response. For your additional info, I used 8Mhz. crystal with two 22pf capacitors connected to pins 13 & 14 of the PIC18F4550 Microcontroller. Therefore, I expected a better accuracy than what I am getting presently. I have a strong feeling that something is wrong with my setup timer code. So, I need an assistance from any forum member in order to remove the timer inaccuracy or reduce it to the bearest minimum.

    Thank you.
    folorunsoa
     
  2. timwhite

    Member

    Apr 10, 2014
    50
    7
    If you're having an issue with the precision of your timing using a crystal, look into using a silicon oscillator. They're a little bit more expensive but still very affordable, and very very precise.

    Here's a link to a Digikey search for 8MHz oscillators.


    Also, if you feel like it's your code, could you post the code here?
     
    Last edited: Aug 12, 2014
  3. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,392
    1,605
    As I first asked in your other post:

    What is the timer source?

    What frequency?

    What accuracy?
     
  4. MrChips

    Moderator

    Oct 2, 2009
    12,446
    3,362
    Just to give you an idea of the kind of accuracy to expect, I am working on my clock project using a TI MSP430G2553 driven with a 32768Hz crystal. At the moment I am calibrating the real-time clock timer and able to achieve accuracy to better than 1 sec in 10 days.

    A crystal oscillator can be accurate to better than 1 part in 1,000,000.

    During my initial testing I observed accuracy of 1 part in 500. This lead me to my error that I was incorrectly setting my timer to overflow at 512 counts instead of 511.
     
    Last edited: Aug 12, 2014
    absf likes this.
  5. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,392
    1,605
    I have that exact trophy on my wall too.
     
  6. MrChips

    Moderator

    Oct 2, 2009
    12,446
    3,362
    Great minds think alike.:D
     
  7. THE_RB

    AAC Fanatic!

    Feb 11, 2008
    5,435
    1,305
    I test a lot of xtals. Normal xtals like from hobby suppliers (like 8, 10, 16 MHz etc) are generally only accurate within about a +/- 40 PPM range.

    The 32768 Hz tiny watch xtals are better, generally +/- 10 PPM range with most better than 5 PPM.

    I recently tested the DS3231 RTC IC which showed better than 0.4 PPM out of the box, quickly tuned to 0.1 PPM (but no idea how long that will last).

    I'm still thinking of sticking it in a tiny handheld battery powered frequency meter good for accuracy better than 0.5 PPM. A useful tool.

    You might be interested in the tests in this recent thread;
    http://forum.allaboutcircuits.com/showthread.php?t=99839
    :)
     
Loading...