Shop OBEX P1 Docs P2 Docs Learn Events
Time keeping solution? — Parallax Forums

Time keeping solution?

SRLMSRLM Posts: 5,045
edited 2009-01-16 06:03 in General Discussion
Hi,

I'm looking for something that can work as a timekeeping device. It will be propeller based, so initially I looked at a more accurate crystal. Unfortunately, mouser didn't seem to have anything that was any better. So I looked at timekeeping chips, and I found this one that seemed like it would work, and I found a matching crystal here that matched on the frequency. My question is three fold:

1. Is is possible to tune the propeller crystal using a variable capacitor? The data sheet for the timekeeping chip mentioned that's what it does.
2. If not, what range of capacitance is needed for the variable capacitor to tune the crystal with the timekeeping chip?
3. Is there a better way to keep time?

This is for a clock project, so a drift of up to two seconds per day would be okay, although a more accurate solution would be great.

Thanks for all help..

Post Edited (SRLM) : 1/14/2009 5:51:36 AM GMT

Comments

  • LeonLeon Posts: 7,620
    edited 2009-01-14 06:24
    A trimmer capacitor might make things worse in terms of temperature stability.

    I'd use an OCXO 5 MHz oscillator module instead of a crystal. Most crystal manufacturers make them:

    www.golledge.com/pdf/products/ocxos/mcocxo.pdf

    One of those should be accurate enough for you.

    Leon

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Amateur radio callsign: G1HSM
    Suzuki SV1000S motorcycle

    Post Edited (Leon) : 1/14/2009 6:32:24 AM GMT
  • kwinnkwinn Posts: 8,697
    edited 2009-01-14 16:01
    I have seen three methods (listed below) used to produce a stable time base. For one or two seconds a day drift a high accuracy oscillator should be more than adequate. If I were building a time reference using a micro I would buy a high accuracy oscillator and a temperature sensor to build my own oscillator oven right on the circuit board.

    If you are powering your project off the power lines you can count AC cycles. The average frequency is very precise. Since power outages are usually brief the standard crystal should be ok for the short periods on battery backup. Good long term accuracy, not so good for short term.

    A high accuracy crystal or oscillator, kept at a near constant temperature to be as stable as possible. This would mean having the crystal/oscillator or the entire board mounted in a temperature controlled enclosure. Good long and short term accuracy. Not too practical for battery operation.

    Drift can be corrected for in software by measuring the ambient temperature and making corrections based on that. First you would need to create a drift table or curve by comparing your clock with a very accurate calibrated time signal over the temperature range you expect in use. Fairly good accuracy for both long and short term. Producing the calibration data is time consuming and requires additional equipment.
  • LeonLeon Posts: 7,620
    edited 2009-01-14 16:08
    OCXO mean oven-controlled crystal oscillator. The one I mentioned is in a standard 14DIL package.

    Leon

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Amateur radio callsign: G1HSM
    Suzuki SV1000S motorcycle
  • SRLMSRLM Posts: 5,045
    edited 2009-01-14 22:27
    @Leon

    I like the crystal that you mentioned Leon (it's easy on my part), but so expensive! For $100 I could buy a GPS to do the same thing. It's a very good device, but much too expensive for a hobby project. Do you happen to know a source that can provide something for cheaper?

    @kwinn
    I'll probably power my circuit from a standard wall wart, so I won't be able to have access to the AC source. As for having a mounted heater and a control loop it seems beyond my skills. However, I do like the idea of setting standards (#3). I could probably put the module in the refridgerator for an hour or so, measure how many pulses are in a minute, then do it at room temperature for an hour, measure, and an oven at low temperature. Assuming that the crystal deviation is more or less linear, this should work well with a temperature probe. However, if at all possible I would like to avoid extensive preparation.

    Any other possible solutions? Or a value for the trimming capacitor?

    Thanks for all the help.
  • LeonLeon Posts: 7,620
    edited 2009-01-15 00:36
    They are expensive. It isn't difficult to build one, but it will be a lot larger.

    Leon

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Amateur radio callsign: G1HSM
    Suzuki SV1000S motorcycle
  • ZootZoot Posts: 2,227
    edited 2009-01-15 01:01
    Why not use a DS1302 (SPI w/backup batt. or cap.) or a DS1307 (I2C, backup batt., sq. wave out)? With the proper crystal these are really accurate, and the DS1307 will also let you output a precise square wave at various preset frequencies if you need something to as a benchmark for higher frequency syncing (e.g. the Prop counts). < $4 gets you a chip and crystal.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST

    1uffakind.com/robots/povBitMapBuilder.php
    1uffakind.com/robots/resistorLadder.php
  • Paul BakerPaul Baker Posts: 6,351
    edited 2009-01-15 03:45
    You could use a WWVB radio clock module, they can be hacked from a radio controlled clock, or bought outright. Digikey sells the C-Max CMMR-6 module, it still requires a suitable ferrite antenna. These modules are used for synchronization, IOW check the value once a day (typically at night when thees less radio interference) and synch your main clock.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
  • SRLMSRLM Posts: 5,045
    edited 2009-01-15 05:05
    Well, I looked at the DS1302, and it looks like it will work. I also looked at the WWVB, but as I'm stretching the limits of my electrical engineering abilities at the moment, I'll save that for a future date. After meandering around on the web, I discovered Parallax has a DS1302 module. Looks pretty good, but I have a general crystal question:

    How important is the load capacitance? The reason I ask is that there are lots of highly accurate modules available ( Here for example) that could keep time for years, except the stated capacitance is 12.5 pF while the time keeping chip wants 6 pF. Same thing with crystals that I can hook up directly to the propeller. So, would the crystal I mentioned work even though there is a difference in the capacitance, or could I use an additional component to get it within spec?

    Ideally, I would like to use a more accurate crystal on the Propeller itself, and not have to use a dedicated timekeeper. Speed isn't really an issue, since all the propeller will do is drive the clock.
  • kwinnkwinn Posts: 8,697
    edited 2009-01-15 05:09
    A reasonably priced 32.768 KHz crystal has a calibration tolerance of 20 PPM and a temperature coefficient of around -0.0040PPM per degree C.
    That means:
    The time could be off as much as 631 seconds ( 31,536,000sec. x 0.000020 ) in a year due to the calibration tolerance. Worst case error slightly better than the 2 seconds per day you specified.
    If the crystal is kept close to room temperature (20-25 degrees C) the temperature variation could add another 0.631 seconds (31,536,000*5*0.000000004 ) to the error.

    So if you could correct for the calibration tolerance it would keep time to within a few seconds a year. There is a simple way to do that, and that is to set the clock using one of the time reference signals initially, wait for a period of time (months) and then compare the time to the reference again. The difference can be used to correct for the calibration error. If you are using a high frequency crystal you could even correct the number of cycles to count for a second.

    If temperature stability is a problem it is not hard to build an oven for the crystal. Epoxy a temperature sensor on one side of the crystal and a 1/4 watt resistor to the other side, put a blob of insulating foam over the assembly, use a transistor and a prop pin to turn power on and off the resistor based on the temperature you read from the the sensor. Works well and lasts a long time.
  • SRLMSRLM Posts: 5,045
    edited 2009-01-15 06:00
    The homebuilt temperature oven looks simple...

    But, you mentioned that we can correct for the drift of the crystal? My impression is that one day the crystal would be +20 ppm, the next it would be -10 ppm, maybe a week later +5 ppm, and so on. So, is the rating for the +- 20 ppm a constant error in manufacturing, or is it the natural changes that the crystal experiences from one moment to the next (or something else entirely)?
  • kwinnkwinn Posts: 8,697
    edited 2009-01-15 16:42
    The calibration tolerance of the crystal is a constant due to small variations in production. The calibration tolerance can be removed mathematically. There is a program for Windows that does that for the PC clock. It goes to the internet and downloads the time from one of the sites that maintains a very precise timebase and sets the PC clock. By doing this after some period of time has passed it can tell how much the PC clock drifts and calculate a calibration factor to correct for this. I have no need for such precise timekeeping myself, but some of my customers do, and they tell me it keeps their PC time accurate to less than a minute per year (10 times better than your spec).
  • SRLMSRLM Posts: 5,045
    edited 2009-01-15 19:12
    Ah, perfect! I've ordered some nice little temperature sensors from mouser, and this will be a prime opportunity to try out a PI control loop. I'm guessing that the temperature that I keep the crystal doesn't really matter, right? As long as it's constant. I'll try it with the crystal on the propeller and see how it goes. Thanks for all the help everyone!
  • kwinnkwinn Posts: 8,697
    edited 2009-01-16 00:40
    It shouldn't matter what temperature you keep it at as long as you can maintain it. We set the temperature to 38-40 degrees C (100-104 F) on our spectrometer chambers so it is far enough above room temperature to make only heating (no cooling required) effective.
  • SRLMSRLM Posts: 5,045
    edited 2009-01-16 01:23
    That's exactly what I was thinking. I have a peltier cell (albeit a little large) that I could use I suppose to heat/cool, but more trouble than it's worth. I'll let you know how well the timekeeping goes... Check back in 6 months. [noparse]:)[/noparse]
  • jdpetersdocjdpetersdoc Posts: 26
    edited 2009-01-16 03:37
    Guys im 2 years into the Basic STAMP 2 and ive got some knowledge but I wanted to make a clock like the guy who started this forum. I have a BS2 with an LCD AppMod. I want to make a User Interfaced click with PB (Push Buttons) The AppMod has PB built on to it. But I looked at the hardware this guy bought, should I buy the same stuff? IDont think the tempeture chi[noparse][[/noparse] is really needed its going to be sitting on a desk in a 67 F home and nothing higher or lower. I get the fact that temperture afects the Quartz Occ. Can you please help........'

    Joshua
  • SRLMSRLM Posts: 5,045
    edited 2009-01-16 06:03
    I decided to forgo the external timekeeping chip because I wanted to keep it simple, and just use the propeller. Since the BS2 does not have a internally available clock like the propeller, you'll need to go with a chip. I particularly liked the DS1302 that Zoot mentioned. When I finish the project, I'll post the code in the completed projects forum.
Sign In or Register to comment.