Submitted for partial fulfillment of award of



Submitted by:
Swati Kapoor Roll No. 2305385 4th Year ECE


CONTENTS 1) Company profile 2) PCB Designing
 Functions of PCB

 Classifications of PCBs  Technique used for PCB design  PCB design software 3) OrCad design environment  PCB design steps in OrCad i. Entry to schematic ii. Creating Netlist  Placement of Layout Plus  Setting board parameters  Creating board outline  Placement of components  Conductor routing  Design rule check  Post processing
4) Power system design

 Unregulated power supplies  Regulated power supplies  Bench supply diagram
5) Embedded Systems  What is Embedded System  Applications  Difference between microprocessor & micro controller 2

 Types of microcontroller Architectures  Difference between CISC & RISC  History of 8051  8051 core architecture  Pin description of 8051  Atmel’s AT89S8252 microcontroller  Feature of AT89S8252  Pin description of AT89S8252  Hardware interfacing & programming using AT89S8252  Software used for Embedded system design using MCS-51 family  Advantage of Embedded C over Assembly language programming  Interfacing o LED interfacing o LCD interfacing o Seven Segment Display Interfacing o ADC interfacing o Relay Interfacing o Matrix Keyboard Interfacing o Serial communication [b/w PC & Microcontroller] o Hardware interrupt programming

6) Project Details (Home Automation)


I would like to express my heartiest concern for Mr. Not to forget the pain staking efforts of our college training and placement cell and specially my training and placement officer Mr. Harmesh lal for his able guidance and for his inspiring attitude. I owe my deep regards for the supporting and kind staff authorities who are helping me in my lean patches during these six months.ACKNOWLEDGEMENT First of all I would like to thank almighty GOD who has given this wonderful gift of life to us. He is the one who is guiding us in right direction to follow noble path of humanity. Last but not the least I would express my utmost regards for the electronics and communication department of our Institute. In my six months industrial training it is a wonderful experience to be a part of NETMAX TECHNOLOGIES where I have opportunity to work under brilliant minds. Charanjeet Singh. The knowledge I am gaining throughout my studies have the practical implementation during this period. 4 . praiseworthy attitude and honest support. I am grateful to all the staff of NETMAX and for their timely support and sharing of their experience with me.

Mohali Glide Internet Services Rana Group IDS HFCL Infotel Ltd. Mohali BBMB The Tribune Quark 5 . Their clients for R&D support in field of embedded systems are: 1) 2) 3) 4) 5) Recorders and Medicare ltd Chandigarh. TELEBOX India ltd. Mohali Premier ISP. KANTA Electrical Ltd. In Education. Chandigarh. Targus technologies pvt ltd STPI. LINUX) and embedded systems (Micro controller based design. Chandigarh NIPER. Chandigarh Software Technology Parks India. Ltd. Network training and Embedded systems. Chandigarh Emmtel ISP. Impearl Electronics Pvt. Netmax technologies also conduct courses in CADENCE based design tools. Mohali Navik Technologies.COMPANY PROFILE Netmax Technologies is an organization which is established in the field of Network Support. Chandigarh. Netmax Technologies also provide Technical Research & Development support and consultancy to some Electronics companies. Chandigarh Innovative Solutions. It is also NOVELL EDUCATION PARTNER with which it provides NOVELL and SUSE LINUX courses. Lotus Machines Pvt. Electronics system design). Mohali. It provides support and training in the field of networking solutions (CISCO. The partial list of our clients for network field is as below: 1) 2) 3) 4) 5) 6) 7) 8) 9) 10) 11) 12) 13) 14) 15) 16) CEDTI. it has strategic alliance with REDHAT Inc. Ltd.

To meet the demands of Post PC era Netmax provides complete solutions as well as design-to-order services to satisfy its customers. CCNP b) RED HAT LINUX c) SUN SOLARIS d) WINDOWS 2000. 6 . Cache Engine. Switches. RAS etc) d) Bandwidth Manager software and hardware e) Radio Links f) Security Solutions Design Services (Embedded Systems) a) AVR family b) MCS 51 c) ELECTRONIC SYSTEM DESIGN Network Training a) CISCO CCNA. 2003 Netmax Technologies is a leader in education services and developer of innovative embedded solutions.17) Ind Swift Support Area (Networking Solutions) a) LINUX / UNIX networks b) SUN networks c) CISCO devices (Routers. Firewalls.

And also the size is large in these case but these are cheap. The size of this PCB is smaller than that of double sided PCB but it is very costly.In this case the board consists of alternating layers of conducting pattern and insulating material.These are the PCBs on which the conductive pattern is in on both sides. The size of board is small in this case but it is costlier than that of above. PCBs may also be either rigid. The conductive material is connected across the layers through plated through holes. Types of PCB PCB may be of different types:1) Single-sided 2) Double-sided 3) Multilayer Single sided PCBs: . the combination of PCB and 7 . silver and tin are also used in some cases.As the name suggest in these designs the conductive pattern is only at in one side. A PCB consists of a non-conducting substrate (typically fiber glass with epoxy as resin) upon which the conductive pattern or circuitry is formed. Copper is the most prevalent conductor although nickel. Printed circuit board (PCB) provides both the physical structure for mounting and holding the components as well as the electrical interconnection between the components. flexible. Multilayer PCBs: . That means a PCB = PWB (printed wiring board) is the platform upon which electronic components such as integrated circuit chips and other components are mounted. Double sided PCBs: . When the electronic components have been mounted on the PCB.PCB DESIGNING PCB stands for “PRINTED CIRCUIT BOARD”. or the combination of two (rigid-flex).

Each layer (top. components pads can be prepared by using black pads. DISADVANTAGS OF HAND-TAPING FOR PCB DESINING: o Each layer has to be designed separately. o In hand taping. Hand Taping 2. 1. o Routing of the board can be done by tapes with different widths. TECHNIQUES USED FOR PCB DESIGNING There mainly two techniques which are use for the PCB designs. o We cannot generate NCD files for CNC drilling. They are some times referred to as the base line in electronic packaging. bottom) has to prepare separately. Electronic packaging is fundamentally an inter connection technology and the PCB is the baseline building block of this technology. o Difficult to modify the design in the designing process or after designing. o Difficult to get good design overview. This assembly is the basic building block for all the electronic appliances such as television. computer and other goods.components is an electronic assembly. FUNCTIONS OF PCB Printed circuited boards are dielectric substrates with metallic circuitry formed on that. also called PRINTED CIRCUIT ASSEMBLY. Computer Aided Design 1) PCBs using Hand Taping: o PCB design using hand taping is the process of technical drawing. 8 . o In hand taping method layout should be prepared on grid paper.

semi-circular at different angles. Protel. CAD system for PCB designing requires following: o A computer system. The main advantages are given below: o Auto placement o Auto routing o After routing. o We can draw conductors as an arc. There are many enhanced features in electronics design automation tools which not possible in the hand taping. o Provides physical design reuse modules o Electrical rule check (ERC) o All the layers are generated from the same design by giving different options. TANGO. o Design Rule Check o Advanced CAD systems have high speed analysis.2) PCB DESIGNING USING CAD All the above difficulties can be removed by using CAB system. optimization of tracks can be done. Mentor etc. BASIC DESIGN STEPS IN CAD. o PCB design software like OrCad. o CAD system provides all NCD files and Gerber data files for photo plotting. o A photo plotter for art work generation.SYSTEM The following design steps are very common while designing a PCD in CAD: 9 . o Bill of material can be generated which contains number of different components used. CADSTAR.

• Net list file creation.• Entry the schematic diagram.SYSTEM Capture Gerber tools Gerber and plotter drawing Libraries Footprint libraries Layout Gerber and drill files Overview of a PCB Design Software There many soft wares which are used for PCB designs. • Placement of components manually or automatically. Some of them are given below:• OrCad • CADSTAR • Protel • TANGO • Mentor 10 . A TRADITIONAL DESIGN FLOW IN CAD. • Routing of the board using manual routing tools or auto router • Design rule check physical and electrical. • Artwork generation.

OrCad Layout delivers all the capabilities to designers need from netlist to place and route. The ease-of use and intuitive capabilities of OrCad Layout provides for quick startup and rapid learning right out of the box. Modern electronic design automation (EDA) tools are beginning to support a more efficient and integrated approach to electronic. or designing a digital block diagram with an HDL module. seamless tool integration.5 release continues that tradition. OrCad Capture provides simple schematic commands you need to enter. to final output.The most commonly software which are used for PCB design in India are Protel and OrCad OrCad Design Environment OrCad has a long history of providing individuals and teams with a complete set of technologies that offer unprecedented productivity.OrCad Capture® design entry is the most widely used schematic entry system in electronic design today for one simple reason: fast and universal design entry. and exceptional value. New 10. 11 . revising schematic diagram for an existing PCB. OrCad Layout ® offers PCB designers and PCB design teams the power and flexibility to create and share PCB data and constraints across the design flow. Today's lower cost and yet highly sophisticated electronic design automation systems have created a unique challenge to nearly every engineering department. Therefore the use of EDA tools has become increasingly important as product lifecycles have become shorter and shorter. Whether you're designing a new analog circuit. modify and verify the design for PCB.

