Shop OBEX P1 Docs P2 Docs Learn Events
Propeller accuracy? — Parallax Forums

Propeller accuracy?

RavenkallenRavenkallen Posts: 1,057
edited 2010-08-30 14:57 in Propeller 1
I was wondering if the Prop's timekeeping functions are accurate enough to create a basic digital clock? losing a few seconds a day is an acceptable margin. I know this question has a lot to do with the type of crystal/ oscillator that the prop is using. So you should assume it uses the common 5 MHZ/ 6.25 MHZ crystals that Parallax sells. If it is capable of serial communications up to 14 mega baud, it should also be capable as a digital clock. Right? Or should i use my DS1307?

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-08-24 20:31
    It all depends on the crystal and the range of temperatures your system experiences. You will have to read the specs for the crystal you're using and do the math to determine the expected accuracy.

    -Phil
  • pjvpjv Posts: 1,903
    edited 2010-08-24 20:44
    As Phil said, the crystal is the timing source, but if you keep the board (oscillator) at a reasonably even temperature, you could calibrate the clock by having your software add or subtract as appropriate one tick every N ticks. Probably in the range of a couple of ticks per million I would guess. So add a "Faster" and "Slower" button to alter the seconds divider.

    Cheers,

    Peter (pjv)
  • bill190bill190 Posts: 769
    edited 2010-08-24 20:58
    I always thought it would be neat to have a digital clock, which when you adjusted it, would calculate the amout of time it was off, then add a correction to the time keeping.

    For example it would keep track of the last date / time it was set, and say it was set 30 days ago and is reset, then was 30 seconds fast. From then on it would subtract a second each day (or whatever).

    In theory if you set it exactly, then subsequently set it exactly, then eventually it should keep pretty accurate time.

    Sort of like our "leap seconds"...
    http://en.wikipedia.org/wiki/Leap_second
  • RavenkallenRavenkallen Posts: 1,057
    edited 2010-08-24 21:07
    So if the crystal has a accuracy of -+50 parts per million and it is a 5 MHZ crystal, that means that the total deviation would relate to 50 x 5 = 250 parts per five million. Right? So does that mean that the crystal would deviate by -+250 ticks a second? That would be .005 percent, right? need a little help.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-08-24 21:09
    You can also adjust the timing by lying about the _xinfreq setting. This only works, though, when you use clkfreq as a timing reference.

    -Phil
  • Heater.Heater. Posts: 21,230
    edited 2010-08-24 21:17
    It's a good idea to put some calibration code in there to compensate for any error in your particular crystal.

    Problem is the crystal frequency changes with temperature. Check the temperature coefficient specification.

    Solution is to build a little "crystal oven" that keeps the crystal at a constant temperature. A bit above your highest ambient temperature at your locality.

    Perhaps glue the xtal to a power transistor whose current is pulse width modulated by the Prop. Have a temp sensor for feed back. Keep the xtal and power transistor nicely thermally insulated.
  • RavenkallenRavenkallen Posts: 1,057
    edited 2010-08-24 21:25
    I would be keeping my project at room temperature and the normal deviation wouldn't be more than a few degrees. The datasheet is kinda vague about the expected percent of increase/ decrease of stability based upon temperature.
  • Heater.Heater. Posts: 21,230
    edited 2010-08-24 21:35
    Sounds like you have a good project there, measuring the temp coefficient of your particular crystal.
  • RavenkallenRavenkallen Posts: 1,057
    edited 2010-08-24 21:39
    What do you mean?
  • pjvpjv Posts: 1,903
    edited 2010-08-24 21:39
    You have the right understanding.

    Cheers,

    Peter (pjv)
  • RavenkallenRavenkallen Posts: 1,057
    edited 2010-08-24 21:45
    @Pjv....Oh, that is good. so the individual quality of the processor will have no effect on the timing stability of the whole system as long as the crystal is dead on? I am learning something everyday....Thanks guys. You are the best.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2010-08-24 21:52
    There was an article in N&V (I think) about a clock without any setting interface. It had a radio to retrieve the "radio clock" signal. I don't remember what the radio clock service is called but it's supposed to have really long range but be susceptible to interference. It would up data the clock when possible with the radio signal but when it couldn't receive the signal it used a software clock. It keep track of the difference between the expected time and the radio time and dynamically adjusted its crystal correction factor.

    I thought it was pretty cool. I don't have a radio to pick up the clock signal but I do have a couple GPS modules. I thought I'd use the GPS to occasionally update the time of my software clock.

    Duane
  • Martin HodgeMartin Hodge Posts: 1,246
    edited 2010-08-24 22:17
    http://www.nist.gov/physlab/div847/grp40/wwvb.cfm

    They transmit a 1 bit per second BCD code that's tied to a (bank of) cesium atomic time references.
  • Roger LeeRoger Lee Posts: 339
    edited 2010-08-24 22:21
    Bill190> " I always thought it would be neat to have a digital clock, which when you adjusted it, would calculate the amount of time it was off, then add a correction to the time keeping."

    I had a Mazda RX-7 years ago with a similar analog clock.
    Set it forward - runs faster
    Set it back - runs slower

    Daylight savings time took about 2 weeks to stabilize. PITA! :mad:
  • schillschill Posts: 741
    edited 2010-08-25 08:55
    http://www.nist.gov/physlab/div847/grp40/wwvb.cfm

    They transmit a 1 bit per second BCD code that's tied to a (bank of) cesium atomic time references.

    And that's what things like my watch use to adjust the time (it checks every day in the early morning).

    For microcontroller-based projects, it seems to be becoming more and more common to use a GPS receiver to get the time. They are getting pretty cheap these days (I don't know the cost of buying/building a receiver for the "atomic clock" time). The receiver may need to be near a window (but the "atomic clock" receivers can depend on this as well).

    GPS will work anywhere in the world. There are "atomic clock" broadcasts in the US, Japan, and Europe. They are at different frequencies and may be different protocols. I don't know about the rest of the world.

    I'd probably go with either a more accurate device (like the macetech one) or a GPS receiver.
  • RavenkallenRavenkallen Posts: 1,057
    edited 2010-08-25 09:01
    Hey, Ron. You are not the first person to say that the DS1307 is actually not that accurate. I heard some say that it loses nine seconds a day....That one does sound pretty cool. Losing only one minute i a year is great for applications where you can't have a central clock reset it....I might have to purchase one now...Between saving up for school and buying electronics parts i am going to be a poor man, haha
  • Martin HodgeMartin Hodge Posts: 1,246
    edited 2010-08-25 11:05
    @schill: You used to be able to get WWVB movements for around $10 - $15 at clockkit.com The antenna had the receiver chip built in and needed only Vcc & GND and would provide TTL output. I haven't checked lately if they still have them. GPS is easier, like you say. Just parse the text output.
  • w8anw8an Posts: 176
    edited 2010-08-25 19:25
  • Heater.Heater. Posts: 21,230
    edited 2010-08-25 23:58
    Ravenkallen:
    What do yo mean.

    Just a simple experiment. Measure the xtal frequecny at different ambient temperatures. Then you know how much it gains/looses at each operating temperature. Then if you completed clock had a temperature sensor software compensation could be applied.

    Of course it's not so simple to do properly as you would need a temperature (variable) controlled environment and an accurate counter to measure it's frequency.
  • Nick McClickNick McClick Posts: 1,003
    edited 2010-08-26 00:57
    The DS3232 will give you very precise time. It is only available as an SOIC, but that chronodot is a handy package.

    I ran the DS1307 for several weeks (using the RTC code in the obex) and was surprised just how accurate it was, within a second or two. With a A 12.5pf xtal connected to the DS1307, you really shouldn't see more than 10ppm deviation when running from 32f - 100f. That's an error of 30 seconds a month. Getting drift of 10 seconds a day is either a temperature issue or a bad pcb design.

    Really, though, I bet the prop xtal will be sufficiently accurate for this project. Cheaper & simpler, too. You could always use a TXCO on the Prop, too.
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2010-08-26 03:47
    The Maxim link http://www.maxim-ic.com/products/timers/DS3231_demo/ shows a DS3231 that was set in Oct 2005 and it is only 7 min 20 sec off now.

    I ordered a couple of the Chronodot modules - I guess I'll see how accurate they are...
  • K2K2 Posts: 693
    edited 2010-08-28 09:01
    If you've got the time ;) and the interest, the two methods of precise frequency control that Heater mentioned (OCXO and TCXO) are very interesting to experiment with, and the results can be amazingly accurate. A TCXO I made in '93 w/ a 16c54 would gain or lose about a second a year.

    Most microprocessor crystals above 1 MHz are AT-cut, which means that there is a point of inflection in their freq/temp curve just above room temp. If you can target this temperature with a small and simple homemade crystal oven, amazing stability can be achieved. That's an OCXO.

    A TCXO can use a thermistor to change the operating properties of the oscillator circuit (such as by including a varactor diode in place of a fixed capacitor) or by counting the crystal oscillations differently. It was this second approach that was used with the 16c54. The short-term average temp guided minute changes to the frequency divider chain, sometimes amounting to a one or two count difference across several minutes time. That is one of the great things about modern high speed microcontrollers - you can count and act on every cycle of a 4MHz crystal oscillator.

    One other fun thing to try is operating a crystal at an odd overtone, typically 3rd or 5th overtone. Everything else being equal (and they never are) this produces a higher crystal "Q"
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2010-08-30 14:57
    I received my Chronodot DS3231 RTC modules today. Of course I can't speak to the accuracy yet, but this chip is compatible with the DS1307.
    It handles leap year up to 2100 and has two alarms

    Features:

    Accuracy ±2ppm from 0°C to +40°C
    Accuracy ±3.5ppm from -40°C to +85°C
    Battery Backup Input for Continuous Timekeeping
    Operating Temperature Ranges
    Commercial: 0°C to +70°C
    Industrial: -40°C to +85°C
    Low-Power Consumption
    Real-Time Clock Counts Seconds, Minutes,Hours, Day, Date, Month, and Year with Leap Year
    Compensation Valid Up to 2100
    Two Time-of-Day Alarms
    Programmable Square-Wave Output
    Fast (400kHz) I2C Interface
    3.3V Operation
    Digital Temp Sensor Output: ±3°C Accuracy
    Register for Aging Trim
    RST Output/Pushbutton Reset Debounce Input
    710 x 710 - 142K
Sign In or Register to comment.