Shop OBEX P1 Docs P2 Docs Learn Events
Crystal and Counter for Timebase — Parallax Forums

Crystal and Counter for Timebase

dtalvacchiodtalvacchio Posts: 36
edited 2006-06-26 17:46 in BASIC Stamp
Hello-- I'm about to use a variation of the circuit and code from an AppNote in the Basic Stamp Programming Manual (manual is attached; the note is #20: An Accurate Timebase, pg. 97 of the PDF). It uses a 32,768 crystal and a 4060 counter to produce a 2-Hz signal, which the code then converts to a one-cycle-per-second heartbeat for the clock.

The only difference for me is: instead of using the counter and code to divide the 32,768-Hz signal to a 1-Hz signal, I'll only want to divide it down to an 8-Hz signal for my application. This part I believe I can handle.

What I am hoping for is a little help with the circuit. I see that I need to use two resistors and two capacitors but: (1) I'm not sure what function they are serving, and so (2) I don't know how to find the right values for these components. Will the pulse be inaccurate if I don't find the appropriate values? Is it mainly a matter of trial and error? If so, in which direction would I correct if I saw that the clock was gaining or losing time? Any theoretical explanation would be greatly appreciated, so that I'll know how to get started.

I'm very much a newbie, so please be gentle.

Thanks!

Comments

  • Larry~Larry~ Posts: 242
    edited 2006-06-21 21:38
    ·
    · Here are some programs and notes I have for the 4060 as a pulse generator. The EXE file is a qbasic program which will caculate your xtal needs for any freq.

    Larry
  • dtalvacchiodtalvacchio Posts: 36
    edited 2006-06-23 02:27
    Thanks for the program. I see that with my 32,768 Hz crystal, I'll have to use pin 1 for an 8-Hz signal, but I still don't know what values to use for the resistors and capacitors.
  • Larry~Larry~ Posts: 242
    edited 2006-06-23 14:24
    ··

    ·· Did you see the second file, The PDF file is shows all you need for hook up
  • dtalvacchiodtalvacchio Posts: 36
    edited 2006-06-23 14:31
    Does this PDF mean that no matter what crystal I use, and no matter which frequency I want on the output, I use two 740 pF capacitors, one 10K resistor, and one 1M-ohm resistor?
  • Larry~Larry~ Posts: 242
    edited 2006-06-23 15:18
    ·Thanks for pointing out the 740pf in the drawing, I use 14pf and 17pf caps I will change the drawing.

    If you use the adjustable cap setup how will you be checking for freq do you have a scope or will you be using count or pulsin for this.
  • dtalvacchiodtalvacchio Posts: 36
    edited 2006-06-24 00:15
    I'll be using the Count command. I thought I would just time it against a clock, to see if it's accurate. Is this not the right approach?
  • Larry~Larry~ Posts: 242
    edited 2006-06-24 17:29

    If this is the case then use the 17pf or 19pf caps and let it run. I’m not sure the count command or looking at a clock will show any difference. But! why don't you try some different cap sizes and let us know what the count command shows. I would be interested to see the difference

  • dtalvacchiodtalvacchio Posts: 36
    edited 2006-06-24 22:36
    I'm having a hard time finding 17pF and 19pF capacitors . . . lots of 10pF, 15pF, and 22pF. I've been searching for low voltage ceramic disc capacitors . . . is this not right? Here are some 17pF ones

    cgi.ebay.com/10pcs-500V-17PF-Dipped-Silver-Mica-Capacitors-NEW_W0QQitemZ3870616717QQihZ017QQcategoryZ36336QQssPageNameZWD1VQQrdZ1QQcmdZViewItem

    but they're not ceramic and the voltage rating is very high. Does this matter?
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2006-06-25 00:55
    It only matters if it doesn't work, but nothing will be destroyed if you use/try 15pF.· Another consideration is tolerance, Mr. 15pF probably has a 10% tolerance; might be 16.5pF or 14.5pF?

    Nothing ventured, nothing gained.

    Give it a shot, it isn't that critical, it's capacitance, not critical mass.

    ·[noparse]:)[/noparse]
  • Larry~Larry~ Posts: 242
    edited 2006-06-25 15:50
    I just found out why I use the 15pf caps there 3 cents each, they also have some 20's get an assortment


    ···· http://www.jameco.com/Jameco/catalogs/c262/P72.pdf
  • dtalvacchiodtalvacchio Posts: 36
    edited 2006-06-26 15:52
    When I use two 15-pF capacitors (and a 10 M-Ohm and a 220 K-Ohm resistors), the count command is showing one cycle too few every 51 seconds. (I'm going for eight cycles per second, and I see a 7 every 51 seconds . . . occasionally I'll see back-to-back 7s). This is definitely making the clock I'm building fast. I'll try other capacitor values (have to wait for mail-order), but in the meantime, if anyone could give me an explanation about how the capacitor value is affecting the crystal's stability, I'd be very thankful. (Thanks, already, for all of your posts so far . . .)
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2006-06-26 16:08
    dtalvacchio said...
    I'm having a hard time finding 17pF and 19pF capacitors . . . lots of 10pF, 15pF, and 22pF. I've been searching for low voltage ceramic disc capacitors . . . is this not right? Here are some 17pF ones
    The schematic shows 33pF.· Why are you looking for 17pf, 19pF???

    THIS is the circuit drawing from the PDF youreferenced on the original post --

    attachment.php?attachmentid=42238

    There is a 33pF fixed cap and a 33pF variable, and a·10M and a 220K resistors.· If you go using odd-ball values then·you're off the reservation and all bets are off.

    The variable is for frequency adjustment, it's for slight variation not broad variation.

    If you want anything other than the 2Hz in the experiment, then you'll have to use the other output IC pins (4060).· I believe somebody posted a table previously.· I have not read that.

    N.B. -- The output on pin 3 is the input freq/16,000 = 2.048.· The output on pin 1 is the input freq/4,000 = 8.192· After pulling your hair out, you may find that you can adjust that cap enough to lose the decimal place (it'll drift with temperature, other factors.)


    Post Edited (PJ Allen) : 6/26/2006 4:57:54 PM GMT
    469 x 227 - 11K
  • Larry~Larry~ Posts: 242
    edited 2006-06-26 17:46
    ·This should work fine 7 pulses every 51 seconds = 1 pulse every 7.2857 seconds times 8 ( what you want) every 58.29 seconds so if you set up the count command for 60 seconds you would get 8 pulses. remember the count command will be off some the caps will be off some on and on. you are looking for 1 pulse every 7.5 seconds or 8 in 60 seconds you off by .21 seconds. now if your using the count command then by the time you do something and get back to reloading the count command you will eat up .21 seconds
Sign In or Register to comment.