One can print from within the schematic page editor. The entry of schematic diagram is the first step in PCB design using OrCad. So that one can parts.5 Entry of Schematic Diagram Schematic diagram provides the functional flow and the graphical representation of an electronic circuit.PCB DESIGN STEPS IN OrCad 10. buses and draw graphics. A schematic diagram consists of:• Electrical connections(nets) • Junctions • Integrated circuits symbols • Discrete components symbols like resistors. • Input / output connectors • Power and ground symbols • Buses • No connection symbols • Components reference names • Text The Schematic Page Editor: The schematic page editor is used to display and edit schematic pages. capacitors etc. 12 . or from the project window. wires. The schematic page editor has a tool palette that you can use to draw and place everything you need to create a schematic page.

includes message resulting from using capture’s tools.The Part editor: The part editor is used to create and edit parts. In part view one can:• Create and edit parts and symbols. off-page connector symbols. To display context-sensitive help for an error message. 13 . From the view menu of the part editor you can choose either part or package. then store in new or existing libraries. and title block • Use the tool palette’s electrical tools to place pins on parts. The Session Log: The session log lists the events that have occurred during the current Capture session. • Create and edit power and ground symbols. and its drawing tools to draw parts and symbols. put the cursor in the error message line in the session log press F1.

Your tab setting are saved and used each time you start capture. One can search for information in the session log using the find command on the Edit menu. The Toolbar: Capture’s toolbar is dock able (that means you can select and drag the toolbar to new location) as well as resizable. If tool button is dimmed. depending on which measurement system is selected in the window panel. you can’t perform that task in the current situation. and displays tool tips for each tool. You can also save the contents of the of the session log to a file. The default filename is SESSION. which is useful when working with Orcad’s technical support to solve technical problems.TXT. by choosing a tool button you can quickly perform a task. 14 .The ruler along the top appears in either inches or mill meters.

The schematic page editor tool palette: The first group of tools on the tool palette is electrical tools. used to create graphical objects without electrical connectivity. while others give you a choice of either operating on what is selected or expanding the scope to entire project. The drawing tools on the two tool palettes are identical. For hiding select from the schematic page editor’s view menu. The Tool Palette: Capture has two tool palettes: one for the schematic page editor and one for the part editor. and you press the right mouse button to display a context. 15 .Some of the tools operate only on what you have selected. however. You can hide the toolbar.sensitive pop-up menu. then display it again when u need it. They can also display tool tips that identify each tool. Both tool palettes are dock able and resizable. each tool palette has different electrical tools after you choose a tool. used to place electrical connectivity objects. The second group of tools is Drawing tools. choose TOOLBAR.

cutting. The net list dialog box displays. • From the tools. objects and edit them. The second group of tools is drawing tools. be sure one’s project is completed.The part editor tool palette: The first group of tools on the part palette is electrical tools. power and ground symbols. junctions. They have been already explained above within the schematic page editor tools. or editing. mirroring. rotating. used to create graphical objects without objects any electrical connectivity and is described: Pin Tools: Place pins on part Pin Array: Place multiple pins on part Selecting and deselecting of objects Once one selects an object. connectors. include moving. components. resizing. annotated and it is free from electrical rule violations. Grouping objects maintain relation ship among them while one moves them to another location. A net list file consists of nets. or group them in to a single object. Creating Net list File Net-list file is a document file which contains information about the logical interconnections between signals and pins. One can also select multiple. used to place pins and symbols. Creation of net list in capture: • Select your design in the project manager. 16 . no connection symbol. one can perform operations on it. copying. Before one create a net list file. choose create net list.

For the placement and routing of the components we normally use auto-placement and auto-routing. Steps for board design: • At first. • Layout plus includes design rules in order to guide logical placement and routing. • Click ok to create the net list. including nits of measurements. • Specify board parameters: Specifying global setting for the board. • If necessary. Unfortunately. If the selected format creates an additional file. and spacing in OrCad.• Choose a net list format tab. set the part value and PCB foot print combined property strings to reflect the information you want in the net list. pad stacks and via's. grids. In layout plus we also define the layer stacks. and spacing • Place components: Use the components tool in order to place manually the components which are fixed by the system designer on the board or otherwise use auto-placement. enter its file name in the second text box. • In the net list file text box. Within other soft wares you also have to place and route the components in similar way. grid. we have created a net list from our schematic diagram by using capture. enter a name for the output file. 17 . PLACEMENT OF LAYOUT PLUS What is Layout Plus? Layout plus is one part for the PCB design in which we place as well as route the components an set unit of measurement. At the same time you have to specify the board parameters. in a lot of soft wares some critical signals have to be routed manually before auto-routing. That means. load the net list into layout to create the board.

rename components. and create reports. which moves track you are currently routing as well as you can also auto route the board. It also provides tools to facilitate the design process such as to update components and design rule violation. cleanup design. run post processor. • Provide finishing of the board: Layout supplies an ordered progression of commands on the auto menu for finishing your design. Main window 18 .• Route the board: Use different routing technologies to route the board and take advantage of push and shove (a routing technology). it is primary window you use when designing your board. back annotate. These commands include design rule check. The design window: The design window provides a graphical display of printed circuit board.

• From the layout session frame’s file menu.Method to create a board with Layout Plus: • Ensure that net list with all footprints and necessary information has been created. Design window • Select the technology template (. then choose the open button and load the net list in other box. OrCad provides a directory for this purpose. choose New. The load template file in the dialog box displayed.TCH). and boar will co-exit and put the schematic design and net list. • Create a directory in which the schematic design. net list. 19 .

• Draw the board outline by using the obstacle tool in the tool bar. A designer should follow the following steps before going for it:• Optimize the board for component placement. So it is the main step in layout. Placement of components: Placement of components means that to place the components in designed box. respond to link footprints to component dialog. Setting board parameters: There is some parameter which should be set before placing the components on board. • Place components on the board. to draw the board outline of the actual size of PCB board. • Optimize placement using various placements Components can be placed by using two techniques:20 .• Then apply the auto ECO. • If necessary. They are as follows:• Set Datum • Create a board outline • Set units of measurements • Set system grid • Add mount holes Creating of board outline: Board outline is the graphical representation of the size of the actual PCB board. • Load the placement strategy file.

place it there. conductor widths and clearance. land-to-hole-ratio. Such type of verifications/design rule check contains beside the general verifications commonly two types:21 . Components sizes. and click ok. After completing the design of printed circuit board with the help of an EDA-Tool. choose the queue for placement. One may route board manually or automatically by auto router.1) Manual placement of components 2) Auto placement of components Choose the components tool bar button. a designer has again to verify the PCB in order to find out errors. positional accuracy and of course electrical interconnections had tad to be personally reviewed with a great deal of care. From the pop up men. Enter the reference designator of the components that you want to place in the appropriate text box. clearance to the edges. Drag the components to desired location. 100% auto routing can be achieved only when components are placed in the order of functional flow of electronic circuit. The components selection criteria dialog box appears. Conductor Routing in Layout:After placing all the components the other main step is to route the board from the electrical connections between the components. board areas to be free of components. The main routing tool available in OrCad is as flow:• Add/edit route mode • Edit segment mode • Shove track mode • Auto path route mode Design Rule Check:In manual designs every thing was checked as a possible source of error. hole sizes.

then use an active feedback circuit to eliminate the remaining ripple and dependence of output voltage on 22 . The unregulated power can be obtained using rectifying circuit after AC supply. i. work with DC. Regulated power supplies These are the power supplies in which the output voltage is constant. The common way is still a process to generate GERBER data and NCD files which can be used for photo plotting and for steps of CNC manufacturing and PCB. POWER SYSTEM DESIGN First part of electronics ckts. it may AC to or DC to DC voltage. load and other external conditions. The main power supply is in AC but mostly electronic ckts. A better approach to power supply design is to use enough capacitance to reduce ripple to low level. unregulated. The regulator voltage is mainly the DC voltage.drilling. etc. may be of different types such as regulated. and also effected by the environment conditions such as temperature. the out put voltage is independent of the input voltage. so these are the variable supplies. load. Power supplies may be used in.• Physical verification • Electrical verification Post processing:Post processing can be done once the design is completed in all aspects. That it is varies with input voltage. So to obtain the regulated voltage using different regulators. Commonly these supplies are not employed as there efficiency is very less. So a system is required to convert ac to dc and these sources should able to produce stable supplies.e. Unregulated power supplies These are the power supplies in which the out put is not constant. smps etc. is power.

e.These are the regulator whose output voltage can be varied according to the desired need. no 1 2 3 4 Name of regulator LM7905 LM7910 LM7912 LM7915 Output voltage -5v -10v -12v -15v Variable voltage regulators:. These regulators can be used to produce negative and positive voltage of required value. load and environment conditions.:• Positive • Negative 23 .input. Name of regulator Output voltage 1 LM 7805 5v 2 LM 7810 10v 3 LM 7812 12v 4 LM 7815 15v These regulators are used according to the required voltage need.These are also the constant output voltage regulator but there output is negative in polarity. These active devices are known as Regulators. Some of them are given below with there outputs:S. Constant negative voltage regulators:. The voltage regulators are of three types:1) Constant positive voltage regulators 2) Constant negative voltage regulators 3) Variable voltage regulators Constant positive voltage regulators:These are the regulators which are able to produce positive and constant voltage. Some of them are given below:S. These regulators are also employed according to voltage requirements. no. These regulators again of two types i.

