Resonator Accuracy

tmfkam

Senior Member
Is there any data regarding the accuracy and stability relative to temperature (or otherwise) of the resonator/crystal fitted to the AXE201 (28X2) module?

I ask as I'm trying to read frequency with an accuracy well into in the mHz range. I understand that the internal resonator in the M2 series is close to 1% but with a 50Hz input, 1%=500mHz which is rather a long way from the +/- 5mHz accuracy I'm aiming for. As I can use #SetFreq to shift the M2 resonator in what is suggested to be 0.1% steps (still 50mHz though) I wondered if it would be possible to use a 28X2 on an AXE201 module as a reference and calibrate the M2 devices from that.

Needless to say, while I have a frequency counter, I don't have anything that comes close to the +/- 5mHz degree of accuracy I'd like. The best I've got gives a reading of +/- 250mHz and little about accuracy.

On a similar line... Is there a command that controls the multiplication of the PLL within the 28X2? Using #SetFreq EM32 (EM16 or EM64) seems to have no effect on the values returned by PulsIn?
 

eggdweather

Senior Member
Do you mean 5000ppm frequency accuracy, which is usually quoted in parts-per million and that level of stability is usually quite easy to achieve. A crystal would easily achieve 10-20ppm or 10-20uHz. You need a lot of resolution to measure 50hz with that level of accuracy and usually can only achieve that with a time not frequency measurement.
 

srnet

Senior Member
As I can use #SetFreq to shift the M2 resonator in what is suggested to be 0.1% steps (still 50mHz though) I wondered if it would be possible to use a 28X2 on an AXE201 module as a reference and calibrate the M2 devices from that.
Sure about that, are you confusing Setfreq with calibfreq ?

Anyway, the internal resonator on PIC chips wont get close to the temperature stability of a crytal, so calibrating an M2 seems pointless unless you can keep it at a very stable temperature and supply voltage.
 

srnet

Senior Member
On a similar line... Is there a command that controls the multiplication of the PLL within the 28X2? Using #SetFreq EM32 (EM16 or EM64) seems to have no effect on the values returned by PulsIn?
No, you cannot adjust the PLL division, its as the manual says;

"Note that the X2parts have an internal x4 PLL inside the chip. This multiplies the
external resonator speed by 4. Therefore the external resonator value to be used
is 1/4 of the desired final speed (ie in mode em40 use an external 10MHz
resonator, for em16 use a 4MHz resonator)"

So with an exteranal 16Mhz resonator, it makes no differance if you use the EM32 or EM64 command.
 

tmfkam

Senior Member
Do you mean 5000ppm frequency accuracy, which is usually quoted in parts-per million and that level of stability is usually quite easy to achieve. A crystal would easily achieve 10-20ppm or 10-20uHz. You need a lot of resolution to measure 50hz with that level of accuracy and usually can only achieve that with a time not frequency measurement.
The resolution of PulsIn (according to my calculations) at 50Hz is (with integer rounding applied) 3mHz with the processor running at 32MHz. That is within my +/- 5mHz. My problem is that the oscillator of the M2 processor is +/- 1% or 500mHz.

Sure about that, are you confusing Setfreq with calibfreq ?

Anyway, the internal resonator on PIC chips wont get close to the temperature stability of a crytal, so calibrating an M2 seems pointless unless you can keep it at a very stable temperature and supply voltage.
I did momentarily confuse SetFreq with CalibFreq. Sorry.

The reason I'm trying to find out how stable the external resonator is (or isn't) on the 28X2 (AXE201) is to determine whether it is more or less stable and accurate than the M2 internal resonator. If is no more or less accurate, I'll have to use a processor with a crystal oscillator as my reference. Once I have a reference, I can hopefully determine by what amount the M2 processors do or don't drift by. If the drift is too great then, again, I'll have to consider some other processor for my design.

No, you cannot adjust the PLL division, its as the manual says;

"Note that the X2parts have an internal x4 PLL inside the chip. This multiplies the
external resonator speed by 4. Therefore the external resonator value to be used
is 1/4 of the desired final speed (ie in mode em40 use an external 10MHz
resonator, for em16 use a 4MHz resonator)"

So with an exteranal 16Mhz resonator, it makes no differance if you use the EM32 or EM64 command.
The manual states that PulsIn is affected by the frequency, yet as far as I can tell, while using SetFreq on an M2 processor does alter the values returned by PulsIn, using SetFreq on the 28X2 (AXE201) has no effect on the values returned by PulsIn.
I see that the PLL multiplies the external resonator by four, so what does SetFreq do on the 28X2 (AXE201) to the frequency of operation?
 

