Introduction: Bootloading and Mounting Arduino Atmega328 - I Made It at TechShop

About: Computer Engineering Undergraduate

This Instructable shows how to bootload and mount an Atmega328, Atmega328p or Atmega328p-pu for any project. This is a great way to save money by purchasing Atmega328 DIP package microcontrollers instead of using the Arduino development board itself. I put this together at techshop to be able to bootload microncontrollers for future applications they don't do a ton in electronics or programming but you can make some sweet gagets / enclosure there: http://www.techshop.ws!

You can purchase bootloaded Atmega328s from places like sparkfun but it's usually quite cheaper to get a non-bootloaded microcontroller. The Atmega328p-pu used in this instructable was purchased from tayda electronics for 3.50$, its a good place to buy many electrical components. All components except the wires and the arduino itself was purchased from http://www.taydaelectronics.com

I didn't make the code for the bootloading, I'm using the code offered at https://github.com/WestfW/OptiLoader

For required parts you will need:
Atmega328 Bootloading

1 - Arduino Uno with a bootloaded Atmega328
1 - Atmega328, Atmega328p or Atmega328p-pu
1 - 16MHz crystal
2 - 22pF Capacitor
1 - 10k ohm resistor
1 - breadboard
wires
Mounting Flashed Atmega328
1 - Atmega328, Atmega328p or Atmega328p-pu
1 - 16MHz crystal
2 - 22pF Capacitor
1 - 10k ohm resistor
1 - breadboard
5v DC power source or
DC power source above 5v with voltage regulator (Step 6)
wires
(optional parts)
1 - LED
1 - 220 ohm resistor
1 - pushbutton
1 - 10k ohm resistor
1 - 0.1uF capacitor


Step 1: Bootloading Schematic

With the parts required, this is the schematic for bootloading the Atmega328.

In some cases the 16Mhz crystal circuitry is not required if the Atmega328 registers are set to use the internal clock. But if you include the circuitry it wont matter either way. (so I just recommend including it anyways)

A possible issue: as you can see the VCC to the Atmega on the breadboard is powered by Digital pin 9. This could be a problem since it can only supply so much current to the breadboard. So do not add any other circuitry to this otherwise it may not work. The VCC is connected to pin 9 so the code can easily reset the microcontroller for programming.

Step 2: Bootloading Program

I'm using code from the source https://github.com/WestfW/OptiLoader

You need to make a program with a .ino file (arduino file) also a .h file (header file) and copy the code from the website.

I also included a zip file that has the program already.

Once you have this project made verify and upload to your Arduino.

If you want some feedback while the Atmega328 is being bootloaded you can connect a serial terminal to the Atmega328s serial TX pin (pin 3). To do this you will need a RS-232 to USB cable, and a terminal program like docklight or X-CTU. (This is not required)

Once the Atmega328 is bootloaded you can test it by taking the Atmega328 from the Arduino and replacing it with the recently bootloaded one. Try uploading a program to the new Atmega328 and see if it works! I would suggest uploading the blink program since no circuitry is required to see if its working.

Step 3: Bootloading Atmega328

That should complete it for bootloading yourself a new Atmega328!

If bootloading was unsuccessful you can reference the https://github.com/WestfW/OptiLoader readme. You can also try switching the pin 9 to VCC for powering the Atmega328.

I have done this bootloading multiple times with many microcontrollers. I would recommend getting the Atmega from tayda electronics  and getting the Atmega328p-pu. The Atmega328 is a higher power chip than the p/p-pu model so if your using that model the current from pin 9 may not be enough.

Step 4: Mounting a Flashed Atmega328

This part of the instructable is for mounting a Flashed Atmega328 (the chip has been bootloaded and programmed by the Arduino). 

In this instructable the blink program is flashed on to my Atmega328p-pu.

Note: The capacitor connected between VCC to Ground isn't needed and it isn't included in the schematic. (it's a 1uF capacitor)

Step 5: Mounting Atmega328 Schematic

Here is the schematic for mounting the Atmega328 onto a breadboard, in most cases if your making a project you will be mounting this onto a PCB or a prototyping board. 

The LED connected to digital pin 13 is not needed, but works as a good test to check and make sure your circuit works.

The circuitry for the RESET (pin 1) is also optional, if you dont want to include a reset button you must directly wire that pin to VCC. 

As you may notice there is no power source, this is because its optional what way you want to do it. The power to this circuit MUST be 5v. If you have a power source higher than 5v you can include a 5v voltage regulator in the circuit. (circuit example on next step).

Also in some cases if your using the analog pins you need to connect pin 21 to VCC.

The second picture is a schematic of the breadboard layout, the circuit is exactly the same. The external circuitry depends on what you have connected to the pins for your projects.

Step 6: Mounting Atmega328 Voltage Regulator

Here is a circuit example of using a voltage regulator.

ONLY NEEDED if your DC source is above 5v.

You can purchase a 5v Voltage Regulator from here:
http://www.taydaelectronics.com/ic-integrated-circuits/voltage-regulators/lm7805-l7805-7805-voltage-regulator-ic-5v-1-5a.html

The C1 and C2 capacitors depend on the voltage regulator your using. The Voltage Regulator's datasheet should tell what values the capacitors need to be. These capacitors are usually around 0.5uF to 0.1uF.

Step 7:

Here is the pin mapping for the Atmega328. (it says Atmega 168 but its also the same for Atmega328).

This picture is useful to reference if your not familiar with the pin layout of a DIP package.

Step 8: Conclusion

In most cases you will be mounting the Atmega328 onto a prototyping board and soldering it for projects. I suggest you get a 28 PIN DIP Socket for the microcontroller so it can be removed. You can purchase them here:
http://www.taydaelectronics.com/connectors-sockets/sockets/dip-sockets/28-pin-dip-ic-socket-adaptor-solder-type.html

I hope this instructable was helpful, following these processes is quite simple you just need the required parts! If you have any questions or problems feel free to ask or make suggestions!

LED Blink Test Youtube video:
http://www.youtube.com/watch?v=rGIme3vQol4&feature=youtu.be