Crystal uses (compared to ceramic resonators)

For virtually every resonator based board, someone comments "Will there be a crystal version" or "I'd buy it, but it uses a resonator".

So, why would you like a crystal? What would you use it for?

In my opinion, a crystal is only useful if you want to have an extremely accurate real-time clock. A resonator is more than adequate for most general timing purposes as its accuracy is typically something like 0.2 - 0.5%.

  • Ben

Ben, I agree with you 100% (which is why I make kits with resonators).

To be fair, the following illustrates the difference between resonators and crystals:

AWCR-16.00MD ABL-16.000MHZ-B2
Price $0.18 $0.27 (plus caps)
Tolerance 0.5% 0.05% (50ppm)
Temp Stability 0.3% 0.05% (50ppm)
10yr Stability 0.3% 0.05% (50ppm)

The worst case scenario (end of the temperature scale, 10+ years old, and worst sample) is about 1.1% (15.82MHz - 16.17MHz) while the crystal is about %0.15 (15.976MHz - 16.024MHz). Obviously you're unlikely to see this kind of error in either component. You'd have to look it up, but I believe NASA testing showed their resonators to be within 100ppm of the target frequency from the factory. It's also important to realize these numbers are based on a perfect board layout (and capacitor matching for the crystal, badly matched load caps can severely throw off the native frequency).

The main reason I've seen given for using crystals is that the accuracy is required for stable serial communications.

--Phil.

serial ports are designed to cope with 3%+ error with no problems


The "recommended" 8 bit maximum error, even in double-speed mode, is an order of magnitude greater than the fundamental error of a resonator and well within any expected deviation. The maximum error is greater than even the worst case resonator error.

The maximum error is greater than even the worst case resonator error.

Is it greater than double the worst case resonator error?

Example: ATmega #1 has a resonator with max error in the negative direction, ATmega #2 has resonator with max error in the positive direction, so that's a total error (as far as RS232 is concerned) of double the max error. That's your true worst case scenario, IMO.

I've stayed away from resonators and internal RC oscillators to avoid errors, since some of my stuff operates at temperature extremes (>100F in a vehicle in the Alabama summer, down to -70C in a high altitude balloon payload).

I did spend a good chunk of last week playing with at ATmega644 that used the internal RC oscillator. We transferred lots of data at (I think) 19.2k, with no errors. Not sure if we were using error correction, as the comm library was provided and I didn't peek inside.

-j

I've never experienced resonator-introduced serial problems, even when communicating at 115.2 kbps (with a 20 MHz resonator). Unless you're using the internal oscillator, the dominant error in serial timing typically comes from your being unable to reach the exact frequency of the baud you want to use. For example, when using a perfect 16 MHz clock, the closest you can come to 115.2 kbps is 111.1 kbps (which results in an error of -3.5%). The next highest baud you can reach exactly is 125 kbps. In this situation, a 16 MHz crystal will not noticeably improve performance over a 16 MHz resonator.

Is it greater than double the worst case resonator error?

It's not if you use 6-bit bytes. Additionally, in my experience you can exceed the recommended maximum receiver error by a few tenths of a percent and still be just fine, which means that in the absolute worst case you're still ok (and also note just how unlikely the absolute worst case is given the requirement that all the various error sources in the equation all be a their extremes with the same sign on one AVR and all be at their extremes with the opposite sign on the other AVR).

Lastly, if your receiver error is slightly above the recommended maximum error, all this means is that over time you will lose synchronization with your target if you are transmitting as fast as the hardware can transmit with no breaks. This might happen after you have transmitted 50 bytes or 100 bytes. The solution is to simply insert a very small delay every x bytes so that the UARTs can resynchronize. The maximum receiver error is the error below which synchronization will never be lost even if you stream bytes non-stop forever.

  • Ben

I've stayed away from resonators and internal RC oscillators to avoid errors, since some of my stuff operates at temperature extremes (>100F in a vehicle in the Alabama summer, down to -70C in a high altitude balloon payload).

Most crystals/resonators are specked to nearly 160F, 100F is actually fairly close to the centre of the spec range. It's worth noting, that of the crystals and resonators I order, all of the resonators have a wider temperature range spec than all of the crystals. One resonator is specced for 145c (nearly 300F); the highest rated crystal is good to only 85c.
-70c is well beyond the operating range of most electronics, so I have no real comment on that. -40c is the lowest spec I see for both crystals and resonators. Don't most high-alt balloons include thermal insulation or even heating? Certainly all of the commercial high-alt weather gear I've seen does.

