Shop OBEX P1 Docs P2 Docs Learn Events
24 hour clock — Parallax Forums

24 hour clock

T ChapT Chap Posts: 4,223
edited 2007-04-11 22:38 in Propeller 1
For a 24 hour clock to base some events around, can a counter be just as accurate and drift-free as an external IC? If so, isn't there a minimum of 1 pin that has to be sacrificed? If there was a guesstimate on drift what would that be over 1 year? Thanks

Comments

  • bambinobambino Posts: 789
    edited 2007-04-11 16:14
    TChapman,

    Don't remember off the top of my head, but Andy Lindsey goes into some detail about it in the PE Kit Labs. I am pretty sure it is in the second lab!
  • bambinobambino Posts: 789
    edited 2007-04-11 16:21
    I/O and Timing Basics is the one I believe it is in and the main thing I recall from it is that the better the Clock Source(ie. Crystal, Oscillator) the better the Clock.
  • Mike GreenMike Green Posts: 23,101
    edited 2007-04-11 16:26
    The external IC gives you very low power consumption, battery backup, and formatting of the data (with compensation for months, leap-years, etc.) The accuracy and drift are set by the crystal itself and the environment (temperature stability mostly). For any kind of external clock, you'd need 2 I/O pins. You could provide just a 1 second pulse using an external counter (which would only need 1 pin), but then you'd need to power the processor to count the pulses.

    Dallas/Maxim has a temperature compensated crystal oscillator (see: www.maxim-ic.com/quick_view2.cfm/qv_pk/2940) that's good to 1 minute per year and can be attached to a counter or one of their real time clocks like the DS1307 (which could be attached to the same pins as the boot EEPROM saving an extra pin or two).
  • bambinobambino Posts: 789
    edited 2007-04-11 16:35
    TChapman,

    Sorry if I misread your question, If you are thinking of useing the propeller as a time base look at the PE Lab.

    Mike,

    Any chance that oscillator could be used as a clock source for the Prop or does it just count out seconds or something?
  • Mike GreenMike Green Posts: 23,101
    edited 2007-04-11 16:44
    The oscillator could be used as a clock source. It's slow (32768Hz), could be multiplied by 16 with the PLL to make 512KHz. You'd be better off to use a 5MHz crystal on the Propeller to get an 80MHz system clock and use the 32KHz oscillator on an I/O pin to drive one of the cog counters to get a very accurate real time clock.
  • bambinobambino Posts: 789
    edited 2007-04-11 16:52
    I like that second idea, in fact if I ever get the dev time I would like to desoldier one of the old 32K crystals laying around on old Motherboards and see if I can get them to work on a couple I/O pins.

    There is no telling how many of them there·is in my room!
  • Tracy AllenTracy Allen Posts: 6,662
    edited 2007-04-11 17:03
    32768 hz clock crystals are speced to tight tolerance at room temperature, +/- 20ppm typically, but high frequency crystals can also be purchased with that kind of tolerance or better. It can be improved with temperature compensation or ovens.

    I've been following the development of the Dallas RTC chips. They have just this week released the data sheet for the DS32C35, which contains a 3.5ppm RTC (-40 to +85 degC), with FRAM memory (up to 8kbytes), heartbeat/alarm output and I2C interface, 3.3 volt power.

    Mike, I think the 32khz cannot be multiplied by the PLL--The PLL only accepts around 4-8mhz input.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • Christof Eb.Christof Eb. Posts: 1,166
    edited 2007-04-11 17:05
    Hello,
    I have built a clock with a 5 Mhz crystal driving the prop at 80MHz.
    I think I have set it about 3 weeks ago and I have lost today 15 seconds.

    Perhaps one could add a software correction factor.

    Christof
  • Graham StablerGraham Stabler Posts: 2,510
    edited 2007-04-11 20:24
    Possibly OTT but I was reading make magazine today and they have an article on taking out the time piece from clocks to use as an oscillator for unusual time pieces, you just read the signal that would be going to the coil that operates the clock. If you select a cheap radio controlled clock then you are accurate to an atomic clock somewhere or other.

    Graham
  • mirrormirror Posts: 322
    edited 2007-04-11 22:31
    Christof Eb. said...
    Hello,
    I have built a clock with a 5 Mhz crystal driving the prop at 80MHz.
    I think I have set it about 3 weeks ago and I have lost today 15 seconds.

    Perhaps one could add a software correction factor.

    Christof
    3 weeks = 3 * 7 * 24 * 60 * 60 seconds
    ··· = 1814400 seconds.
    15 seconds of drift means 15 parts of·drift over an elapsed time of 1.8e6 seconds, which is roughly 8 parts per million.

    This is probably not unrealistic for a 30ppm or even 50ppm crystal. You'll probably do worse as you move away from room temperature - and with ageing.

    You could include a temperature sensor on your board, and map the crystal accuracy. The problem is you've got to do it for every board. This leaves 2 options:
    1)·It takes several·months to calibrate each board if you don't have access to a super accurate reference (Oh, and a temperature chamber).
    2) If you have a super accurate reference, then the process could probably be completed in a day or two (you need to let the temperature chamber stabilize before doing the calibration). With a 5Mhz crsytal at 30ppm you're drifting by 150 cycles every second!

    You'd need to pick the right number of temperature calibration points for your application, but half a dozen points and some linear interpolation will probably get you most of the way to your target accuracy.
    ·
  • JonathanJonathan Posts: 1,023
    edited 2007-04-11 22:38
    Software correction will help for sure. You can also add a small variable cap to one side of your crystal, the small ceramic type. Then you can use a scope and emperical testing to get pretty good accuracy.

    You can also use the 1PPS from a cheap "atomic" clock to use as a time base. Reading the actual WWVB data can be done, but is not easy.

    I set up a somewhat more complex system. I have a GPS unit mounted on my roof, and and read the time/date and rebroadcast it locally using a 433mHz transmitter like Parallax sells. Then I can use a cheap USD15 receiver to get the time anywhere in my house. I have a Nixie clock, aquarium timer and garden timers all running on the same time base. It's great because I never need to set the time on any of my devices, don't have to use any I/O for setting the time, just one pin for the 433mHz receiver. If you are going to have more than one project around the house, it is a great way to go. I got the GPS ( a Motorola Oncore II) cheap on e-pay, and the whole setup cost me less than USD50. Mind you, I did scrounge a lot of the parts including the water-proof enclosure for the GPS. It would cost more if just ordering the parts.

    Jonathan

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    www.madlabs.info - Home of the Hydrogen Fuel Cell Robot
Sign In or Register to comment.