Following are very basic topics for beginners (taken directly from my book),
1.Introduction to Microcontroller
New to micro-controllers ? Wanna learn about it ? I was also in the same condition few years back ! (May 2006) Got some help from seniors and almighty Google then things got started.
So lets start from the very basic !
You must be knowing about Digital Integrated Circuits (ICs) right ? For example:
There are AND, XOR, NAND, NOR, OR logic gate ICs, Counters, Timers, Seven Segment Display Drivers and much more. Just check out 7400 Series and 4000 Series of Integrated Circuits.
Now lets take Quad 2 input AND gate IC. It has 4 AND gates, each having 2 pins for input and 1 pin for output. The truth table or the function table of each gate is fixed. Which is as folllows:
Input 1 | Input 2 | Output |
0 | 0 | 0 |
0 | 1 | 0 |
1 | 0 | 0 |
1 | 1 | 1 |
Similarly all the Integrated circuits have there function tables and input and output pins fixed. You can not change the function and no input pin act as output and vice versa. So whenever you want to design some circuit you first have to get the output as a function of inputs and then design it using gates or whatever the requirement is.
So once a circuit is built we can not change its function ! Even if u want to make some changes again you have to consider all the gates and components involved. Now if you are designing any circuit which involves change of the function table every now and then you are in trouble ! For example if I want to design an Autonomous Robot which should perform various tasks and I don’t just want to fix trhe task. Suppose I make it to move in a path then I want to change the path ! How to do that ?
Here comes the use of Microcontrollers ! Now if I give you an Integrated Circuit with 20 pins and tell you that you can make any pin as output or input also you can change the function table by programming the IC using your computer ! Then your reactions will be wow ! that’s nice :) That’s what the most basic function of a microcontroller is. It has set of pins called as PORT and you can make any pin either as output or input. After configuring pins you can program it to perform according to any function table you want. You can change the configuration or the function table as many times you want.
There are many Semiconductor Companies which manufactures microcontrollers.
Some of them are:
- Intel
- Atmel
- Microchip
- Freescale
- Motorola
- ZiLOG
We will discuss about Atmel Microcontrollers commonly known as AVR in this section.
Question: How a microcontroller works !
Answer: Well I can not go into lot of details about the working because it is a vast topic in itself. I can just give an overview.
Microcontroller consists of an Microprocessor (CPU that is Central processing Unit) which is interfaced to RAM (Random Access Memory) and Flash Memory (one your pen drive has !). You feed your program in the Flash Memory on the microcontroller. Now when you turn on the microcontroller CPU access the instruction from RAM which access your code from Flash. It sets the configuration of pins and start performing according to your program. For details refer,
- Wikipedia (good link for knowing about anything ! )
- AVR Freaks (nice community for AVR users)
Question: How to make the code ?
Answer: You basically write the program on your computer in any of the high level languages like C, C++, JAVA etc. Then you compile the code to generate the machine file. Now you will ask what this machine file is ? All the machines understands only one language, 0 & 1 that is on and off. Now this 0 & 1 both corresponds to 2 different voltage levels for example 0 volt for 0 logic and +5 volt for 1 logic. Actually the code has to be written in this 0,1 language and then saved in the memory of the microcontroller. But this will be very difficult for us ! So we write the code in the language we understand (C) and then compile and make the machine file (.hex) After we make this machine file we feed this to the memory of the microcontroller.
Question: How to feed the code in the flash of Microcontroller ?
Answer: Assuming you have the machine file (.hex) ready and now you want to feed that to the flash of the microcontroller. Basically you want to make communication between your computer and microcontroller. Now computer has many communication ports such as Serial Port, Parallel Port and USB (Universal Serial Bus).
Lets take Serial Port, it has its own definition that is voltage level to define 0 & 1 (yeah all the data communication is a just collection of 0 & 1 ) Serial Port's protocol is called as UART (Universal Asynchronous Reciever & Transmitter) Its voltage levels are, -12 volt for 0 logic and +12 volt for 1 logic.
Now the voltage levels of our micrcontroller is based on CMOS (Complimentary Metal Oxide Semiconductor) technology which has 0 volt for 0 logic and +5 volt for 1 logic.
Two different machines with 2 different ways to define 0 & 1 and we want to exchange information between them. Consider microcontroller as a French and Computer's Serial Port as an Indian person (obviously no commom language in between !) If they want to exchange information they basically needs a mediator who knows both the language. He will listen one person and then translate to other person. Similarly we need a circuit which converts CMOS (microcontroller) to USART (serial port) and vice versa. This circuit is called as programmer. Using this circuit we can connect computer to the microcontroller and feed the machine file to the flash.
Compiler / IDE (Integrated Development Environment)
Atmel Microcontrollers are very famous as they are very easy to use. There are many development tools available for them. First of all we need an easy IDE for developing code. I suggest beginners to use CVAVR (Code Vision AVR) Evaluation version is available for free download from the website. It has limitaion of code size. It works on computers with Windows platform that is Windows XP & Vista.
Some famous compilers/development tools supporting Windows for Atmel Microcontrollers are:
- WINAVR (AVRGCC for Windows)
- Code Vision AVR (CVAVR)
- AVR Studio (Atmel's free developing tool)
AVRGCC is a very nice open source compiler used by most of the people.
Programmer
Programmer basically consists of two parts:
- Software (to open .hex file on your computer)
- Hardware (to connect microcontroller)
Hardware depends on the communication port you are using on the computer (Serial, Parallel or USB). I suggest beginners to use Serial Programmer as it is very easy to build. Software for that is Pony Prog or At-prog. Some famous Windows (XP, Vista) programmers are:
Assuming you must have got a basic idea about microcontrollers now. So lets start some real stuff ! go to the next link :-)
No comments:
Post a Comment