, , , , ,

How to use Proteus for circuit design

Important: As Proteus does not bound us to connect power supply, XTAL,reset circuit,EA pin and other basic connections so we are ignoring them for sake of simplicity. The important things like Xtal frequency of micro controller can be set from properties of micro controller, as discussed below.

While in actual hardware form for you must follow basic circuit shown at very beginning of this post.
1) Open Proteus

proteus1

 

2) Click on “P to open up part list.
Locate AT89C51 IC as shown below:
proteus2

 

proteus3

 

3) Locate LEDs as shown below

proteus4

 

4) Make connections from 8051 to LEDs

proteus5

5)Locate GND terminal as shown below

proteus6
6) Connect all LEDs to GND
proteus7

7) Double click on 8051 IC to open up its properties window.

— Set the operating frequency i-e 12.0MHz
— Give controller the desired HEX file.
proteus8
8) Click on Play Button to start simulation
proteus9

CIRCUIT SHOULD START WORKING AS SHOWN BELOW

proteus10

,

How to use keil software for 8051

1) As you will open Keil software , you will see following screen:

keil1

 

2) Create new project as shown below:

keil2

 

3) Name it. Make sure that you already have made the separate folder to minimize confusion of new project files with old ones. New folder will keep all files related to only to one project hence making it easy to locate files you need afterwards.

keil3

 

4) Select chip manufacturer, in our case Atmel then select chip model i-e AT89c51

keil4

 

keil5

 

5) Software will ask you whether to include 8051 start up code, select YES.

keil6

 

6) This is how you working environment should look like till now:

keil7

 

6) As new project folders are created, now it is time to create a text file which will include your assembly code. Go to file drop down menu and select “New” or simply click blank paper icon in file toolbar.

keil8

 

keil9

 

7) Write your code in the new white work space that just has been created.

keil10

 

keil11

8) It’s time to save your C code file now.
Go to file drop down menu and select save. Save the file into your main project folder.

keil12

 

NOTE: SAVE FILE WITH .C EXTENSION AS OUR CODE IS IN C LANGUAGE.

 

As you will save the file, the software will detect the .C language keywords and they become colorful to make them prominent from rest of code.

keil12

 

 

9) Now you have to add .C code file to your project. Right click on the source group folder (sub-folder of main target1 folder) and select “Add files to group (source group)”

keil13

 

10) A small window will appear asking you for location of your .C code file. Give it the path of wherever you have saved your file, it should be in your project folder. Select the file click “Add”.

keil14

keil15

 

11) You may check the .C file by clicking on the little plus sign at the left of source group.

keil16

12) There are some configuration changes that you have to make before you build the final .HEX file.

keil17

 

-In target tab set the frequency that you are using with 8051, in our case 12MHz. So change default value 24.0MHz to 12Mhz

keil18

 

-In output tab check the “Create HEX file” box otherwise HEX file will not be created.

After all these settings click OK.

keil19

 

13) It’s now time to get final output that HEX file.

Right click on .C file which is in source group folder and select “Build target”.

keil20

 

14) If there are no errors in code your code will be compiled in couple of seconds showing progress in window at the bottom.

If there are errors in code then they will also be mentioned in same bottom window with number of line that contains error. You may recheck that line rectifying the mistake(s).

keil21

 

15) After successful compilation of code you can find final HEX file in same project folder that contains main project file/.C file/other files.

keil22

 

 

,

Interfacing of Led using ATMEGA16

Overview

In this tutorial we will learn about following below things:-

  • What is Led?
  • How does it work?
  • Interfacing of Led using Atmega16 microcontroller
  • Connection of Led using Atmega16 microcontroller using Proteus Design
  • Programming in C language

Led has number of applications ,it form alpha numeric numbers on digital clocks & led display, transmit information from remote controls to device, light up digital watches & tell you when your appliances are turned on or not. Combined together, they can form images on a LED television screen or illuminate a traffic light. Led are most widely used means of taking output from devices. Led is very economical and easily available in electronics shops & market with variety of shape, size and colors according to requirements of user.

leds

Explanation

