8051 report

52
CHAPTER 1 INTRODUCTION 1.1 Introduction Circumstances that we find ourselves in today in the field of microcontrollers had their beginnings in the development of technology of integrated circuits. This development has made it possible to store hundreds of thousands of transistors into one chip. That was a prerequisite for production of microprocessors, and the first computers were made by adding external peripherals such as memory, input-output lines, timers and other. Further increasing of the volume of the package resulted in creation of integrated circuits. These integrated circuits contained both processor and peripherals. That is how the first chip containing a microcomputer, or what would later be known as a microcontroller came about. An embedded computer is a computer that is a component of a larger system; it helps implement the system functionality. Embedded computers exist in automobiles, airplanes, home appliances, military vehicles & equipments, medical devices, robotic, mobile communication system etc. Sophisticated embedded computers have been used in products and systems for over twenty years. Embedded computing includes several aspects: methodology, architectures, and applications which is practiced in conducting research. Methodology is important because the prime goal is to be able to reliably, predictably develop new systems. Embedded computers is used to make a wide variety of systems, therefore methodology of designing an embedded system that enable assessment of a system requirements, develop an architecture, and implement the embedded system is very important. Architecture is used here in a broad sense: both software and hardware. Early decisions can make or break a design. It is important to get the structure of the software and hardware right at the architectural stage in order to avoid expensive problems later in the design process. This generally means jointly considering the effects of architectural decisions on both the hardware and software sides of the implementation. 1

Upload: sachin

Post on 12-Jan-2016

23 views

Category:

Documents


3 download

DESCRIPTION

8051 interfacing report

TRANSCRIPT

Page 1: 8051 report

CHAPTER 1

INTRODUCTION

1.1 Introduction

Circumstances that we find ourselves in today in the field of microcontrollers had their beginnings in the development of technology of integrated circuits. This development has made it possible to store hundreds of thousands of transistors into one chip. That was a prerequisite for production of microprocessors, and the first computers were made by adding external peripherals such as memory, input-output lines, timers and other. Further increasing of the volume of the package resulted in creation of integrated circuits. These integrated circuits contained both processor and peripherals. That is how the first chip containing a microcomputer, or what would later be known as a microcontroller came about. An embedded computer is a computer that is a component of a larger system; it helps implement the system functionality. Embedded computers exist in automobiles, airplanes, home appliances, military vehicles & equipments, medical devices, robotic, mobile communication system etc. Sophisticated embedded computers have been used in products and systems for over twenty years.

Embedded computing includes several aspects: methodology, architectures, and applications which is practiced in conducting research. Methodology is important because the prime goal is to be able to reliably, predictably develop new systems. Embedded computers is used to make a wide variety of systems, therefore methodology of designing an embedded system that enable assessment of a system requirements, develop an architecture, and implement the embedded system is very important.

Architecture is used here in a broad sense: both software and hardware. Early decisions can make or break a design. It is important to get the structure of the software and hardware right at the architectural stage in order to avoid expensive problems later in the design process. This generally means jointly considering the effects of architectural decisions on both the hardware and software sides of the implementation.

Applications are the motivation for embedded computing. It is important to take application characteristics into account during the design of an embedded system, and also important to understand at least one application area well in order to do the best research in embedded computing.

In summary Embedded Computing research cluster involve in enhancing knowledge and creating technologies in hardware & software design techniques through a combination of related fundamental and applied research projects.

1.2 Meaning of Embedded systems

In the literature discussing microprocessors, We often see the term embedded systems.

“An embedded product uses a microprocessors and microcontroller to do one task and one task only”.

1

Page 2: 8051 report

Generally basic meaning of embedded is given as follows:

It is HIDDEN inside the main computer which controls it.

Other that PC everything is embedded.

It is combination of electronic hardware and software and additional mechanical parts designed to perform a specific set of tasks within a given time frame.

1.3 Microprocessor versus microcontroller

What is the difference between a microprocessor and microcontroller? The microprocessor (such as 8086, 80286, 68000 etc.) contain no RAM, no ROM and no I/O ports on the chip itself. For this reason they are referred as general-purpose microprocessors. A system designer using general-purpose microprocessor must add external RAM, ROM, I/O ports and timers to make them functional. Although the addition of external RAM, ROM, I/O ports makes the system bulkier and much more expensive, they have the advantage of versatility such that the designer can decide on the amount of RAM, ROM, I/O ports needed to fit the task at hand. This is the not the case with microcontroller. A microcontroller has a CPU in addition to the fixed amount of RAM, ROM, I/O ports, and timer are all embedded together on the chip: therefore, the designer cannot add any external memory, I/O, or timer to it. The fixed amount of on chip RAM, ROM, and number of I/O ports in microcontroller make them ideal for many applications in which cost and space are critical. In many applications, for example a TV remote control, there is no need for the computing power of a 486 or even a 8086 microprocessor. In many applications, the space it takes, the power it consumes, and the price per unit are much more critical considerations than the computing power. These applications most often require some I/O operations to read signals and turn on and off certain bits. It is interesting to know that some microcontroller manufactures have gone as far as integrating an ADC and other peripherals into the microcontrollers.

1.4 Applications Of Embedded Systems

A embedded system is designed to perform a dedicated function.

An embedded system is a computer with higher quality and reliability requirements than other types of computer systems.

One of the most critical needs of an embedded systems is to decrease power consumption and space. This can be achieved by integrating more functions into the CPU chip.

1.5 Objective

The objective is to explore the details of embedded computing aspects which are the Methodology, Architecture and Application. This will enable cutting edge technology development in hardware and software through embedded system applications development.

1.6 List of training Modules

Introduction to Embedded Systems

2

Page 3: 8051 report

Interfacing of Microcontroller with Light Emitting Diode

Interfacing of Microcontroller with Seven Segment Display

Interfacing of Microcontroller with Liquid Crystal Display

Interfacing of Microcontroller with DC Motor

Interfacing of Microcontroller with Stepper Motor

Interfacing of Microcontroller with Switches

Interfacing of Microcontroller with

CHAPTER 2

INTRODUCTION TO MICROCONTROLLERS

2.1 Definition of a Microcontroller

Microcontroller, as the name suggests, are small controllers. They are like single chip computers that are often embedded into other systems to function as processing/controlling unit. For example, the remote control you are using probably has microcontrollers inside that do decoding and other controlling functions. They are also used in automobiles, washing machines, microwave ovens, toys ... etc, where automation is needed.

