I have read several tutorials showing how to run an Arduino Uno Atmega chip as standalone
after programming it on the Arduino board. My query is- Why do we need capacitors & 16MHz Crystal?
If I have grasped it correctly, the capacitors on the power-pins are required to remove
the DC ripple effect.
About the 16 MHz Crystal, I think Arduino Uno has 16MHz external clock & this Crystal
does that function on the standalone. However, the Atmega328 chip has an internal clock. Can I not use it, without the Crystal, on the standalone board?
You can eliminate the crystal and associated load capacitors if you change the fuses to select the internal 8 MHz RC oscillator. You can do this by selecting one of the 8 MHz boards (like "LilyPad Arduino w/ ATmega328") and burning a fresh bootloader. You will need an ISP to burn the bootloader.
The internal clock is limited to half the speed that is usually present on Arduino and is subject to inaccuracies if you have not calibrated it. But yes, it can be used (with a bootloader adapted for it), but timing-dependent stuff like serial communications might be unreliable.
Similarly, the power supply filter capacitor is not necessary per se, but it is very useful and improves reliability.
Thanks John, Fat D & Rob for replying. So the internal clock would require a new bootloader.
That doesn't help if one wishes to program the chip on-board & just place it on a PCB.
A new bootloader & a fuse select is needed for the internal clock to work.
Got it. So, primarily, the chip is dependant on the clock frequency that its corresponding
bootloader was burnt on.
johnwasser:
You can eliminate the crystal and associated load capacitors if you change the fuses to select the internal 8 MHz RC oscillator. You can do this by selecting one of the 8 MHz boards (like "LilyPad Arduino w/ ATmega328") and burning a fresh bootloader.
Unfortunately you'll need to modify the boards.txt file and change the fuse settings if you're using an ATmega328. The current 328 Lilypad entry expects an external 8MHz crystal.
Currently only the "LilyPad Arduino w/ ATmega168" will work "out of the box" with the internal oscillator.
An option which allows the arduino to work like an arduino without changing the fuses and is simpler than a crystal and capacitors is to use a 16Mhz ceramic oscillator (like the Uno). 1 component rather than 3 and no workarounds to get it working at half speed on the internal oscillator.
Just buy the resonator and skip the internal oscillator option
Now, that is a good idea. ... I should try that...
Most in my breadboard project, I only use a 16 MHz crystal, no 22 pF cap. But on a PCB version, I do have a crystal - 16 MHz and the 2 cap of 22 pF. For a reliability operation of my project... it is a must.
I just don't understand why you don't want to use it in your project....( I don't know your situation... )
I just don't understand why you don't want to use it in your project....( I don't know your situation... )
@Techone Nothing like that. I was just curious to know what was the need & what prevents the internal clock from being used as is. Beginners knowledge sake
Unfortunately this tutorial does not set a very good example. Two things that come to mind are the lack of decoupling capacitors at the IC power pins and the long wires between the crystal and the IC.
All true... But it does have a readily available Board.Txt file with all the fuses and settings for running at 8MHz without a crystal making the bootloading and fuses easy as pie....
If I have grasped it correctly, the capacitors on the power-pins are required to remove
the DC ripple effect.
No, the power supply capacitors are for decoupling - for logic circuits they prevent the high-speed(*) switching transients from all the 10,000's of transistors adding up on the supply rail and causing circuit misbehaviour - incorrect logic switching. Since the Arduino chip has analog inputs as well the decoupling also is very important in reducing analog noise. With high speed decoupling its important the capacitors are right next to the chips connected via a low impedance (low inductance) path - that means short fat wires/PCB-traces.
Often voltage regulators require a certain amount of capacitance on the output rail to be able to live up to their specifications. Typically you want 0.1uF ceramic caps next to each chip and 10uF to 100uF somewhere on the board for lower-frequency decoupling.
Inadequate decoupling shows up as unreliable behaviour, pattern sensitive and difficult to trace with a logic analyser or 'scope since monitoring the signals changes the high-speed transients that are causing the problem. It will drive you crazy trying to work out what's happening, so never skimp on decoupling.
Incidentally DC ripple should be handled by the voltage regulator circuit/chip.
(*) modern CMOS devices switch output pins in 1 to 10 nanoseconds, but internally some might be switching in 10's to 100's of picoseconds (and have local decoupling capacitors built onto the surface of the chip!).
@MarkT Wow. That was heavy I will have to read it several times more & cross-reference it with the help of Google Uncle before I fully understand it. Thanks all the same for willing to share your knowledge.