The output of these regulators can be varied by varying the resistance of the variable resistance which is connected to the adjustable pin the regulators. supplies of several hundred volts can be regulated as long as the maximum input to output differential is not exceeded. 24 . Also.. thermal overload protection and safe area protection. An optional output capacitor can be added to improve transient response. Further. avoid short-circuiting the output. In addition to higher performance than fixed regulators. i. The adjustment terminal can be bypassed to achieve very high ripple rejection ratios which are difficult to achieve with standard voltage. They are exceptionally easy to use and require only two external resistors to set the output voltage. Included on the chip are current limit. no capacitors are needed unless the device is situated more than 6 inches from the input filter capacitors in which case an input bypass is needed. So these are the most commonly used regulators in the electronic industry as wide range of stable voltage can be obtained from single chip by varying the resistance connected to the adjustable pin of the regulators.e. The most commonly variable regulators are:• LM317 (it is positive regulator) • LM 337(it is negative regulator) There description is given below:LM317 3-Terminal Adjustable Regulator:General Description: The LM317 series of adjustable 3-terminal positive voltage regulators is capable of supplying in excess of 1. both line and load regulation is better than standard fixed regulators.5A over a 1.2V to 37V output range. theLM317 series offers full overload protection available only in IC’s. All overload protection circuitry remains fully functional even if the adjustment terminal is disconnected. Normally. the LM117 is packaged in standard transistor packages which are easily mounted and handled.

0. Guaranteed max.3% load regulation (LM317) 4. Guaranteed 1. Typical application: L 1 V M 3 1 2 U 7 / C Y L U 3 V I N I N V ADJ O T V O U T R 2 1 1 2 0 E C 2 . Guaranteed 1% output voltage tolerance (LM317A) 2. Current limit constant with temperature 25 .2V where most loads draw little current. or by connecting a fixed resistor between the adjustment pin and output.Also. Adjustable output down to 1. theLM317 can be used as a precision current regulator. 1 u F R 5 2 k Features 1. 1 u F C 1 . a programmable output regulator. 0.5A output current 5.01%/V line regulation (LM317A) 3. Guaranteed max.2V 6. Supplies with electronic shutdown can be achieved by clamping the adjustment terminal to ground which programs the output to 1. it makes an especially simple adjustable switching regulator.

constant current I1 then flows through the output set resistor R2.25V reference voltage.7. 80 dB ripple rejection 9. giving an output voltage of 26 . VREF. since the voltage is constant. P+ Product Enhancement tested 8. The reference voltage is impressed across program resistor R1 and. between the output and adjustment terminal. Output is short-circuit protected Packages of LM317 I Application Hints: In operation. the LM317 develops a nominal 1.

the output capacitor will discharge into the output of the regulator. If there is insufficient load on the output. In the LM317.Since the 100μA current from the adjustment terminal represents an error term. This is not true of other types of 27 . PROTECTION DIODES:When external capacitors are used with any IC regulator it is sometimes necessary to add protection diodes to prevent the capacitors from discharging through low current points into the regulator. and the rate of decrease of VIN. the output will rise. Although the surge is short. all quiescent operating current is returned to the output establishing a minimum load current requirement. To do this. the LM317 was designed to minimize IADJ and make it very constant with line and load changes. this discharge path is through a large junction that is able to sustain 15A surge with no problem. The discharge current depends on the value of the capacitor. the output voltage of the regulator. When an output capacitor is connected to a regulator and the input is shorted. Most 10μF capacitors have low enough internal series resistance to deliver 20A spikes when shorted. there is enough energy to damage parts of the IC.

Figure 3 shows an LM317 with protection diodes included for use with outputs greater than 25V and high values of output capacitance. For output capacitors of 25μF or less. No protection is needed r for output voltages of 25V or less and 10μF capacitance.positive regulators. 28 . Discharge occurs when either the input or output is shorted. Internal to the LM317 is a 50  esistor which limits the peak discharge current. there is no need to use diodes. The bypass capacitor on the adjustment terminal can discharge through a low current junction.

The LM337 are ideal complements to the LM317 adjustable positive regulators. The LM337 serves a wide variety of applications including local on-card regulation.2V to −37V.5A over an output voltage range of −1. These regulators are exceptionally easy to apply. thermal shutdown and safe-area compensation. making them virtually blowout-proof against overloads.LM337 3-Terminal Adjustable Regulator:- General Description: The LM337 is adjustable 3-terminal negative voltage regulators capable of supplying in excess of −1. programmable-output voltage regulation or precision current regulation. requiring only 2 external resistors to set the output voltage and 1 output capacitor for frequency compensation. The circuit design has been optimized for excellent regulation and low thermal transients. the LM337 series features internal current limiting. Further. Pin diagram 29 .

30 .002%/W 6) 77 dB ripple rejection 7) Excellent rejection of thermal transients 8) Temperature-independent current limit 9) Internal thermal overload protection 10) Standard 3-lead transistor package 11) Output is short circuit protected. which is much sufficient to drive any electronic circuit. −55°C to +150°C 3) Line regulation typically 0.2V to −37V 2) 1. 0. These two Ic's i. LM337and LM317are mainly used in the regulated power supplies because using these regulator a wide range of output can be obtain which can be varied from 0v to 30v.e.5A output current guaranteed.3% 5) Excellent thermal regulation.Features: 1) Output voltage adjustable from −1.01%/V 4) Load regulation typically 0.

Bench supply diagram D 1 2 U L 3 2 2 C 0 8 C B B J 1 2 3 C O N 3 R 4 8 3 R R 1 I D + 2 G 1 E 1 1 0 1 4 10uF 25V T AN T C 12 R R 0 u F 5 0 V 5 2 N 4 1 L M 3 2 1 7 / T O 2 2 0 I N 3 2 1 D R 1 R R R 9 P 1 O 0 T R 8 1 1N 4007 C 9 C 1K 1W R 12 470uF 50V C 1 A 0 P 3 1 D 4 5 6 U C T O V R S J 1 2 S 3 C A 7 U D I O _ 0 0 0 7 V IV N O ADJ U T 2 .V S L M 3 3 1 7 / T 2 D 1 N 5 O 2 D 2 0 1 N 4 4 0 0 I N 4 0 0 7 D U C T O R A U D I O _ 0 31 .V O N 3 1 1 R 1 1 P3 O 4 T R 1 5 C 13 R R R 16 C 470uF 50V 1 5 C C 1 A 6 P 10uF 25V T AN T 2 2 0 0 u F C C 1 41 7 15 00 4V U 2 6 1 R V ADJ I N 3 V O U R T 1 1 2 7 6 5 7 4 1K 1W L 2 1 2 3 .

consumer and office appliances.g. It is a part of a larger system which may not be a “computer”Works in a reactive & time constrained environment. in contrast to a general-purpose computer that loads its programs into RAM each time. • Consumer products. desktop or laptop computer is known as embedded system. FAX machines etc. • ATMs • Aircrafts 32 .g. but that is not a general-purpose workstation. the software is permanently set into a read-only memory such as a ROM or flash memory chip. cell phones. The uses are endless. machine tools. microwave ovens etc. • Automobiles (anti-lock braking. Any electronic system that uses a CPU chip. planes. e.. e. space vehicles. Sometimes.) • Industrial process controller & defense applications. and billions of microprocessors are shipped every year for a myriad of applications. In embedded systems. engine control etc. washers. cameras. cameras. PDAs and other handhelds as well as robots and toys. single board and rack mounted generalpurpose computers are called "embedded computers" if used to cont Embedded System Applications :• Consumer electronics. Such systems generally use microprocessors. They are used in automobiles.g. cell phones etc. microcontroller or they may use custom-designed chips or both. printers. trains. • Computer/Communication products.EMBEDDED SYSTEM What is Embedded System? Embedded system employs a combination of software & hardware to perform a specific function. e. • Medical Equipments.

P.P. I/O ports and a timer all on a single chip. ROM.P. Memory. • In order to make a Microprocessor functional we must add RAM.U • Whereas Microcontrollers may have one or two operational codes.U) popularly known as CPU on the chip. I/O Ports and timers externally to them. DISADVANTAGES OF MICROPROCESSORS OVER MICROCONTROLLERS • System designed using Microprocessors are bulky • They are expensive than Microcontrollers • We need to add some external devices such as PPI chip.U(microprocessor) in addition to a fixed amount of RAM. 33 . ROM. to make it functional. The Microprocessors contain no RAM.DIFFERENCE BETWEEN MICROPROCESSORS AND MICROCONTROLLERS: • A Microprocessor is a general purpose digital computer central processing unit(C. • On the other hand a Microcontroller has a C. • The Microprocessors have many operational codes(opcodes) for moving data from external memory to the C.e any amount of external memory can be added to it. and no I/P O/P ports on the chip itself.etc. Timer/counter chip.i. • But in controllers there is a fixed amount of memory which makes them ideal for many applications. no ROM. Interrupt controller chip.

4k bytes of on chip ROM. meaning that the CPU can work on only 8 bit data at a time. History of 8051 Intel Corporation introduced an 8-bit microcontroller called 8051 in 1981 this controller had 128 bytes of RAM. In common CISC chips are relatively slow (compared to RISC chips) per instruction. These are: 1)RISC. more instructions are needed to accomplish a task. It has for I/O 8 bit wide. Features of the 8051:Feature ROM RAM Timer I/O pins Serial port Interrupt sources Quantity 4K bytes 128 bytes 2 32 1 6 34 . Data larger than 8 bits broken into 8 bit pieces to be processed by CPU. The philosophy behind it is that almost no one uses complex assembly language instructions as used by CISC. RICS stands for Reduced Instruction Set Computer. Therefore fewer. MCS-51 family microcontrollers based on CISC architecture. and people mostly use compilers which never use complex instructions. one serial port. For instance Intel and AMD CPU's are based on CISC architectures. simpler and faster instructions would be better.Reduced instruction set computer 2)CISC.Complex instruction set computer Difference between CISC and RISC: CISC stands for Complex Instruction Set Computer. and four ports all are on single chip. However. Atmell’s AVR microcontroller based on RISC architecture. Typically CISC chips have a large amount of different and complex instructions.Types of microcontroller architecture: There are two types of Microcontroller architecture designed for embedded system development. The 8051 is an 8 bit processor. but use little (less than RISC) instructions. Most PC's use CPU based on this architecture. than the large. two timers. complex and slower CISC instructions.