The key features of microcontrollers include:

High Integration of Functionality Microcontrollers sometimes are called single-chip computers because they have on-

chip memory and I/O circuitry and other circuitries that enable them to function as small standalone computers without other supporting circuitry.

Field Programmability, Flexibility Microcontrollers often use EEPROM or EPROM as their storage device to allow field

programmability so they are flexible to use. Once the program is tested to be correct

3

Page 4: 8051 report

then large quantities of microcontrollers can be programmed to be used in embedded systems.

Easy to Use Assembly language is often used in microcontrollers and since they usually follow

RISC architecture, the instruction set is small. The development package of microcontrollers often includes an assembler, a simulator, a programmer to "burn" the chip and a demonstration board. Some packages include a high level language compiler such as a C compiler and more sophisticated libraries.

Most microcontrollers will also combine other devices such as:

A Timer module to allow the microcontroller to perform tasks for certain time periods.

A serial I/O port to allow data to flow between the microcontroller and other devices such as a PC or another microcontroller.

An ADC to allow the microcontroller to accept analogue input data for processing.

Figure 3.1: Block diagram of Microcontroller

2.2 Criteria for choosing a microcontroller

The basic criteria for choosing a microcontroller suitable for the application are:

1. The first foremost criterion is that it must meet the task at hand efficiently and cost effectively. In analyzing the needs of a microcontroller-based project, it is seen whether an 8 – bit,16- bit or 32- bit microcontroller can best handle the computing needs of the task most efficiently.

Speed: The highest speed that the microcontroller supports.

4

Page 5: 8051 report

Packaging: It may be a 40 pin DIP or a QFP, or some other packaging format. This is important in terms of space, assembling, and prototyping the end product.

Power consumption: this is especially critical for battery-powered products. The number of I/O pins and the timer on the chip. How easy it is to upgrade to higher-performance or lower consumption versions. Cost per unit: This is important in terms of the final cost of the product in which

a microcontroller is used.

2. The second criterion in choosing a microcontroller is how easy it is to develop products around it. Key considerations include the availability of an assembler, debugger, compiler, technical support.

3. The third criterion in choosing a microcontroller its ready availability in needed quantities both now and in the future. Currently of the leading 8-bit microcontroller, the 8051 family has the largest number of diversified suppliers. By supplier is meant a producer besides the originator of the microcontroller. In the case of the 8051, this has originated by Intel several companies also currently producing the 8051. Thus the microcontroller AT89C52, satisfying the criterion necessary for proposed application is chosen for the task.

2.3 INTRODUCTION TO 8051

In 1981, Intel corporation introduced an 8-bit microcontroller called the 8051. This microcontroller had 128 bytes of on chip ROM, two timers, one serial port and four ports (8-bits) all on a single chip. The 8051 is an 8 bit processor by the CPU. The 8051 has a total of four I/O ports, each 8-bit wide. Although 8051 can have a maximum of 64K bytes of on chip ROM, many manufacturers put only 4K bytes on the chip.

The 8051 became widely popular after Intel allow another manufactures to make any flavour of the 8051 they please with the condition that they remain code compatible with . the 8051. This led to many versions of the 8051 with different speeds and amount of on chip ROM marketed by the more than half a dozen manufactures. It is important to know that although there are different flavours of 8051, they are compatible with the original 8051 as far as the instructions are concerned. This means that if you write your program for one, it will run on any one of them regardless of the manufacturer. The 8051 manufactures are INTEL, ATMEL. DALLAS semiconductors, Philips corporation, Infineon.

2.4 AT89C52 from ATMEL Corporation

This popular 8051 clip has on-chip ROM in the form of flash memory. This is ideal for fast development since flash memory can be erased in seconds compared to twenty minutes or more needed for the earlier versions of the 8051. To use the AT89C52 to develop a microcontroller-based system requires a ROM burner that supports flash memory. However, a ROM eraser is not needed. Notice that in a flash memory you must erase the entire contents of ROM in order to program it again. The PROM burner does this erasing of flash itself and this is why separate burner is not needed. To eliminate the need for a PROM burner Atmel is working on a version of AT89C51 that can be programmed by serial COM port of the PC.

5

Page 6: 8051 report

2.5 Features of AT89C52

-256 Bytes internal RAM

-32 I/O pins

-Two 16 bit timers

-Six interrupts

-Serial programming facility

-40 pin Dual-in-line package

-on chip ROM 8 KB

2.6 Pin Description

The 89C52 have a total of 40 pins that are dedicated for various functions such as I/O, RD, WR, address and interrupts. Out of 40 pins, a total of 32 pins are set aside for the four ports PO, P1, P2, and P3, where each port takes 8 pins. The rest of pins are designed as V cc, GND, XTAL1, XTAL2, RST, EA, and PSEN. All these pins except PSEN and ALE are used by all members of the 8051 and 8031 families. In other words they must be connected in order to system to work, regardless of whether the microcontroller of the 8051 or the 8031 family. The other two pins, PSEN and ALE are used mainly in the 8031 based system.

2.6.1 Vcc

Pin 40 provides +ve supply voltage to the microcontroller. The voltage source is +5V, which is obtained from the regulated power supply circuit.

2.6.2 GND

Pin 20 is the ground.

2.6.3 XTAL1 and XTAL2

The 8051 have an on-chip oscillator but require external clock to run it. the most often quartz crystal oscillator is connected to the input XTAL1 (pin 19) and XTAL2(pin 18). The quartz crystal oscillator is connected to XTAL1 and XTAL2 also needs two capacitors of 33 pF value. One side of each capacitor is connected to the GND. Pin 20 is the GND. It must be noted that there are various speed of the 8051 family. Speed refers to the Max oscillator frequency connected to the XTAL. For e.g. a 12 MHz microcontroller must be connected to the crystal with 12 MHz frequency or less. Likewise, q 20 MHz microcontroller requires no more than 20 MHz. When the 8051 is connected to a crystal oscillator and is powered up, we can observe the frequency on the XTAL2 pin using CRO. The crystal oscillator is used in our system as a frequency of 11.0592 MHz.

6

Page 7: 8051 report

P1

RESET

RXD

TXDINT0INT1

T0

T1

RDWR

XTAL1

XTAL2GND

P3

Vcc

P0

EA

PSEN

ALE

P2

Figure 2.2 PIN Diagram of MICROCONTROLLER 8051

2.6.4 RST

