Thursday, May 26, 2016

LED blinking with 8051

LED blinking with 8051 (P89V51RD2) (using keil and BASCOM)
Hey embedded lovers from today I started to post series of 8051 tutorials and first post is use port as output using led interfacing with keil, BASCOM,Proteus.
This post is introduces you the very basic phenomena of taking an output from the microcontroller8051,
Hrer we are use P89V51RD2 which is made by using 8051 core which belongs to the family of 8051 series of microcontrollers, is very commonly used by a large community of hobbyist and engineers. Its simplicity and se of programming with inbuilt ftures sily makes its position in the top preferred list ofmicrocontroller for both beginners and advanced user.
LEDs are by far the most widely used mns of taking output. They find huge Appliion as indiors during experimentations to check the validity of results at different stages. They are very c and sily available in a variety of shape, size and colours.
The principle of operation ofLEDs is simple. The commonly availableLEDs have a drop voltage of 1.7 V and need 10 mA to glow at full intensity.The value of resistance R can be calculated using the equationSince most of the controllers work on 5V,470 ohm is commonly used substitute in case 330 ohm, because 330 ohm is not available.
P89V51RD2is a 40 pin microcontroller which belongs to 8051 series of microcontroller. It has four ports ch of 8 bits P0, P1, P2 and P3.TheP89V51RD2has 64K+8K FLASH bytes of programmable flash. The port P0 covers the pin 39 to pin 32, the port P1 covers the pin 1 to pin 8, the port P2 covers the pin 21 to pin 28 and the port P3 covers the pin 10 to pin 17. Pin 9 is the reset pin. The reset is active high. Whenever the controller is given supply, the reset pin must be given a high signal to reset the controller and bring the program counter to the starting address 0x0000. The controller can be reset by manually connecting a switch or by connecting a combination of resistor and capacitor as shown in the circuit diagram.A 11.0592 MHz crystal is connected between pin 18 pin 19. Pin 40 is Vcc and pin 20 is ground. Pin 40 is connected to Vcc.
LEDs are connected to the port P0.LEDs need approximately 10mA current to flow through them in order to glow at maximum intensity. However the output of the controller is not sufficient enough to drive theLEDs, so if the positive leg of theLEDis connected to the pin and the negative to ground as shown in the figure, theLEDwill not glow at full illumination.To overcome this problemLEDs are connected in the reverse order and they run on negative logic i.e., whenever 1 is given on any pin of the port, theLEDwill switch off and when logic 0 is provided theLEDwill glow at full intensity.As soon as we provide supply to the controller, theLEDs start blinking i.e., they become on for a certain time duration and then become off for the same time duration. This delay is provided by calling the delay function.

ü Circuit diagram:
ü with Keil: /* * Description : Source file to use c pin as output. * File Name : main.c * hder files Name : /REG51F.H , delay.h * compiler : keil uVision4 * Author : Biren Ramoliya ( "" ),( "Computer Zone" ) * Last Update : 11.09.2012, 08:00 AM */
/* system file include */ #include </REG51F.H> #include "delay.h"
/* define pin and port */ #define led P0 //port P0 as output
/* main */ void main() { led = 0x00; //led off while(1) { led = ~led; //toggle led sdelay(1); //wait 1s } }

ü with BASCOM:
'------------------------------------------------------------------------------- '* Description : Source file to use c pin as output. '* File Name : main.bas '* compiler : BASCOM 8051 '* Author : Biren Ramoliya ( "" ),( "Computer Zone" ) '* Last Update : 11.09.2012, 08:00 AM '-------------------------------------------------------------------------------
'==================== syastem configrasen ======================================
'To use crystalfrequency 11.0592mhz = 11059200hz $crystal = 11059200
'==================== define Pin and Port ====================================== Led1 Alias P0
'==================== main fxn =================================================
Led1 = 255 'all led off Wait 1 'delay of 1 second
Led1 = 0 'all led on Wait 1 'delay of 1 second
Loop 'contenuas loop
'==================== end main fxn =============================================

You can download all and simulate from hr.

No comments:

Post a Comment