optimized for control applications with extensive Boolean processing (single-bit logic capabilities). or an application-specific requirement. Whether it's low power operation. The 8051 microcontroller family offers developers a wide variety of high-integration and cost-effective solutions for virtually every basic embedded control application. the 8051 architecture puts you on the first step of a smooth and cost-effective upgrade path .c deliver high performance together with a choice of configurations and options matched to the special needs of each application. 35 . It's an 8-bit CPU. 8051 based microcontrollers are offered in hundreds of variants from many different silicon manufacturers . expanded on-chip RAM.The 8051 is based on an 8-bit CISC core with Harvard architecture. higher frequency performance. there's a version of the 8051 microcontroller that's right for the job. 8051 u. From traffic control equipment to input devices and computer networking products.8051 Architecture Overview The 8051 family is one of the most common microcontroller architectures used worldwide. 64K program and data memory address space and various on-chip the enhanced performance of the 151 and 251 microcontrollers. When it's time to upgrade product features and functionality.

Block diagram of 8051 36 .

Internal Architecture of 8051


Pin configuration of 8051


There are four ports P0, P1, P2 and P3 each use 8 pins, making them 8-bit ports. All the ports upon RESET are configured as output, ready to be used as output ports. To use any of these ports as an input port, it must be programmed. Port 0:- Port 0 occupies a total of 8 pins (pins 32-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 externally to a 10K ohm pull-up resistor. This is due to the fact that P0 is an open drain, unlike P1, P2, and P3.Open drain is a term used for MOS chips in the same way that open collector is used for TTL chips. With external pull-up resistors connected upon reset, port 0 is configured as an output port. For example, the following code will continuously send out to port 0 the alternating values 55H and AAH Port 0 as input:- With resistors connected to port 0, in order to make it an input, the port must be programmed by writing 1 to all the bits. In the following code, port 0 is configured first as an input port by writing 1's to it, and then data is received from the port and sent to


When ALE = 0. allowing it to be used for both address and data. It can be used as input or output. but when ALE =1 it has address and data with the help of a 74LS373 latch. Port 1 is configured as an output port. this port does not need any pull-up resistors since it already has pull-up resistors internally. it provides data D0-D7. port 0 provides both address and data. The 8051 multiplexes address and data through port 0 to save pins. ALE indicates if P0 has address or data. Dual Role of Port 0 :-Port 0 is also designated as AD0-AD7.Port 1 occupies a total of 8 pins (pins 1 through 8). When connecting an 8051/31 to an external memory.P1. Port 1:. In contrast to port 0. For 40 . Upon reset.

port 2 must be used along with P0 to provide the 16-bit address for the external memory. In other words.R6 & R5.example. it must programmed as such by writing 1 to all its bits. when 8031 is connected to external memory. For example.In systems based on the 8751. it must be programmed as such by writing 1 to all its bits. indicating the dual function. Then data is received from that port and is sent to P1 continuously. P2 does not need any pull-up resistors since it already has pull-up resistors internally. In the following code. While P0 provides the lower 8 bits via A0-A7.28). it is the job of P2 to provide bits A8-A15 of the address. Upon reset. As shown in pin configuration 8051. port 2 is configured first as an input port by writing 1’s to it.Port 2 is configured as an output port. P2 is used for the upper 8 bits of the 16 bit address. Just like P1. the following code will continuously send out to port1 the alternating values 55h & AAh Port 1 as input:-To make port1 an input port. 8951. then data is received from the port and saved in R7 . and DS5000.To make port 2 an input. In the following code port1 is configured first as an input port by writing 1’s to it. 41 . However. in 8031-based systems. Port 2 :-Port 2 occupies a total of 8 pins (pins 21. and it cannot be used for I/O. It can be used as input or output. it needs a path for the 16 bits of the address. port 2 is also designed as A8-A15. Port 2 as input:. Since an 8031 is capable of accessing 64K bytes of external memory. the following code will send out continuously to port 2 the alternating values 55h and AAH. That is all the bits of port 2 toggle continuously. P2 is used as simple I/O. Dual role of port 2:.

ALE operation can be disabled by setting bit 0 of SFR location 8EH.5 are used for timers 0 and 1. Setting the ALE-disable bit has no effect if the microcontroller is in external execution mode. that one ALE pulse is skipped during each access to external data memory. This information applies both 8051 and 8031 chips.2 P3.3 P3. Although port 3 is configured as an output port upon reset. Bits P3. pins 10 through 17. the same as P1 and P2 did not.6 and P3. PSEN Program Store Enable is the read strobe to external program memory. the pin is weakly pulled high. ALE is active only during a MOVX or MOVC instruction. Otherwise.3 are set aside for external interrupts.1 P3. Bits P3. P3 does not need any pull-up resistors. It can be used as input or output. ALE/PROG Address Latch Enable is an output pulse for latching the low byte of the address during accesses to external memory.4 P3. When the AT89S8252 is executing code from external program memory. Note.2 and P3. Port 3 has the additional function of providing some extremely important signals such as interrupts.Port 3:. There functions are as follows:PORT 3 P3.6 P3. PSEN is activated twice each machine 42 .4 and P3. In normal operation.0 P3. however.port 3 occupies a total of 8 pins.5 P3. This pin is also the program pulse input (PROG) during Flash programming.1 are used for the RxD and TxD serial communications signals. With the bit set.0 and P3.7 are used to provide the WR and RD signals of external memories connected in 8031 based systems. If desired.7 Function RxD TxD ___ Int0 ___ Int1 T0 T1 ___ WR ___ RD pin 10 11 12 13 14 15 16 17 P3. Finally P3. ALE is emitted at a constant rate of 1/ 6 the oscillator frequency and may be used for external timing or clocking purposes.

that if lock bit 1 is programmed. except that two PSEN activations are skipped during each access to external data memory. EA should be strapped to VCC for internal program executions. high-performance CMOS 8-bit microcomputer with 8K bytes of Downloadable Flash programmable and erasable read only memory and 2K bytes of EEPROM. programmable watchdog timer. The AT89S8252 is a low-power. 2K bytes of EEPROM. By combining a versatile 8-bit CPU with Downloadable Flash on a monolithic chip. and clock circuitry. The AT89S8252 provides the following standard features: 8K bytes of Downloadable Flash. 256 bytes of RAM. AT89s8252 AT89S8252 is an ATMEL controller with the core of intel MCS-51. The Power Down Mode saves the RAM contents but freezes the oscillator. a six-vector two-level interrupt architecture. the AT89S8252 is designed with static logic for operation down to zero frequency and supports two software selectable power saving modes. It has same pin configuration as give above. however. EA/VPP External Access Enable. This pin also receives the 12volt programming enable voltage (VPP) during Flash programming when 12-volt programming is selected. The Downloadable Flash can be changed a single byte at a time and is accessible through the SPI serial interface. serial port. The Idle Mode stops the CPU while allowing the RAM. disabling all other chip functions until the next interrupt or hardware reset. a full duplex serial port. 43 . In addition. and interrupt system to continue functioning. on-chip oscillator. the Atmel AT89S8252 is a powerful microcomputer which provides a highly flexible and cost effective solution to many embedded control applications. XTAL2 Output from the inverting oscillator amplifier. timer/counters. XTAL1 Input to the inverting oscillator amplifier and input to the internal clock operating circuit. EA will be internally latched on reset. EA must be strapped to GND in order to enable the device to fetch code from external program memory locations starting at 0000H up to FFFFH. The on-chip Downloadable Flash allows the program memory to be reprogrammed insystem through an SPI serial interface or by a conventional nonvolatile memory programmer. 32 I/O lines. Note.cycle. The device is manufactured using Atmel’s high density nonvolatile memory technology and is compatible with the industry standard 80C51 instruction set and pinout. two Data Pointers. Holding RESET active forces the SPI bus into a serial programming interface and allows the program memory to be written to or read from unless Lock Bit 2 has been activated. three 16-bit timer/counters.

0V to 6V Operating Range • Fully Static Operation: 0 Hz to 24 MHz • Three-Level Program Memory Lock • 256 x 8 bit Internal RAM • 32 Programmable I/O Lines • Three 16 bit Timer/Counters • Nine Interrupt Sources • Programmable UART Serial Channel • SPI Serial Interface • Low Power Idle and Power Down Modes • Interrupt Recovery From Power Down • Programmable Watchdog Timer • Dual Data Pointer • Power Off Flag Pin Description Furthermore.000 Write/Erase Cycles • 4.5.Endurance: 1.SPI Serial Interface for Program Downloading . P1. and P1.000 Write/Erase Cycles • 2K bytes EEPROM . P1.Features • Compatible with MCS-51™Products • 8K bytes of In-System Reprogrammable Downloadable Flash Memory .4. P1. 44 .7 can be configured as the SPI slave port select. data input/output and shift clock input/output pins as shown in the following table.Endurance: 100.6.

Note. When the AT89S8252 is executing code from external program memory. With the bit set. This pin is also the program pulse input (PROG) during Flash programming. that one ALE pulse is skipped during each access to external data memory. If desired. Setting the ALE-disable bit has no effect if the microcontroller is in external execution mode. In normal operation. Hardware interfacings and programming There are two types of programming language used for microcontroller programming: 1)Low Level Language(Assembly Language) 2) High Level Language(C Language)_ ALE/PROG Address Latch Enable is an output pulse for latching the low byte of the address during accesses to external memory. Otherwise. ALE is emitted at a constant rate of 1/ 6 the oscillator frequency and may be used for external timing or clocking purposes. ALE operation can be disabled by setting bit 0 of SFR location 8EH. PSEN is activated twice each machine 45 . however.Port 1 also receives the low-order address bytes during Flash programming and verification. PSEN Program Store Enable is the read strobe to external program memory. the pin is weakly pulled high. ALE is active only during a MOVX or MOVC instruction.