hippy

Technical Support
Staff member
The manual states that PulsIn is affected by the frequency, yet as far as I can tell, while using SetFreq on an M2 processor does alter the values returned by PulsIn, using SetFreq on the 28X2 (AXE201) has no effect on the values returned by PulsIn.
SETFREQ sets the operating speed of the PICAXE and the operating speed determines the values returned by PULSIN; that is PULSIN measures in units of 10us at 4MHz, 5us at 8MHz, 2.5us at 16MHz, 1.25us at 32MHz, and 0.625us at 64MHz.

When used with an X2 and an external resonator you have to use "SETFREQ EMxx" where 'xx' is four times the resonator frequency, or use a "SETFREQ M..." option to use the internal oscillator rather than external resonator.

When using an external resonator and an "EM..." setting, the operating speed is actually set by the resonator not by the SETFREQ command. In such a case the "SETFREQ EM..." command has to match the resonator.
 

srnet

Senior Member
The reason I'm trying to find out how stable the external resonator is (or isn't) on the 28X2 (AXE201) is to determine whether it is more or less stable and accurate than the M2 internal resonator.
An external crystal will be more stable\accurate than the PICs internal resonator by a factor of 100 to 1000 or more.

The manual states that PulsIn is affected by the frequency, yet as far as I can tell, while using SetFreq on an M2 processor does alter the values returned by PulsIn, using SetFreq on the 28X2 (AXE201) has no effect on the values returned by PulsIn.
So when on the M2, you measure pulsin with say 'SETFREQ m4' set and then 'SETFREQ m8' and the vlaue recorded by pulsin changes as expected ?

But when you use 'SETFREQ m4' and 'SETFREQ m8' on the X2 the value recorded by pulsin does not change ?
 

tmfkam

Senior Member
If you are making a tool/meter, what would be the reasoning for NOT using a crystal?
Simply I don't have a PicAxe that accepts a crystal oscillator. I hoped that the resonator on the 28X2 (AXE201) might be more accurate than the internal resonator in the M2 devices and was wondering if there was any information regarding how the 28X2 (AXE201) with on board external resonator accuracy compared to the M2.
 

tmfkam

Senior Member
SETFREQ sets the operating speed of the PICAXE and the operating speed determines the values returned by PULSIN; that is PULSIN measures in units of 10us at 4MHz, 5us at 8MHz, 2.5us at 16MHz, 1.25us at 32MHz, and 0.625us at 64MHz.

When used with an X2 and an external resonator you have to use "SETFREQ EMxx" where 'xx' is four times the resonator frequency, or use a "SETFREQ M..." option to use the internal oscillator rather than external resonator.

When using an external resonator and an "EM..." setting, the operating speed is actually set by the resonator not by the SETFREQ command. In such a case the "SETFREQ EM..." command has to match the resonator.
Thanks for that.

If the SetFreq EM... is not four times the resonator, what would happen?
 

tmfkam

Senior Member
An external crystal will be more stable\accurate than the PICs internal resonator by a factor of 100 to 1000 or more.
But does that apply to the resonator that is fitted on the AXE201 module with the 28X2?

axe201.jpg
The resonator fitted can just be seen in front of the eight pin regulator.

So when on the M2, you measure pulsin with say 'SETFREQ m4' set and then 'SETFREQ m8' and the vlaue recorded by pulsin changes as expected ?

But when you use 'SETFREQ m4' and 'SETFREQ m8' on the X2 the value recorded by pulsin does not change ?
Correct.
The values returned on the 28X2 (AXE201) are consistent with an operating frequency of 64MHz despite the value of 'SetFreq' whether this is set to EM16, EM32 or EM64.

On the M2 devices it changes in accordance with the values given in the manual and as posted above by Hippy: "SETFREQ sets the operating speed of the PICAXE and the operating speed determines the values returned by PULSIN; that is PULSIN measures in units of 10us at 4MHz, 5us at 8MHz, 2.5us at 16MHz, 1.25us at 32MHz, and 0.625us at 64MHz."
 
Last edited:

hippy

Technical Support
Staff member
^ When you have a 16MHz resonator, the PICAXE operates at four times that when "SETFREQ EM..." is used, 64MHz, so you should be using "SETFREQ EM64".

Using "SETFREQ EM16" or "SETFREQ EM32" won't change the operating speed; it will still operate at 64MHz with a 16MHz resonator.

You can perhaps think of it this way -