Pin 9 is the RST (reset) pin. It is an input and active high circuit (normally low). Upon applying high pulse to this pin, the microcontroller will reset and terminate all the activities. This is often referred to as a power-on RST. Activating a power – on RST will cause all the values in resistor is lost. Notice that the value of PC is 0000 upon RST, forcing the CPU to fetch the first code from ROM memory location 0000. This means that you must placed the first line of source code in ROM location 0000 that is where CPU wakes up and expects to find the first instruction. In order that RST input is to be effective, it must have a minimum duration of two machine cycles. In others words, the high pulse must be high for a minimum of two machine cycle before it is allowed to go low.

2.6.5 EA

All the 8051 family members come with on chip ROM to store program. In such cases EA pin is connected to the Vcc. For the family members such as 8031 and 8032 in which there is no on chip ROM, code is store in external ROM and is fetched by the 8031/32. Therefore for the 8031, the EA pin must be connected to the GND to indicate that a code is stored

7

Page 8: 8051 report

externally. EA which stands for “external Access” is pin no 31 in the DIP packages. It is input pin and must be connected to either Vcc or GND in others words it must not be lied un-connected.

2.6.6 PSEN

This is an output pin. PSEN stands for “Program Store Enable “. It is the read store to the external program memory. When the microcontroller is executing from external memory PSEN is activated twice in each machine cycle.

2.6.7 ALE

ALE stands for “Address Latch Enable”. It is an O/P pin and is active high. When connecting a microcontroller to a external memory, port P0 provides both address and data. In the other words the microcontroller multiplexes data and address through port P0 to save pins. The ALE pin is used for de-multiplexing the address by connecting to the G pin of the 74LS373 chip.

2.6.8 I/O port pins and their functions

The four ports P0, P1, P2, P3, we use eight pins, making them 8 -bit ports. All the port upon RST are configured as O/P, ready to be used as O/P ports. To use any of these as I/P port it must be programmed.

2.6.8.1 Port 0

Port 0 occupies a total of 8 pins (pins 32 to 39). It can be used for input or output. To use the pins of port 0 as both input and output ports, each pin must be connected to a 10 K-ohm pull-up resistors. This is due to fact that port 0 is an open drain, unlike P1, P2 and P3. With external pull up resistors connected upon reset, port 0 is configured as output port. In order to make port 0 as input, port must be programmed by writing 1to all the bits of it. Port 0 is also designed as AD0-AD7, allowing it be used as bots data and address. When connecting a microcontroller to an external memory, port 0 provides both data and address. The microcontroller multiplexes address and data through port 0 to save pins. ALE indicates if P0 has address or data. When ALE=1, it provides address(A0-A7) and when ALE-0, it provides data(D0-D7). Therefore ALE is used for demultiplexing address and data with the help of latch 74LS373.

2.6.8.2 Port 1

Port 1 occupies a total of 8 pins (pins 1 to 8). It can be used for input or output .In contrast to port 0, this port doesn’t requires pull up resistor. Since it has already pull up resistor internally. Upon reset, port1 configured as an O/P port. Similar to port 0, port1 can be used as an input port by writing 1 in the program.

2.6.8.3 Port 2

Port 2 occupies a total of 8 pins (pins 21 to 28). It can be used for input or output. Just like P1, port 2 doesn’t requires pull up resistor. Since it has already pull up resistor internally. Upon reset, port2 configured as an O/P port. Similar to port 1, port2 can be used as an input port by writing 1 in the program.

8

Page 9: 8051 report

2.6.8.4 Port 3

Port 3 occupies a total of 8 pins (pins 10 to 17). It can be used for input or output. Just like P1, port 3 doesn’t requires pull up resistor. Since it has already pull up resistor internally. Upon reset, port3 configured as an O/P port. Similar to port 1, port3 can be used as an input port by writing 1 in the program.

2.7 Registers

In the CPU, registers are used to store information temporarily. That information could be a byte of data to be processed, or an address pointing to the data to be fetched. In the 8051 there is only one data type: 8 bits. With an 8 bit data type, any data larger than 8 bits has to be broken into 8-bit chunks before it is processed.

The most commonly used registers of the 8051 are A (accumulator), B, R0, R1, R2, R3, R4, R5, R6, R7, DPTR (data pointer) and PC (program counter). All the above registers are 8-bit registers except DPTR and the program counter. The accumulator A is used for all arithmetic and logic instructions.

2.8 Program Counter and Data Pointer

The program counter is a 16- bit register and it points to the address of the next instruction to be executed. As the CPU fetches op-code from the program ROM, the program counter is incremented to the next instruction. Since the PC is 16 bit wide, it can access program addresses 0000 to FFFFH, a total of 64K bytes of code. However, not all the members of the 8051 have the entire 64K bytes of on-chip ROM installed.

The DPTR register is made up of two 8-bit registers, DPH and DPL, which are used to furnish memory addresses for internal and external data access. The DPTR is under the control of program instructions and can be specified by its name, DPTR. DPTR does not have a single internal address, DPH and DPL are assigned an address each.

2.9 Flag bits and PSW Register

Like any other microprocessor, the 8051 have a flag register to indicate arithmetic conditions such as the carry bit. The flag register in the 8051 is called the program status word (PSW) register.

The program status word (PSW) register is an 8-bit register. It is also referred as the flag register. Although the PSW register is 8-bit wide, only 6 bits of it are used by the microcontroller. The two unused bits are user definable flags. Four of the flags are conditional flags, meaning they indicate some conditions that resulted after an instruction as executed. These four are CY (carry), AC (auxiliary carry), P (parity) and OV (overflow).

CY, The Carry Flag

This flag is set whenever there is a carry out from the d7 bit. This flag bit is affected after an 8-bit addition or subtraction. It can also be set to 1 or 0 by an instruction such as “SETB C” and “CLR C”, where “SETB C” stands for set bit carry and “CLR C” stands for clear carry.

9

Page 10: 8051 report

AC, The Auxiliary Carry Flag

If there is carry form D3 to D4 during an ADD or SUB operation, this bit is set; otherwise cleared. This flag is used by instructions that perform BCD arithmetic.

P, The Parity Flag

The parity flag reflects the number of 1s in the accumulator register only. If the register A contains an odd number of 1s, then P=1. Therefore, P=0 if A has an even number of 1s.

OV, The Overflow Flag

This flag is set whenever the result of a signed number operation is too large, causing the high order bit to overflow into the sign bit. In general, the carry flag is used to detect errors in unsigned arithmetic operations.

2.10 Internal ROM