8051 assembler cum simulator. literature to refer to codes and abbreviations that are relatively easy to remember . XTAL2 Output from the inverting oscillator amplifier. EA will be internally latched on reset. This pin also receives the 12volt programming enable voltage (VPP) during Flash programming when 12-volt programming is selected. EA/VPP External Access Enable. however. Introduction to programming in assembly language: assembly languages were developed that provided mnemonics for the machine code instructions.cycle. Note. XTAL1 Input to the inverting oscillator amplifier and input to the internal clock operating circuit. EA should be strapped to VCC for internal program executions. that if lock bit 1 is programmed.The term mnemonic is frequently used in computer science and engg.Asssembly language programs must be translated into 46 . except that two PSEN activations are skipped during each access to external data memory. plus others features that made programming faster and less prone to error. EA must be strapped to GND in order to enable the device to fetch code from external program memory locations starting at 0000H up to FFFFH. Hardware interfacings and programming There are two types of programming language used for microcontroller programming: 1)Low Level Language(Assembly Language) 2) High Level Language(C Language) Programming in assembly language: TOOLS USED: 1). 2).command prompt as a programming environment.

The comment field begins with a “.A Here.The assembly language mnemonics(instruction) and operands fields together perform the real work of the program and accomplish the tasks for which the program was written.comment] Brackets indicates that a field is optional.Assembly language is referred to as a low-level-language . 2)MUL:-this instruction is used to multiply 2 operands.#20 MOV A. MOV R0. 47 .#10 ADD A.the label field can not exceed a certain no.R0 MOV P1. Now we look at 8051 assembly language format and use an 8051 Assembler to create a ready-to run program.The label field allows the program to refer to a line of code by name.the 1 operand should be in accumulator and 2 in the other register.loop. 8051 basic instructions: we describe the basic instructions of the 8051 and give their formats with some examples. eg.logical instructions 3).machine code by a program called an ASSEMBLER.subtraction . Comments may be at the and of a line or on a line by themselves’s .Bracket should not be typed in.this instruction is used to add 2 operands. 2. An assembly language instruction consists of four field’s:[label:] mnemonic [operands] [.jump. of character’s.arithmetic instructions 2).multiplication. division instructions arithmetic instructions: the arithmetic instructions are used to perform arithmetic operations like addition. 1. the 1 operand should be in accumulator and 2 in the other register.”. 1)ADD:. 3.and not all lines have them.# is used to load immediate value and we observe the final value on port 1. 1).

MOV R0. 48 logical instructions: Apart from the input/output instructions .A=A OR 30H(now A=34H) According to this operation.A AND 0FH(now A=05) According to this operation. MOV A. eg.A Here.#04 ORL A. the 1 operand should be in accumulator and 2 in the other instructions: the Jump.A Here. 2). MOV A.A=04 .A=35H . the content 35H gets ANDing with 0FH.#30H .the logical instructions are used to perform logical operations likeAND.# is used to load immediate value and we observe the final value on port 1.#10 MUL AB MOV is often necessary to transfer program control to a different location.logic instructions are some of the most widely used instructions. 1). MOV R0.OR.# is used to load immediate value and we observe the final value on port 1. 3)DIV:.EXOR etc.loop. Jump.this instruction is used to divide 2 operands.#0FH . the content 35H gets ANDing with 0FH.#10 DIV AB MOV P1.#20 MOV A.#35H ANL A.#20 MOV instructions are used to perform logical operations in the sequence of instructions to be executed .

Existing programs can be quickly adapted to other processors as needed. because of the comfortable modular program construction techniques. • • Details like register allocation and addressing of memory and data is managed by the compiler. • • • • • Programming and program test time is drastically reduced. The supplied and supported C libraries contain many standard routines such as numeric conversions. THE 8051 INTERRUPTS There are two methods in which a micro-controller can provide its services to its internal and external environment: 1) POLLING: Microcontroller checks the device continuously while using this method. Keywords and operational functions can be used that come closer to how humans think.We have used high level language for microcontroller programming due to its given advantages over assembly: Advantages of C over Assembly language programming: • Knowledge of the processor instruction set is not required. this increases efficiency. But it results in wastage of machine cycles of the micro-controller. Reusable code: Existing program parts can be more easily included into new programs. The C language based on the ANSI standard is very portable. 49 . Programs get a formal structure and can be divided into separate functions. 2) INTERRUPTS: Here every device tells the micro-controller when it needs the services from microcontroller.

2) and 13(p3.Actually. a spring pulls the armature to its normal state of open or closed. The armature’s contact acts like a switch and closes or opens a circuit. The electromechanical (or electromagnetic) relay (EMR) has 3 components: the coil. In the NC type. The voltage can vary from a few volts to 50 volts. There can be one or more contacts (SPST. In the NO. 2). ELECTROMAGNETIC RELAYS A relay is an electrically controllable switch widely used in industrial controls.Reset: when the reset pin is activated. 4). respectively.Two interrupts are set aside for hardware external hardware interrupts. The voltage and current needed to energize the coil. When current flows through the coil.memory locations 000BH and 001BH in the interrupt vector table belong to timer0 and timer1. In choosing a relay. These external interrupts are also referred to as EX1 and EX2. Pin numbers 12(p3. while the current can be from few mA to 20mA. the following characteristics need to be considered: 1) 2) 3) The contacts can be normally open (NO) or normally closed (NC). 3).this is the power-up reset. The 6 interrupts in the 8051 are allocated as follows: 1). automobiles and appliances. spring and contacts. This minimum voltage is called the “pull-in” voltage. SPDT. When the coil is not energized. the 8051 jumps to address location 0000. but many manufacturers data sheets state that there are 6 interrupts since they include reset. DPDT relays).Two interrupts are set aside for the timers: One for timer 0 and one for timer 1. 50 . It allows the isolation of two separate sections of a system with two different voltage sources. only 5 interrupts are available to the user in the 8051.3) in port 3 are the external hardware interrupts INT0 and INT1. respectively. the contacts are closed when the coil is not energized. a magnetic field is created around the coil (the coil is energized) which causes the armature to be attracted to the coil.Serial communication has a single interrupts that belongs to both receive and transmit. the contacts are open when the coil is un-energized. The relay has a minimum voltage below which the coil will not be energized.

7 3 V 1 C 7 R B C C 3 C C 3 0 L EE D / / / / / / 4 5 D 4 0 7 2 A 6 R 7 1 0 K GND / 11 6 V 2 P 1 3 P 1 4 P 1 5 P 1 6 P 1 7 P 1 8 P 1 P 1 A T 8 . . 2 2 P 2 . . . . 02T 4 P / T 2 0 . 32 P 2 . . 1 1 / 0T X D 4 P / 3S . E A /V P P V Q 1 C 3 C3 6 R B C 4 5 0 L EE D 1 D 4 7 2 A 7 V C C C 4 7 1 0 u F 2 / I N 2T 3 P / I 2 N . S0 / R X D 5 / M O S I 6 / M I S O 7 / S C K V 8 2 5 2 S 20 3 0 L EE D Q B R 1 C 8 5 D4 6 3 0 L EE D 72 A 5 C 3 C3 Q B R 1 C 3 9 5 D4 9 0 L EE 72 A 4 V Q B C 3 C3 2 C R 3 3 C 2 C R 1 5 3 3 0 D 5 D4 8 0 L EE 72 A 3 D V Q B C 4 D 7 2A 2 7 H a r d w a r e i n t e r f a c i n3 3 g0 L E E D o f L E D T S D i t l e < T w i t h i t l e > m > s d a e y n t . . 0 1 2 3 4 5 6 7 3 3 3 3 3 3 3 3 / / / / / / / / 9 8A 7A 6A 5A 4A 3A 2A A 10 /21 A /3 A 4A 5A 6A 7A 8A A D D D D D D D D 8 9 1 1 1 1 1 1 0 1 2 3 4 5 V Q 0 1 2 3 4 5 6 7 C D 4 1 7 2 A 8 P P P P T A PL T A PL P S T P VCC 3 3 3 3 . 9 1 7 P 3 . 52 P 2 . 42 P 2 . . . . N A T 8 9 s 8 2 5 2 i z eD o c u C u < s D t o o mc a t eT : u e u m b e r R < 2 6 e R . . 12 5 P / T2 1. 71 / 6 R D 0 P / T3 2. . . . 6 2 / 9 W R 1 / P T S2 3-E E 0 N X A2 L E / 1 P 1 R O G 3 P 3 . . 62 P 2 . . . v e 2 v 0 C 0 6 o d e > D S e h c e e 1e m t ob f e 1 r 51 .INTERFACING OF VARIOUS DEVICES 1) LED Interfacing V Q 1 C B 4 C C 5 4 7 A R 6 D 2 2 9 V V 8 3 3 Cp F4 Y 5 4 12 3 3 3 Cp F4 6 1 1 9 1 1 1 1 9 8X X R 2 3P 4P 5P P 8 M hU z 1 31 CV 0 CC CC 4 8 1 0 4 Q 1 C 3 C3 5 R 0 L EE D 6 5 40 B 0 0 0 0 10 20 0 0 . .