Is it greater than double the worst case resonator error?

The datasheet shows a recommended +/-2.0 error rate for regular speed clocking, the worst you can do for resonator error is 1.1%, but keep in mind, to have double this, you need to keep one resonator at -40 and the other at +85. Even then you're below the max total error rate. Even at double speed, you're below the maximum allowed error rate.

If, however, you're really operating at -70 then at over +85, you're going to have bigger issues than serial com's with the resonator, the ATmega itself will need replacing, the FT232 it's talking to will need replacing, and the regulator will too... ...all of these will need to be extended temp devices, and even in this case, the usart error is still within the maximum allowable failure (and keep in mind, this is with two resonators, that both barely pass initial quality controls, in oposite directions, and have 10+ years of service life each, decaying in opposite directions). Given that even concocting this situation, we're still within the allowed error rates, I think it's safe to say a resonator is OK for a-sync serial comms. Keep in mind, any sort of synchronous serial is unaffected by these errors, so you have to be actually using the UART serial port at these temperatures.

I would suggest you try a resonator in your target application, unless it's time keeping I suspect you'll be pleasantly surprised.

Just to be a protagonist, what about the aesthetics? Yes I said it. Resonators are fugly - crystals are sexy. Does it always have to be about tolerances?

:smiley:

-B

I don't know, I like the small resonator packages as compared to the huge crystals:

Arduino Stamp

vs

Baby Orangutan B-168

The boards are the same size, but the smaller resonator (and mega168) leaves room for so many more components. By sacrificing clock accuracy most people will never need or use, you get enough room to add a dual motor driver, a trimmer potentiometer, an extra LED, reverse battery protection, a six-pin ISP header, and an LC filter on the AREF pin for cleanear ADC results. In my opinion, the typical user is getting way more than he is giving up.

  • Ben

In my opinion, a crystal is only useful if you want to have an extremely accurate real-time clock. A resonator is more than adequate for most general timing purposes as its accuracy is typically something like 0.2 - 0.5%.

  • Ben

One thing to consider with using a crystal versus a resonator for timing is how long you are going to be keeping time. There are 10080 minutes in a week. If your resonator is off by 0.5% (worst case) your clock will be off by 50 minutes. where as a crystal at worse case (0.05%) will only be off by 5 minutes. So if I need a timer for cooking an egg, the resonator is fine, but when I come back from a week's vacation, i could tolerate my arduino based alarm clock going off 5 minutes late, but not 50 minutes late.

Look at what you are wanting to do figure out what will work.

If you really need it for long-term timing, the other alternative is observe what the real frequency is and calibrate your timing routine to compensate for the error. For example, run your timing routine for an hour and see how many seconds you are off by (e.g. if your error is -0.5%, you will be off be 18 seconds slow). Once you know how many seconds you lose/gain in an hour, you can effectively recalibrate your timing routine to be orders of magnitude more accurate. As long as your Arduino-based alarm clock isn't experiencing massive temperature swings while you're gone, the frequency error will be systematic (i.e. relatively constant).

For example, this is how you can often safely use the mega168's internal RC oscillator for serial communication. If instead of trying to use a fixed baud rate you set your baud based on how you measure the baud of the incoming data, your serial frequency error can be well within the 2% limit even if your RC oscillator is off by 10%.

  • Ben

re: long term timing (or more accurate short term timing) with a crystal vs resonator

It is true that you could calibrate to every resonator that you use for such a purpose.

But the difference in price for a more accurate crystal (9 cents plus caps) with the improved temperature and long term stability a crystal brings, seems to make the crystal a real bargain where timing IS critical. IMHO.

70c is well beyond the operating range of most electronics, so I have no real comment on that. -40c is the lowest spec I see for both crystals and resonators.

The industrial rated ICs tend to have temp ranges -40C to 85C, give or take. I'm talking about custom applications, not using an Arduino directly. When I buy ICs I tend to get the industrial instead of the commercial so it doesn't matter if it's on my desk, in a balloon, or in a vehicle. I don't put FTID's on 'em either - no point, really. If they don't have serial comms as part of the mission, they don't even get rs232 transceivers.