As we know that Led is stand for light emitting diode which emitted light only forward biased i,e. When we applied a voltage source across the terminals of led, means +ve terminal of source to anode of led & -ve to cathode then electron & holes recombine & reaches the higher energy state and higher energy state is unstable so that it release the energy in form of light (photons). This process is called electroluminescence.

Out of two terminals for Led, Longer one is anode & shorter one cathode as shown below.

led terminals

Logic to Glow Led

To glow a LED we give a logic one (+ve) to the anode and we put ground means logic zero (-ve) to the cathode. We thing should be noted that we need to connect one resistance between led & our microcontroller to prevent it from damage because as we know led operate at 2v & 10 mA but microcontroller output is 5v so place resistance for better life of led & damage proof.

LED LOGIC

Here for Interfacing of Led using Atmega16 we are using ATMEGA16 AVR Mega series microcontroller for controlling the led or we can say this to take an output. It is Advance Harvard Architecture and is a 8-bit microcontroller with 16K Flash memory and 512 Bytes of EEPROM, 1K SRAM and uses 1 MHz Crystal Oscillator for clock generation, which provides a 1MIPS and it has in build 1-16MHz oscillator and which can provide speed up to 16MIPS.

atmega16

It has 32 input/output port out of 40 pin architecture, CPU, and peripheral in a single chip. Reason for using an AVR microcontroller is that it uses low power, and is application specific, and AVR stands for advance virtual RISC (Reduced Instruction Set Computer) machine.

AVR uses pipelining concept for data, address fetching as well as execution. The Atmega16 is based on CMOS technology for low heat dissipation

Circuit Design

Proteus Design of interfacing of led using Atmega16.

We have connected LED with pin PD0 and we will get the blinking of LED because we have given the logic 1 to the pin PD0. After 1 second LED turns off because we have given logic 0 to the pin PD0 after the delay function as one can see in the programming portion.

Led circuit Design

C Code

C Programming of interfacing of Led using Atmega16

********************************************************************************
http://www.embeddinator.com/

This program is developed by EMBEDDINATOR DEVELOPERS.
********************************************************************************

#include<avr/io.h>               // header file for avr input-output operations

#include<util/delay.h>        // header file for the delay function

void main()                           // program main body

{

DDRD= 0b11111111;          // enable port D as output port

while(1)                               // infinite loop

{

PORTD= 0b00000001;            // passing pin PD0 as logic 1 to glow LED

_delay_ms(1000);                    // delay of 1000 ms.(i.e. 1 second)

PORTD= 0b00000000;       // passing pin PD0 as logic 0 now to off LED

_delay_ms(1000);                // again passing delay of 1 second

}      }

*******************************************************************************
End program

Thank you for visiting our website

http://www.embeddinator.com/
*******************************************************************************

 

,

Interfacing of led with PIC16F877A microcontroller

Overview

In this tutorial we are going to learn about following below things:-

  • What is LED?
  • Interfacing of LED with PIC16F877A microcontroller
  • Connection of LED with PIC16F877A using Proteus Design
  • Programming in C language
  • We will also learn basic of LED operations & how to generate logic for LED & with the help of microcontroller, we will learn how we can ON/OFF LED.

Explanation

A LED is a p-n junction semiconductor device which emits light when biased in forward direction. i.e, the positive terminal is to be connected to the anode & negative terminal of supply is to be connected to cathode of Led.

Led have two terminals 1st are longer which tends to anode of Led and 2nd is shorter which tends to cathode terminal.

led terminals

As we already know that Led will work on forward biasing means +ve to anode & -ve to cathode of Led, similar way in digital electronics +5V means HIGH or Logic 1(one) & -Ve means LOW or Logic 0(zero).

So its means when Logic 1 or HIGH applied across to anode & LOW or Logic 0 to cathode then Led will Glow. So to glow the Led , toggle & control the Led according to customization of program. We are using one 8-bit PIC16F877A microcontroller of microchip technology PIC family controller.

LEDs have dropped a voltage of 1.3 V to 2.2 V and require 7 to 10 mA to glow Led at full intensity.

R=(Vcontroller – Vled)/I