h> void delay(unsigned int i). delay(0xffff). delay(0xffff).C code for Blinking LEDs connected on PORT2: #include<at89s8252. P2_2=1. while (1) { delay(0xffff). Delay(0xffff). void main(void) { While(1) { P2=0x00. } } void delay(unsigned int i) { while(i!=0) { i--. 52 . P2_1=1. P2_0=1. P2_1=0.h> void delay(unsigned int i). } } C code for running LED connected on PORT2: #include<at89s8252. P2=0x00. Delay(0xff). P2_0=0. void main () { P0=0x00.

P2_3=0.delay(0xffff). P2_7=0. P2_6=1. but if not. P2_7=1. the pins are numbered on the LCD’s printed circuit board. it is quit easy to locate pin1. P2_6=0. } } 2) Hardware interfacing of LCD(JHD162A): On most displays. and it is generally connected to the metal work at some point. Since the pin is connected to ground. delay(0xffff). P2_2=0. P2_0=1 } } void delay(unsigned int i) { while (i!=0) { i--. P2_5=0. 53 . delay(0xffff). delay(0xffff). P2_4=0. P2_5=1. P2_4=1. it often has a thicker PCB track connected to it. delay(0xffff). P2_3=1. delay(0xffff).

For absolute simplicity. Pin 4 is register select (RS) line. Vss & Vdd. as low as 7V in some cases. The Vdd pin should be connected to the positive supply & Vss to the 0V supply or ground. which is used to alter the contrast of the display. Pin 3 is a control pin. A preset potentiometer connected between the power supply lines. but be aware that some modules may require a negative potential. 1 2 3 NAME Vss Vdd Vee 54 FUNCTION Ground +ve supply contrast . PIN NO. these modules can be effectively and economically powered by batteries. supplies of 6V & 4.C. and even 3V is sufficient for some modules. connecting this pin to 0V will often suffice. with its wiper connected to the contrast pin is suitable in many cases. Ideally. these pin should be connected to a variable voltage supply. Consequently. Although the LCD module data sheets specify 5V D. supply (at only a few milliamps). Vee.The function of each of the connections is shown in the table below:Pins 1 & 2 are the power supply lines.5V both work well.

or pulled high to read character data or status information from its registers. In the latter case. data bytes transferred to the display are treated as commands. Data can be transferred to and from the display. 55 . This input is used to initiate the actual transfer of commands or character data between the module and the data lines. and data bytes read from the display indicate its status. Pin 6 is Enable (E) line. This line is pulled low in order to write commands or character data to the module. However.4 5 6 7 8 9 10 11 12 13 14 RS R/W E D0 D1 D2 D3 D4 D5 D6 D7 Register select Read/Write Enable Data Bit 0 Data Bit 1 Data Bit 2 Data Bit 3 Data Bit 4 Data Bit 5 Data Bit 6 Data Bit 7 Three command control inputs. When writing to the display. character data can be transferred to and from the module. data will become available shortly after the low to high transition and remain available until the signal falls low again. only the upper four data lines (D4 to D7) are used. This $-bit mode is beneficial when using a microcontroller. Pins 7 to 14 are the eight data bus lines (D0 to D7). By setting the RS line high. either as a single 8-bit byte or as two 4-bit “nibbles”. Pin 5 is (R/W) line. When this line is low. data is transferred only on the high to low transition of this signal. when reading from the display. as fewer I/O lines are required.

1 / T 32 .h> #define LCDPRT P1 #define RS P3_3 #define EN P3_4 void delay(unsigned int i). 5 / T 1 P P P P P P AP AP A AP AP A A L P A P 2 2 2 2 2 2 D2 D2 D D3 D3 DP DE 3 D 3 2 1 . 6 / M 8 I S O 1 .6 7 / A 1 5 5 1 7 4 7 / 1R 6 D . 0 /2 T 2 1 . 3 0 / I 1N 4 T 1 P 3 . 2 / A 41 0 2 . . 2 / PI N 3 T. 1 / T X D V C C C 3 1 0 u F R 1 1 0 K H a r d w a r e i n t e t r f a c i n g 20 A T 8 9 S G N D 1 6 3V 3 3 3 3 3 3 3 2 3 4 5 6 7 8 9 P P P P P P P P 0 0 0 0 0 0 0 0 . 56 .3 6 / W 9 R 2 2 E 3N 0 S 1/ P R 0 O G 1 . 4 / A 61 2 2 .E X P 1 . . void display(unsigned char b).J 2 L C D 1 1 1 1 1 1 1 R 5 6 V C C VC C 5 E 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 31 E A /V P P VC C 3 3 pC F 1 40 U Y 4 12 3 3 3 p CF 2 1 1 P 1 9 1 8 X T A X T A 9 1 2 1 5 R P P S L 1 L P2 P T P 1 P 1 . 4 / T 0 RS EN 3 . 7 6 5 4 3 2 1 0 / / / / / / /A / 5 2 VC C 2 o f L C D w i t h A T 8 9 s C code for LCD display #include <at89s8252. void Init_lcd(void). . . 3 / A 51 1 2 . 5 3 P 1 . 4 2 P 1 . 7 6 / A 81 4 2 . void main(void) { init_lcd(). void wait(void). . 5 / A 71 3 2 . . 7 / S C K 1 3 3 . void cursor_position(unsigned char c). void lcd_cmd(unsigned char a). . 5 / M 7 O S I 1 . . 00 / R 1 1X D . 1 /2 A 3 9 . 4 / 6S S 1 . 0 /2 A 2 8 .

RS=0. LCDPRT=a. } } void lcd_cmd(unsigned char a) { wait(). display('N'). display('M'). cursor_position(0x05). display('E'). EN=1. cursor_position(0x03). cursor_position(0x04). display('A').while(1) { cursor_position(0x01). RS=1. cursor_position(0x06). } void display(unsigned char b) { wait (). cursor_position(0x02). display('X'). } } void delay (unsigned int i) { while (i!=0) { i--. EN=0. EN=1. LCDPRT=b. 57 . display('T').

void Init_lcd(void).h> #define LCDPRT P1 #define RS P3_3 #define EN P3_4 code unsigned char name_arry[]={"NETMAX$"}. lcd_cmd(0x0c). void wait(void). void display(unsigned char b). 58 . while(count!=0) { count--. lcd_cmd(0x06). } C code for string display on LCD: #include<at89s8252. } void clear_lcd(void) { lcd_cmd(0x01). void lcd_cmd(unsigned char a). lcd_cmd(0x01). void display_string(unsigned char *sp). } void wait(void) { unsigned int count=300.EN=0. } void cursor_position(unsigned char c) { lcd_cmd(c+0x80). } } void Init_lcd(void) { lcd_cmd(0x3c).

display_string(&name_arry). EN=1. } void wait(void) { unsigned int count=300.void cursor_position(unsigned char c). cursor_position(0x40). EN=1. LCDPRT=b. 59 . sp=sp+1. } void display_string(unsigned char *sp) { while(*sp!='$') { display(*sp). EN=0. } void display(unsigned char b) { wait (). RS=1. LCDPRT=a. EN=0. } } void lcd_cmd(unsigned char a) { wait (). RS=0. void main(void) { Init_lcd().

rejection and permits offsetting the analog zero-input voltage value. and hence no interfacing logic is required. Features • 80C48 and 80C80/85 Bus Compatible . lcd_cmd(0x0c). lcd_cmd(0x01). lcd_cmd(0x06). successive-approximation A/D converters which use a modified potentiometer ladder and are designed to operate with the 8080A control bus via three-state outputs.No Interfacing Logic Required • Conversion Time < 100s • Easy Interface to Most Microprocessors • Differential Analog Voltage Inputs 60 . These converters appear to the processor as memory locations or I/O ports. } } void Init_lcd(void) { lcd_cmd(0x3c). } 3) ADC-0804 interfacing with AT89s52: The ADC0804 family is CMOS 8-Bit. } void cursor_position(unsigned char c) { lcd_cmd(c+0x80). In addition. the voltage reference input can be adjusted to allow encoding any smaller analog voltage span to the full 8 bits of resolution. The differential analog voltage input has good common mode.while(count!=0) { count--.

• TTL Compatible Inputs and Outputs • On-Chip Clock Generator • 0V to 5V Analog Voltage Input Range (Single + 5V Supply) • No Zero-Adjust Required PIN DIAGRAM 61 .

. 4 . is always grounded.code For temperature monitoring system #include <at89s8252. otherwise controller can not read the data. 2 / 1 I N2 / R X D / R D G N D 20 8 2 5 2 / / / / / / / / U 4 E V C C /V R E F C 6 1 0 u R 2 1 0 K 9 F / 2 AG N D 8 10 A T 8 9 S S O C G N D 1 3 2 1 1 1 1 0 9 6 0 7 P A P P P P 3 L S 3 3 3 . 6 / A 2 / TP X 2 D . 0 . 1 3 / A 2 AP D2 . . 5 / A 2 P 2 . 3 . 4 / 6S S 1 .Hardware interfacing of ADC-0804 for Temperature monitoring C O N 1 6 _ 0 L C V C 3 3 pC F 4 Y 2 4 12 3 3 3 p CF 5 1 1 9 1 1 R Y C V CC L C C 1 3 1 0 4 D 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 V C C R SE N R 5 5 5 6 E 3 40 31 SU T 2 A E A /V P P U G O 2L 2M N U 2 3 5 D V T P R 5 1 k C U / S 1 C T 3 O P 9 8 X T A X T A R 3 4 P P 3 3 S L 1 L P2 P T P 1 P 1 . 2 2 / A 2 AP D2 .E X P 1 . . is software controlled. C. 1 / T 32 . 7 6 5 4 3 2 1 0 / I N T 1 / T 0 A D 7 A D 6 A D 5 2 A P D 2 4. 53 P 1 . 42 P 1 . 0 / 2 A A P D 2 3. 0 4 / A 2 P 2 . 5 / T / PW 3 R. 0 /2 T 2 1 . 7 / A / P R O G 1 N P 3 . .h> #define LCDPRT P1 #define RS P3_3 #define EN P3_4 #define SOC P3_2 62 2 V C C 3 2 3 3 3 4 3 5 3 6 3 7 3 8 F 3 19 P 0 P 0 P 0 P 0 P 0 P 0 P 6 V0 P 0 P R 5 1 0 K 1 2 8 3 9 41 0 51 1 61 2 71 3 81 4 1 5 1 1 1 1 1 1 1 1 8 7 6 5 4 3 2 1 20 A D C 0 8 3 1 U 2 1 C 1 4 T L 4 3 11 u f / 1 6 v F D D D D D D D D B B B B B B B B 0 1 2 3 V R E 4 5 C L K 6 C L K 7 6 + I N 7 . 1 / 2 A AP D2 . 7 1 9 4R I N C 8 1 u f / 1 6 v 5 E O C 1 T 0 5 I N T R C R W 1 S 2 D 3 R R 1 7 1 0 K C 7 1 5 0 p Temprature monitoring system When interfacing is being done then gets lowered then only it allows the controller to read the data. . 1 E E .I N . 6 / M 8 I S O 1 . . 5 / M 7 O S I 1 . 7 / S C K V C C C 9 C A 0 4 VC C V C C V C C R 6 2 2 0 R E S N . . 6 .

} } unsigned char read_adc(void) { unsigned char n.'2'. void wait(void). Init_lcd().#define EOC P3_5 unsigned char read_adc(void). e=read_adc(). void Init_lcd(void). void disp_dec(unsigned int digit). void cursor_position(unsigned char c). void display(unsigned char b).'3'.'6'.'8'.'4'.'9'}. void main(void) { unsigned char e. while(EOC==1) { n=P2. code unsigned char table[16]={'0'. disp_dec(e). SOC=0.'5'. void clear_lcd(void). void delay(unsigned int i). } void delay (unsigned int i) { while (i!=0) { i--. } return n. } } 63 . P2=0xff.'7'.'1'. void lcd_cmd(unsigned char a). SOC=1. while(1) { cursor_position(0x00).

RS=0. } void wait(void) { unsigned int count=300. } } void Init_lcd(void) { lcd_cmd(0x3c). lcd_cmd(0x06). } void cursor_position(unsigned char c) { lcd_cmd(c+0x80). while(count!=0) { count--.void lcd_cmd(unsigned char a) { wait(). LCDPRT=a. EN=1. } void disp_dec(unsigned int digit) { 64 . EN=1. EN=0. } void display(unsigned char b) { wait (). lcd_cmd(0x0c). RS=1. EN=0. LCDPRT=b. lcd_cmd(0x01).

1 0 . } 6) Serial communication between At89s8252 and PC a) Serial Transmission V C 3 3 pC F 1 6 Y 4 12 3 3 3 p CF 1 7 1 1 9 1 1 1 1 4 R Y C V CC L C C 1 9 1 0 4 31 40 SU T 5 A E A /V P P 9 8 X T A X T A R 2 3 P 4 P 5 P P S 3 3 3 3 . . temp=digit/10. temp=digit-temp*10. display(table[temp]). 0 / R M O S I M I S O S C K 7 6 D 9 R 0 1O G X0 D X D 1 0 U 7 8 C 2 0 F / 1 16 3 2 T 2 O U R 2 I N V C C V 1 1 + + - R XS DE F / 1 6 R V I A L P O R T O F P C V C C 4 +5 2 6 V X 2 3 12 0 U F C / 1 6 2 2 V M A 65 .unsigned int temp. . digit=digit-(temp*10). . display(table[temp]). 7 / 1R TP 2 3 . . 0 1 2 3 4 5 6 7 / / A / / / / 1 P 3 . 1 2 3 4 5 6 7 / / / / / / / / 3 A3 A3 A3 A3 A3 A3 A3 A 2 /2 A /2 A A 2 A 2 A 2 A 2 A 2 A 9 D 8 D 7 D 6 D 5 D 4 D 3 D 2 D 1 2 8 3 9 41 51 61 71 81 1 0 1 2 3 4 5 6 7 VC C VC C V C C C 1 8 1 0 u F R 4 1 0 K I N T I N 2T P T P0 2 TP 1 2 . . . temp=digit. 0 1 2 3 4 5 6 7 0 . display(table[temp]). } if(digit>99 && digit<1000) { temp=digit/100.S E 3N E X L E / P R 1 P 3 . T 2 3 4 5 L L P P P P 1P 2P P P / / / / 0 0 0 0 0 0 0 0 . . P 2 . 6 / W 2 T 2P . display(table[temp]). . . display(table[temp]). . P 2 . P 2 . . . 1 / T1 PS 3S . . P 2 . P 2 . . . . . digit=digit-(temp*100). / / / / / / 0 1 2 3 4 5 U 6 1 1 V C C 16 C 2 3 1 0 4 J U 1 3 R 1 I N 4 T 1 T 1 O U T T T 2 R 2 C C O 2 1 I N 9 U 0 T 7 1 2 T 1 I N R 1 O S P T S P T C 21 40 U T 12 X D 3 1 6 G N D 20 A T 8 9 S 8 2 5 2 15 C 2 1 0 U 1 F / 1 6 V G N D V1 2 3 4 5 6 7 8 P P P P P P P P 1 1 1 1 1 1 1 1 . if(digit<100) { temp=digit/10.

delay(0XFFFF). void main(void) { Init_SPT(). SCON=0x40. } } void Init_SPT(void) { TMOD=0x20.code for serial transmission(from Microcontroller to PC) #include<at89s8252. 66 . void delay(unsigned int i). void transmit_serial(unsigned char a).C. delay(0XFFFF). TH1=0xfd. transmit_serial('T'). transmit_serial('N'). transmit_serial('E').h> void Init_SPT(void). delay(0XFFFF). delay(0XFFFF). delay(0XFFFF). transmit_serial('A'). transmit_serial('X'). while(1) { delay(0XFFFF). TR1=1. delay(0XFFFF). transmit_serial('M').

. 7 5 / A 2 AP D2 . . 5 / M 7 O S I 1 . . 42 P 1 . A A R E S N V C 3 2 3 3 3 4 C 3 5 3 6 3 7 C 4 9 3 8 1 0 u F 3 19 R 8 1 0 K P 0 P 0 P 0 P 0 P 0 P 0 6P V 0 P 0 VC C 0 1 2 3 4 5 U 1 2 V C C 16 C 5 4 1 0 4 J U R T 1 3 1 I N 4 1 1 O U T 8 7 6 D 9 R 0 1O G X0 D X D 1 0 U T 7 T 2 O U T 8 R 2 I N C 5 1 1 0 T 2 I N F / 1 16 V C 1 + 3 9 C 1 R 2 O U T G N D C 2 U 5 2 F / 1 V + 6 V C C 2 2 4 +5 -6 1 1 1 2 T 1 I N R 1 O S P T S P T C 51 50 U T X D 1 2 3 R XS DE F / 1 6 R V I A L P O R T O F P C V C 20 A T 8 9 S 8 2 5 2 15 C 1 0 V - M A X 2 3 12 0 U F / 1 C 5 6 V 3 67 . .E X P 1 . 2 / A 2 P 2 . 7 / S C K 1 2 3 41 51 61 71 81 1 8 9 VC C I N T 0 2 I N 2T . 53 P 1 . TI=0. 4 /6S S 1 . 1 /2 A TP 1 2 . . 6 / M 8 I S O 1 . } void delay(unsigned int i) { while(i!=0) { i--. 5 7 / A A D 4 A D 3 1 A P D 3 2 7 / 1R . 1 / T1 P 3 . delay(500). . . 0 / R G N D SU T 1 A 1 L E A /V P P 9 8 X T X T R 2 3 P 4 P 5 P P S 3 3 3 3 .} void transmit_serial(unsigned char a) { SBUF=a. 6 6 / A 2 AP D2 . } } b)Serial Reception(From PC to microcontroller) J 3 L C D NETMAX R VC C SE N 1 1 1 1 1 1 1 R 5 6 V C 3 3 pC F 3 Y 9 4 12 3 3 3 p CF 3 5 1 1 9 1 1 1 1 R 4 Y C V CC C C 5 0 1 0 4 VC C 5 E 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 4 31 40 P L 1 L P2 P T P 2 3 4 5 7 6 5 4 3 2 1 0 / / / / / / / / / / / / A 1 P 1 . . 1 / T 32 . . . 1 6 / W 2 A DP S E 3 N 0 L E / P R 1 P 3 . 0 /2 T 2 1 . . AP D3 . 1 0 / 2 A P T P 0 2 . 4 / A 2 AP D2 . 3 / A 2 P 2 .