Don't most high-alt balloons include thermal insulation or even heating?

Yes, and in reality, a -70C or -40C payload isn't going to last long, simply because the chemical reaction that's giving you power will slow down to the point you don't have enough voltage to operate. Been there, done that. Energizer lithium batteries list -40 as the lower limit of the operating range, but the voltage dropped so low at that temperature my system failed.

You've given me enough reason to try ceramic resonators, if for no other reason I happen to be working on a very space-constrained board and the resonator is smaller than the crystal can, not counting the caps. Shoot, I may even try the internal RC oscillator.

-j

One thing to consider with using a crystal versus a resonator for timing is how long you are going to be keeping time. There are 10080 minutes in a week. If your resonator is off by 0.5% (worst case) your clock will be off by 50 minutes. where as a crystal at worse case (0.05%) will only be off by 5 minutes. So if I need a timer for cooking an egg, the resonator is fine, but when I come back from a week's vacation, i could tolerate my arduino based alarm clock going off 5 minutes late, but not 50 minutes late.

Look at what you are wanting to do figure out what will work.

Surely if you were worried out this sort of time scale you'd use a watch crycstal anyways? They have in turn a better accuracy than a typical microcontroller crystal

Ben, I agree with you 100% (which is why I make kits with resonators).

To be fair, the following illustrates the difference between resonators and crystals:

AWCR-16.00MD ABL-16.000MHZ-B2
Price $0.18 $0.27 (plus caps)
Tolerance 0.5% 0.05% (50ppm)
Temp Stability 0.3% 0.05% (50ppm)
10yr Stability 0.3% 0.05% (50ppm)

The worst case scenario (end of the temperature scale, 10+ years old, and worst sample) is about 1.1% (15.82MHz - 16.17MHz) while the crystal is about %0.15 (15.976MHz - 16.024MHz). Obviously you're unlikely to see this kind of error in either component. You'd have to look it up, but I believe NASA testing showed their resonators to be within 100ppm of the target frequency from the factory. It's also important to realize these numbers are based on a perfect board layout (and capacitor matching for the crystal, badly matched load caps can severely throw off the native frequency).

To be fair, here's a correction to your numbers there spiffed: 50ppm != .05%. 50ppm = .005%. The ABL-16.000MHZ-B2 that I found on digikey is rated at +/- 20ppm (.002%). According to the spec sheet the 2 at the end of the part number = 20ppm tolerance. Worse stability for that part series is 35ppm. Assuming 10yr stability (which isn't in the datasheet) might be 50ppm, that puts worse case on this partnumber at 105ppm, or 0.0105%.
That means the frequency range would be (worse case not accounting for caps) 15.99832MHz - 16.00168MHz, which to me is a good bit more accurate than the specs you quoted for the ABL-16.000MHZ-B2.

Current price difference between the afore mentioned parts on digikey is $0.12 for the resonator and $0.20+caps for the cyrstal.

I'm not trying to sway anyone one way or the other, I just noticed a misrepresentation of ppm (which stands for parts per million, IE 20ppm = 20/1,000,000). My field of work deals with parts that require tolerance as low as <0.1ppm accuracy so every decimal makes a big difference, 10 fold in fact.

Quijonsith is correct, I dropped a 0 on all of the crystal measurements, and the "ordering options" does indeed indicate a native tolerance of +/-20ppm. I was however unable to find the stability option for either Mouser's or Digikey's offering. In volume these come as -X's with +/-20ppm. If you're saving a few pennies, -4H models are out there though, which is still only +/-0.003.5%.
Long term stability is given for 25yr lifespan at +/-5ppm, specs for the ABL's surface mount cousin (who's model escapes me) show a nice smooth graph ramping rapidly to about 4.5ppm within 5 years and then a slow rise to 5ppm over the next 20 years. It is not clear what ageing effects occur at temperatures other than 25c.

I apologize for lousy math on the crystal; most of my intention was to show resonator accuracy was within acceptable rates for many tasks. The crystal specs were shown for comparison of what could be achieved - lesson, don't do math at night, without using a calculator, then don't depend on it later to do more math.

With regard to pricing, those are /1000 prices. While commercial orders should be in the 10-1000K range, I'm fairly sure most thread readers are not budgeting their Arduino projects in that range.