external crystal for better timing attiny85

Hi,

Thank you for helping me out on my previous topic (calibrating attiny85), couldn't do it without the help.

I calibrated my attiny85 and it was off only 1,66% , but for my purpose it just too much. (it needs to dimm on and off some ledstrips for multiple days)

question: can you guys point me into a good direction about using and setting up crystals on an attiny85.? (some sort of instructable)

I believe I read it cannot be > 20Mhz for the attiny85. What about the precision, the higher the better? What's more precise, crystal (+ capacitors) or ceramic resonators or watch crystal ?

Please take into consideration I'm a n00b :wink:

I don't know how to connect one to an ATTiny, but if you want accuracy you want to be looking for a Temperature Compensated Crystal Oscillator (TCXO).

A crystal is far more accurate than a ceramic resonator (which is, not entirely, but essentially what is inside the chip already).

You can connect a crystal up to an ATTiny in exactly the same way as you would to an ATMega. The trouble with using on for an 85 is that you lose 2 of the 5 I/O pins in the process.

If you use a TCXO or other crystal oscillator, they produce a TTL/CMOS square wave which you feed in to the ATTiny using just 1 I/O pin instead of 2.

For oscillators the lower the ppm the more accurate. Crystals tend to be anywhere from 10ppm to 100ppm but they also have a temperature tolerance and also depend on how accurate your capacitor loading is.

Thermal stability is also Most important... Make Certain that you use NP0 types.. Chinese parts usually have a black dot of paint on the top of NP0 types..
If the non NP0 type caps drift much thermally you will not only have timing errors but the oscillator may well quit or become very sensitive to both thermal and Vcc variations.. Especially at low Vcc conditions.
It's a common thought that the 328 will work fine @ 3.3V & 16 MHz crystal.. And 99.9% will work fine.. @ 20C, however at Low or High temps you may well find the clock drifting or intermittent.

Doc

Thank you guys for explaining!

I think the TCXO is the best but litterly and figurally to big for my small project.

What about using a "32.768Khz Cylinder Watch Crystal Oscillator " ?

Asking your experience, at what % do you guys think it can drift off clockwise looking at it a few days ? (assuming temperatures between 0 - 40 celcius)

You know any projects about a attiny with such a oscillator ?

*EDIT: found this: LINK and this LINK

I see he doesn't use resonators with this type crystal ?

creamers:
I calibrated my attiny85 and it was off only 1,66%

Was the tuning voltage the same as the testing voltage?

eezee tiny 84 has provisions for a 16 MHz resonator (stock).
eezee tiny once made a board W/resonator too, I have one...
Kind of a waste but simple enough..
There is a lot of Tiny BOB's on Tindie... I own the 8, 14 and 20 pin eezee tiny boards W & W/O resonators and I like what I own, they work well.. Stand alone or plugged into a breadboard.
All have 6 pin ISP programmer capacity.. Nice well thought out products

Doc

Yes I didn't move the table :wink:
I also tried it several times to see if it gave me the same value.
*edit: tried today again and it gave me the same value today as it did several days back.

Maybe I should just buy and try to see what result it gives.

Buying a "32.768Khz Cylinder Watch Crystal Oscillator" doesnt require caps?
Or buying a "Crystal 20MHz" with 2 x caps 20pF ?

What would work best for a attiny85 5v, between 0 en 40 celcius ?

I once tried using a watch x-tal @32 kHz without luck.
The problem is that you have to use a very slow upload speed.

The TinyISP has an option:

#define PROGRAMMER_SPI_CLOCK  SLOW

But that was not slow enough in my case (or I made some other mistake)

I think the easiest option is to use a 16 MHz x-tal, it is in the boards.txt by default.

I was thinking you could you use a DS3231 but only connect the 1Hz output to your tiny and count seconds but this is not enabled by default so you need to program over I2C first.

Depending on what country your in maybe you could use a radio clock module and one again use it's 1Hz output to count seconds.

Thank you for the tips !

Found this to calibrate your attiny with code. Could be useful for someone finding this thread.

binary clock

And yes, think I just have to use a crystal for simplicity...cause my attiny is definately not running consistently