The 89C52 has 8K bits of on-chip ROM. This 8K bytes ROM memory has memory addresses of 0000 to 0FFFh. Program addresses higher than 0FFFh, which exceed the internal ROM capacity will cause the microcontroller to automatically fetch code bytes from external memory. Code bytes can also be fetched exclusively from an external memory, addresses 0000h to FFFFh, by connecting the external access pin to ground. The program counter doesn’t care where the code is: the circuit designer decides whether the code is found totally in internal ROM, totally in external ROM or in a combination of internal and external ROM.

2.11 Internal RAM

The 1289 bytes of RAM inside the 8051 are assigned addresses 00 to 7Fh. These 128 bytes can be divided into three different groups as follows:

1. A total of 32 bytes from locations 00 to 1Fhare set asidefor register banks and the sack.2. A total of 16 bytes from locations 20h to 2Fh are set aside for bit addressable read/write

memory and instructions.3. A total of 80 bytes from locations 30h to 7Fh are used for read and write storage, or what

is normally called a scratch pad. These 80 locations of RAM are widely used for the purpose of storing data and parameters by 8051 programmers.

10

Page 11: 8051 report

CHAPTER 3

INTERFACING OF MICROCONTROLLER

3.1 INTERFACINGS WITH THE REAL WORLD DEVICES

3.1.1 INTERFACE

A program that controls a display for the user (usually on a computer monitor) and that allows the user to interact with the system part of a system exposed to a user. In general, the system can be any kind of system with which a user may interact at will, such as a mechanical system or a computer system. (Fluid, Electronic, Optic…) One of the important issues in micro-fluidics is the interfacing of all the elements. How to align optical fibres? How to connect wires to the micro-device? How to introduce a sample into the fluid channel? These are some of the questions, which have to be solved.

An interface is a set of commands or menus through which a user Communicates with a program. A command-driven interface is one in which you enter commands. A menu-driven interface is one in which you select command choices from various menus displayed on the screen.

Interfacing is a common term for a variety of materials used on the unseen or "wrong" side of fabrics in sewing. Interfacings can be used to stiffen or add body to fabric, such as the interfacing used in shirt collars; to strengthen a certain area of the fabric, for instance where buttonholes will be sewn; or to keep fabrics, particularly knit fabrics, from stretching out of shape. Interfacings come in a variety of weights and stiffnesses to suit different purposes.

3.1.2 USER INTERFACE

The user interface is the aggregate of means by which people (the users) Interact with a particular machine, device, computer program or other complex tool (the system). The user interface provides means of: * Input, allowing the users to control the system* & Output, allowing the system to inform the users (also referred to as feedback). A good user interface makes it easy for users to do what they want to do.

The junction between a user and a computer program. An interface is a set of commands or menus through which a user communicates with a program. A command-driven interface is one in which you enter commands. A menu-driven interface is one in which you select command choices from various menus displayed on the screen. The user interface is one of the most important parts of any program because it determines how easily you can make the program do what we want to. It is widely accepted that the user interface can make a critical difference in the perceived utility of a system regardless of the system's performance.

In other words, the physical means of communication between a person and a software program or operating system. At its most basic, this is the exchange of typed statements in English or a program-like set of commands. It is the method by which the human operator communicates with the various database, system, and applications modules.

11

Page 12: 8051 report

3.1.3 Efficiency of User Interface Design

Many technological innovations rely upon User Interface Design to elevate their technical complexity to a usable product. Technology alone may not win user acceptance and subsequent marketability. The User Experience, or how the user experiences the end product, is the key to acceptance. And at is where User Interface Design enters the design the process. While product engineers focus on the technology, usability specialists focus on the user interface. For greatest efficiency and cost effectiveness, this working relationship should be maintained from the start of a project to its rollout.

When applied to computer software, User Interface Design is also known as Human-Computer Interaction or HCI. While people often think of Interface Design in terms of computers, it also refers to many products where the user interacts with controls or displays. Military aircraft, vehicles, airports, audio equipment, and computer peripherals, are a few products that extensively apply User Interface Design. Optimized User Interface Design requires a systematic approach to the design process. But, to ensure optimum performance, Usability testing is required. This empirical testing permits naïve users to provide data about what does work as anticipated and what does not work. Only after the resulting repairs are made can a product be deemed to have a user optimized interface. The importance of good User Interface Design can be the difference between product acceptance and rejection in the marketplace. If end-users feel it is not easy to learn, not easy to use, or too cumbersome, an otherwise excellent product could fail. Good User Interface Design can make a product easy to understand and use, which results in greater user acceptance.

3.2 The need of Power Supply

To prepare any circuit, first of all we need a power supply to operate it. Similarly, for interfacing the devices we require a power supply. A microcontroller operates at a regular voltage of 5 volts, which is generated by using the following components:

(a) Transformer

(b) Bridge Rectifier

(c) Shunt Capacitor

(d) Voltage Regulator

FIGURE:3.1 Block Diagram of Power Supply.

3.2.1 Description of Power Supply

The transformer steps down the 220 V a/c into the 12 V a/c. The transformer works on the principle of magnetic induction, where two coils: primary and secondary are wound around an iron core. The two coils are physically insulated from each other in such a way that

12

TRANSFORMER BRIDGE RECTIFIER SHUNT CAPACITOR VOLTAGE REGULATOR

Page 13: 8051 report

780512-0-12 V

1N 4007

passing an a/c current through the primary coil creates a changing voltage in the primary coil and a changing magnetic field in the core. This in turn indicates a varying a/c voltage in the secondary coil.

The a/c voltage is then fed to the bridge rectifier. The rectifier circuit used in the most electronic power supplies is the single phase bridge rectifier with capacitor filtering, usually followed by a linear voltage regulator. A rectifier circuit is necessary to convert a signal having zero average value into a non-zero average value. A rectifier transforms alternating current into direct current by limiting or regulating the direction of flow of current. The output resulting from a rectifier is a pulsating D.C. voltage. This voltage is not appropriate for the components that are going to work through it.

FIGURE 3.2: Circuit diagram of power supply

The ripple of the D.C. voltage is smoothened using a filter capacitor of 1000microF–25V The filter capacitor stores electrical charge. If it is large enough, the capacitor will store charge as the voltage rises and give up the charge as the voltage falls. This has the effect of smoothing out the waveform and provides steadier voltage output. A filter capacitor is connected at the rectifier output and the d.c voltage is obtained across the capacitor. When this capacitor is used in this project, it should be twice the supply voltage. When the filter is used, the RC charge time of the filter capacitor must be short and the RC discharge time must be long to eliminate ripple action. In other words, the capacitor must charge up fast, preferably with no discharge.