C.'6'.'9'.'1'.'4'.h> #define LCDPRT P1 #define RS P3_3 #define EN P3_4 void Init_SPT(void).'3'. void lcd_cmd(unsigned char a). void disp_dec(unsigned int digit). cursor_position(0x00).'D'.'8'. Init_lcd().'7'. void clear_lcd(void). code unsigned char lkup_tbl01[16]={'0'. while(1) { e=receive_serial().code for serial reception: #include <at89s8252. unsigned char receive_serial(void). display(e). void wait(void). void disp_hex(unsigned char digit). void cursor_position(unsigned char d). void delay(unsigned int i). Init_SPT(). void main(void) { unsigned char e. } } void Init_SPT(void) { 68 . void display(unsigned char b).'5'.'2'.'B'.'C'.'E'. void Init_lcd(void).'A'.'F'}.

TMOD=TMOD&0x0F. TR1=1. EN=1. LCDPRT=b. EN=0. } void delay (unsigned int i) { while (i!=0) { i--. LCDPRT=a. while(count!=0) { 69 . TH1=0xfd. RS=1.PCON=PCON&0x7F. } } void lcd_cmd(unsigned char a) { wait(). SCON=0X50. } void wait(void) { unsigned int count=300. } void display(unsigned char b) { wait (). RS=0. TMOD=TMOD|0x20. EN=0. EN=1.

3 / I 1N 2 T 1 PS 3S . . } Interfacing of seven segment display V R 1 0 K S I P 3 5 1 C C V C C V C C 16 V R 3 7 1 0 k S C I P C V 8 3 3 P C F 4 3 Y C 3 3 P F 4 2 4 12 3 1 1 9 3 M h zU C 1 6 E A /V P P C 1 0 4 9 8 7 6 5 4 3 2 4 5 3 6 2 1 7 7 4 L U 8 7 6 5 4 3 2 V C C C 4 9 VC C 1 R R R R R R R V R 1 0 k C S I P 1 1 1 C C 31 40 B I / R R B I L T D D D D 3 2 1 0 S 4 3 7 B O 9 8 X T A X T A R S T L L V C C C 4 8 1 0 u F R 3 6 1 0 K 3 2 0 9 A P P 2 P 2 P 2 P 2 L E / P P R 2 S E N P 2 0 1 2 3 4 5 V C 3 4 5 6 2 1 7 C 16 8 7 6 5 4 3 2 1 1 1 1 9 1 1 2 3 5 4 0 1 R R R R R R R 12 32 1 1 2 2 2 3 42 62 02 42 52 42 0 2 2 2 2 2 E 0 0 0 0 0 E E E E E E g f G /V a b g f G /v a b P P 2 . 6 G / . 0 1 2 3 4 5 6 7 / / / / / / / / 3 A3 A3 A3 A3 A3 A3 A3 A 9P DP 8 DP 7 DP 6 DP 5 DP 4 DP 3 DP 2 D 0 00 10 20 30 40 50 60 7 1 2 3 4 5 6 7 8 B A F G E C D 8 G N D 1 1 1 1 9 1 1 2 3 5 4 1 0 32 7 8 9 1 1 2 2 2 2 2 52 92 12 0 2 2 2 2 2 2 E 0 0 0 0 0 0 E E E e E c E d E VC C V C C U D 1 3 I P 2 0 L T B I / R R B I D D D D 3 2 1 0 / 1 20 A T 8 9 S G N D 6 V1 2 3 4 5 6 7 8 P P P P P P P P 1 1 1 1 1 1 1 1 . 7 / 2 /2A /2A A 2 A 2 A 2 A 2 A 2 A 1 2 8 3 9 41 51 61 71 81 1 V C 20 19 18 17 VC C 16 15 14 13 12 11 P P P P 1P 2P P P 0 0 0 0 0 0 0 0 . lcd_cmd(0x14). . } } void Init_lcd(void) { lcd_cmd(0x3c). . lcd_cmd(0x0C). 3 / . 6 / W 5 R 1 T P2 3 E . lcd_cmd(0x06). } void cursor_position(unsigned char d) { lcd_cmd(d+0x80). 2 / I 1N 1 T 0 MP 3O . . lcd_cmd(0x01). . . . S1 /I T1 X0 D P 3 I S. . 0 O / R X D M S C K 2 5 2 2 0 U 1 2 7 4 L S 8 4 7 8 70 VC C 1 2 3 4 5 6 7 8 9 10 V C C e d c B B O A F G E D C VC C e d G /V c dot e d G /V dot c . 5 / O. 0 1 2 3 4 5 6 7 G N D / / / / / / 1 7 P 3 . 4 /1 T 3 0 P 3 . . .count--. . 0 2 . . 2 / . lcd_cmd(0x1C). . 1 . 5 X /1 T 4 1 P 3 . 4 / . 7 / 1R 6 D TP 2 3 . .

delay(0xffff). delay(0xffff). 71 .h> #define EOC P3_6 #define SOC P3_7 void delay(unsigned int i). void main (void) { unsigned char a=0.C code for seven segment display #include<at89s8252. void dec(unsigned int digit) . } } void delay(unsigned int i) { while(i!=0) { i--. delay(0xffff). unsigned char read_adc(void). delay(0xffff). P0=0x08. a++. delay(0xffff). P0=1. dec(a). a=read_adc(). while(1) { delay(0xffff). dec(a). P0=2. P0=4. P0=3.

P0=x. } 72 . y=y>>4.} } unsigned char read_adc(void) { unsigned char n=0. SOC=0. y=mb&0xf0. y=y|0x30. display(y). } void dec(unsigned int x) { x=(x/10)*6+x. display(x). x=mb&0x0f. x=x|0x30. unsigned char y. while(EOC==1) { n=P2. } void bcdconv(unsigned int mb) { unsigned char x. SOC=1. } return n.

P0=0x0F. EX0=1. delay(0xFFFF). delay(0xFFFF). delay(0xFFFF). delay(0xFFFF). } void int0(void) interrupt 0 { if(INT0==0) { while(1) { P0=0xF0.h> void delay(unsigned int i) { while(i!=0) i--. }} 73 . }}} void main() { EA=1. While(1) { P0=0xFF.6) 8051 Interrupt Programming C-code for handling of INT0 interrupt: #include<at89s8252. P0=0x00.

Block Diagram: Circuit Diagram: 74 . respectively. heater. KEYBOARD 2: {device 2 ON} & {device 1 OFF}.PROJECT DETAILS Project Name: Home Automation Description and Working: The project is concerned about controlling the switching (on or off) of various home appliances such as lights. This also means that at the receiving end there must be a serial-in-parallel-out shift register to receive the serial data and pack them into a byte. KEYBOARD 4: {BOHT DEVICE ON}. the byte of data must be converted to serial bits using a parallel-in-serial-out shift register then it can be transmitted over a single data line. Serial communication uses a single data line instead of 8-bit data line of parallel communication which makes it much cheaper. fan. The MAX232 IC is used to convert the voltage levels of Computer in accordance with the voltage levels of Microcontroller. The ASCII codes of the keys pressed from keyboard are sent to the microcontroller. So. we use the device configuration as 1 and 2. These codes are evaluated inside the if-else statement and accordingly the pins (on any port) of microcontroller are made high or low. Using the configuration as: On pressing KEYBOARD 1: {device 1 ON} & {device 2 OFF}. This microcontroller is programmed to work with the keyboard of the computer using serial port communication. The codes received by the microcontroller are stored in SBUF (Serial Buffer). KEYBOARD 3: {BOTH DEVICE OFF}. etc using At89s8252 microcontroller. For serial data communication to work. The relay corresponding to a HIGH pin is driven to make connection between pole and NO and the device connected to it is switched ON whereas one corresponding to a LOW pin remains OFF.

75 . just by pressing a key from our PC.Applications: The concept used in this project has a wide scope. We can control 220 Volts appliances at any time without moving from our place. It can be used to control a large number of appliances at a time through a Computer. All the devices of a home can be connected to computer using microcontroller for automated switching. 76 .google.BIBLIOGRAPHY • • 8051 Microcontroller – Programming (Mohammad Ali Mazidi) http://www.