Arduino Forum

General Category => General Discussion => Topic started by: bigbuck83 on Aug 26, 2013, 07:54 pm

Title: temperature compensation crystal oscillator
Post by: bigbuck83 on Aug 26, 2013, 07:54 pm
has anyone ever replaced the clock crystal with a "temperature compensation crystal oscillator" or tcxo I believe for short..... I am I need of ridiculous timing accuracy but I am finding little info on this topic anyone out there have any ideas or sugestions
Title: Re: temperature compensation crystal oscillator
Post by: MAS3 on Aug 26, 2013, 08:10 pm
A long time ago (somewhere in the eighties) i saw an Elektor article mentioning a "furnace".
That was a thermal isolated metal chamber heated by a transistor (i think).
(The transistor and the oscillator were inside the chamber).
By keeping the temperature at some higher level as the surroundings, one didn't need to do extra compensation i guess.
I'm not sure what the article was telling but i remember it was mentioned.

Must be better / easier ways nowadays.
Title: Re: temperature compensation crystal oscillator
Post by: bigbuck83 on Aug 26, 2013, 10:02 pm
Does anyone know how well arduino uno r3 keeps time......... I am using this board to run a world clock and am needing very accurate time over a long period.. which the uno r3 may be able to provide I am just wanting to make sure....... I just don't want to be losing seconds and in a week be off by minuets
Title: Re: temperature compensation crystal oscillator
Post by: MAS3 on Aug 26, 2013, 11:46 pm
This has recently been discussed (http://forum.arduino.cc/index.php?topic=182803.0).
Title: Re: temperature compensation crystal oscillator
Post by: bigbuck83 on Aug 26, 2013, 11:53 pm
yes I see something was discussed but I still don't feel like that answered my question really...if I let arduino uno r3 run for say 2 months is it still accurate within a minute..... this clock I am repairing has the capability to read time down to 1/1000 of a second is the arduino going to keep the right time at such a small reading
Title: Re: temperature compensation crystal oscillator
Post by: JChristensen on Aug 27, 2013, 12:51 am
Just to be clear on the difference between accuracy and resolution. Being able to read a clock to a millisecond (.001 sec) describes its resolution. Being correct within a minute over two months describes accuracy. The two aren't particularly related.

Now, does this properly describe the requirements? Accurate to one minute over two months, and millisecond resolution?
Title: Re: temperature compensation crystal oscillator
Post by: bigbuck83 on Aug 27, 2013, 12:59 am
Yes this is correct I need both..... more importantly is the accuracy  I have a sketch written and am currently running my most sensitive clock to see the accuracy of my current set up..... so far after running all day it is right on the money I was just hoping to get some idea of what I can expect over a long time period
Title: Re: temperature compensation crystal oscillator
Post by: bigbuck83 on Aug 27, 2013, 01:11 am
I forgot to add that these clocks are analog and are old....... originally engineered  in the late 60's so  I am not sure if this clock can keep up with the arduino as is this pic may help you visualize
Title: Re: temperature compensation crystal oscillator
Post by: bigbuck83 on Aug 27, 2013, 01:20 am
this may work better the first pic didn't load or something
Title: Re: temperature compensation crystal oscillator
Post by: JChristensen on Aug 27, 2013, 01:21 am
So what accuracy is needed? I don't have an R3 but last I knew, Unos had ceramic resonators which are on the order of ±0.5% accurate, which most people wouldn't find acceptable for a wall clock.
Title: Re: temperature compensation crystal oscillator
Post by: JChristensen on Aug 27, 2013, 01:27 am

this may work better the first pic didn't load or something


Interesting looking clock! What is it used for (or maybe I should say what was it originally used for)? What technology does it use, do you have any of the original specs?
Title: Re: temperature compensation crystal oscillator
Post by: bigbuck83 on Aug 27, 2013, 01:35 am
it is a world clock and this is the master I have 15 slave clocks that run based on this main clock as for specs no I have a busted up manual that is in German so it isn't much good I have re- wired the entire thing and am currently putting it all back together and testing but I fear the Arduino isn't going to give me the accuracy I need over a period of time .......how do I correct this
Title: Re: temperature compensation crystal oscillator
Post by: JChristensen on Aug 27, 2013, 02:39 am
The Maxim Integrated DS3231/32/34 RTCs are popular, they have temperature compensated crystal oscillators and are accurate to ±2ppm from 0°C to +40°C. Macetech makes an RTC based on the DS3231 called the Chronodot, it's available at several of the popular sites, Adafruit, Sparkfun, etc. etc.
Title: Re: temperature compensation crystal oscillator
Post by: bigbuck83 on Aug 27, 2013, 03:43 am
well now what a nifty little gadget seems pretty straight forward I guess the chronodot is easy to use I am using 2 L298d H-bridges what tutorials could you recommend.........I would like to see it used if posssible
Title: Re: temperature compensation crystal oscillator
Post by: JChristensen on Aug 27, 2013, 03:58 am
Yes nifty indeed! Do you mean tutorials on the Chronodot, or on the H-bridges?
Title: Re: temperature compensation crystal oscillator
Post by: bigbuck83 on Aug 27, 2013, 01:14 pm
oh sorry the chronodot and I will be using it with my h-bridges basicly I am not sure how to hook it up with what I have hooked up already........ does it use a arduino all to its own or is it applied to what I have already.....................just not sure what to do with it........ I will need two of them unless 1 chronodot can be hooked up to 2 uno's
Title: Re: temperature compensation crystal oscillator
Post by: JChristensen on Aug 27, 2013, 01:58 pm
Just google for "real-time clock" and Arduino. The Chronodot/DS3231 connects to the I2C bus which is pins A4 and A5 on an Uno. There are libraries available to make the programming a bit easier but it's not that difficult to just use the Wire library which does general I2C communication. Another very popular but less accurate RTC is the DS1307, you'll also find a ton of information on those. Internally, the registers for the DS3231 and DS1307 are very similar, so libraries or code that works for one will often work for another. You will need one RTC for each Uno.
Title: Re: temperature compensation crystal oscillator
Post by: bigbuck83 on Aug 27, 2013, 02:20 pm
ok thanks very much I will do my homework If I have any questions I will definitely ask.......... I asume you have used this device before have you had any weird problems worth mentioning 
Title: Re: temperature compensation crystal oscillator
Post by: JChristensen on Aug 27, 2013, 02:44 pm

ok thanks very much I will do my homework If I have any questions I will definitely ask.......... I asume you have used this device before have you had any weird problems worth mentioning 


Yes I've used DS1307, DS3231 and DS3232. They're all good devices, well behaved, easy to use. I did write a library for the DS3232/31. Still working on finishing the documentation but it's available on github (https://github.com/JChristensen/DS3232RTC) FWIW.
Title: Re: temperature compensation crystal oscillator
Post by: bigbuck83 on Aug 27, 2013, 10:22 pm
ok, after doing some reading it seems the chronodots work well with digital clocks or LCD screens but will it work with a analog clock as posted in the pic I dont seem to find much info on using an anolg clock with these devices
Title: Re: temperature compensation crystal oscillator
Post by: JChristensen on Aug 28, 2013, 01:47 am

ok, after doing some reading it seems the chronodots work well with digital clocks or LCD screens but will it work with a analog clock as posted in the pic I dont seem to find much info on using an anolg clock with these devices


I imagine the Chronodot can act as a time base, but the important question is what is the interface to the analog clock? Do you intend to drive the analog clock with an Arduino? How will that work?
Title: Re: temperature compensation crystal oscillator
Post by: bigbuck83 on Aug 28, 2013, 12:51 pm
I am using the arduino to run the clock yes and I need it to keep accurate time I am hoping the chronodot will act as the time base you mentioned but I am unsure how that works exactly
Title: Re: temperature compensation crystal oscillator
Post by: bigbuck83 on Aug 28, 2013, 01:49 pm
what I have exactly is the following:

I am using a arduino uno r3 connected to a l293 H-bridge which runs a magnetic coil for the clock............... now do I simply wire up the Chronodot as I have read and implement a sketch so the arduino recognizes the RTC ...........basicly replacing the clock module that is on the arduino uno r3 currently while still allowing the arduino to run the l293................. this is what I am hoping to accomplish .....................thanks for all of your help also I am new to all of this and am unsure how to proceed
Title: Re: temperature compensation crystal oscillator
Post by: JChristensen on Aug 28, 2013, 02:39 pm
The Arduino will need to do both, but this is no problem. It needs to run the H-bridge and also communicate with the RTC.

The RTC will provide time of day and date information, but I'm not clear whether this is actually needed in this case, or if the Arduino just needs to use it as an accurate time base to drive the clock coil. Most inexpensive quartz clocks I think just pulse the coil once per second, but I'm not sure in this case. It that what is needed, or something else, a faster signal?

There are a couple options. To use the RTC just as a time base/frequency reference, it has an output pin that can provide a 1Hz (one pulse per second) signal. (There are also several other frequencies that can be selected.)

OTOH, to use the RTC to track time and date, I like the Time library, http://playground.arduino.cc/Code/Time

The Time library implements a software RTC and then synchronizes it with the hardware RTC (Chronodot) on some given schedule (every five minutes by default).

PS: The Uno does not really have a "clock module" in the sense of an RTC. It does have a ceramic resonator to provide the system clock. All microcontrollers need a system clock of some sort, and there are many ways to provide it. Note that the system clock is not a time-of-day (real-time) clock, it is simply a regular signal that the MCU uses to synchronize all its internal logic. As noted earlier, the ceramic resonator is not all that accurate for timekeeping purposes.

There are a lot of options and a lot of flexibility, so take some time to understand what is possible and figure out what the best approach for driving the clock is. For instance, the Time library can function perfectly well without an external hardware RTC, using the system clock for its timing. If the system clock were derived from a more accurate source (e.g. a crystal), this could provide decent timekeeping, but even most commonly used crystals will still be an order of magnitude less accurate than the Chronodot/DS3231. Have a look at the DS3231 datasheet (http://datasheets.maximintegrated.com/en/ds/DS3231.pdf) so you know what you're dealing with and what its capabilities are.

Whew. HTH.
Title: Re: temperature compensation crystal oscillator
Post by: bigbuck83 on Aug 30, 2013, 02:34 pm
hello again do I need the pull up resistors when connecting to uno R3 I just got the chronodot and am going to see if this works
Title: Re: temperature compensation crystal oscillator
Post by: JChristensen on Aug 30, 2013, 03:38 pm

hello again do I need the pull up resistors when connecting to uno R3 I just got the chronodot and am going to see if this works


Yes. The Chronodot has locations where they can be installed, or they can be placed elsewhere on the I2C bus. Anything between 2.2K and 10K should work. Actually it may work without them, as the Wire library enables the internal AVR pullups, but they are technically a little weak for I2C, so I always use external pullups.
Title: Re: temperature compensation crystal oscillator
Post by: retrolefty on Aug 30, 2013, 04:02 pm


hello again do I need the pull up resistors when connecting to uno R3 I just got the chronodot and am going to see if this works


Yes. The Chronodot has locations where they can be installed, or they can be placed elsewhere on the I2C bus. Anything between 2.2K and 10K should work. Actually it may work without them, as the Wire library enables the internal AVR pullups, but they are technically a little weak for I2C, so I always use external pullups.


Good advice. However I have tested at least three different I2C RTC chip types and all three worked fine using just the internal weak pull-ups the Wire library provides and uses. One RTC module I had used jumper clips to enable or disable on board I2C pull-up resistors mounted on the module (I forget their resistance values), and the arduino/RTC setup would work with or without the resistor jumper clips installed or not. This module was wired on to a proto-shield board so there was short runs to the two I2C signals being used, if one was wiring the RTC some longer distance between the arduino and RTC then the weak pull-ups might cause problems.

Lefty
Title: Re: temperature compensation crystal oscillator
Post by: JChristensen on Aug 30, 2013, 04:15 pm

Good advice. However I have tested at least three different I2C RTC chip types and all three worked fine using just the internal weak pull-ups the Wire library provides and uses. One RTC module I had used jumper clips to enable or disable on board I2C pull-up resistors mounted on the module (I forget their resistance values), and the arduino/RTC setup would work with or without the resistor jumper clips installed or not. This module was wired on to a proto-shield board so there was short runs to the two I2C signals being used, if one was wiring the RTC some longer distance between the arduino and RTC then the weak pull-ups might cause problems.

Lefty


Right, I don't doubt it. Just from reading around, 4.7K seems to be the rule of thumb when operating the I2C bus at 100kHz and 2.2K for 400kHz. The Arduino Wire library runs at 100kHz but can be increased to 400kHz. As always I like to err on the side of caution, take the conservative approach, so I've been sticking with 2.2K lately. Experimenting like you did is useful, it gives a level of confidence in the robustness of the design; always glad to hear those kind of experiences.
Title: Re: temperature compensation crystal oscillator
Post by: bigbuck83 on Aug 30, 2013, 04:38 pm
well I can say that it is working without the resistors but i will be adding them as a precaution anyway thanks for the replys and help I will explain this project when I am finished I think y'all would enjoy what I have done here..............
Title: Re: temperature compensation crystal oscillator
Post by: JChristensen on Aug 30, 2013, 05:25 pm

well I can say that it is working without the resistors but i will be adding them as a precaution anyway thanks for the replys and help I will explain this project when I am finished I think y'all would enjoy what I have done here..............


Glad to help a little bit. Looking forward to hearing about the project!
Title: Re: temperature compensation crystal oscillator
Post by: bigbuck83 on Aug 31, 2013, 12:59 am
I have noticed the battery in the chronodot wants to try and power the arduino when the arduino is powered  off I guess adding the 2 pull up resistors will correct this issue
Title: Re: temperature compensation crystal oscillator
Post by: JChristensen on Aug 31, 2013, 01:29 am

I have noticed the battery in the chronodot wants to try and power the arduino when the arduino is powered  off I guess adding the 2 pull up resistors will correct this issue


That should not happen. What are the symptoms? The battery power is separate from the main supply. How do you have it wired?
Title: Re: temperature compensation crystal oscillator
Post by: JChristensen on Aug 31, 2013, 01:36 am
FYI connect the Chronodot as follows: GND to Arduino GND, Vcc to Arduino +5V, SDA to A4, SCL to A5. Leave the Chronodot BAT pin unconnected.
Title: Re: temperature compensation crystal oscillator
Post by: bigbuck83 on Aug 31, 2013, 02:00 am
Yea that's it I had the 3.3v pin connected to the BAT on the chronodot and I was getting back feed when the arduino was off......... other than that it is working without changing anything
Title: Re: temperature compensation crystal oscillator
Post by: JChristensen on Aug 31, 2013, 02:42 am
I'd make sure the coin cell in the Chronodot looks OK, not swollen or leaking, etc. The 3.3V pin was probably forcing current into it, those aren't rechargeable cells...
Title: Re: temperature compensation crystal oscillator
Post by: bigbuck83 on Aug 31, 2013, 05:10 pm
ok I just changed the cell it looked ok but I changed it anyway............. the chronodot is working very well and the previous issue was resolved
Title: Re: temperature compensation crystal oscillator
Post by: bigbuck83 on Sep 05, 2013, 03:15 pm
Hello,
I was wondering If I can control 2 arduino uno  with one chronodot.... I have tried this and it works but I am not sure if it is ok to do