SETFREQ M - Tells the PICAXE what speed it will run at

SETFREQ EM - Tell the user what resonator to fit and indicate what speed the PICAXE will run at with that resonator fitted.
 
Last edited:

tmfkam

Senior Member
^ When you have a 16MHz resonator, the PICAXE operates at four times that when "SETFREQ EM..." is used, 64MHz, so you should be using "SETFREQ EM64".

Using "SETFREQ EM16" or "SETFREQ EM32" won't change the operating speed; it will still operate at 64MHz with a 16MHz resonator.

You can perhaps think of it this way -

SETFREQ M - Tells the PICAXE what speed it will run at

SETFREQ EM - Tell the user what resonator to fit and indicate what speed the PICAXE will run at with that resonator fitted.
Many thanks. That would explain why it appeared to do nothing to the operation of the program.
 

srnet

Senior Member
But does that apply to the resonator that is fitted on the AXE201 module with the 28X2?
That resonator is a crystal, so unless its some form of crystal unknown to electronics, it will be massivly more stable than the internal resonator on a PIC.

Correct.
The values returned on the 28X2 (AXE201) are consistent with an operating frequency of 64MHz despite the value of 'SetFreq' whether this is set to EM16, EM32 or EM64.
Read what I actually said;

"But when you use 'SETFREQ m4' and 'SETFREQ m8' on the X2 the value recorded by pulsin does not change ?"

Note that there is a very big differance between 'SETFREQ m8' and 'SETFREQ em8'
 
Last edited:

tmfkam

Senior Member
That resonator is a crystal, so unless its some form of crystal unknown to electronics, it will be massivly more stable than the internal resonator on a PIC.
Now I wondered about that, but in the manual (section 1: page 36) it is clearly referred to as a resonator.

To Quote:
"AXE201/AXE200
The AXE201 and AXE200 are physically identical apart from chip and resonator:
AXE201
- PICAXE-28X2
- 16MHz resonator
(=64MHz operation)

AXE200
- PICAXE-28X2-5V - 8MHz resonator
(=32 MHz operation)"

Read what I actually said;

"But when you use 'SETFREQ m4' and 'SETFREQ m8' on the X2 the value recorded by pulsin does not change ?"

Note that there is a very big differance between 'SETFREQ m8' and 'SETFREQ em8'
Ahh... I see what you *said* and what I *read*...

With the unit having the external resonator, I only used 'SetFreq EM'. At no time did I try 'SetFreq M'. As I wanted maximum accuracy, I saw little point in using the internal resonator.

I don't doubt that SetFreq M would work for the reasons stated by Hippy. I was expecting SetFreq EM to have a similar effect by changing the PLL multiplication. Hippy has replied that SetFreq EM is purely for the programmer's benefit and has no effect on the speed of program execution as I was originally anticipating.
 
Last edited:

techElder

Well-known member
I found out some time back that the "resonator" is a package which includes a "crystal" and "capacitors" that you normally see drawn separately on schematics.

There may be different specifications of ppm drift, etc. than a separate crystal and capacitors that you can assemble yourself. Mostly to make it a cheaper alternative.
 

tmfkam

Senior Member
I think I mentioned that in post #4
You did, sorry for failing to credit you with that.

At that point, I'd failed to understand the correct useage of the SetFreq EM... command. Whilst I had read the section you quoted from the manual the significance of the SetFreq EM... command had failed to sink in. I was still anticipating SetFreq EM... to work in the same way as SetFreq M... but using the external resonator and not the internal resonator.
 

tmfkam

Senior Member
I found out some time back that the "resonator" is a package which includes a "crystal" and "capacitors" that you normally see drawn separately on schematics.

There may be different specifications of ppm drift, etc. than a separate crystal and capacitors that you can assemble yourself. Mostly to make it a cheaper alternative.
Thanks, I've seen those crystal and capacitor packs.

Above all, I was hoping someone might be able to point out the parts listing for the 28X2 (AXE201) from which I could determine the accuracy or otherwise of the resonator (or crystal) unit fitted so I could determine whether it was likely to be better (or worse) than an internal resonator in the M2 devices.
 

srnet

Senior Member
I found out some time back that the "resonator" is a package which includes a "crystal" and "capacitors" that you normally see drawn separately on schematics.

There may be different specifications of ppm drift, etc. than a separate crystal and capacitors that you can assemble yourself. Mostly to make it a cheaper alternative.
Those are ceramic resonators, normally 3 pin, centre pin ground and they include the two capacitors the PIC oscillator requires.