If we want to allow 10mA current through the LED then resistor value will be as below:-

R = (Vcc-led voltage)/current.

R = (5-1.7)/10mA.

R= 330 Ohms

The following picture describes “how to glow a led”.

led circuit

Now it’s time for interfacing of Single Led with microcontroller. We are using 8-bit  PIC16F887A Microchip 40 pin microcontroller, it has all 33 input/output port, CPU, and peripheral in a single chip. Reason for using a PIC microcontroller is that it uses low power, and is application specific and PIC16F877based on HIGH Performance RISC (Reduced Instruction Set Computer) machine. It has 14.3KB flash memory & 368 bytes SRAM with UART & SPI , I2C communication protocol support in a single chip IC.

PIC pin diagram

Circuit Design

Proteus Design for interfacing of led with PIC16F877A microcontroller.

For connection of Led with PIC16F877A , we take PORTB as output direction and connect the RB0 pin to +ve terminal of Led and – ve terminal of Led connected Ground as you can see from below figure.

Pic Led Design

C Code

C programming for interfacing of Led with PIC16F877A microcontroller using MicroC compiler.

********************************************************************************
http://www.embeddinator.com/

This program is developed by EMBEDDINATOR DEVELOPERS.
********************************************************************************

void delay(int a)

{

int b,c;

for(b=0;b<a;b++)< p=””>

{

for(c=0;c<500;c++)

{}}}

void main() {

TRISB=0b0000000;

while(1)

{

PORTB=0b00000001;        //on the led (led get 1)

delay(100);                //delay of 100 msec.

PORTB=0b00000000;        //off the led (led get 0)

delay(100);

}}

*******************************************************************************
End program

Thank you for visiting our website

http://www.embeddinator.com/
*******************************************************************************

,

Interfacing of led with 8051 microcontroller

Overview

This tutorial gives you an introduction a very basic operation of Led to get an output from the 8051 MCS family i.e. AT89S51. As we aware that in our day to day running life Led has a wide range of useful application in almost every electronics & electrical devices like as an indicator, in TV & monitor, in electronics circuit, digital clock, watches, traffic light panel etc. Due wide applications of Led this tutorial will show the principle behind the interfacing of Led with 8051 microcontroller’s family as shown in picture below. Now we are going to interface single Led with AT89S51 microcontroller in our explanation section.

Explanation

Before proceed toward the interfacing of led, we should know about the basic Led operation, principle of Led working & AT89S51 microcontroller.

So for interfacing of Led with AT89S51 microcontroller, we will use the AT89S51, which belongs to the Atmel family of 8051 series of microcontrollers, is very commonly used by a large consumer’s of hobbyist, electronics lover, engineers & project designer for learning & developing purpose. Its simplicity and easy way of programming with inbuilt features with mostly device compatibly, easily makes its position in the top preferred list of microcontroller for both new learner and experts’ user for projects.

We need a one controlling unit in our circuit which understand programming logic which is written by us. So for this we are using an 8-bit AT89S51 8051 series microcontroller which has 64 kB Flash Memory (ROM) and 1024 bytes of data RAM which operates at 11.059n Mhz crystal frequency. It is 40 Pin Package which contain 4 Ports & 8 Pin each i.e. 32 pin of Input/output Programming & rest of 8 Pin for other operation like crystal oscillator pins, reset pin, external memory pins & its operate at 5V & 60mA current we can withdraw from Pins as shown in below picture. Its supports the in serial In-System Programming (ISP). ISP feature of 8051 MCS that allows a device which reprogrammed with high speed data that transfer with software control. AT89S51 has capability to update the application firmware makes a huge range of applications in industry.

8051 pin diagram 

As we can see that from above picture that our microcontroller AT89S51 has 4 ports P0, P1, P2, P3 each port contain 8 pin for input/output operations.

As we know that Light Emitting Diodes, mainly called LEDs, which emit the light when forward biased or we can say that it emits the light when it’s excited by external power voltage source. When we applied a voltage source across the terminals of led, means +ve terminal of source to anode of led & -ve to cathode then electron & holes recombine & reaches the higher energy state and higher energy state is unstable so that it release the energy in form of light (photons).

led circuit

Most of the commonly available LEDs have dropped a voltage of 1.3 V to 2.2 V and require 7 to 10 mA to glow Led at full intensity.But our microcontroller give an output of 5V & 60mA, due to this we will connect led through the resistance of 330 ohms using below formula.

R=(Vcontroller – Vled)/I

R = (Vcc-led voltage)/current.

R = (5-1.7)/10mA.

R= 330 Ohms.

Logic to Glow the Led from AT89S51 Microcontroller.

As we already explained that led will work on forward biasing means +ve to anode & -ve to cathode of led, similar way in digital electronics +5V means HIGH or Logic 1(one) & -Ve means LOW or Logic 0(zero).

LED LOGIC

So its means when Logic 1 or HIGH applied across to anode & LOW or Logic 0 to cathode then Led will Glow.

Circuit Design

Proteus Design of Interfacing of Led with 8051 microcontroller.

In the circuit of interfacing of led with 8051, we need an AT89S51 MCS, Led, resistor 330 ohms & connecting wires. Microcontroller need a clock for proper working & synchronization, without the clock the microcontroller will not do task. Hence a Crystal oscillator of clock 11.0592 MHz is connected between two pins 19 Xtal1 and 18 Xtal2 along with two 33pf capacitors as shown in design.

Led Design

As you can refer the above circuit image. We are connecting the Led to PORT 2 Pin number 0(zero) followed by resistance 330 ohms. When we put the program into microcontroller & then give the power to circuit then Port 2 Pin 0 give Logic 1 or HIGH to Led & Led Start Glowing with full intensity.

C Code

C Programming

********************************************************************************
http://www.embeddinator.com/

This program is developed by EMBEDDINATOR DEVELOPERS.
********************************************************************************

#include<reg51.h>

sbit LED = P2^0;  // define Port2 pin as an LED

void delay(int k)  // Delay Function

{

int i,j;

for(i=0;i<k;i++)

for(j=0;j<1250;j++);

}

void main()

{

while(1)  // infinite loop

{

LED = ~LED;  //  LED Glow

delay(10000);

}// end of while loop

} // end of main
*******************************************************************************
End program

Thank you for visiting our website

http://www.embeddinator.com/
*******************************************************************************

, , , , ,

LED

Overview

This tutorial gives you an explanation of following things:-

  1. What is LED & what does it’s means?
  2. Operation & Principle.
  3. Modes  & Testing.
  4. Logic to operate of LED with microcontrollers.

leds

Explanation

Light Emitting Diode, mainly called LED, It is real hero & very basic first component in the electronics & electrical world due to its lots of different jobs and are found in all kinds of devices.Among other things, they form alpha numeric numbers on digital clocks & led display, transmit information from remote controls to device, light up digital watches & tell you when your appliances are turned on or not. Combined together, they can form images on a LED television screen or illuminate a traffic light. Led are most widely used means of taking output from devices. They find wide range application as indicators while experimenting to check the validation of results at different stages. Led is very economical and easily available in electronics shops & market with variety of shape, size and colors according to requirements of user.

Principle & Operation

LED worked on Electroluminescence Principle, A LED is a p-n junction semiconductor device which emits incoherent light when biased in forward direction(the positive terminal is to be connected to the anode & negative terminal of supply is to be connected to cathode of Led). Most of the LEDs are realized using a highly doped n and a p Junction. It has two regions one is p-region and another is n-region, this two combine and make a junction. The p region is have more +ve electric charges as compare to n-region and the n region is have more -ve electric charges as compare to p-region.

Operation of Led is very simple to understand, Basically Two type of Basing in Led:-

  1.  Forward Biasing
  2. Reverse Biasing

Forward Biasing

In this mode, the positive terminal (+ve) of the cell or battery is connected to the anode of the LED & the negative terminal (-ve) is connected to the cathode terminal of the LED.

                               FORWARD BAISING OF LED

When a forward voltage +ve terminal of voltage is connected with +ve (anode) terminal of led and –ve terminal of voltage is connected with -ve (cathode) terminal of led is applied to an LED, the potential barrier of the P-N junction become smaller, then causing electron & holes recombine & reaches the higher energy state and higher energy state is unstable so that it release the energy in form of light (photons).

In short When we applied a voltage source across the terminals of led, means +ve terminal of source to anode of led & -ve to cathode then electron & holes recombine & reaches the higher energy state and higher energy state is unstable so that it release the energy in form of light (photons). This process is called electroluminescence & color of light depends on the gap between the semiconductor materials, as shown below

led circuitled circuit 1

Reverse Biasing

                               REVERSE BAISED OF LED

If LED is reverse biased, then the electrons of n-type region are pulled towards the terminal. Similarly the holes of the p-type region are pulled towards the terminal. This causes the widening of the depletion region in the p-n semiconductor. The widening of the depletion region increases the resistance of the diode so that it works as an open circuit when reverse biased.The reverse current flows due to the minority charge carriers (very few) in the semiconductors after the breakdown. The reason for the breakdown is the electric field inside the diode created by the depletion.

Testing & Determination of Led Terminals

As you can see below image of Led in which symbol & physical view is there. Now if we talk about the Led symbol on left side of picture there will be one line or plate which act as a cathode & other side is anode. Right side of image of led it has 2 legs, major one is anode & shorter one is cathode of led.

led termianls

There is another way to find cathode & anode of led by using front & top view of led as shown below. As in front view you will find two plates one thick & other is thin, so thick one cathode & thin one is anode of led.

led view

In top view of led you will find a D shape in which straight line is anode & curve shape is cathode.

One more approach to find out the terminals of led by looking the outer lower area of led, you will found there will be a cut surface in lower circle area of led, that cut area beside leg is always a cathode. Apart from this method we need volt meter & led tester for testing of led

LED CloseUp

Led Interfacing with Microcontrollers

Most of the commonly available LEDs have dropped a voltage of 1.3 V to 2.2 V and require 7 to 10 mA to glow Led at full intensity. The following picture describes “how to glow a led”.

led with cell

But we know that our most of microcontrollers give an output of 3 to 5V & 60mA corresponding to pins. If we connect Led directly to any of ports pins as shown below picture then direct 3v to 5v of the port is applied to an LED, so that LED may get damaged.

led when demage

If we connect the led as above, led will glow for very small time with high brightness and burn out. Because large current will be sink via LED from source due to high voltage. Sometimes this large current may damage our microcontrollers Port and then IC.

To limit the current allowed into LED we need to divide the voltage by adding a resistor to the circuit by finding the value of resistor according to ohm’s law.

R=(Vcontroller – Vled)/I

If we want to allow 10mA current through the LED then resistor value will be as below:-

R = (Vcc-led voltage)/current.

R = (5-1.7)/10mA.

R= 330 Ohms.

Resistor values will vary 220 ohm to 470 ohm according to value of Led voltage.

led with resistance

 

In above picture, we connected a 330 ohms resistor to allow 10mA current through the LED for its glow. If we reduce the value of led then will be glow brighter than previously.

Logic to Glow the LED from Microcontrollers.

As we already explained that led will work on forward biasing means +ve to anode & -ve to cathode of led, similar way in digital electronics +5V means HIGH or Logic 1(one) & -Ve means LOW or Logic 0(zero).

LED LOGIC

So its means when Logic 1 or HIGH applied across to anode & LOW or Logic 0 to cathode then Led will Glow.

Configuration of connection of led with Microcontrollers

Led operate in two configuration, because of this reason if we connect the both terminals of led to microcontroller then it consume more pin of IC & programming values also become complex in both configuration only half of pin used as compared to normal configuration & only differance in both configuration is logic .

  1. Common Cathode or Logic 1
  2. Common Anode or Logic 0

Common Cathode

Led have two terminal one +ve and second -ve.

In common cathode all the –ve terminal externally connected with Ground. And all + ve terminal connected with microcontroller.

cc config

Common Anode

Led have two terminal one +ve and  second  -ve.

In common Anode all the +ve terminal externally connected with vcc (Power Supply). And all – ve terminal connected with microcontroller.

ca config