When the capacitor output voltage is increasing, the capacitor charges to the peak voltage Vm. Just past the positive peak, the rectifier output voltage starts to fall but at this point the capacitor has +Vm voltage across it. Since, the source voltage becomes slightly less than Vm, the capacitor will try to send current back through the diode of rectifier. This reverse biases the diode. The diode disconnects or separates the source from the load. This prevents the load

13

Page 14: 8051 report

voltage from falling to zero. The capacitor continues to discharge until source voltage becomes more than capacitor voltage. The diode again starts conducting and the capacitor is again charged to the peak value Vm. When the capacitor is charging, the rectifier supplies the charging through capacitor as well as the load current, the capacitor sends currents through the load. The rate at which capacitor discharges depends upon the time constant RC. The longer the time constant, the steadier is the output voltage. An increase in the load current i.e. decrease in resistance makes time constant of discharge path smaller. The ripple increases and d.c output voltage Vdc decreases. Maximum capacity cannot exceed a certain limit because the larger the capacitance the greater is the current required to charge the capacitor.

The voltage regulator regulates the supply if the line voltage increases or decreases. Input voltage is applied at the IC input pin i.e. pin 1, which is filtered by capacitor. The output terminal of IC i.e. pin 3, provides a regular output. The third terminal i.e. pin 2, is connected to ground. While the input voltage may vary over some permissible voltage range, and the output voltage remains constant within specified voltage variation limit. The 78XX ICs are positive voltage regulators while 79XX ICs are negative voltage regulators.

These voltage regulators are integrated circuits designed as fixed voltage regulators for a wide variety of applications. These regulators employ a current limiting, thermal shutdown and safe area compensation. With adequate heat sinking, they can deliver output currents in excess of 1A. These regulators have internal thermal overload protection. It uses output transistor safe area compensation and the output voltage offered is in 2% and 4% tolerance.

3.3 Interfacing Led With Microcontroller

3.3.1 LED

A light emitting diode (LED) is a semi-conductor diode that emits incoherent narrow spectrum light when electrically biased in the forward direction of the p-n junction. This effect is a form of electro-luminescence. An LED is usually a small area source, often with extra optics added to the chip that shapes its radiation pattern. The colour of the emitted light depends on the composition and condition of the semiconducting material used, and can be infrared, visible or near ultra-violet. An LED can be used as a regulator household light source.

Like a normal diode, the LED consists of a chip of semiconducting material doped with impurities to create a p-n junction. As in other diodes, current flows easily from the p-side, or anode, to the n-side, or cathode, but not in the reverse direction. Charge-carriers—electrons and holes flow into the junction from electrons with different voltages. When an electron meets a hole, it falls into a lower energy level, and releases energy in the form of a photon.

The wavelength of the light emitted, and thus its color, depends on the band gap energy of the materials forming the p-n junction. In silicon or germanium diodes, the electrons and holes recombine by a non-radiative transition which produces no optical emission, because these are indirect band gap materials. The materials used for the LED have a indirect band gap with energies corresponding to near-infrared, visible or near-ultraviolet light.

LED development began with infrared and red devices made with gallium arsenide. Advances in material science have enabled making devices with ever-shorter wavelengths, emitting light in a variety of colors.

14

Page 15: 8051 report

Figure 3.3: Light Emitted Diode.

3.3.3 Program For LED Interfacing

3.3.3.1 Programs for LEDs Pattern.#include<reg51.h>

#include<intrins.h>

void ms_delay(unsigned char n)

{

unsigned char i,j;

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

{

For(j=0;j<=70;j++)

{

_nop_( );

}

}

}

void sec_delay(unsigned char n)

{

unsigned char i,j;

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

15

Page 16: 8051 report

{

For(j=0;j<=250;j++)

{

ms_delay(4);

}

}

}

void main( ) // 1. For Blinking led.

{

while(1)

{

P1=0xff;

sec_delay(1);

P1=0x00;

Sec_delay(1);

}

}

3.3.3.2. For left shift.

void main( )

{

unsigned char i,a;

while(1)

{

a=0xff;

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

{

P1=a;

a=a<<1;

16

Page 17: 8051 report

sec_delay(1);

}

}

}

3.3.3.3. For Single led shift left.

void main( )

{

unsigned char i,a;

while(1)

{

Sec_delay(1);

a=0xFE;

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

{

P1=a;

a=a<<1;

a=a+1;

sec_delay(1);

}

}

}

3.4 INTERFACING OF LCD WITH MICROCONTROLLER

An intelligent LCD has two lines with 20 characters each line.The display contains two internal byte wide registers, one for commands and second for characters to be displayed. It also contains a user programmed RAM area that can be programmed to generate any desired character that can be formed using a dot matrix. To distinguish between these two data areas, the hex command byte 80 will be used to signify that the display RAM address 00h is chosen.

17

Page 18: 8051 report

From diagram Port 1 of microcontroller is used for 8 bit data display on the LCD. Data lines of the LCD Pin no.7 to pin no 14 are connected to the port 1 of the microcontroller. The control pin no.4 register select is connected to P3.5, pin no.5 of LCD for Read/write is connected to P3.6 and the enable pin (6) is connected to microcontroller

3.4.1 LCD Display

Liquid crystal displays (LCDs) are widely used as compared to LEDs. This is due to the declining prices of LCDs, the ability to display numbers, characters and graphics, incorporation of a refreshing controller into the LCD, thereby relieving the LCD of the task of refreshing the LCD and also the ease of programming for characters and graphics. HD44780 based LCDs are most commonly used.

Table 3.1 LCD pin description

Pin Symbol I/O Description

1 VSS - Ground

2 VCC - +5V power supply

3 VEE - Power supply to control contrast

4 RS I RS=0 to select command register, RS=1 to select data register.

5 R/W I R/W=0 for write, R/W=1 for read

6 E I/O Enable

7 PB0 I/O The 8 bit data bus

8 PB1 I/O The 8 bit data bus

9 DB2 I/O The 8 bit data bus

10 DB3 I/O The 8 bit data bus

11 DB4 I/O The 8 bit data bus

12 DB5 I/O The 8 bit data bus

13 DB6 I/O The 8 bit data bus

14 DB7 I/O The 8 bit data bus

3.4.2 LCD Pin Description

