Pages: [1] 2   Go Down
Author Topic: What If?. (Regarding Crystals and Caps)  (Read 911 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Edison Member
*
Karma: 20
Posts: 2101
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Take any Atmel chip which relies on a 2 pin crystal oscillator.

You attach the 27pf caps, wire it all up correctly, upload and have it blink 1second of / 1 second off.

We now remove the 2 ceramic caps. (i've tried this)

In my test.

2 Attiny85s

1 Attiny, used the Caps and a 2 pin 20mhz crystal
2nd Attiny, used just the 20mhz crystal

The only visible difference was the LED's were starting to shift out of phase, maybe 1 - 2ms gain/loss every second..


But what i found interesting is the chip kept on working without the Caps.... I wish i tried to upload without the caps and just relying on the crystal now, so why
are the 2 ceramic low value cap's so vital in the role of time keeping?
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 331
Posts: 16459
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Take any Atmel chip which relies on a 2 pin crystal oscillator.

That is really a 2 pin crystal resonator. A crystal oscillator is a different animal. A crystal resonator plus the internal clock electronics inside a AVR chip creates a crystal controlled oscillator.

You attach the 27pf caps, wire it all up correctly, upload and have it blink 1second of / 1 second off.

We now remove the 2 ceramic caps. (i've tried this)

In my test.

2 Attiny85s

1 Attiny, used the Caps and a 2 pin 20mhz crystal
2nd Attiny, used just the 20mhz crystal

The only visible difference was the LED's were starting to shift out of phase, maybe 1 - 2ms gain/loss every second..


But what i found interesting is the chip kept on working without the Caps.... I wish i tried to upload without the caps and just relying on the crystal now, so why
are the 2 ceramic low value cap's so vital in the role of time keeping?

Because the marked frequency of the crystal resonator was manufactures based on it working with a specified fixed amount of external capacitance loading. Some of the capacitance loading comes from the internal capacitance of the clock pins of the AVR and the external 'padding capacitors' supply the rest. The crystal resonator will still oscillate at different cap loading values, but just not at the exact frequency it is marked at. So it still works but at a slightly different frequency, typically higher as you lesson the cap loading.
Lefty

Logged

Offline Offline
Edison Member
*
Karma: 20
Posts: 2101
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

ahhh, well out of curiosity, i went and just re-tried what i tried a few weeks back

I was wrong..


You CAN upload via ISP of an Arduino and flash the bootload and upload binaries, with nothing more than just a 20mhz crystal, no caps.
You CAN'T however run a sketch and have it run with just the 20mhz crystal, eg let's say pin 0 on/1000ms/0 off , what will happen is pin 0 will trigger high or low and not turn off, no idea what's going on here.

Interesting, to simply flash a new bootloader or upload a sketch, the Cap's don't appear to be needed!
Logged

Offline Offline
Full Member
***
Karma: 3
Posts: 244
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If he doing this on a solder-less bread board the board has capacitance
That let's the chip run but the same setup on a PCB will not run. Seen people do this.
Ive even seen the solder-less bread board load a crystal using caps remove them and it  runs fine.
Logged

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 118
Posts: 4534
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I've tried this and it works!!!

The 'Mythbusters' approach to science isn't always the best...

Logged

No, I don't answer questions sent in private messages...

Germany
Offline Offline
Faraday Member
**
Karma: 49
Posts: 2717
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
eg let's say pin 0 on/1000ms/0 off , what will happen is pin 0 will trigger high or low and not turn off

I'm specialist for silly errors:
What about a sketch like: pin 0 on/1000ms/0 off /1000ms
Perhaps that one works even with stray caps only smiley-wink
Logged

Offline Offline
Edison Member
*
Karma: 116
Posts: 2205
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
why
are the 2 ceramic low value cap's so vital in the role of time keeping?

You can upload / run a mcu without those caps, except that the clock will be off by 100ppm (for most crystals). That translates into about 10 seconds off every 24 hours, or 0.1ms per second.
Logged

Offline Offline
Edison Member
*
Karma: 20
Posts: 2101
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Apparently not so, i've tried smiley-razz (yes you can upload just fine).

Code:
/*
  Blink
  Turns on an LED on for one second, then off for one second, repeatedly.
 
  This example code is in the public domain.
 */
 
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 0;

// the setup routine runs once when you press reset:
void setup() {                
  // initialize the digital pin as an output.
  pinMode(led, OUTPUT);    
}

// the loop routine runs over and over again forever:
void loop() {
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);               // wait for a second
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);               // wait for a second
}

Uploaded to an Attiny85 using a 20mhz crystal no problems!

Running it however.... just a no go, the Pin stays high or low, it seems a little erratic.

Place the caps back, reset it, off it goes quite happily.
Logged

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 118
Posts: 4534
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Apparently not so, i've tried smiley-razz (yes you can upload just fine).

I don't think you need a clock for uploading a program.

(somebody correct me if I'm wrong...!)
Logged

No, I don't answer questions sent in private messages...

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 71
Posts: 3494
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Apparently not so, i've tried smiley-razz (yes you can upload just fine).

I don't think you need a clock for uploading a program.

(somebody correct me if I'm wrong...!)

A clock is required for ICSP programming and when using the bootloader.
Logged

MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 118
Posts: 4534
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

A clock is required for ICSP programming and when using the bootloader.

Sort of...

The datasheet says you need a clock input if the fuse bits have been set to 'external clock'. If the fuses are set for 'internal clock' then you don't need a crystal.

(This seems a bit silly - why not always use the internal clock when programming? That way it can never fail...)


Obviously some sort of clock is always needed for the bootloader it's a program running on the chip...

Logged

No, I don't answer questions sent in private messages...

0
Offline Offline
Shannon Member
****
Karma: 159
Posts: 10409
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
(This seems a bit silly - why not always use the internal clock when programming? That way it can never fail...)

Its probably that the relevant parts of the chip (clock source select and ICSP programming) aren't neighbours so
you'd have to route a signal all the way across the die to implement it (and this wasn't deemed a priority as the
chip comes from the factory with internal 8MHz clock pre-fused - the common case is programming the chip
once from factory-state during mass-production)
Logged

[ I won't respond to messages, use the forum please ]

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 118
Posts: 4534
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Its probably that the relevant parts of the chip (clock source select and ICSP programming) aren't neighbours

They don't have to be. The relevant signal comes from the RESET pin and that's connected all across the chip.

Logged

No, I don't answer questions sent in private messages...

Worst state in America
Offline Offline
God Member
*****
Karma: 23
Posts: 663
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Take any Atmel chip which relies on a 2 pin crystal oscillator.

You attach the 27pf caps, wire it all up correctly, upload and have it blink 1second of / 1 second off.

We now remove the 2 ceramic caps. (i've tried this)

In my test.

2 Attiny85s

1 Attiny, used the Caps and a 2 pin 20mhz crystal
2nd Attiny, used just the 20mhz crystal

The only visible difference was the LED's were starting to shift out of phase, maybe 1 - 2ms gain/loss every second..


But what i found interesting is the chip kept on working without the Caps.... I wish i tried to upload without the caps and just relying on the crystal now, so why
are the 2 ceramic low value cap's so vital in the role of time keeping?

I don't know what real good the capacitors do. I've built bare boards with replica Duemilanove boards and I never use the crystal loading caps.

Also, for what it's worth, I don't use the stock "low power crystal" fuse setting.... I use full swing. I get double the waveform height on the crystal, more immunity from stray capacitance (i.e. finger touching the board or wiring in a protoboard) and it draws a whopping 1 milliamp more.

If you want to do this, change "LOW FUSE" from 0xFF to 0xF7.
« Last Edit: December 13, 2012, 12:18:03 pm by Krupski » Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 220
Posts: 6587
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Apart from loading the crystal to get the correct frequency, the caps form a grounded centre-tap on the resonant circuit so that the signal inserted at one end is phase shifted by 180 degrees when it emerges at the other end. Look up Colpitts Oscillator on wikipedia.

If you don't connect the capacitors, you are relying on pin + stray capacitance, which will often work, but isn't guaranteed to. So you should always use the capacitors, unless you use a 3-terminal ceramic resonator instead of a crystal.
Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Pages: [1] 2   Go Up
Jump to: