Friday, May 9, 2014

Simple LED Project Explained Using ATMEGA 16 (in Proteus)

This post is for the beginners who wants to put their first step towards Embedded system or Robotics. 
Lets start...
First set up your computer ready before starting...
1. Download and Install Proteus 8.0 full cracked 
    Download it from our software section. Click here to download
2. Download and Install AVR Studio and Win AVR 2010.
    Download it from our software section. Click here to download

Note: While working with Proteus 8.0 it may crash often after running for once. So for that save your work before simulating. To avoid this buy the professional version from the developer and support their work. Or else you have to restart it every time after simulating.

Atmega 16 is a micro-controller. To know more about it and its pin configuration Click here

After completing the above steps. Follow these steps:

Working on Proteus:-
Step 1: Open Proteus.
Step 2: Click on ISIS.

Step 3: Click in P to pick library.

Step 4: Select the component you want to connect.


Step 5: Connect the Pin as per the circuit diagram.


Now its programming time!!! Get Ready programmer!!!

Working with AVR Studio:
Step 6: Open AVR Studio 4.

Step 7: Follow create a new file and name it.

Step 8: Select the micro controller type as ATMEGA 16.

Step 9: Start writing program.

Step 10: After writing the program compile it by pressing F7.

Note: You should know any programming language to proceed forward. That will make your task easy.

Lets start from basic.

"avr/io.h" : Header file for input output of AVR
"avr/delay.h" or "util/delay.h" : Header file to add delay function.
DDRX : Used to assign the Slot A,B,C,D either to input or output. Where X = A / B / C /D.
PORTX : Used to assign the value for the pins of the slot when  it is set to output. Where X = A / B /C /D.
PINX : Used to get the value when the port is assign as input.
_delay_ms(i) : Used to provide delay in milliseconds. Where i is any integer. Example: _delay_ms(500) provides delay of 500 milliseconds. 

Q. How to assign the PORT as input or output?
--> Input is always assign as LOW and output is assign as HIGH.
       Example: To assign slot A and B as input we can write as PORTA=0x00 or PORTA=0b00000000 or PORTA=0. Similarly for B, we can write as PORTB=0x00 or PORTB=0b00000000 or PORTB=0.
       To assign slot C and D as output we can write as PORTC=0xff or PORTC=0b11111111 or PORTC=255. Similarly for D we can write as PORTD=0xff or PORTD=0b11111111 or PORTD=255.

***Where 0x is for hexadecimal, 0b is for binary and simply writing the integer is in decimal format.

Note: You can make any port as input or output. It totally depends on you.

Problem Statement 1:
Make a simple LED program to blink all LED simultaneously with a delay of 500 milliseconds.
--> Open AVR studio and set yourself ready to program.
                                
#include<avr/io.h>
#include<avr/delay.h>
int main()
{
DDRA=0xff;
PORTA=0x00;
while(1)
   {
   PORTA=0xff;
   _delay_ms(500);
   PORTA=0x00;
   _delay_ms(500);
  }

Using the program in Proteus:
Step 11: Open Proteus and right click on the micro controller and click on edit.


 Step 12: Select the program file which you have made. Make sure the file extension is .hex.

Step 13: Click open and then click ok.
Step 14: Click on simulation button shown in the figure.



Proteus Crashes:



All you can do is close it and then again start it. Or better you buy the software if you can save enough buck from your pocket-money.



Try more program with different problem statement or wait for my next problem statement in my next post. Till then happy learning. And don't forget to comment if it was really helpful for you. 

Like us --> Facebook

For any query feel free to ask @ prashantsavior@gmail.com

Author: Unpredictable
Source provided by: Aakash Kumar Das

No comments:

Post a Comment