Having just gone through the process of designing and building my first Arduino-compatible PCB, I know very intimately two things. First, it’s not easy. The process is riddled with minor pitfalls that left me scratching my head. The second is that the documentation on the process is few and far between. It seems that there are many people asking for help installing firmware for custom boards, but few of them actually building their own boards.
Selecting a processor
There are a number of Arduino compatible microcontrollers out there. Even the official Arduino boards, use a variety of different microcontrollers. As someone who is still relatively new to Arduino, I highly recommend simply picking an existing board and modeling your board after it unless you are quite familiar with the Arduino firmware and are comfortable with the idea of porting and/or recompiling it.
In my case, I chose the Atmega32u4 which is a used by the Leonardo board and conveniently has an onboard USB controller. While not entirely necessary, having the built in USB controller will make programming this the “Arduino way†much simpler.
Designing the core microcontroller wiring
Each microcontroller, Atmega or otherwise, will have some minimum components or wiring that you’ll need to satisfy. While this information is detailed in the datasheet for the microcontroller, it is likely to be quite cryptic unless you make a habit or hobby of reading technical datasheets.
In general, you’ll need a stable power supply, a decoupling capacitor or two for good measure, and an ICSP breakout. Optionally you can add an external oscillator and/or a USB port which may require a USB controller if it is not included (as with the Atmega32u4).
The first resource you should lean on heavily for this step is the pin descriptions for your processor. For Atmegas, these are listed at the top of the data sheet and contains basic information on what the pin needs to be connected to.
Some of the pin descriptions can get a little cryptic, don’t be afraid to hunt down the more detailed information on that pin that comes later in the data sheet. Often these include different wiring diagrams for different configurations. Often the base requirements are very minimal but for many projects, depending on your requirements, it won’t be sufficient.
I’d highly suggest trying to find a bare-bones wiring diagram that someone else has designed for your processor. Here is one for the Atmega32u4 that I found with some Googling:
Here is the version I ended up using for the starting point for my projects.
Oscillator (AWSCR-16.00CV-T): The external oscillator is not necessary even for USB, the internal oscillator seems to function fine for most applications. That said, many of the boards I’ve seen use an external oscillator. At this point, I’m operating under the otherwise baseless assumption that the external oscillator is somehow a good idea. I suspect that it has something to do with the accuracy of the oscillator, but I don’t know enough about it to know for sure. The linked part includes the two capacitors shown in the Atmega32u4 datasheet.
22 Ohm resistor (MNR12ERAPJ220):Â This component is a bussed resistor. Because the two 22 Ohm resistors are right next to each other on the USB data lines, using a bussed resistor seems like a pretty good idea, though individual resistors will function just as well.
Diode D2 (MBR0520LT1G):Â This diode provides the ability to power your board via USB. This is again, not necessary, but exceedingly useful. Often I’ve found that projects will have their own power supply, but during development are ultimately more convenient to power via USB.
Once assembled, you should be able to connect an AVR ICSP to the ICSP port and use the Arduino IDE to “Burn Bootloader” while the “Leonardo” is selected. This will load the Arduino firmware and will enable programming via USB. There may be a way of loading the bootloader through USB by taking advantage of a built-in USB bootloader that I’ve seen mentioned a few places in the Atmega32u4 datasheet, but I have not tested this myself.
Please email me any comments, questions, or corrections you have about this post at julianh2o@gmail.com.