The LCD discussed in this section has the most common connector used for the Hitachi 44780 based LCD having 14 pins in a row and modes of operation and how to program and interface with microcontroller is described in this section.

VCC, VSS, VEE

18

Page 19: 8051 report

The voltage VCC and VSS provided by +5V and ground respectively while VEE is used for controlling LCD contrast. Variable voltage between ground and VCC is used to specify the contrast (or “darkness”) of the characters on the LCD screen.

RS (register select)

There are two important registers inside the LCD. The RS pin is used for their selection as follows. If RS=0, the instruction command code register is selected, then allowing the user to send a command such as clear display, cursor at home etc.. If RS=1, the data register is selected, allowing user to send data to be displayed on the LCD.

R/W (read/write)

The R/W (read/write) input allowing the user to write information to it or to read information from it. R/W=1, to read and R/W=0, to write.

EN (enable)

The enable pin is used by the LCD to latch information presented to its data pins. When data is supplied to data pins, a high-power, high to low pulse must be applied to this pin in order to for the LCD to latch in the data presented at the data pins.

D0-D7 (data lines)

The 8-bit data pins, D0-D7, are used to send information to the LCD or read the contents of the LCD’s internal registers. To display the letters and numbers, we send ASCII codes for the letters A-Z, a-z, and numbers 0-9 to these pins while making RS=1. There are also command codes that can be sent to clear the display or force the cursor to the home position or blink the cursor.

We also use RS=0 to check the busy flag bit to see if the LCD is ready to receive the information. The busy flag is D7 and can be read when R/W=1 and RS=0, as follows: If R/W=1 and RS=0, when D7=1 (busy flag=1), the LCD is busy taking care of internal operations and will not accept any information. When D7=0, the LCD is ready to receive new information.

An Example of Hardware Configuration

As we’ve mentioned, the LCD requires either 8 or 11 I/O lines to communicate with. For the sake of this tutorial, we are going to use an 8-bit data bus, so, we’ll be using 11 of the 8051’s I/O pins to interface with the LCD.

Figure 3.4: Pin descriptionof LCD Interfacing with Microcontroller

3.4.3 Checking the Busy Status of the LCD

19

Page 20: 8051 report

As previously mentioned, it takes a certain amount of time for each instruction to be executed by the LCD. The delay varies depending on the frequency of the crystal attached to the oscillator input of the 44780 as well as the instruction which is being executed.

While it is possible to write code that waits for a specific amount of time to allow the LCD to execute instructions, this method of “waiting” is not very flexible. If the crystal frequency is changed, the software will need to be modified. Additionally, if the LCD itself is changed for another LCD which, although 44780 compatible, requires more time to perform its operations, the program will not work until it is properly modified.

A more robust method is to use the “Get LCD Status” command to determine whether the LCD is still busy executing the last instruction received.

The “Get LCD Status” command will return to us two bits of information; the information that is useful to us right now is found in DB7. In summary, when we issue the “Get LCD Status” command the LCD will immediately raise DB7 if it’s still busy executing a command or lower DB7 to indicate that the LCD is no longer occupied. Thus our program can query the LCD until DB7 goes low, indicating the LCD is no longer busy. At that point, we are free to continue and send the next command.

3.4.4 LCD Command Code

TABLE 3.2: important commands.

3.4.5 PROGRAM FOR LCD INTERFACING

20

Code

(HEX)

Command to LCD Instruction

Register0x01 Clear the display screen0x02 Return home0x04 Decrement cursor(shift cursor to left)0x05 Shift display right by 1 bit0x06 Increment cursor(shift cursor to right)0x07 Shift display left by 1 bit0x08 Display off, cursor off0x0A Display off, cursor on0x0C Display on, cursor off0x0E Display on, cursor blinking0x0F Display on, cursor blinking0x10 Shift cursor position to left0x14 Shift cursor position to right0x18 Shift the entire display to left0x1C Shift the entire display to right0x80 Force cursor to the beginning of 1st line0xC0 Force cursor to the beginning of 2nd line0x38 16x2 display

Page 21: 8051 report

3.4.5.1 Program to create a function of COMMAND of LCD.

3.4.5.2 PROGRAM to create a function of DATAWRITE on LCD

void lcd_datawrite(unsigned char n)

{

ms_delay(20);

data=n;

RS=1;

RW=0;

E=1;

E=0;

}

3.4.5.3 Program to display a string on LCD.

#include<reg51.h>

#include<intrins.h>

#define data P0

#define RS P25

#define RW P26

#define E P27

Void main()

{

Lcd_cmd(0x38); //Calling to the FUNCTION of COMMAND on LCD

Ms_delay(5); // Calling to program of MS-DELAY.

Lcd_cmd(0x38); //Calling to the FUNCTION of COMMAND on LCD

Ms_delay(5); // Calling to program of MS-DELAY.

Lcd_cmd(0x06); //Calling to the FUNCTION of COMMAND on LCD

Lcd_cmd(0x0C); //Calling to the FUNCTION of COMMAND on LCD

21

Page 22: 8051 report

Lcd_cmd(0x01); //Calling to the FUNCTION of COMMAND on LCD

While(1)

{

Lcd_cmd(0x80); //Calling to the FUNCTION of COMMAND on LCD

Display(“ELETRONICS AND ”)

Lcd_cmd(0xc4); //Calling to the FUNCTION of COMMAND on LCD

Display(“COMMUNICATION”);

}

}

3.5 INTERFACING SEVEN SEGMENT DISPLAY WITH MICROCONTROLLER

3.5.1 Seven Segment Display

A seven-segment display, or seven-segment indicator, is a form of electronic display device for displaying decimal numerals that is an alternative to the more complex dot-matrix displays. Seven-segment displays are widely used in digital clocks, electronic meters, and other electronic devices for displaying numerical information. A seven segment display, as its name indicates, is composed of seven elements. Individually on or off, they can be combined to produce simplified representations of the Arabic numerals. Often the seven segments are arranged in and oblique (slanted) arrangement, which aids readability. In most applications, the seven segments are of nearly uniform shape and size (usually elongated hexagons, though trapezoids and rectangles can also be used), though in the case of adding machines, the vertical segments are longer and more oddly shaped at the ends in an effort to further enhance readability.

The seven segments are arranged as a rectangle of two vertical segments on each side with one horizontal segment on the top, middle, and bottom. Additionally, the seventh segment bisects the rectangle horizontally.

The segments of a 7-segment display are referred to by the letters A to G, where the optional DP Decimal Point (an "eighth segment") is used for the display of non-integer numbers.

