SparkFun Forums 

Where electronics enthusiasts find answers.

Questions relating to designing PCBs
By smdFan
#50537
Hi there,

Why people use oscillators with AVR microcontrollers?


Why they choose different values of oscillators?


What are the considerations when installing a oscillator on PCB? any pitfalls? Should they be closer to AVR? away from power line and source?


I need some tips about this. Thanks



Regards
User avatar
By leon_heller
#50539
smdFan wrote:Hi there,

Why people use oscillators with AVR microcontrollers?


Why they choose different values of oscillators?


What are the considerations when installing a oscillator on PCB? any pitfalls? Should they be closer to AVR? away from power line and source?


I need some tips about this. Thanks



Regards
MCUs don't work unless they have an oscillator.

The oscillator frequency used in a particular design is a trade-off between performance and power consumption. Sometimes a specific value is needed that divides down to give standard baud rates for serial comms.

An oscillator module can be some distance from the MCU. Oscillator crystals and their capacitors need to be as close as possible to the MCU.

Leon
By smdFan
#50543
leon_heller wrote:
smdFan wrote:Hi there,

Why people use oscillators with AVR microcontrollers?


Why they choose different values of oscillators?


What are the considerations when installing a oscillator on PCB? any pitfalls? Should they be closer to AVR? away from power line and source?


I need some tips about this. Thanks



Regards
MCUs don't work unless they have an oscillator.

The oscillator frequency used in a particular design is a trade-off between performance and power consumption. Sometimes a specific value is needed that divides down to give standard baud rates for serial comms.

An oscillator module can be some distance from the MCU. Oscillator crystals and their capacitors need to be as close as possible to the MCU.

Leon

Thanks Leon.

Suppose you have a microcontroller run by a 3 V battery. The microcontroller is supposed to run for the life of the battery. So what would be the maximum frequency of the oscillator.
Is there some kind of formula to calculate the max freq. of oscillator you can use for a particular battery?

You mentioned that w/o oscillators, the MCU will not operate. How about the internal oscillator of the MCU?

Thanks

Regards
User avatar
By leon_heller
#50547
You need to read the MCU data sheet for that information.

Many MCUs have an internal oscillator but it isn't stable enough for many applications.

Leon
By muntron
#50581
leon_heller wrote:MCUs don't work unless they have an oscillator.
Many MCUs have built in oscillators. The primary benefit is that this reduces component count. The disadvantages includes accuracy and frequency. If you require higher performance and or oscillator accuracy, you have to add an external oscillator to your circuit.
By smdFan
#50593
muntron wrote:
leon_heller wrote:MCUs don't work unless they have an oscillator.
Many MCUs have built in oscillators. The primary benefit is that this reduces component count. The disadvantages includes accuracy and frequency. If you require higher performance and or oscillator accuracy, you have to add an external oscillator to your circuit.

What are the most common frequencies of oscillators used along with AVR microcontrollers?

Regards
User avatar
By leon_heller
#50598
Impossible to say.

Leon
By smdFan
#50600
leon_heller wrote:Impossible to say.

Leon

A couple of years ago when I was dealing with AVRs, I think I would notice 4 MHz and 8 MHz a lot. But I am not sure




.
User avatar
By bigglez
#50603
Greetings smdFan,
smdFan wrote: Why people use oscillators with AVR microcontrollers?
(1) Some uC devices do not have internal (RC) oscillators. (2) Internal oscillators have lower accuracy than external ones.
smdFan wrote:Why they choose different values of oscillators?
Power consumption id directly proportional to clock speed.
Slowing the uC will extend battery life. Some oscillators have "magic"
numbers that when divided down provide industry standard timing
(for serial data comms) or accurate RTC (Real Time Clock) values.
An oscillator with a binary-weighted value requires fewer components
to divide down to a standard frequency. Example: a "32kHz"
crystal is really 32.768KHz, when divided by 2^15 (i.e.
fifteen binary counter stages with no feedback) you will get
1pps (one pulse per second). Used in all digital watches and clocks!
smdFan wrote:What are the considerations when installing a oscillator on PCB? any pitfalls? Should they be closer to AVR? away from power line and source?
Depends if the "oscillator" is analog or
digital. A digital oscillator is a packaged device with all the
analog parts inside, and only supply, ground, and a digital output
pin. The device can be placed "anywhere", but will work
better away from varying temps (power resistors, ICs, etc).

A crystal or resonator requires the internal analog circuits
of the IC (uC in this case). The leads should be very short,
attention paid to both shunt capacitance and short ground
path returns. No other signals (even power and ground) should
pass under or near the crystal and it's loading capacitors.
The capacitors should be NPO types. If the PCB has a
ground or power plane that should be removed under the
crystal and associated traces.

