Oscillator Accuracy

alhoop

Member
While researching Picaxe oscillator accuracy on different chips, I found that Microchip specs on the PIC16F886( Picaxe 28X1) states that the internal oscillator is factory calibrated to +/- 1%. The following shows that most resonators are around +/- 0.5% so would a crystal and caps improve on this? I want to drive a Model Railroad turntable for about 30 seconds with at least +/- 0.5% accuracy.

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1215234838/0

I plead guilty of almost asking why sertxd would not work on a Picaxe-08 until I read the manual.

PS - I checked a Picaxe-08 and a 20m with the following code and results:
Code:
pause 30000
high 1
Picaxe-08 29.86,29.72,29.77,29.71 and 29.67 seconds
Picaxe-20M - 29.91,29.93,29.96,29.96 and 29.99 seconds

It seems the accuracy is more than adequate.


Al
 
Last edited:

Dippy

Moderator
Have you answered your own question here? :)

Internal resonator is fine for many apps, and can be adjusted. They have a bit of a tempco so this can upset things a bit when used in extremes.

Crystals are very accurate and should give much better than 0.5% error.
I tend to use crystals in designs to give reliable baud rates and tight timer functions. It also removes a 'variable' in timer related designs i.e. one less thing to have to fiddle with.
(If space is an issue then maybe Plan B is required of course)

Your figures show the internal is pretty good and as I say it can be tweaked a bit with PIC OSCTUNE register: have a read on CALIBFREQ.
 

BeanieBots

Moderator
Internal oscillator is the least accurate.
External resonator is better.
External crystal is as good as you can get. (several ppm or link to atomic clock is you want better!)

Why the required accuracy?
How would you even control it to that level of accuracy even if you had an atomic clock as the reference?
What type of motor would you use?

Even using the internal resonator you should be able to get the timing of your controls down to a few tens of microseconds with a little tweaking.

Maybe you confused timing accuracy with position accuracy?
You cannot position accurately by timing the motor drive. You will need an accurate position sensor for that. (or use a stepper motor).
 

MFB

Senior Member
Also be careful not to confuse stability with accuracy. A crystal can produce a very stable frequency over a wide temperature and operating voltage range. However, crystals sold for use with micros (as apposed to radio) may have initial accuracies that are no better than PIC internal oscillators. Just because it has 8MHz printed on the top of a cheap crystal does not mean that it will not oscillate at 0.5% either side of that frequency.
 

AlC

Member
0nly 0.5% diversity among different chips? Very interesting find, although thats bad news for my "firefly" project.
 

Dippy

Moderator
Is that true?

Whilst I haven't measured every crystal have ever used, the ones I hve checked on a calibrated Tek 'scope were very good.
They were 'accurate' to 2 dec places e.g. 20.00MHz for a crystal marked 20.000.
(These were cheap crystals from Rapid and Farnell).

Other crystals with funny frequencies e.g. 3.5795 MHz (again cheap) were also good for the limited degree of precision on the Tek.

I don't have an expensive proper calibrated frequency counter.

I'm genuinely surprised that there is a 'tolerance' of up to 0.5%.

All the ones I've ever used have a 'fequency tolerance' (NOT 'frequency stability') of <50ppm. Obv assuming correct loading.

Have you link for this Data as it interests me.
 

hippy

Ex-Staff (retired)
0nly 0.5% diversity among different chips? Very interesting find, although thats bad news for my "firefly" project.
That may be the finding for one particular sample but it may not be universally true. The Microchip data sheet for the 16F677 ( PICAXE-20M ) shows what the Internal Oscillator "Frequency Accuracy Over Device Vdd and Temperature" is and around 3V5 and 25'C it's +/-1%. So two different chips could have up to 2% difference at same Vdd and temperature, at 4V the difference could be 4%. Though, yes, on average ( mean ? median ? ) they should tend to be closer rather than further.

One thing to note is that the test measured "real world versus expected" results, not actual oscillator frequency.

In practice the difference between each chip may be great enough for your firefly project and, if not, you can randomise CALIBFREQ which will set them all at different frequencies. There are a number of ways to set the same code running on perfectly identical PICAXE's executing at slightly different rates.
 

MFB

Senior Member
Dippy. Unfortunately it’s true. Although I have only been caught out a few times (over too many years in electronics to mention) with crystals that are significantly out of calibration, it has stopped me from taking their accuracy for granted. The main reason that these errors often go unnoticed is that most users do not have access to equipment that is capable of measuring the errors and interface standards like RS-232 are very tolerant on timing.
 

Dippy

Moderator
I see.

Are you saying that this degree of error is common or one-in-a-million (ish) ?

So, Manufacturer's claims of 'frequency tolerance' of 20ppm - 100ppm are "optimistic" to be polite?

Or was it a duff batch of real cheapoes?

Or was it from a parituclar manufacturer or supplier?

Or were the load capacitors at fault or unsuitable?

There are many Apps were PICs are used as RTCs. If this fault was common there would be a lot of upset people. Maybe there are...

I'm truly amazed and slightly concerned if this error is worse than 1:1000. I'd like to know more.
 

MFB

Senior Member
Dippy, I am not sure why you are having trouble with my statement that on, rare occasions, I have found crystals that do not operate at the specified frequency. Just warning people that there is nothing magic about crystals. There are out of spec examples around just like any other electronic component (but even the duff crystals remain very stable).
 

Dippy

Moderator
MFB: Fair comment. But I like numbers/statistics etc. You don't indicate. What's "rare"?
I appreciate there are always duffers, but 1:10000000 doesn't worry me, however 1:100 does.

No, nothing is magic, I obv understand that - but a level of uncertainty is always helpful. And being able to nail it down is even more helpful.
 

papaof2

Senior Member
I have found crystals that do not operate at the specified frequency. Just warning people that there is nothing magic about crystals. There are out of spec examples around just like any other electronic component (but even the duff crystals remain very stable).
Brings back memories of working on CB radios when they used a pair of crystals per channel (receive & transmit), with one or two notable exceptions that used a single crystal. Out of 20 manufacturers, perhaps any 3 would use compatible crystals.

Crystals are manufactured to be on frequency in a specific circuit.
Is the crystal being used in the circuit specified by the manufacturer?
Things like required parallel capacitance can make a large difference in the actual frequency of oscillation - those transmitters were usually brought into frequency tolerance by adjusting the trimmer on each transmit crystal.

Is it a fundamental or overtone crystal?
A crystal marked 27.255MHz may very well be designed for a multiplier circuit in the specified device and the actual frequency is perhaps 1/3 of the marked frequency. It may also be an overtone crystal which effectively operates on an odd harmonic (3rd, 5th) to get the desired frequency. Overtone crystals must have the circuit the manufacturer created them for (inductance, capacitance).

A marked frequency of 10MHz or below nearly always indicates a fundamental frequency crystal. Between 10 and 20MHz, it's usually a fundamental. Above 20MHz, it's likely an overtone.

Today's lesson from an old radio technician is done ;-)

(I had the FCC First Class Radiotelephone license back in the days when it meant something - I could work on 50KW TV transmitters.)

John
 
Last edited:

boriz

Senior Member
I’m with DPG. A single microswitch would be much simpler AND more accurate than timing based methods. Your table will always stop at the same place. Is there is something strange about this turntable that you haven’t said yet?
 

andrew_qld

Senior Member
If you just want to turn a turntable and have it stop in the same place each time , why not use a stepper motor and count off the pulses? This would be far more accurate than timimg how long the motor turns for. If it's a DC motor, unless its geared down a lot the speed of the motor would vary with load and voltage.

Or have I missed something?
 
Top