how close does a clock crystal have to be to the MCU - Page 1
Forum section: electronics / general

author: Simon
author_rank: Unknown
timestamp: November 09, 2012, 10:46:15 pm
content: I'm chucking together a development board on veroboard for microcontrollers, a few leds, pots, switches that sort of thing. I'll put a 20MHz crystal on there too, how close does this need to be ? I was going to use molex connector sockets next to stuff so that I can use breadboard jumper wires on. so how long a wires can i use ?

author: mrflibble
author_rank: Super Contributor
timestamp: November 10, 2012, 02:01:42 am
content: I'd say about an inch should be doable. That way you don't have to worry about it being too far, and should give you enough wiggle room for component placement...

author: Simon
author_rank: Unknown
timestamp: November 10, 2012, 07:46:59 am
content: looks like I need to do a plugin module that plugs into the chip's header to get as close as possible. All pic's have the 2 oscilator pins next to each other don't they ?, infact I could put suitable pins on the module so that it can go into the zif socket toowould I correctly assume that the earth wire can be a bit longer and that it is the crystal to chip wires that need to be short.

author: David_AVD
author_rank: Super Contributor
timestamp: November 10, 2012, 08:51:50 am
content: I always locate the resonator (or crystal) as close as practically possible to the micro. Usually less than 10mm of trace on each pin.

author: Simon
author_rank: Unknown
timestamp: November 10, 2012, 08:56:50 am
content: except in this case I am using a 40 pin zif socket with 2 rows of molex headers down each side and the crystal is an optional thing and needs to move around for the correct pins on each micro. So I'm thinking that I'll put the crystal on a tiny board of it's own that will either plug into the relevant pins on the molex connector or have short wires so that it can sit on the chip and the wires drop into the zif socket with the CLK pins, can't get close than that

author: SeanB
author_rank: Super Contributor
timestamp: November 10, 2012, 11:17:05 am
content: The ground wire has to be low inductance. So either it is short or it is wide and flat. Remember it has considerable current flowing in it at the crystal operating frequency.

author: Bored@Work
author_rank: Super Contributor
timestamp: November 10, 2012, 11:37:15 am
content: This sounds more like a one-off than a product. So if the MCU can take an external clock signal I would use an external crystal oscillator (as opposite to a simple crystal). They cost a bit more, but have more omphf to drive some (properly laid out) PCB tracks.

author: Simon
author_rank: Unknown
timestamp: November 10, 2012, 12:06:39 pm
content: correct, this is a one off on veroboard. I'm throwing together my own development platform, a zif socket for any MCU, a couple of pots, bank of dip switches and some LEDs. So things are not too close together but it will make it easy for me to play with code and test it out, which is why i wanted a proper crystal module just like I'd have in the final circuit so that I can verify that I've set it all up right.The crystal goes between the 2 pins of the pic and there are just some small capacitors going to ground, does that much really flow ?

author: SeanB
author_rank: Super Contributor
timestamp: November 10, 2012, 12:31:12 pm
content: You will be surprised at how little noise will make the oscillator either unreliable or jittery. remember that the power is limited, and the input is quite sensitive to noise. Even 1cm of thin trace at 20mHz will make it an issue, there needs to be a ground plane between the oscillator and the MCU ground and the supply decoupling. Feed in an output from an external oscillator module and place a resistor in line at the pin, 330R or so, and a 15pF cap at the oscillator out as loading. This will emulate the crystal load well enough with little noise issues.

author: Simon
author_rank: Unknown
timestamp: November 10, 2012, 12:48:47 pm
content: hm best I can do it put the shortest wire possible and plug into the nearest ground pin next to the zif socket. Maybe have to make a module for each pin count pic so that it can plug in over the top of the pic

author: mrflibble
author_rank: Super Contributor
timestamp: November 10, 2012, 12:59:04 pm
content: Quote from: Bored@Work on November 10, 2012, 11:37:15 amSeconded. In fact, that was what I was assuming the OP was using on auto-pilot... Those oscillator modules are cheap enough that they are well worth it for a one off. Saves you the hassle of non-interesting crap to debug.

author: Simon
author_rank: Unknown
timestamp: November 10, 2012, 01:04:32 pm
content: yes but my idea was to make a development board that can mimick as closely as possible the final product, yes this is a one off on veroboard

