Wednesday, October 12, 2011

Chapter 8: The AVR I/O

What you have read in my blog so far were for preparing you to be able to program a Microcontroller. Now you can write some code in AVR Studio and program the AVR flash memory with the compiled hex file. Its time to go mainstream. From this chapter lets start building our dreams. You will see what a simple block of code can do. Its time to experience it. Its amazing, its fun and it will evaluate the creative part of your mind.

I will go with coding techniques and algorithms for various functions of a microcontroller. Most of them are interrelated. I will explore them in a certain sequence. This chapter deals with I/O; the most essential portion of an embedded system.


Concepts of I/O
I/O is the shorter version of the term Input/Output. In every programmable device, there is some sort of interface to communicate with the outside world.

Ports & Pins
The total number of pins varies from device to device. For example, ATmega8 has 28 pins, ATmega16 has 40 pins and the smallest one ATTiny15 has 8 pins only. We can't use all the pins for our I/O purposes. Some pins are reserved for some special jobs; for example VCC, GND etc. Different pins of a MCU perform different functions. For our I/O needs, some pins are available in a collective form called PORTS. A port means a collection of Pins. Generally, in an 8 bit MCU, each port consists of 8 pins.
Fig: Cable and Port Analogy

Here is an analogy for you between a cable consisting of several lines and a port that consists of several pins.

Wednesday, October 5, 2011

Chapter 7: Programming with the USB Programmer

We have used Pony Prog for programming using the Serial/Parallel ISP Cables. Pony Prog does not support any USB programmer. So, we need to look for alternate software. One of them is AVRDUDE. It is a command line based programmer. Writing command lines is annoying for most of us .There are Graphical User Interface (GUI) based programmers available. They are quite good too.

I will discuss about AVR8 Burn-O-Mat; so far the best one in my judgement. Before you use that, you should practice a few AVRDUDE commands which will give you some insight on accessing usbasp and the target devices. In fact, AVR8 Burn-O-Mat employs AVRDUDE for its programming tasks. Lets get started with AVRDUDE.

Monday, October 3, 2011

Chapter 6: Making your own USB Programmer

Fig: USB In System Programmer for AVR
Programming the microcontroller with parallel or serial port programmers seems to be a tedious task. Especially for those using laptops, there is no way out. These ports are extinct now a days. So, USB remains as the only option. I am going to demonstrate the process of building, configuring and installing a USB programmer. It is easy to build and the required components are widely available.

The Circuit
The original creation was by Thomas Fischl. To know more, you can visit his site.
I have done a few modifications of the original to make it simpler to implement.

Wednesday, April 27, 2011

Chapter 5: Programming the AVR


As we progress with our mission to deal with Microcontrollers, its time that we really start programming it. I have shown you how to construct an ISP Cable. Its time to test it. We will implement and test our system in a breadboard.

We will need a power supply for the digital circuits. We know a digital circuit runs from either 3.33V or 5V of supply. We will be commonly using 5V logic. So we need a 5V power supply capable of feeding all the devices we might run.

Wednesday, March 23, 2011

Chapter 4: Making Your Own Programmer

We have already explored some theory. We can't wait to start building embedded projects. I discussed the embedded system development process in chapter 2. Programming a Microcontroller requires some hardware & some software. The upcoming chapters will cover the following two parts,
  • Setting up your Hardware
  • Setting up your Software
We will need a computer. We will devise an interface that will connect our Programmable Device to the PC.
Firstly, we will set up our hardware. The AVRs support In System Programming. I will give you some idea about it. This chapter will exclusively deal with In System Programming.




In System Programming
AVR Microcontrollers can be programmed in system. They support In System Programming (ISP). There is no need to remove the chip from the embedded system. It can be programmed or reprogrammed on the run.
 
Fig: In System Programming
In many cases we will program the AVR before installing it in a permanent board. We may need to reconfigure or update the program. We will just need access to

Sunday, February 27, 2011

Chapter 3: The features of a microcontroller

What are the features that a microcontroller have? We know, a uC is a small computer which has almost everything built in a single chip. In this chapter we will learn about some of them by exploring a sample MCU. As we are going to use AVR microcontrollers, we will explore a general purpose model of AVR, named ATmega8.



A brief History
I will tell you some history now. Intel (Integrated Electronics) developed its first microprocessor chip 4004 in 1971 which was 4 bit. Intel opened the 8 bit market in 1974 when they released 8008 and 8080. During that time Motorola released its first one, 6800 which was also 8 bit.
Intel Corporation introduced 8051 series MCU in 1981. It was built according to the Harvard Architecture. It is referred to as the MCS-51 series. Many different vendors use this MCS-51 architecture originally developed by Intel.

Atmel Corporation introduced its first 8 bit Flash based microcontroller in 1994 which was a MCS-51 derivative. In 1996 Atmel released 8 bit AVR RISC microcontroller for the first time. Two students at the Norwegian Institute of Technology (NTH), Alf-Egil Bogen and Vegard Wollan conceived AVR which follows the Modified Harvard Architecture.

What does the term AVR stands for is not mentioned clearly. Many people think AVR stands for Alf Vegard RISC. From now on we will use the term AVR to refer to Atmel’s 8 bit AVR microcontrollers.

Microchip Technology has a popular series of uCs called PIC. If you want to know more about PICs, you can visit the Microchip Website.



The Architecture of AVR
The term RISC stands for Reduced Instruction Set Computing. The RISC processors are designed to run faster and provide better performance by using a reduced number of instructions.

Monday, February 21, 2011

Chapter 2: Embedded Systems

What is an Embedded System?
You may commonly encounter a term "Embedded System". Simply we can say, we use microcontrollers to build Embedded Systems. We will embed a MCU in a system which will perform our desired operation. Starting from digital watches and mp3 players up to traffic system controllers and Nuclear reactor controllers all are embedded systems. We already mentioned that the devices or the systems which require a computing brain can be implemented using microcontrollers.


The Steps to Build an Embedded System
Now we know the basics of a computer system. We can start designing our own embedded systems. The beauty of this work is that you can design

Saturday, February 12, 2011

Chapter 1: The Basics



What is a Microcontroller?
The obvious question should be answered first. The word microcontroller is similar to the word microprocessor which is the core of modern computers.

Micro means something very small or tiny. The integrated circuits are fabricated in very small chips which have made our modern computers smaller.

Controller means something which has the ability to control. For example, deciding how much amount of heat to maintain in a microwave oven when it is set to run on auto cook modes or a worker robot which has to decide which box to put in which truck.
Figure: Two robot characters in the movie Wall E by Pixer Animation Studios.
Both the oven and the robot need some sort of thing which can make these decisions for them. Otherwise both of them are going to be useless. Another example can be a cell phone. It shows its battery level, warns us if the battery is low. When the charge is full, it tells us to

Friday, February 11, 2011

Introduction


A Microprocessor in a Motherboard
Dear Readers, welcome to my Microcontroller blog. I am a student of Electrical & Electronic Engineering at BUET. My intention here is to provide the basic concepts of Microcontrollers and a Beginners tutorial on how to program and use it. I am not a pro on this but I will try to help you out on the first steps. Only a few blogs or a few tutorials can’t teach you everything because