Author Topic: how close does a clock crystal have to be to the MCU  (Read 8521 times)

0 Members and 1 Guest are viewing this topic.

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 17943
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
how close does a clock crystal have to be to the MCU
« on: November 09, 2012, 10:46:15 pm »
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 ?
 

Offline mrflibble

  • Super Contributor
  • ***
  • Posts: 2051
  • Country: nl
Re: how close does a clock crystal have to be to the MCU
« Reply #1 on: November 10, 2012, 02:01:42 am »
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...
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 17943
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: how close does a clock crystal have to be to the MCU
« Reply #2 on: November 10, 2012, 07:46:59 am »
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 too  ;D would 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.
 

Offline David_AVD

  • Super Contributor
  • ***
  • Posts: 2858
  • Country: au
Re: how close does a clock crystal have to be to the MCU
« Reply #3 on: November 10, 2012, 08:51:50 am »
I always locate the resonator (or crystal) as close as practically possible to the micro.  Usually less than 10mm of trace on each pin.
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 17943
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: how close does a clock crystal have to be to the MCU
« Reply #4 on: November 10, 2012, 08:56:50 am »
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  8)
 

Offline SeanB

  • Super Contributor
  • ***
  • Posts: 16362
  • Country: za
Re: how close does a clock crystal have to be to the MCU
« Reply #5 on: November 10, 2012, 11:17:05 am »
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.
 

Offline Bored@Work

  • Super Contributor
  • ***
  • Posts: 3932
  • Country: 00
Re: how close does a clock crystal have to be to the MCU
« Reply #6 on: November 10, 2012, 11:37:15 am »
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.




I delete PMs unread. If you have something to say, say it in public.
For all else: Profile->[Modify Profile]Buddies/Ignore List->Edit Ignore List
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 17943
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: how close does a clock crystal have to be to the MCU
« Reply #7 on: November 10, 2012, 12:06:39 pm »
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 ?
 

Offline SeanB

  • Super Contributor
  • ***
  • Posts: 16362
  • Country: za
Re: how close does a clock crystal have to be to the MCU
« Reply #8 on: November 10, 2012, 12:31:12 pm »
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.
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 17943
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: how close does a clock crystal have to be to the MCU
« Reply #9 on: November 10, 2012, 12:48:47 pm »
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
 

Offline mrflibble

  • Super Contributor
  • ***
  • Posts: 2051
  • Country: nl
Re: how close does a clock crystal have to be to the MCU
« Reply #10 on: November 10, 2012, 12:59:04 pm »
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.

Seconded. 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.
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 17943
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: how close does a clock crystal have to be to the MCU
« Reply #11 on: November 10, 2012, 01:04:32 pm »
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
 

Offline mrflibble

  • Super Contributor
  • ***
  • Posts: 2051
  • Country: nl
Re: how close does a clock crystal have to be to the MCU
« Reply #12 on: November 10, 2012, 01:32:24 pm »
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. ;)
 

Offline mikeselectricstuff

  • Super Contributor
  • ***
  • Posts: 13914
  • Country: gb
    • Mike's Electric Stuff
Re: how close does a clock crystal have to be to the MCU
« Reply #13 on: November 10, 2012, 02:14:16 pm »
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.
Youtube channel:Taking wierd stuff apart. Very apart.
Mike's Electric Stuff: High voltage, vintage electronics etc.
Day Job: Mostly LEDs
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 17943
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: how close does a clock crystal have to be to the MCU
« Reply #14 on: November 10, 2012, 02:30:13 pm »
I guess that is an option, I was hoping to make a fully flexible platform but i guess i can't break physics  |O

will "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
 

Offline electrode

  • Regular Contributor
  • *
  • Posts: 141
  • Country: au
Re: how close does a clock crystal have to be to the MCU
« Reply #15 on: November 18, 2012, 02:43:26 am »
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...
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 17943
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: how close does a clock crystal have to be to the MCU
« Reply #16 on: November 18, 2012, 08:07:23 am »
here we are
 

Offline iiKoe

  • Newbie
  • Posts: 1
  • Country: nl
Re: how close does a clock crystal have to be to the MCU
« Reply #17 on: November 18, 2012, 01:24:42 pm »
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.pdf page 24
http://www.qsl.net/pa3ckr/bascom%20and%20avr/avr%20clock/index.html
 

Offline ptricks

  • Frequent Contributor
  • **
  • Posts: 672
  • Country: us
Re: how close does a clock crystal have to be to the MCU
« Reply #18 on: November 18, 2012, 01:35:31 pm »
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.
 

Offline NiHaoMike

  • Super Contributor
  • ***
  • Posts: 9184
  • Country: us
  • "Don't turn it on - Take it apart!"
    • Facebook Page
Re: how close does a clock crystal have to be to the MCU
« Reply #19 on: November 18, 2012, 04:16:59 pm »
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.
Cryptocurrency has taught me to love math and at the same time be baffled by it.

Cryptocurrency lesson 0: Altcoins and Bitcoin are not the same thing.
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 17943
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: how close does a clock crystal have to be to the MCU
« Reply #20 on: November 18, 2012, 05:51:21 pm »
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.pdf page 24
http://www.qsl.net/pa3ckr/bascom%20and%20avr/avr%20clock/index.html

this 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.
 

Offline NiHaoMike

  • Super Contributor
  • ***
  • Posts: 9184
  • Country: us
  • "Don't turn it on - Take it apart!"
    • Facebook Page
Re: how close does a clock crystal have to be to the MCU
« Reply #21 on: November 23, 2012, 12:04:40 am »
Put a crystal socket at every position that it can be used in along with jumpers to isolate the I/O.
Cryptocurrency has taught me to love math and at the same time be baffled by it.

Cryptocurrency lesson 0: Altcoins and Bitcoin are not the same thing.
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 17943
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: how close does a clock crystal have to be to the MCU
« Reply #22 on: November 23, 2012, 07:28:12 am »
doesn't that add a lot of "wire" length ?
 

Offline hlavac

  • Frequent Contributor
  • **
  • Posts: 536
  • Country: cz
Re: how close does a clock crystal have to be to the MCU
« Reply #23 on: November 25, 2012, 02:58:53 pm »
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?

Good enough is the enemy of the best.
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 17943
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: how close does a clock crystal have to be to the MCU
« Reply #24 on: November 25, 2012, 04:55:14 pm »
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.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf