Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Help with Crystal Values for a new comer to PIC's

Status
Not open for further replies.

Dawny

Member
I hope I’m posting this to the right thread…

As soon as my parts arrive I want to build a project based on a PIC, now at this point I should mention I’ve never tinkered with PIC’s before so I know nothing about them…

Ok my question is this… the circuit I want to build calls on a 13MHz Crystal the PIC in the circuit is a 16F870, which according to it’s datasheet can run up to 20MHz (correct me if you know I’m wrong) Anyway I was just wondering seeing I can’t find a 13MHz Crystal but I can find a 10 or 20MHz one could I replace the called for Crystal with one of the two I can get and if I do so, will that mean I have to change the code I’m meant to load onto the PIC (and is changing the code like what I’m asking even possible?)

I hope this makes sense.

Thank you in advance…

Dawn.
 
It depends why it uses such an unusual value?, the two most common frequencies used are 4MHz and 20MHz - presumably there's a good reason for it using a 13MHz one?.
 
Timing accuracy is usually the reason to use a crystal instead of the internal oscillator.

You can get a crystal or oscillator made specially for not too much money, or you can change to code to keep the timing correct with a different crystal.

If you tell us something about the application, we might be able to work out how critical the timing is.
 
You will need to get the specified crystal if you are not comfortable on modifying the original software of the PIC to use other more standard frequency crystals.

See the following quote from that website.

The accuracy of this counter is set by the frequency of the 13MHz crystal. I advice you to choose a good and stable crystal. In my case I use a very stable and accurate SMD 13.000MHz crystal.
 
You did not say where you live so it is difficult to let you know where to look for parts.

In the US I often use Mouser.

They have


Mouser's discription say 130MHz but in another column it lists the frequency as 13 MHz. The 130 must be a typo.

About $8

Post some pics when you get it working.
 
Okay going back to my first question and adapting it slightly in your opinions how hard would it be for me to change the code of the 16F870 to make it suitable with a 10MHz or 20MHz Crystal?

Dawn.
 
Dawny said:
Okay going back to my first question and adapting it slightly in your opinions how hard would it be for me to change the code of the 16F870 to make it suitable with a 10MHz or 20MHz Crystal?

Dawn.

Unfortunately, the author of the code has not made the source code available and this makes it almost impossible to change.

Mike.
 
oh well thank you anyway. Guess I should look for a differentfrequency counter that uses more common parts.

Dawn.
 
Or, write the author and ask for a different version. Some are more than willing.

Or, possibly easier, spend the 1.0 € for the specified crystal. He claims shipping is (1€ - 2.5€ Worldwide).
 
That reminds me I've got to finish the Frequency counter on the Dragonfly. Was much easier to use a 18F2525 as its got a gated timer.
**broken link removed**
 
It's probably best to tinker with PICs so that among other things (the thrill of making stuff happen) you may have some idea of what to do if something goes wrong. Now I realize that writing the code for this yourself is a bit far fetched at the moment.

It seems to me that a 13Mhz crystal was either something he had on hand and needed to get rid of or some tight code loop needs exactly the right crystal frequency. Using LEDs does place some overhead on the task, as does serial communication.

Were I to make one, which some day I hope to, I would used a timed interrupt every millisecond to read TMR1 and figure how far it has advanced since the last iteration. This will allow up to 65MHz, which is beyond the rating of TMR1's input of 50MHz. The external chip is a high speed divider, which is what I would use to get the high MHz or GHz range.

That much having been said, I recommend looking around for another project like this one. I believe you'll be able to find one that uses most of the same parts, except for a more common crystal.


After finding the above mentioned article independently when running another search, I thought about it more. This is the first one I've noticed that has an RF probe built in- wonderful if you're a radio enthusiast but may complicate using it some times.
 
Last edited:
Dawny said:

Dawny, I think you must to developing your own software, cause i think the guy who design this circuit have smart idea to used pll ic as prescaler, as we know the special prescaler ic have much price then pll ic that was used for this circuit. You can get lmx2322/lmx2346 for USD 2.5 from digikey and special prescaler ic can be USD 6-8.


I will give you a clue to do it, first you must set the ic pll as test mode, so you will get the N counter at the output cpo pin (at lmx2322) or LD pin (lmx2346). Download the datasheet and read it so you know what i mean.

And finally you will only need a routine to measure the frequency. I've try it, but i'm not good enough with tmr, sorry

By the way, i've stock for 13Mhz smd from ABracon.
 
For pic...

For pic it is better to use crystals of multiple of 4 MHz.

like 4 Mhz , 8 MHz , .... uptil 40 MHz depending on type of pic controller....

Better to start with 4 MHz.... it will be ok...

Avoid 12 MHz for better accuracy...

Regards,

Simran..:)
 
Dawny said:
Ok my question is this… the circuit I want to build calls on a 13MHz Crystal the PIC in the circuit is a 16F870, which according to it’s datasheet can run up to 20MHz (correct me if you know I’m wrong) Anyway I was just wondering seeing I can’t find a 13MHz Crystal but I can find a 10 or 20MHz ...

Thank you in advance…

Dawn.

Ok... if not able to get 13 MHz then use 12 MHz..

no problem... as too much accuracy is not required in your project ... it seems...

Ok,

it will work well with 12 MHz also...

I feel ... try... then only you'll learn....:eek:

Regards,

Simran..:)
 
simrantogether said:
Ok... if not able to get 13 MHz then use 12 MHz..
no problem... as too much accuracy is not required in your project ... it seems...
it will work well with 12 MHz also...
Huh? If she uses a 12Mhz crystal, without changing the code to compensate, the frequency counter will be out by 8% or so. ie a 100Mhz frequency will read as 108.33Mhz!
A quote from the author's page:
The accuracy of this counter is set by the frequency of the 13MHz crystal. I advice you to choose a good and stable crystal. In my case I use a very stable and accurate SMD 13.000MHz crystal. The crystal frequency can be fine tuned by a variable capacitor C11 to obtain very high accuracy.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top