Help with capacitors values

Go To Last Post
9 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm making my first project , it is a clock project , with 4MHz crystal, I put 12pf capacitors but it delays a little, I need the value of the capacitors to give me that frequency without delaying

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If you have a good frequency counter you can measure the exact frequency, and by using a variable cap on one side of the crystal you can "pull" the frequency a little.

Two other options, however, are to use a 32.xxx KHz watch crystal as your clock timing source, and to measure how much you clock is off by every hour/day/etc., and make a software adjustment every hour/day/etc., to adjust the timimg.

For example, if your clock gains 1 second every day, then once a day you subtract one second.

Other options exist, as well. In many countries the long term accuracy of the Mains power is very good, and counting powerline cycles can be used as the clock's timing reference. (Fails when power is lost...).

A micro can easily read the time from a GPS signal.

JC

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

But is the crystal actually selected as the AVR clock source instead of internal RC oscillator?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

12 pF is probably the wrong value. You don't just pluck a value out of the air, you need to choose the capacitors according to the load capacitance of the crystal - see the relevant AVR app. notes.

Leon Heller G1HSM

Last Edited: Sun. Jun 19, 2011 - 08:47 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

just try 22pf....or 2 x 2 x 12pf in parallel. Without trim caps, you are unlikely toget better than 1 minute a month.32K watch xtals always have a trim cap to set accuracy and 1-2 secs a month is normal. BUT this is in a controlled temperature environment, i.e. the watch is assumed to always be at body temperature because it is permanently worn on a wrist....Running a micto in a normal environment will not see this level of temperature stability so you will never get it 'perfect'....

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

How much is it in error? Maybe you have a software problem also - how does the software work. Maybe you have an error in setting the timer - are you using the timer?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

leon_heller wrote:
[...] you need to choose the capacitors according to the load capacitance of the crystal - see the relevant AVR app. notes.
The datasheet for the crystal is likely to be of more specific help. Often, crystal manufacturers will have an application note or other technical paper that discusses calculating the load capacitor value.

If you can't find a datasheet for your crystal, get a different crystal. For a time critical application like yours you may want to choose a crystal with a higher accuracy and/or broader temperature range. Note, however, that even a crystal that has 30PPM accuracy could result in an error of more than 70 seconds/month.

Don Kinzer
ZBasic Microcontrollers
http://www.zbasic.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Jepael wrote:
But is the crystal actually selected as the AVR clock source instead of internal RC oscillator?

The OP hasn't come back yet, but Jepeal has a good point.

Are the fuses set up to use an external crystal?

"I may make you feel but I can't make you think" - Jethro Tull - Thick As A Brick

"void transmigratus(void) {transmigratus();} // recursio infinitus" - larryvc

"It's much more practical to rely on the processing powers of the real debugger, i.e. the one between the keyboard and chair." - JW wek3

"When you arise in the morning think of what a privilege it is to be alive: to breathe, to think, to enjoy, to love." -  Marcus Aurelius

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

Maybe you have a software problem also - how does the software work

That's my favourite guess so far - as I gaze deep into the crystal and the smoke clears I see CTC being used to count to N rather than the N-1 it needs to be...