Introduction to Arduino UNO Hardware Design
Published on 2/21/2017 1:58:34 AM
Description
<style>.e_editor{font:14px/24px Arial,'microsoft yahei','Times New Roman','b8bf53';}.e_editor div,e_editor p,e_editor td,e_editor th,e_editor li{font-weight:inherit;font-size:inherit;font-style:inherit;font-family:inherit;}.e_editor ul{margin:-10px 0 20px;}.e_editor li{padding:5px 0;}.e_table{width:96%;border-collapse:collapse;empty-cells:show;}.e_table th,.e_table td{padding:5px;border:2px solid #eee;}.e_img{padding:10px 0;text-align:center;}.e_p{line-height:20px;padding:0 0 20px;text-indent:0em;}</style> <div class="e_editor"> <div class="e_p"> <strong>Components Overview</strong> </div> <div class="e_p"> The PCB design of the Arduino UNO uses SMD (Surface Mount Device) components. I entered the SMD world years ago when I dug into Arduino PCB design while I was a part of a team redesigning a DIY clone for Arduino UNO. </div> <div class="e_p"> Integrated circuits use standardized packages, and there are families for packages. </div> <div class="e_p"> SMD package code for discrete components such as resistors, capacitors, and inductors. Image courtesy of Wikimedia. </div> <div class="e_p"> Most packages are generic and can be used for different parts with different functionality. The SOT-223 package, for example, can contain a transistor or a regulator. </div> <div class="e_p"> In the table below, you can see a list of some components in the Arduino UNO with their respective package: </div> <div class="e_p"> <table> <tbody> <tr> <th> Part </th> <th> Package </th> </tr> <tr> <td> NCP1117ST50T3G 5V regulator </td> <td> SOT223 </td> </tr> <tr> <td> LP2985-33DBVR 3.3V regulator </td> <td> SOT753/SOT23-5 </td> </tr> <tr> <td> M7 diode </td> <td> SMB </td> </tr> <tr> <td> LMV358IDGKR dual channel amplifier </td> <td> MSOP08 </td> </tr> <tr> <td> FDN340P P-channel MOSFET transistor </td> <td> SOT23 </td> </tr> <tr> <td> ATmega16U2-MU </td> <td> MLF32 </td> </tr> </tbody> </table> </div> <div class="e_p"> Arduino UNO System Overview </div> <div class="e_p"> Before we can understand the UNO's hardware, we must have a general overview of the system first. </div> <div class="e_p"> After your code is compiled using Arduino IDE, it should be uploaded to the main microcontroller of the Arduino UNO using a USB connection. Because the main microcontroller doesn’t have a USB transceiver, you need a bridge to convert signals between the serial interface (UART interface) of the microcontroller and the host USB signals. </div> <div class="e_p"> The bridge in the latest revision is the ATmega16U2, which has a USB transceiver and also a serial interface (UART interface). </div> <div class="e_p"> To power your Arduino board, you can use the USB as a power source. Another option is to use a DC jack. You may ask, “if I connect both a DC adapter and the USB, which will be the power source?” The answer will be discussed in the “Power Part” section from this article. </div> <div class="e_p"> To reset your board, you should use a push button in the board. Another source of reset should be every time you open the serial monitor from Arduino IDE. </div> <div class="e_p"> I redistributed the original Arduino UNO schematic to be more readable below. I advise you to download it and open the PCB and schematic using Eagle CAD while you are reading this article. </div> <div class="e_p"> Redistributed version of the original Arduino schematic. Click to enlarge. </div> <div class="e_p"> The Microcontroller </div> <div class="e_p"> It is important to understand that the Arduino board includes a microcontroller, and this microcontroller is what executes the instructions in your program. If you know this, you won't use the common nonsense phrase "Arduino is a microcontroller" ever again. </div> <div class="e_p"> The ATmega328 microcontroller is the MCU used in Arduino UNO R3 as a main controller. ATmega328 is an MCU from the AVR family; it is an 8-bit device, which means that its data-bus architecture and internal registers are designed to handle 8 parallel data signals. </div> <div class="e_p"> ATmega328 has three types of memory: </div> <ul> <li> <div class="e_p"> <strong>Flash memory:</strong> 32KB nonvolatile memory. This is used for storing application, which explains why you don't need to upload your application every time you unplug arduino from its power source. </div> </li> <li> <div class="e_p"> <strong>SRAM memory:</strong> 2KB volatile memory. This is used for storing variables used by the application while it's running. </div> </li> <li> <div class="e_p"> <strong>EEPROM memory:</strong> 1KB nonvolatile memory. This can be used to store data that must be available even after the board is powered down and then powered up again. </div> </li> </ul> <div class="e_p"> Let us briefly go over some of this MCU's specs: </div> <div class="e_p"> <strong>Packages:</strong> </div> <div class="e_p"> This MCU is a DIP-28 package, which means that it has 28 pins in the dual in-line package. These pins include power and I/O pins. Most of the pins are multifunctional, which means that the same pin can be used in different modes based on how you configure it in the software. This reduces the necessary pin count, because the microcontroller does not require a separate pin for every function. It can also make your design more flexible, because one I/O connection can provide multiple types of functionality. </div> <div class="e_p"> Other packages of ATmega328 are available like TQFP-32 SMD package (Surface Mount Device). </div> <div class="e_p"> <strong>Power:</strong> </div> <div class="e_p"> The MCU accepts supply voltages from 1.8 to 5.5 V. However, there are restrictions on the operating frequency; for example, if you want to use the maximum clock frequency (20 MHz), you need a supply voltage of at least 4.5 V. </div> <div class="e_p"> <strong>Digital I/O:</strong> </div> <div class="e_p"> This MCU has three ports: PORTC, PORTB, and PORTD. All pins of these ports can be used for general-purpose digital I/O or for the alternate functions indicated in the pinout below. For example, PORTC pin0 to pin5 can be ADC inputs instead of digital I/O. </div> <div class="e_p"> There are also some pins that can be configured as PWM output. These pins are marked with “~” on the Arduino board. </div> <div class="e_p"> <strong>Note</strong>: The ATmega168 is almost identical to the ATmega328 and they are pin compatible. The difference is that the ATmega328 has more memory—32KB flash, 1KB EEPROM, and 2KB RAM compared to the ATmega168's 16KB flash, 512 bytes EEPROM, and 1KB RAM. </div> <div class="e_p"> Arduino UNO R3 pinout. Image courtesy of GitHub.ADC Inputs: </div> <div class="e_p"> This MCU has six channels—PORTC0 to PORTC5—with 10-bit resolution A/D converter. These pins are connected to the analog header on the Arduino board. </div> <div class="e_p"> One common mistake is to think of analog input as dedicated input for A/D function only, as the header in the board states ”Analog”. The reality is that you can use them as digital I/O or A/D. </div> <div class="e_p"> ATmega328 block diagram. </div> <div class="e_p"> As shown in the diagram above (via the red traces), the pins related to the A/D unit are: </div> <ul> <li> AVCC: The power pin for the A/D unit. </li> <li> AREF: The input pin used optionally if you want to use an external voltage reference for ADC rather than the internal Vref. You can configure that using an internal register. </li> </ul> <div class="e_p"> Internal register settings for selecting the Vref source. </div> <div class="e_p"> UART Peripheral: </div> <div class="e_p"> A UART (Universal Asynchronous Receiver/Transmitter) is a serial interface. The ATmega328 has only one UART module. </div> <div class="e_p"> The pins (RX, TX) of the UART are connected to a USB-to-UART converter circuit and also connected to pin0 and pin1 in the digital header. You must avoid using the UART if you’re already using it to send/receive data over USB. </div> <div class="e_p"> SPI Peripheral: </div> <div class="e_p"> The SPI (Serial Peripheral Interface) is another serial interface. The ATmega328 has only one SPI module. </div> <div class="e_p"> Besides using it as a serial interface, it can also be used to program the MCU using a standalone programmer. You can reach the SPI's pins from the header next to the MCU in the Arduino UNO board or from the digital header as below: </div> <div class="e_p"> 11<->MOSI </div> <div class="e_p"> 12<->MISO </div> <div class="e_p"> 13<->SCK </div> <div class="e_p"> TWI: </div> <div class="e_p"> The I<sup>2</sup>C or Two Wire Interface is an interface consisting of only two wires, serial data, and a serial clock: SDA, SCL. </div> <div class="e_p"> You can reach these pins from the last two pins in the digital header or pin4 and pin5 in the analog header. </div> <div class="e_p"> Other Functionality: </div> <div class="e_p"> Other functionality is included in the MCU, such as that offered by the timer/counter modules. You may not be aware of the functions that you don't use in your code. You can refer to the datasheet for more information. </div> <div class="e_p"> Arduino UNO R3 MCU part. </div> <div class="e_p"> Returning to the electronic design, the microcontroller section has the following: </div> <ul> <li> <strong>ATmega328-PU:</strong> The MCU we just talked about. </li> <li> <strong>IOL and IOH (Digital) Headers:</strong> These headers are the digital header for pins 0 to 13 in addition to GND, AREF, SDA, and SCL. Note that RX and TX from the USB bridge are connected with pin0 and pin1. </li> <li> <strong>AD Header:</strong> The analog pins header. </li> <li> <strong>16 MHz Ceramic Resonator (CSTCE16M0V53-R0):</strong> Connected with XTAL2 and XTAL1 from the MCU. </li> <li> <strong>Reset</strong> <strong>Pin:</strong> This is pulled up with a 10K resistor to help prevent spurious resets in noisy environments; the pin has an internal pull-up resistor, but according to the AVR Hardware Design Considerations application note (AVR042), “if the environment is noisy, it can be insufficient and reset may occur sporadically.” Reset occurs if the user presses the reset button or if a reset is issued from the USB bridge. You can also see the D2 diode. The role of this diode is described in the same app note: “If not using High Voltage Programming it is recommended to add an ESD protection diode from RESET to Vcc, since this is not internally provided due to High Voltage Programming”. </li> <li> <strong>C4 and C6 100nF Capacitors:</strong> These are added to filter supply noise. The impedance of a capacitor decreases with frequency: <div class="e_p"> $$Xc$$ = $$\frac{1}{2 \pi f C}$$ </div> <div class="e_p"> The capacitors give high-frequency noise signals a low-impedance path to ground. 100nF is the most common value. Read more about capacitors in the AAC textbook. </div> </li> <li> <strong>PIN13:</strong> This is connected to the SCK pin from the MCU and is also connected to an LED. The Arduino board uses a buffer (the LMV358) to drive the LED. </li> <li> <strong>ICSP (In-Circuit Serial Programming) Header:</strong> This is used to program the ATmega328 using an external programmer. It’s connected to the In-System Programming (ISP) interface (which uses the SPI pins). Usually, you don’t need to use this way of programming because bootloader handles the programming of the MCU from the UART interface which is connected using a bridge to the USB. This header is used when you need to flash the MCU, for example, with a bootloader for the first time in production. </li> </ul> <div class="e_p"> The USB-to-UART Bridge </div> <div class="e_p"> As we discussed in the “Arduino UNO System Overview” section, the role of the USB-to-UART bridge part is to convert the signals of USB interface to the UART interface, which the ATmega328 understands, using an ATmega16U2 with an internal USB transceiver. This is done using special firmware uploaded to the ATmega16U2. </div> <div class="e_p"> From an electronic design perspective, this section is similar to microcontroller section. This MCU has an ICSP header, an external crystal with load capacitors (CL), and a Vcc filter capacitor. </div> <div class="e_p"> Notice that there are series resistors in the D+ and D- USB lines. These provide the proper termination impedance for the USB signals. Here is some further reading about these resistors: </div> <div class="e_p"> <ol> <li> Why USB data series resistors </li> <li> USB Developers FAQ </li> </ol> </div> <div class="e_p"> Z1 and Z2 are voltage-dependent resistors (VDRs), also called varistors. They are used to protect the USB lines against ESD transients. </div> <div class="e_p"> The 100nF capacitor connected in series with the reset line allows the Atmega16U2 to send a reset pulse to the Atmega328. You can read more about this capacitor here. </div> <div class="e_p"> The Power </div> <div class="e_p"> For a power source, you have the option of using the USB or a DC jack. Now it’s time to answer the following question: “If I connect both a DC adapter and the USB, which will be the power source?” </div> <div class="e_p"> The 5V regulator is the NCP1117ST50T3G and the Vin of this regulator is connected via DC jack input through the M7 diode, the SMD version of the famous 1N4007 diode (PDF). This diode provides reverse-polarity protection. </div> <div class="e_p"> The output of the 5V regulator is connected to the rest of 5V net in the circuit and also to the input of the 3.3V regulator, LP2985-33DBVR. You can access 5V directly from the power header 5V pin. </div> <div class="e_p"> Another source of 5V is USBVCC which is connected to the drain of an FDN340P, a P-channel MOSFET, and the source is connected to the 5V net. The gate of the transistor is connected to the output of an LMV358 op-amp used as a comparator. The comparison is between 3V3 and Vin/2. When Vin/2 is larger, this will produce a high output from the comparator and the P-channel MOSFET is off. If there is no Vin applied, the V+ of the comparator is pulled down to GND and Vout is low, such that the transistor is on and the USBVCC is connected to 5V. </div> <div class="e_p"> Power source switching mechanism. Click to enlarge. </div> <div class="e_p"> The LP2985-33DBVR is the 3V3 regulator. Both the 3V3 and 5V regulators are LDO (Low Dropout), which means that they can regulate voltage even if the input voltage is close to the output voltage. This is an improvement over older linear regulators, such as the 7805. </div> <div class="e_p"> The last thing I'll talk about is the power protection that is provided in Arduino UNO. </div> <div class="e_p"> As mentioned above, VIN from a DC jack is protected from reverse polarity by using a serial M7 diode in the input. Be aware that the VIN pin in the power header is not protected. This is because it is connected after the M7 diode. Personally, I don’t know why they decided to do that when they could connect it before the diode to provide the same protection. </div> <div class="e_p"> VIN pin from power header. Click to enlarge. </div> <div class="e_p"> When you use USB as a power source, and to provide protection for your USB port, there is a PTC (positive temperature coefficient) fuse (MF-MSMF050-2) in series with the USBVCC. This provides protection from overcurrent, 500mA. When an overcurrent limit is reached, the PTC resistance increases a lot. Resistance decreases after the overcurrent is removed. </div> </div>
147
comment
All comments
6302
0
147
Rules about cashback: 1. Valid time: ALLPCB cashback activity will end on April 1st. 2. Capped amount: The capped amount of cashback for each account is $5,000. Each order can get a maximum of $2,000 cashback. That means every author can get $5,000 max. 3. Cashback range: The cashback activity only covers the corresponding PCB order. The order amount for other combined payment products will be invalid. 4. Clicking your own promotional link will be invalid. The same email address, shipping address, contact information, and phone number are all recognized as the same account. 5. ALLPCB has the final interpretation right of the cashback activity.
ALLPCB will donate 2% to the author for this promotion link.