Cheaper and easier to use than a crystal, but not as accurate or stable.
 

srnet

Senior Member
Above all, I was hoping someone might be able to point out the parts listing for the 28X2 (AXE201) from which I could determine the accuracy or otherwise of the resonator (or crystal) unit fitted so I could determine whether it was likely to be better (or worse) than an internal resonator in the M2 devices.
It will be better, read my comments in posts #3,#8 and #14.

As you have a frequency counter, why dont you measure the differance ?
 

tmfkam

Senior Member
It will be better, read my comments in posts #3,#8 and #14.

As you have a frequency counter, why dont you measure the differance ?
Sadly my frequency counter is some way off accurate and the resonator pins are soldered underneath (some sort of SMD) as is the processor so near impossible to attach any connections to.

While this type of resonator/crystal/oscillator may be *better*, it is by how much it is *better* I'm trying to determine.
 

hippy

Technical Support
Staff member
While this type of resonator/crystal/oscillator may be *better*, it is by how much it is *better* I'm trying to determine.
The problem is that, beyond the raw specification, there is no specific *better* as that varies for each component. An on chip oscillator usually has an accuracy stated of around +/-1% and a resonator or crystal is better than that but a chip with an internal oscillator which just happens to have 0% inaccuracy is more accurate than a resonator with some inaccuracy no matter how small.
 

tmfkam

Senior Member
The problem is that, beyond the raw specification, there is no specific *better* as that varies for each component. An on chip oscillator usually has an accuracy stated of around +/-1% and a resonator or crystal is better than that but a chip with an internal oscillator which just happens to have 0% inaccuracy is more accurate than a resonator with some inaccuracy no matter how small.
It was the raw specification for the resonator I was hoping to find, to enable me to compare against the +/- 1%.
 

Goeytex

Senior Member
If the supplier cannot provide specs on the Resonator, then "best case" is 20PPM. But it is more likely likely that the part is an "economy import" and
rated at the more common ".5%".

For about a dollar you can get a 10 PPM 16MHz Crystal and a couple of caps.
 

srnet

Senior Member
3 pin reasonators vary a lot from maybe +\-0.5% to +\-0.02%.

Crystals are typically +\-0.001% to +\-0.005%, although TCXOs go down to circa +\- 0.000005%
 

hippy

Technical Support
Staff member
Resonators are available for a range of purposes commercial, industrial, automotive and others, often with standard and tighter tolerances with more or less frequency drift with temperature.

The rule of thumb for off the shelf components is an internal oscillator will be less accurate and drift more than a resonator which will usually be less accurate and may drift more than a crystal.
 

fernando_g

Senior Member
I checked a very popular, low cost ceramic resonator by Murata, (CSTLS8M00G53-B0) and the frequency stability is quoted as 0.2%, and the initial frequency tolerance of 0.5%
The advantage of using a ceramic resonance material is that the load capacitors may be easily integrated.

A proper quartz crystal would give you at least an order of magnitude better performance. You would have to fit the external loading caps.
 

tmfkam

Senior Member
Many thanks all. I may not have made my original request as clearly as I'd hoped. The resonator I'm referring to is already fitted to the 28X2 (AXE201) module. As I didn't specify it, I'm not in any position to say what make, model or tolerance it is. My hope was that someone could direct me to the information that would allow me to find out the make and model of the resonator so that I could evaluate the accuracy of the 28X2 (with the resonator - as already fitted to the AXE201 module), relative to the M2 processors with their internal resonators.

I thank everyone for their suggestions regarding the merits or otherwise of crystals over resonators and so on, but it was the specification of the *actual resonator unit already fitted* to the AXE201 module I was wanting to evaluate. Were I starting with a blank canvas, I would use a crystal and a processor with the facility for connecting one. Sadly I don't have any PicAxe units that have connections for external crystals (or resonators), all I have are a handful of M2 devices, and the one 28X2 (AXE201) pre-built module.

The resonator in question should anyone need similar information in the future seems to have been manufactured by Kyocera and comes from the PBRV-H/ PBRV-M/ PRQV Series. From the approximate dimensions, it looks as though it is either a PBRC-H or PBRV-H. Assuming this is correct, the tolerance varies from 0.1% to 0.5% depending of the type ordered.
 
Last edited:

fernando_g

Senior Member
Since the AXE201 is an general purpose prototyping board, my guess is that they would have used the lower cost option, in this case a 0.5% one.

Now, if this is not good enough for you, you can always order a better device, and replace the existing one on the board.
 
Top