author: mrflibble
author_rank: Super Contributor
timestamp: November 10, 2012, 01:32:24 pm
content: Well in that case put the XO right next to the mcu because (presumably) on the finished product you put that sucker right next to the mcu.

author: mikeselectricstuff
author_rank: Super Contributor
timestamp: November 10, 2012, 02:14:16 pm
content: if you're putting the MCU in a ZIf I'd suggest you solder the xtal and caps direct to the MCU pins, and cut the pin ends to the osc pins don't even connect to the ZIF or rest of the board.

author: Simon
author_rank: Unknown
timestamp: November 10, 2012, 02:30:13 pm
content: I guess that is an option, I was hoping to make a fully flexible platform but i guess i can't break physicswill "extra" pin/leads be a problem ? I could easily do a small board with wires dropping off the bottom that go into the zif socket with the pic

author: electrode
author_rank: Regular Contributor
timestamp: November 18, 2012, 02:43:26 am
content: Maybe poke all your components into the veroboard (without soldering) and post a pic of what you're proposing to do?It doesn't seem like there should be a problem, even with relatively long wires – unless something magical happens when you jump to 20 MHz from the 16 MHz I usually work with...

author: Simon
author_rank: Unknown
timestamp: November 18, 2012, 08:07:23 am
content: here we are

author: iiKoe
author_rank: Newbie
timestamp: November 18, 2012, 01:24:42 pm
content: Hello,The problem with the long leads on an external crystal is the EMI. This will add a reasonable bit of noise to your clock signal. And this will make your board rather unstable (and that probably won’t be appreciated by consumers).Wat you can do, to be a bit less EMI sensitive, is to use a Crystal Oscillator Module. These are much less EMI sensitive, and if you can then keep the wires as short as possible, you would probably be able to solder the clock on de Vero board itself, and just connect a jumper wire to the pin.It would probably make your board more stable than using an external crystal and then using wires. But this is theoretical, I haven't tested any of this, its just an idea.Sources:http://cache.freescale.com/files/microcontrollers/doc/app_note/AN2764.pdfpage 24http://www.qsl.net/pa3ckr/bascom%20and%20avr/avr%20clock/index.html

author: ptricks
author_rank: Frequent Contributor
timestamp: November 18, 2012, 01:35:31 pm
content: I have made , lost count on the number, perfboard type MCU boards and they can be fairly forgiving on distance from the clock. I don't put it further away than the leads that are on the crystal can reach and keep the path as straight as possible.Really the only problem I have had with wire length to clock sources has been when doing some USB stuff.

author: NiHaoMike
author_rank: Super Contributor
timestamp: November 18, 2012, 04:16:59 pm
content: Use an oscillator module, route the clock in a loop around the socket, take off taps with a 100R or so series resistor (with jumpers to disconnect unused taps), and put a 100R+100p or so snubber on the end of the loop.

author: Simon
author_rank: Unknown
timestamp: November 18, 2012, 05:51:21 pm
content: Quote from: iiKoe on November 18, 2012, 01:24:42 pmthis is not for customers but for me to play with. and to the other replies, no I'd rather not use an oscillator as I'm trying to replicate final conditions but I can consider it.

author: NiHaoMike
author_rank: Super Contributor
timestamp: November 23, 2012, 12:04:40 am
content: Put a crystal socket at every position that it can be used in along with jumpers to isolate the I/O.

author: Simon
author_rank: Unknown
timestamp: November 23, 2012, 07:28:12 am
content: doesn't that add a lot of "wire" length ?

author: hlavac
author_rank: Frequent Contributor
timestamp: November 25, 2012, 02:58:53 pm
content: As you have noted, the crystal pins are usually next to each other, and next to them is usually ground.What I do is use a small 3pin bit of pin header and solder the crystal to it along with the two loading capacitors. Then I just plug this into the breadboard next to the microcontroller.Maybe you could do something similar, put two 1x20 pin header sockets on the sides of the zif socket to plug this into, connect to zif pins?

author: Simon
author_rank: Unknown
timestamp: November 25, 2012, 04:55:14 pm
content: that is a good point, if the oscilator pins and one GND pin always have the same pattern i can indeed have a universal module to plug in.