Tutorial: Building cool projects with MCUs (Part 2)

I’ve always found microcontrollers really cool. After learning how to use MCUs, along with a few other electronics skills – I can’t really think of anything I am NOT able to build.

Okay, maybe not a time machine…

But when it comes to the electronics part of a project, knowing microcontrollers gives you the ability to build A LOT of different things.

Microcontroller circuit

In the previous part of this tutorial, we looked into the basics, and we established that a microcontroller is kind of like a tiny computer. You can connect things like a display, buttons or Wi-Fi, not to mention put programs onto it and run them.

In this segment, we are going to choose the microcontroller to use in our circuit. There are a gazillion options, so we’re going to use a tool to make things easier. But first, we need to figure out our requirements. Choosing a microcontroller becomes much easier once we know what we actually need.

Differences Between Microcontrollers

8-bit, 16-bit and 32-bit

A microcontroller comes in several bit sizes. You can find microcontrollers with 8-, 16- and 32-bit. This size refers to the size of the databus. With a larger databus, you can do more heavy calculations. In the hobbyist world, the 8-bit microcontroller is probably the most common of them all.

Usually, the 8-bit MCUs have fewer pins, and is therefore easier to solder onto a circuit board. In this microcontroller tutorial series, we’ll be keeping it as simple as possible, so we’re going to use an 8-bit.

Memory, Pins and Peripherals

Even an 8-bit microcontroller comes in a lot of different versions. Some have more memory. Some have more input and output pins. Some have USB interface. Some have analog to digital conversion. Some have SPI communication.

These extra functions – like USB or SPI – are called peripherals.

Chip on finger

Finding a Microcontroller for Our Circuit

My goal with this tutorial is to show you how to build a super simple microcontroller circuit.

One thing that affects how simple it is going to be is the programming method. How are we going to get the program we make onto the chip?

Often times, people use an external programmer or debugger that they connect to their microcontroller circuit, but I don’t want you to have to buy an extra tool for this. I want us to be able to just connect the circuit to a USB port on a computer and program it directly.

This leaves us with the following requirements:

  • Can be programmed through USB
  • Few components necessary
  • Possible to solder at home

We can make our circuit programmable through USB in a few different ways. For example, we can do this by adding a USB-to-serial chip onto our circuit – like they do on some of the Arduino boards.

However, since this will increase the number of components, a better solution is to find an MCU with USB interface included. It would also need a bootloader that can accept programming through USB.

Conveniently, some of Atmel’s microcontrollers come pre-loaded with a bootloader called USB DFU Bootloader.

To be able to solder the circuit at home, we want a chip with few pins. The fewer pins a microcontroller has, the easier it is to solder it. So let’s look for a chip with as few pins as possible.

The Microcontroller Selector

With our requirements in place, we can start looking for the perfect microcontroller. The Microcontroller Selector is a very useful tool that Atmel made to help you choose a microcontroller.

Using this tool, we can select what we need from our microcontroller, and it will show us which models that fit our criteria.

Using the Microcontroller Selector

We decided earlier to use an 8-bit MCU, so we select «8-bit AVR» under the «CPU» option.

Also, we want a USB interface. Specifically, we want a USB device interface. So under «USB» we select all the options that include «device».

Since we also want as few pins as possible, we’ll sort the results by number of pins.

Microcontroller Selector Tool

Doing this leaves us with five options that have 32 pins. No microcontroller matching our criteria has fewer than 32 pins., while a few options have more than 32 pins, so we can discard those.

One more criteria we are seeking is if the chip comes preloaded with the DFU bootloader. Unfortunately, we can’t select this criteria in the tool; yet, by looking into the documentation for the DFU bootloader, we can find a list of which microcontrollers are preloaded with this feature.

Here, we can see that one of our options, the ATmega8U2, does not have the bootloader. That leaves us with 4 options:

All of these match our requirements, so let’s just choose the one with the most amount of flash. The more flash we have, the bigger programs we can load onto the chip.

So, we’ll choose the ATmega32U2.

Designing the Circuit

Next, we will be designing the circuit. With the chip selected, I believe this will be pretty straightforward. Not too many components are necessary. Nevertheless, I am writing this as I am doing it – and I’ve never used this chip before – so there is always a chance of some surprises..

Stay tuned for Parts 3-5 in the coming days…

3 thoughts on “Tutorial: Building cool projects with MCUs (Part 2)

  1. Pingback: Tutorial: Building cool projects with MCUs (Part 3) | Bits & Pieces from the Embedded Design World

  2. Pingback: Tutorial: Building cool projects with MCUs (Part 4) | Bits & Pieces from the Embedded Design World

  3. Pingback: Tutorial: Building cool projects with MCUs (Part 5) | Bits & Pieces from the Embedded Design World

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s