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.

Choosing a crystal

Status
Not open for further replies.

Jerran

New Member
What do I need to look for when picking a crystal for a pic project, and can series cut crystals be used at all as microcontrollers clock?

I ordered 2 from Digi-key but think I can only use 1 of them with my pic.

crystal 1 CTX006-ND
4 MHZ hc-49, 20 pf <not really sure what they are refering to as 20 pf, possible what size of caps I should use>

crystal 2 CT062-ND
20 MHZ HC-49 series <dont think I can use this as a clock, some sites have indicated that series crystals may operate at a different speed then specified in a pic project.>
 

udi_hakim

New Member
The crystal is what makes the micro proccessor clock, without it it won't do anything.
You should mind the crystal speed in the following situations:

A) Serial communication with PC - for serial communication with the PC you need a set the baudrate of the communication, the crystal is a major component in the baudrate settings and if the baudrate will not feet to the PC standart you couldn't make a serial communication.
For the standart baudrates you need to use a 11.0592Mhz crystal.

B) Delay and timings - Lets say you made a 1ms delay with a 4Mhz crystal, if you'll change the crystal from 4Mhz to 8Mhz the delay you set to 1ms will turn to be 0.5ms.

C) If you are using the ADC option in the PIC i believe that the crystal also set the conversion time.

D) If you are sampling something from the inputs of the PIC the crystal also set the sampling time.

The most important things are the Serial communication and if you program the chip with somebody elses program that uses delays.
 

Jerran

New Member
cool good info udi_hakim. Im also interested in what physical characteristics to look for in a crystal. Crystals seem to vary widly from distributors and have alot of specifications listed. So I guess what Im asking is if I know I want a 20 Mhz crystal what type of 20 meg crystal do I need to look for. And what qualities makes 1 type of crystal of the same frequency better then another.
 

udi_hakim

New Member
There are basicly 3 types of crystals:

A) Standart crystals, these are the crystalst that everybody uses for uC...
**broken link removed**

B) Low profile crystal, its the same as the above just smaller:
**broken link removed**

C) Cylindrical crystal, also the same but size is very small and can be manufactured for low frequency, uses in the watches industry a lot.
**broken link removed**

E) This one is not a crystal but a full oscillator inside a metal case , its supply a very stable square wave, very good component if to use instead of an RC oscillator.
If you are using this one for you uC you should look in its specifications for connecting an oscillator instead of a crystal...
**broken link removed**

You can use either of the above but the cheapest solution is the standart crystal.
 

StupidDum

New Member
Jerran said:
What do I need to look for when picking a crystal for a pic project, and can series cut crystals be used at all as microcontrollers clock?
.....

There are 3 frequency of crystal oscillator that can be used on PIC, they are 4Mhz, 10Mhz, and 20Mhz.
Some model is meant for 4Mhz only, perhaps to save cost, it can be seen from the number on PIC. For example, PIC16F877-04
THe "04" stands for 4Mhz. Perhaps that is the reason the 20Mhz doesnt work on your pic.
 

ivancho

New Member
People chose a crystal and go on with their lifes.... normally a PIC takes 4Mhz and 20Mhz... and you can put probably anything else in between. Then put some 18pF to 33pF caps and voila!

But crystals are a little bit more complicated than that, and not to mention the stuff you can really have to considered that many people never really do. Like distance from the PIC, sugested trace width, etc. I was one running with some difficulties with a PIC not doing anything, after checking power, I realized that the cystal was not oscillating.... so I started looking up some information. And I found this to be very informational, is from Microchip **broken link removed** It will tell you more than what you wanted to know about crystals..... :wink: At the end I realized that I had 22uF caps instead of the 22pF duh! :oops:

Ivancho
 

TKS

New Member
question

soow if i'm getting it right..

the mhz you chuse have nothinh to do whit the cpu mhz..??/

TKS
 

diode

New Member
Re: question

TKS said:
soow if i'm getting it right..

the mhz you chuse have nothinh to do whit the cpu mhz..??/

TKS

The "Mhz you choose" have everything to do with the "CPU MHz".