Comments Welcome!
By winston
#50699
bigglez wrote: The capacitors should be NPO types. If the PCB has a
ground or power plane that should be removed under the
crystal and associated traces.
Taking a straw poll of various bits of hardware lying around here, I notice some do and some don't. The 3com 3c905 ethernet card has the ground plane removed under the crystal (actually, I think it's an oscillator, a 4 pin device) for both the 25MHz and 20MHz devices.

However, the Intel ethernet card I have here *does not* have the ground plane removed around the timing device (which I think again is an oscillator rather than a crystal).

I've seen other designs where people have a ground plane under a crystal, and other designs where the ground plane was removed.

On reading up about it, when I designed my ethernet board, I removed the ground plane under the crystal/traces to the MAC/PHY. In the layout guide from the chip manufacturer, they admonished you to keep the xtal lines away from the analogue power supply, but they put a 1.8v analogue supply pin *right next* to the crystal input, forcing you to bring the 1.8v supply close to the traces from the crystal! (The best I could do is steer the 1.8Va trace away from the xtal traces as soon as it left the pad). The board works well, so I suppose I must have got it right enough :-)

Presumably, in the case of a 4-pin crystal oscillator in a can, there's no need to drop out the ground plane around the output trace from the oscillator - why might the designer of the 3c905 PCB have dropped the ground plane out around the oscillator, but the Intel designer not? (Surely an oscillator will have a fairly low impedance output).

Generally, how close is considered best practise? For my ethernet board, I got it in as close as possible, which resulted perhaps in a trace length of around 7mm. What about the trace lengths - I presume it's best practise to get the length of the two traces as close as possible to being the same (forgive me if this sounds like a stupid question, I'm a hobbyist not an engineer!)
User avatar
By leon_heller
#50700
Differences in track length won't have any effect - try calculating the wavelength of the clock frequency.

Leon
By winston
#50745
Well, I was thinking more of parastic inductance and capacitance. What had me thinking about this was the manufacturer's layout guide advising that track lengths from the ethernet transformer to the chip are kept as similar as possible. With 100baseTX only having a fundamental frequency of 31.25 MHz, I presumed it was so the parasitic inductance/capacitance on each PCB trace was similar rather than timing issues.
User avatar
By leon_heller
#50747
That's more to do with impedance and VSWR. It doesn't matter with oscillators.

Leon
User avatar
By bigglez
#50759
Greetings Leon,
leon_heller wrote:Differences in track length won't have any effect - try calculating the wavelength of the clock frequency.
Differences in track (trace) length will have a significant
effect on timing skew. That is why memory and processor
PCB design requires accurate trace length matching.
The Rule Of Thumb propagation speed of FR-4 PCB material
(most common) is 6ins per nanosecond. (About 1/4 the
speed of light). To delve deeper into this theory here's a
very useful reference.

It might also help to read the Wikipedia entry for Transmission Lines,
or review the RSGB Handbook.

There is a more rigorous treatment for PCB Striplines here.

Comments Welcome!
User avatar
By bigglez
#50760
Greetings Leon,
leon_heller wrote:That's more to do with impedance and VSWR. It doesn't matter with oscillators.
I'm with Winston on this one. The parastitic capacitance
of even a short PCB trace will affect a crystal. Even a
low frequency unit (popular 32KHz for example). The
crystal is tuned at the factory for a reference capacitance,
adding to it will pull the crystal lower. A typical load
capacitance standard is 20pF, which doesn't leave much
room for poor PCB design.

The dielectric constant of fiberglass/epoxy is 4.0 to 5.5
for FR-4, creating a capacitance of approximately 200
picoFarads per square inch.
See United States Patent 5469324, Integrated decoupling
capacitive core for a printed circuit board and method
of making same
.

The second issue is that crystal drive circuits are
high impedance, low power, and suceptible to RF/EMI
interference, which only increases with larger antenna
(PCB trace) area.

Comments Welcome!
long long title how many chars? lets see 123 ok more? yes 60

We have created lots of YouTube videos just so you can achieve [...]

Another post test yes yes yes or no, maybe ni? :-/

The best flat phpBB theme around. Period. Fine craftmanship and [...]

Do you need a super MOD? Well here it is. chew on this

All you need is right here. Content tag, SEO, listing, Pizza and spaghetti [...]

Lasagna on me this time ok? I got plenty of cash

this should be fantastic. but what about links,images, bbcodes etc etc? [...]