Imagine having your own custom made development boards for rapid prototyping of projects. Sounds exciting right? This set of tutorials will give you step by step guidelines on fulfilling these desires. In this write up I have assumed the reader has some electronics skills.
In order to make this tutorial less ambiguous, I have divided it into 5 major parts:
- Part 1: The End in view
- Part 2: Schematic diagram design
- Part 3: PCB design on KiCAD
- Part 4: Ordering PCBs from jlcpcb
- Part 5: Taking a step further.
Some months ago I developed some interests in the ATmega 328P microcontroller but I did not know just what to start with. As an electronics hobbyist, I tried to find projects on how to build a custom development board but what I saw online was not complete so I decided to put the missing pieces together.
Building a development board requires a great deal of planning and research. First, you need to keep the end in view. You need to ask yourself these crucial questions:
"What functions do I want to achieve with this board? Control or heavy processing ?"
For me, control was more important at that time than heavy processing hence 8-bit microcontrollers were perfect for the job. For heavy processing, I would recommend using some 32-bit microcontrollers like the STM32 series. Sometimes having a multi-core microcontroller gives you an upper edge in heavy processing.
"What kind of communication interfaces would be required (e.g. SPI, I2C, UART, USB etc) ?"
The basic communication interfaces I needed at that time were SPI, I2C, UART. In other to use other interfaces like USB you can check out the ATmega32U4 used in the Arduino Micro. Other communication interfaces are like Controller Area Network (CAN) are available on STM32 chips
"What kind of application is my board suited for?"
Application ranges from low power ones like wearables (e.g. smart wrist watches) to those that are power-intensive. It could also depend on the functionality required. For example, if your application requires some sound processing, you may use a microcontroller that supports digital signal processing (DSP).
Make notes of the software and hardware requirements of the board. A block diagram which is like the black box of your design is a great point to start from.
"How about the physical characteristics of the board?"
The physical characteristics of the board is also a key component in the planning stage. Characteristics like size or shape can also affect your choice of components. For example, using DIP components may take up more space than their SoC counterparts. You do not want to design a product and later discover that the shape or size did not match the product you had in mind.
Next, you need to determine what kind of microcontroller you would need to act as the brain of your board. In addition to the requirements listed above, I chose ATmega 328P microcontroller for the following reasons:
- High performance 8-bit microcontroller.
- It has support for power-on reset and programmable brown-out detection.
- Low power consumption.
- Supports some communication interfaces like SPI, I2C UART
- It has a vast community and a lot of DIY projects accrued to it.
- It was used by the open-source hardware known as the Arduino Uno. Thus, I could program it directly from the Arduino IDE.
After deciding what microcontroller to use, you should then check the datasheet corresponding to it to have further insights as to the working principle of the microcontroller. The datasheet at first sight may look clumsy and filled with too many information. This may deter and reduce your interest but you should also note that the datasheet is like a manual for the microcontroller you're dealing with. Not knowing some peculiar and important details of that microcontroller may make all your efforts futile at the end.
Do we also need datasheets for the other components that will be needed in the PCB design?
Absolutely! Note that in your selection of components you also need to consider the electrical characteristics of your board. You need to consider the voltage and current requirements. For example, the ATmega 328P has an operating voltage range of 1.8V to 5.5V. For input voltages above the maximum voltage ratings, you'll require a voltage regulator. Without this, the components will get fried! You need to consider some properties of the voltage regulator required like the dropout voltage, response time, power draw etc. These properties will help you in aligning your design requirements with the components ratings.
For now, the crucial parts (hardware) of the datasheet will be discussed in the second part of this project.
Due to the fact that ideas don't come out fully formed, you may need to tweak or redesign some parts of your board as new ideas materialize.
"Every great dream begins with a dreamer. Always remember, you have within you the strength, the patience, and the passion to reach for the stars to change the world." - Harriet Tubman
A schematic diagram serves as an electronic blueprint of your circuit. Lots of software are readily available for circuit design and few also have the capability of running simulations on them. An inexhaustible list of such software include:
For the purpose of this write-up we will using KICAD but you are at liberty to use any other software that suites you better.
For the purpose of designing our development board, we will be looking at the different sections of the schematic diagram (check github repository below) in detail. The first part is the power section. The datasheet shows that the operating voltage range for our microcontroller is 1.8-5.5V. In this case, I needed a 5V supply, hence i used an LM7805 voltage regulator. An important thing to note is the maximum rating of the voltage regulator. This will help determine the maximum input voltage. According to the LM7805 datasheet, the maximum input voltage is 35V.
The 100uF capacitor is required if the regulator is located an appreciable distance from the power supply filter. The 1N4007 diode is used to prevent reverse polarity that can damage the microcontroller. In future design, a schottky diode would be more preferable because of its low voltage drop. The LED is used as a power indicator and the resistor is used to limit the current flowing through the LED.
Next, we consider the reset circuit.
How do you reset the microcontroller?
In the reset circuit, we make use of a pull-up resistor (typically 10K). A pull-up resistor is a resistor with a relatively high value that "pulls up" the non-ground side of the button to the high voltage level in the absence of a button press. When the reset button is pressed, a LOW pulse is applied to the RESET pin causing the microcontroller to reset and terminate all activities.
How about a clock source for the ATmega328?
The ATmega328 has several options for its clock source. One of such is an in-built RC Oscillator but it is not accurate enough and also susceptible to temperature changes. Most often a quartz crystal oscillator is connected to the input pins XTAL1 and XTAL2. It also needs two capacitors. One side of each capacitor is connected to the ground as shown below
When all is said and done, how do we then load programs into the microcontroller?
In order to load a program into the microcontroller, we make use of an in-circuit serial programmer (ISP). In-circuit serial programming is excellent for designs that change or require periodic updating. AVR has two methods of ISP namely SPI and JTAG. We will be making use of SPI (Serial Peripheral Interface). The SPI uses 3 pins, one for send, one for receive and one for clock. Thes pins can be used as I/O after the device has been programmed. You also need to connect VCC, GND and RESET as shown below
The full circuit is shown below. You can also check out the github repository to download all associated files.
"It is not enough to wire the world if you short-circuit the soul. Technology without heart is not enough" - Tom Brokaw
Comments