If you have an external xtal of 20MHz (the mhz you choose) the PIC will work internally at 5Mhz (CPU MHz), it's always 1/4 of the quartz or external clock frequency (in PIC).

This in turn means that every cycle on the PIC will take 200nS (1/5MHz). Most operations in PIC are executed in 1 cycle (200nS in this case), except few (those that cause a jump as a rule of thumb) that always take 2 cycles (400nS in this case)
 

TKS

New Member
???

soow if i want the cpu (pic) to work at 20Mhz i should use a cristal of 80Mhz..???

TKS
 

Nigel Goodwin

Super Moderator
Most Helpful Member
Re: ???

TKS said:
soow if i want the cpu (pic) to work at 20Mhz i should use a cristal of 80Mhz..???

No, you use a 20MHz crystal, but the chip runs instructions at one quarter of that speed - it's important to know this to work out timings. Most other processors run even slower than one quarter!.
 

TKS

New Member
i don't get it...

lets say my cpu is a PIC16F877(a) in the specs they say 20Mhz...

i want it to run @ 20Mhz... i have to use a crystal of 20Mhz..

but my instructions run @ 1/4x20Mhz..???

is then the core speed still 20Mhz or how is this..??

TKS
 

Nigel Goodwin

Super Moderator
Most Helpful Member
Re: i don't get it...

TKS said:
lets say my cpu is a PIC16F877(a) in the specs they say 20Mhz...

i want it to run @ 20Mhz... i have to use a crystal of 20Mhz..

but my instructions run @ 1/4x20Mhz..???

is then the core speed still 20Mhz or how is this..??

This applies to all processors, the speed quoted is the clock speed the chip requires, not the speed it executes instructions at. The actual relation between clock speed and instruction speed varies greatly between different processors - the PIC runs particularly fast compared to others.

Going back many years, a 6502 clocked at 1MHz ran considerably faster than a Z80 clocked at 4MHz, just due to the design of the chips.
 

TKS

New Member
performance

mhh...

soow for maxiumum performance i should use a 20Mhz crystal (the maximum of the pic)

and then automaticly the core speed is also @ his maximum..

what about the AVR's??? they always seem to be much slower as a pic..???

12Mhz??/

TKS
 

Nigel Goodwin

Super Moderator
Most Helpful Member
Re: performance

TKS said:
mhh...

soow for maxiumum performance i should use a 20Mhz crystal (the maximum of the pic)

and then automaticly the core speed is also @ his maximum..

Yes, that's correct - assuming you want the maximum speed!. Most PIC processors spend the majority of their time in loops wasting time, so you don't often need the maximum speed anyway.

what about the AVR's??? they always seem to be much slower as a pic..???

12Mhz??/

I've never used them, but I was under the impression that they ran faster than PIC's - there are a fair few AVR users on these forums, no doubt they will respond 8)
 

Exo

Active Member
AVR's have a bigger instruction set, so many things can be solved with less instructions then you would need on a pic. This makes it run 'faster'...

If you use a µC for what it is supposed to, controlling things, then you don't even need the top speed of a pic for most projects...

If you need a number cruncher then get a CPU design, not a µC
 
I have jst submited a PCB layout to technician, but i have forgotten to include capacitors after the XTAL 20 MHz.

Any solution to rectify this situation? will the PIC16F877 still work, even without the capacitors?
 

Nigel Goodwin

Super Moderator
Most Helpful Member
janetsmith2000@yahoo.com said:
I have jst submited a PCB layout to technician, but i have forgotten to include capacitors after the XTAL 20 MHz.

Any solution to rectify this situation? will the PIC16F877 still work, even without the capacitors?

It 'might' oscillate, but it probably won't :cry:

If the boards can't be altered, hang the capacitors on the back of the board - it's a common technique, particularly among Japanese manufacturers.
 

CoTang

Member
Capacitor

I recently purchased some smt crystal from digikey, on it it states the speed and also a capacitor value. ex. "CRYSTAL 4.000 MHZ 18PF" Now what is the 18PF does that mean I HAVE to use 18pf cap to have it running? and will that affect my PIC?
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Top