22

Page 23: 8051 report

Figure 3.5: Seven Segment Display.

3.5.2 Different configurations of LED in Seven Segment Display.

The LED’s in segment are arranged in two different ways:

a) Common anode configurationb) Common cathode configuration

(i) (ii)

Figure 3.6: (i) Common anode configuration. (ii) Common cathode configuration

3.5.3 Hardware Configuration

Figure 3.7: Circuit diagram of Interfacing of Seven Segment Display with Microcontroller

3.5.4 Program for Interfacing Seven Segment Display.

23

Page 24: 8051 report

3.5.4.1 PROGRAM to display the NUMBERS on SEVEN SEGMENT DISPLAY using MICROCONTROLLER.

#include<reg51.h>

#include<intrins.h>

Void main()

{

Unsigned char[9]= {0x11;0xD7;0x32;0x92;0xD4;0x98;0x18;0xD3;10;0x90;0x11)

For(i=0;i<90;i++)

{

P3=a[i];

Sec_delay(1); // CALLING to the function of second DELAY.

}

}

3.6 INTERFACING SWITCHES WITH MICROCONTROLLER

3.6.1 Switches

In Electronics, a switch is an electrical component that can break an electrical circuit, interrupting the current or diverting it from one conductor to another. The most familiar form of switch is a manually operated electromechanical device with one or more sets of electrical contacts. Each set of contact can be in one of two states, either closed or open. In commercial applications, push buttons can be linked together by mechanical linkage so that the act of pushing one button causes other button to be released. In this way, a stop button can force a start button to be released.

Figure 3.8: Tactile Switch.

3.6.2 Program for Interfacing Switches.

24

Page 25: 8051 report

3.6.2.1 Program to use the SWITCHES with the MICROCONTROLLER.

Void main()

