Do the caps in a 4 mhz clock make a difference


Closed Thread
Results 1 to 8 of 8
  1. #1
    Join Date
    Apr 2007
    Location
    Southern Ontario
    Posts
    50

    Default Do the caps in a 4 mhz clock make a difference

    I am trying to make a slot car timing system and I am using a 16f84a. I have already set it up to do the timing using the internal interupts but it is not 100% accurate, it is close (about 1 second per min off). I set the prescaler at 8 and load the tmro with 131 to give 1 sec on paper but it is a bit slow. I can adjust for it in the software but I was wondering if the caps I put on the external clock have anything to do with it. I wanted .22pf just as the schematics said but could not find any so I used .20pf ( I am not quite sure of the exact difference but I know I was close). Any way I was wondering if the clock depended on a R/C circuit or if the caps were only there for filtering.
    Any help would be apreciated and sorry for the spelling.
    Snap
    Beer is proof that God loves us and wants us to be happy.

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Snap View Post
    I am trying to make a slot car timing system and I am using a 16f84a. I have already set it up to do the timing using the internal interupts but it is not 100% accurate, it is close (about 1 second per min off). I set the prescaler at 8 and load the tmro with 131 to give 1 sec on paper but it is a bit slow. I can adjust for it in the software but I was wondering if the caps I put on the external clock have anything to do with it. I wanted .22pf just as the schematics said but could not find any so I used .20pf ( I am not quite sure of the exact difference but I know I was close). Any way I was wondering if the clock depended on a R/C circuit or if the caps were only there for filtering.
    Any help would be apreciated and sorry for the spelling.
    Snap
    You're probably losing a cycle here and there at the PIC level that you're forgetting about or not seeing or something...but yes, you might be able to 'drag' a 4Mhz cystal up to say 4.1Mhz or down to 3.9Mhz by using different load caps...but it won't be stable...in other words, it might be 4.1Mhz today, but it might be 4.05Mhz tomorrow.
    Best to get the crystal locked down with the recommended cap's and dial in the timing by adding or subtract a 'leap count'/'leap second'/whatever whenever it's needed.

  3. #3
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    The capacitor shouldn't affect too much, btw their tolerance is often high... so don't worry too much.

    This will help if we see your actual code.

    'Beer is proof that God loves us and wants us to be happy. This also make ugly people looking better
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  4. #4
    Join Date
    Apr 2007
    Location
    Southern Ontario
    Posts
    50


    Did you find this post helpful? Yes | No

    Default

    Thank you for the help I will try and get the right caps for the crystal. I am new to electronics but can help with water problems if anyone needs them.
    Snap
    Beer is proof that God loves us and wants us to be happy.

  5. #5
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Smile

    Are you counting 1000 overflows to equal 1 second?
    [(256-131*8)*1000 = 1000000uS]

    If so, you need to realize that TMRO has a 2 cycle delay after you write to it (see the datasheet). This would equate to [2*1000*60 = 120000uS (or .12S)] of your error (per minute). The other (part of the erro) from the fact that after you detect the overflow, TMRO is still counting ... you probably have some latency before getting to it to rewrite the 131. I bet this latency is the rest of your error (i.e., you are resetting a TMRO that has interrupted and carried on with counting when you re-write to it).

    Options
    1) adjust in software
    2) free running TMRO - does not stop TMRO http://www.picbasic.co.uk/forum/showthread.php?t=2129

    Lastly, you want XTAL caps of 15-33 pF (not 0.20pF or 0.22pF). It should not matter the value as long as you are in the ballpark – they should run your XTAL near the stated tolerance for the XTAL. I cannot image persuading the XTAL to vary by a percent or so day to day as suggested earlier in this thread – maybe I have been lucky the last 10 years, who knows.

    Good Luck,
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  6. #6
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by paul borgmeier View Post
    Lastly, you want XTAL caps of 15-33 pF (not 0.20pF or 0.22pF). It should not matter the value as long as you are in the ballpark – they should run your XTAL near the stated tolerance for the XTAL. I cannot image persuading the XTAL to vary by a percent or so day to day as suggested earlier in this thread – maybe I have been lucky the last 10 years, who knows.
    Good Luck,
    I was throwing out ideas earlier. I've never tried to see how far I could 'pull' a crystal or even if I could do it.
    But you're definetly right about reloading the timer. A guy should add a number to the timer rather than reload it with a fixed value in a case like this.

    And I think it would really help in this case to see some more code...

  7. #7
    Join Date
    Apr 2007
    Location
    Southern Ontario
    Posts
    50


    Did you find this post helpful? Yes | No

    Default

    I Used the code from Dogan Ibrahims book Pic Basic programming and projects.
    Project 16 I copied the code onto my laptop and do not have the time to copy the entire thing out here. The main point of my question was if the caps could effect the clock and I understand (by the answers) they can if they are way out I really apprecate all the help and will publish the code if you want it but I just wanted to understand the relationship between a clock and the 22pf caps.
    Thanks again
    Snap
    Beer is proof that God loves us and wants us to be happy.

  8. #8
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e View Post
    ...

    'Beer is proof that God loves us and wants us to be happy. This also make ugly people looking better


    That means, the beer is a religious drink given by God.

    Therefore, it is also the proof that God exists.

    To atheists, let it be provided as an evidence of God, then.

    WoW!
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

Similar Threads

  1. 12F683 - how to set it to use external 4 MHz clock?
    By jimbostlawrence in forum mel PIC BASIC Pro
    Replies: 19
    Last Post: - 29th September 2009, 09:16
  2. PICBasic newbie problem
    By ELCouz in forum mel PIC BASIC Pro
    Replies: 32
    Last Post: - 12th February 2008, 00:55
  3. Help with sound command in 2 programs
    By hyperboarder in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 5th July 2007, 20:36
  4. Microcontroller with 2 way paging application problem
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 20th April 2007, 17:27
  5. Replies: 5
    Last Post: - 11th February 2007, 23:55

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