{if(P20==0)

{

While(1)

{

Unsigned char a,i;

a=0xFF;

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

{

P1=a;

a<<1;

Sec_delay(1); // CALLING to the function of second DELAY.

If(P21==0|| P22==0)

Break;

}

If(P21==0)

{while(1)

{unsigned char a,i,b,c;

a=b=c=0xFF;

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

{P1=c;

B=~a;

a=a<<1;

c=a+b;

sec_delay(1); // CALLING to the function of second DELAY.

if(P20==0|| P22==0)

25

Page 26: 8051 report

break;

}

3.7 INTERFACING OF D.C. MOTOR WITH MICROCONTROLLER.

3.7.1 D.C. Motor

Motor is a electromechanical device which converts electrical energy into mechanical energy. A current carrying conductor generates a magnetic field. Every DC motor has six basic parts – axle, rotor, stator, commutator, field magnet(s), and brushes.

Figure 3.9: DC Motor.

3.7.2 Working Principle

The principle upon which a d.c. motor work is very simple. If a current carrying conductor is placed in a magnetic field, magnetic force is experienced on conductor, the direction of which is given by the Fleming’s left hand rule and hence the conductor moves in the direction of force. The magnitude of the mechanical force experienced is given by:

F=BIcLc Newtons

Where B is the field strength in teslas,

Ic is the current flowing through the conductor in amperes

And Lc is the length of the conductor in metres.

26

Page 27: 8051 report

Figure 3.10: Working of DC Motor.

When the motor is connected to the d.c. supply, a direct current passes through the brushes and the commutator to the armature winding; while it passes through the commutator, it is converted into a.c. so that the group of conductors under successive field poles carry current in opposite direction. Also the direction of current in the individual conductors reverse as they pass away from the influence of one pole to that of the next.

The split phase arrangement of the motor creates two fluxes B1 and B2 which induces voltage around them in the rotor and under the influence of these induced voltages current flows in the rotor.

3.7.3 Types of D.C. motor

(i). Permanent Magnet Motors: It consists of an armature and one or several permanent magnets encircling the armature. Field coils are usually not required. However some of these motors do have coils wounded on the poles.

If they exist, these coils are intended only for recharging the magnets in the event that they loose their strength.

(ii). Separately Excited D.C. Motor: These motors have field coils similar to those of a shunt wound machine, but the armature and field coils are fed from different supply sources and may have different voltage ratings.

(iii). Series wound D.C. motor: As the name indicates, the field coils consisting of few turns of a thick wire are connected in series with the armature. The cross sectional area of the wire used for the field has to be fairly large to carry the armature current, but owing to the higher current, the number of turns of wire in them need not to be large.

(iv). Shunt wound D.C. motor: These motors are so named because they are basically operated with field coils connected in parallel with the armature.

The field winding consists of alarge number of turns of comparatively fine wires so as to provide large resistance. The field current is much less than the armature current, sometimes as low as 5%.

27

Page 28: 8051 report

(v). Compound wound D.C. motor: A compound wound D.C. motor has both shunt and series coils. The shunt field is normally stronger of the two. Compound wound motor are of two types:

(a) cumulative compound wound motor.

(b) Differential compound wound motor.

3.7.4 Program for Interfacing DC Motor.

3.7.4.1PROGRAM to control the Speed of the DC motor with the MICROCONTROLLER.

#include<reg51.h>

#include<intrins.h>

Void dc_speed (unsigned int n)

{

m=2.5*n;

P10=0;

Ms_delay(m);

P10=1;

Ms_delay(100-m);

}

Void main()

{

If(P20==0)

{

Dc_speed (10);

}

If(P21==0);

{

Dc_speed(20);

}

If (P22==0)

{

Dc_speed(0);

28

Page 29: 8051 report

}

Getch();

}

3.8 INTERFACING OF STEPPER MOTOR WITH MICROCONTROLLER.

3.8.1 Stepper Motor

A stepper motor is an electromechanical device which converts electrical pulses into discrete mechanical movements. Stepper motor is a form of ac motor. The shaft or spindle of a stepper motor rotates in discrete step increments when electrical command pulses are applied to it in the proper sequence. The motors rotation has several direct relationships to these applied input pulses.

Figure 3.11: Stepper Motor.

3.8.2 Working Principle

Motion control, in electronic terms, means to accurately control the movement of an object based on either speed, distance, load, inertia or a combination of all these factors. There are numerous types of motion control systems including; Stepper Motor, Linear Step Motor, DC Brush, Brushless, Servo, Brushless Servo, etc.

A stepper motor is an electromechanical device which converts electrical pulses into discrete mechanical movements. Stepper motor is a form of ac motor. The shaft or spindle of a stepper motor rotates in discrete step increments when electrical command pulses are applied to it in the proper sequence. The motors rotation has several direct relationships to these applied input pulses. The sequence of the applied pulses is directly related to the direction of motor’s shaft rotation. The speed of the motor shaft rotation os directly related to the frequency of the input pulses and the length of rotation is directly to the number of input pulses applied.

For every input pulse, the motor shaft turns through a specified number of degrees, called a step. Its working principle is one step rotation for one input pulse. The range of step size may vary from 0.72 degree to 90 degree. In position control application, if the number of input pulses sent to the motor is known, the actual position of the driven job can be obtained.

A stepper motor (SM) differs from a conventional motor (CM) as under:

29

Page 30: 8051 report

a. Input to SM is in the form of electric pulses whereas input to the CM is invariable from a constant voltage source.

b. A CM has a free running shaft whereas the shaft of SM moves through angular steps.c. In control system applications, no feedback loop is required when SM is used but a

feedback loop is required when CM is used.d. A SM is a digital electromechanical device whereas a CM is an analog

electromechanical device.

3.8.3 Open loop operation

One of the most significant advantage of a stepper motor is its ability to be accurately controlled in an open loop system. Open loop control meansno feedback information about position is needed. This type of control eliminates the need of expensive sensing and feedback devices such as optical encoders. Control position is known simply by keeping track of the input step pulses.

Every stepper motor has a permanent magnet rotor (shaft) surrounded by a stator. The most common stepper motor has four stator windings that are paired with a centre-tapped common. This type of motor is commonly referred to as a four-phased stepper motor. The centre tap allows a change of current direction in each of the two coils when a winding is grounded, thereby resulting in a polarity change of the stator. Notice that while a conventional motor shaft runs freely, the stepper motor shaft moves in a fixed repeatable increment which allows one to move it to a precise position. The repeatable

FIGURE 3.12: Rotor alignment.

Fixed movement is possible as a result of basic magnetic theory where poles of the same polarity repel and of opposite polarity attracts. The direction of the rotation is dictated by stator poles. The stator poles are determined by the current sent through the wire coils. As the direction of the current is changed, the polarity is also changed causing the reverse motion of the rotor. The stepper motor used here has a total of 5 leads: 4 leads representing the four stator windings and a common for the centre tapped leads. As the sequence of power is applied to

30

Page 31: 8051 report

each stator winding, the rotor will rotate. There are several widely used sequences where each has a different degree of precision. Table shows the normal 4-step sequence. For clockwise go for 1 to 4 & for counter clockwise go for step 4 to 1.

Winding D

Winding B

123

4 5 6

Winding DWinding C

Winding A

Figure 3.13: Stator Winding Configuration of Stepper Motor.

TABLE 3.3: Stator winding configuration.

Winding A Winding B Winding C Winding D0 1 1 11 0 1 11 1 0 11 0 1 0

3.8.4 Step angle & steps per revolution

Movement associated with a single step, depends on the internal construction of the motor, in particular the number of teeth on the stator and the rotor. The step angle is the minimum degree of rotation associated with a single step.

Step per revolution is the total number of steps needed to rotate one complete rotation or 360 degrees (example: 180 steps * 2 degrees = 360) [31].

Since the stepper motor is not ordinary motor and has four separate coils, which have to be energized one by one in step wise fashion. We term them as coil A,B,C,D. At a particular instant the coil A should get the supply and then after some delay the coil B should get supply and then coil C and then coil D and so on the cycle continues. The more the delay is introduced between the energizing of the coils the lesser the speed of the motor and vice versa.

3.8.5 Program for Interfacing Stepper Motor.

3.8.5.1 PROGRAM to control the STEPPER MOTOR with the help of MICROCONTROLLER.

#include<delay.h>

Void open(){P2=0x00;

31

Page 32: 8051 report

ms_delay(100);

P2=0x01;

ms_delay(100);

P2=0x02;

ms_delay(100);

P2=0x04;

ms_delay(100);

P2=0x08;

ms_delay(100);

P2=0x01;

ms_delay(100);

P2=0x02;

ms_delay(100);

P2=0x04;

ms_delay(100);

P2=0x08;

ms_delay(100);

P2=0x01;

ms_delay(100);

P2=0x02;

}

void close()

{

P2=0x00;

ms_delay(100);

32

Page 33: 8051 report

P2=0x08;

ms_delay(100);

P2=0x04;

ms_delay(100);

P2=0x02;

ms_delay(100);

P2=0x01;

ms_delay(100);

P2=0x08;

ms_delay(100);

P2=0x04;

ms_delay(100);

P2=0x02;

ms_delay(100);

P2=0x01;

ms_delay(100);

P2=0x08;

ms_delay(100);

P2=0x04;

}

void main()

{

while(1)

{

close();

33

Page 34: 8051 report

sec_delay(5); // CALLING to the function of second DELAY.

open();

}}}

34

Page 35: 8051 report

3.10 KEIL SOFTWARE

3.10.1 Introduction

Keil Software to provide you with software development tools for 8051 based microcontrollers. With the Keil tools, you can generate embedded applications for virtually every 8051 derivative. The supported microcontrollers are listed in the µVision Device Database. The Keil Software 8051 development tools are designed for the professional software developer, but any level of programmer can use them to get the most out of the 8051 microcontroller architecture.

3.10.2 Software development cycle

When you use the Keil µVision, the project development cycle is roughly the same as it is for any other software development project.

1. Create a project, select the target chip from the device database, and configure the tool settings.

2. Create source files in C or assembly.3. Build your application with the project manager.4. Correct errors in source files.5. Test the linked application.

3.10.3 Keil Components

The Keil Software 8051 development tools listed below are programs you use to compile your C code, assemble your assembly source files, link and locate object modules and libraries, create HEX files, and debug your target program.

3.10.4 How To Use Keil

1. Open the KEIL.2. The following window will pop up.

35

Page 36: 8051 report

Figure 3.14: 3. Go to the project & click on new project

4. Save the project by giving it a name.

36

Page 37: 8051 report

5. When you click on the save button, following window opens.6. Select I.C.

7. Now open a new file and save it as shown below:8. Write your program code and again save it.9. Right click on source group and then click on add files to group ‘source group 1’

10. Add the source file and Select the XTAL frequency.

37

Page 38: 8051 report

11. Click on output and select the option Create HEX File.

12. Open the New File and Write the Program in it.

38

Page 39: 8051 report

39