Sie sind auf Seite 1von 75

SIX WEEKS INDUSTRIAL TRAINING

REPORT
Submitted for partial fulfillment of award of

BACHELOR OF ELECTRONICS & COMMUNICATION


ENGINEERING
I.E.T. BHADDHAL
(ROPAR)

Submitted by:

Shivinder singh
Uni.Roll No:617041617
College Roll No: EC05L5437
3rd 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
Atmels 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

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. 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. I owe my deep
regards for the supporting and kind staff authorities who are helping me in my lean patches
during these six months. The knowledge I am gaining throughout my studies have the
practical implementation during this period. I am grateful to all the staff of NETMAX and
for their timely support and sharing of their experience with me. I would like to express my
heartiest concern for Mr. ROHIT KHOSLA for his able guidance and for his inspiring
attitude, praiseworthy attitude and honest support. Not to forget the pain staking efforts of
our college training and placement cell and specially my training and placement officer Mr.
Charanjeet Singh. Last but not the least I would express my utmost regards for the
electronics and communication department of our Institute.

COMPANY PROFILE
Netmax Technologies is an organization which is established in the field of Network
Support, Network training and Embedded systems. It provides support and training in the
field of networking solutions (CISCO, LINUX) and embedded systems (Micro controller
based design, Electronics system design).
In Education, it has strategic alliance with REDHAT Inc. It is also NOVELL
EDUCATION PARTNER with which it provides NOVELL and SUSE LINUX courses.
Netmax technologies also conduct courses in CADENCE based design tools.
Netmax Technologies also provide Technical Research & Development support and
consultancy to some Electronics companies.
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.
Lotus Machines Pvt. Ltd. Chandigarh.
Impearl Electronics Pvt. Ltd. Chandigarh.
KANTA Electrical Ltd. Mohali.

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, Mohali
Premier ISP, Chandigarh
Innovative Solutions, Chandigarh
Emmtel ISP, Chandigarh
NIPER, Mohali
Navik Technologies, Chandigarh
Software Technology Parks India, Mohali
Glide Internet Services
Rana Group
IDS
HFCL Infotel Ltd.
Targus technologies pvt ltd
STPI, Mohali
BBMB
The Tribune
Quark
5

17)

Ind Swift

Support Area (Networking Solutions)


a) LINUX / UNIX networks
b) SUN networks
c) CISCO devices (Routers, Switches, Firewalls, Cache Engine, 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, CCNP
b) RED HAT LINUX
c) SUN SOLARIS
d) WINDOWS 2000, 2003
Netmax Technologies is a leader in education services and developer of innovative
embedded solutions. To meet the demands of Post PC era Netmax provides complete
solutions as well as design-to-order services to satisfy its customers.

PCB DESIGNING
PCB stands for PRINTED CIRCUIT BOARD. Printed circuit board (PCB) provides
both the physical structure for mounting and holding the components as well as the
electrical interconnection between the components. 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. 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, silver and tin are also
used in some cases.
Types of PCB
PCB may be of different types:1) Single-sided
2) Double-sided
3) Multilayer
Single sided PCBs: - As the name suggest in these designs the conductive pattern is only at
in one side. And also the size is large in these case but these are cheap.
Double sided PCBs: - 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.
Multilayer PCBs: - In this case the board consists of alternating layers of conducting
pattern and insulating material. The conductive material is connected across the layers
through plated through holes. The size of this PCB is smaller than that of double sided
PCB but it is very costly.
PCBs may also be either rigid, flexible, or the combination of two (rigid-flex). When the
electronic components have been mounted on the PCB, the combination of PCB and
7

components is an electronic assembly, also called PRINTED CIRCUIT ASSEMBLY. This


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

o Each layer has to be designed separately.


o We cannot generate NCD files for CNC drilling.
o Difficult to modify the design in the designing process or after designing.
o Difficult to get good design overview.

2) PCB DESIGNING USING CAD


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

Entry the schematic diagram.


Net list file creation.
Placement of components manually or automatically.
Routing of the board using manual routing tools or auto router
Design rule check physical and electrical.
Artwork generation.
A TRADITIONAL DESIGN FLOW IN CAD- SYSTEM

Capture

Gerber
tools

Libraries
Layout
Footprint
libraries

Gerber and
plotter
drawing

Gerber
and drill
files

Overview of a PCB Design Software


There many soft wares which are used for PCB designs. Some of them are given below: OrCad
CADSTAR
Protel
TANGO
Mentor
10

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, seamless tool integration, and
exceptional value. New 10.5 release continues that tradition.
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. Modern electronic design automation (EDA) tools are beginning to support a
more efficient and integrated approach to electronic.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. Whether you're designing a new analog circuit, revising
schematic diagram for an existing PCB, or designing a digital block diagram with an HDL
module, OrCad Capture provides simple schematic commands you need to enter, modify
and verify the design for 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. OrCad Layout delivers all the capabilities to designers need from netlist to
place and route, to final output. The ease-of use and intuitive capabilities of OrCad Layout
provides for quick startup and rapid learning right out of the box.

11

PCB DESIGN STEPS IN OrCad 10.5


Entry of Schematic Diagram
Schematic diagram provides the functional flow and the graphical representation of an
electronic circuit. The entry of schematic diagram is the first step in PCB design using
OrCad.
A schematic diagram consists of: Electrical connections(nets)
Junctions
Integrated circuits symbols
Discrete components symbols like resistors, capacitors etc.
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. So that one can
parts; wires; buses and draw graphics. The schematic page editor has a tool palette that you
can use to draw and place everything you need to create a schematic page. One can print
from within the schematic page editor, or from the project window.

12

The Part editor:


The part editor is used to create and edit parts.
From the view menu of the part editor you can choose either part or package. In part view
one can: Create and edit parts and symbols, then store in new or existing libraries.
Create and edit power and ground symbols, off-page connector symbols, and title
block
Use the tool palettes electrical tools to place pins on parts, and its drawing tools to
draw parts and symbols.
The Session Log:
The session log lists the events that have occurred during the current Capture
session, includes message resulting from using captures tools. To display context-sensitive

13

help for an error message, put the cursor in the error message line in the session log press
F1.
The ruler along the top appears in either inches or mill meters, depending on which
measurement system is selected in the window panel. 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. You can also save the contents of the of the session log to a file, which is useful
when working with Orcads technical support to solve technical problems. The default
filename is SESSION.TXT.
The Toolbar:
Captures toolbar is dock able (that means you can select and drag the toolbar to new
location) as well as resizable, and displays tool tips for each tool; by choosing a tool button

14

you can quickly perform a task. If tool button is dimmed, you cant perform that task in the
current situation.

Some of the tools operate only on what you have selected, while others give you a choice
of either operating on what is selected or expanding the scope to entire project.
You can hide the toolbar, then display it again when u need it. For hiding select from the
schematic page editors view menu, choose TOOLBAR.

The Tool Palette:


Capture has two tool palettes: one for the schematic page editor and one for the part editor.
Both tool palettes are dock able and resizable. They can also display tool tips that identify
each tool. The drawing tools on the two tool palettes are identical, however, each tool
palette has different electrical tools after you choose a tool, and you press the right mouse
button to display a context- sensitive pop-up menu.
The schematic page editor tool palette:
The first group of tools on the tool palette is electrical tools, used to place electrical
connectivity objects. The second group of tools is
Drawing tools, used to create graphical objects without electrical connectivity.

15

The part editor tool palette:


The first group of tools on the part palette is electrical tools, used to place pins and
symbols. They have been already explained above within the schematic page editor tools.
The second group of tools is drawing tools, 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, one can perform operations on it, include moving, copying,
cutting, mirroring, rotating, resizing, or editing. One can also select multiple, objects and
edit them, or group them in to a single object. Grouping objects maintain relation ship
among them while one moves them to another location.

Creating Net list File


Net-list file is a document file which contains information about the logical
interconnections between signals and pins. Before one create a net list file, be sure ones
project is completed, annotated and it is free from electrical rule violations.
A net list file consists of nets, components, connectors, junctions, no connection symbol,
power and ground symbols.
16

Creation of net list in capture:


Select your design in the project manager.
From the tools, choose create net list. The net list dialog box displays.
Choose a net list format tab.
If necessary, set the part value and PCB foot print combined property strings to
reflect the information you want in the net list.
Click ok to create the net list.
In the net list file text box, enter a name for the output file. If the selected format
creates an additional file, enter its file name in the second text box.

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, grids, and spacing in OrCad. Within other soft
wares you also have to place and route the components in similar way. For the placement
and routing of the components we normally use auto-placement and auto-routing.
Unfortunately, in a lot of soft wares some critical signals have to be routed manually before
auto-routing. In layout plus we also define the layer stacks, pad stacks and via's.
Steps for board design:
At first, we have created a net list from our schematic diagram by using capture.
Layout plus includes design rules in order to guide logical placement and routing.
That means, load the net list into layout to create the board. At the same time you
have to specify the board parameters.
Specify board parameters: Specifying global setting for the board, including nits of
measurements, grid, and spacing
17

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

18

Main window

Method to create a board with Layout Plus:


Ensure that net list with all footprints and necessary information has been created.
Create a directory in which the schematic design, net list, and boar will co-exit and
put the schematic design and net list. OrCad provides a directory for this purpose.
From the layout session frames file menu, choose New. The load template file in the
dialog box displayed.

19

Design window
Select the technology template (.TCH), then choose the open button and load the net
list in other box.
Then apply the auto ECO.
If necessary, respond to link footprints to component dialog.
Draw the board outline by using the obstacle tool in the tool bar.
Setting board parameters:
There is some parameter which should be set before placing the components on board.
They are as follows:-

20

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. So it is
the main step in layout, to draw the board outline of the actual size of PCB board.
Placement of components:
Placement of components means that to place the components in designed box. A designer
should follow the following steps before going for it: Optimize the board for component placement.
Load the placement strategy file.
Place components on the board.
Optimize placement using various placements
Components can be placed by using two techniques:1) Manual placement of components
2) Auto placement of components
Choose the components tool bar button. From the pop up men, choose the queue for
placement. The components selection criteria dialog box appears. Enter the reference
designator of the components that you want to place in the appropriate text box, and click
ok. Drag the components to desired location, place it there.
21

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. One may route board manually or
automatically by auto router.
100% auto routing can be achieved only when components are placed in the order of
functional flow of electronic circuit. 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. Components
sizes, hole sizes, conductor widths and clearance, land-to-hole-ratio, board areas to be free
of components, clearance to the edges, positional accuracy and of course electrical
interconnections had tad to be personally reviewed with a great deal of care. After
completing the design of printed circuit board with the help of an EDA-Tool, a designer
has again to verify the PCB in order to find out errors. Such type of verifications/design
rule check contains beside the general verifications commonly two types: Physical verification
Electrical verification

Post processing:Post processing can be done once the design is completed in all aspects. 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- drilling.
22

POWER SYSTEM DESIGN


First part of electronics ckts. is power. The main power supply is in AC but mostly
electronic ckts. work with DC. So a system is required to convert ac to dc and these
sources should able to produce stable supplies.
Power supplies may be used in. may be of different types such as regulated, unregulated,
smps etc.
Unregulated power supplies
These are the power supplies in which the out put is not constant. That it is varies with
input voltage, load, and also effected by the environment conditions such as
temperature, etc. so these are the variable supplies. Commonly these supplies are not
employed as there efficiency is very less. The unregulated power can be obtained using
rectifying circuit after AC supply.
Regulated power supplies
These are the power supplies in which the output voltage is constant, i.e. the out put
voltage is independent of the input voltage, load and other external conditions. So to
obtain the regulated voltage using different regulators. The regulator voltage is mainly
the DC voltage, it may AC to or DC to DC voltage. A better approach to power supply
design is to use enough capacitance to reduce ripple to low level, then use an active
feedback circuit to eliminate the remaining ripple and dependence of output voltage on
input, load and environment conditions. These active devices are known as Regulators.
These regulators can be used to produce negative and positive voltage of required value.
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:23

S. no.
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.
Constant negative voltage regulators:- These are also the constant output voltage regulator
but there output is negative in polarity. These regulators are also employed according to
voltage requirements. Some of them are given below with there outputs:S. no
1
2
3
4

Name of regulator
LM7905
LM7910
LM7912
LM7915

Output voltage
-5v
-10v
-12v
-15v

Variable voltage regulators:- These are the regulator whose output voltage can be varied
according to the desired need. These regulators again of two types i.e.: Positive
Negative
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. 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. The most commonly variable regulators are: LM317 (it is positive regulator)
LM 337(it is negative regulator)
There description is given below:24

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.5A over a 1.2V to 37V output range. They are exceptionally easy
to use and require only two external resistors to set the output voltage. Further, both line
and load regulation is better than standard fixed regulators. Also, the LM117 is packaged in
standard transistor packages which are easily mounted and handled. In addition to higher
performance than fixed regulators, theLM317 series offers full overload protection
available only in ICs. Included on the chip are current limit, thermal overload protection
and safe area protection. All overload protection circuitry remains fully functional even if
the adjustment terminal is disconnected. Normally, 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. An optional output capacitor can be added to improve transient response.
The adjustment terminal can be bypassed to achieve very high ripple rejection ratios which
are difficult to achieve with standard voltage, supplies of several hundred volts can be
regulated as long as the maximum input to output differential is not exceeded, i.e., avoid
short-circuiting the output.
Also, it makes an especially simple adjustable switching regulator, a programmable output
regulator, or by connecting a fixed resistor between the adjustment pin and output,
theLM317 can be used as a precision current regulator. Supplies with electronic shutdown
can be achieved by clamping the adjustment terminal to ground which programs the output
to 1.2V where most loads draw little current.
Typical application:

25

U1
3

V IN

VOUT

2
VOUT

ADJ

VIN

L M 3 1 7 /C Y L

R1
220E

C1
.1 u F
R2
5k

Features
1. Guaranteed 1% output voltage tolerance (LM317A)
2. Guaranteed max. 0.01%/V line regulation (LM317A)
3. Guaranteed max. 0.3% load regulation (LM317)
4. Guaranteed 1.5A output current
5. Adjustable output down to 1.2V
6. Current limit constant with temperature
7. P+ Product Enhancement tested
8. 80 dB ripple rejection
9. Output is short-circuit protected
Packages of LM317

26

C2
.1 u F

Application Hints:
In operation, the LM317 develops a nominal 1.25V reference voltage, VREF, between the
output and adjustment terminal. The reference voltage is impressed across program resistor
R1 and, since the voltage is constant, constant current I1 then flows through the output set
resistor R2, giving an output voltage of

Since the 100A current from the


adjustment terminal represents an error
term, the LM317 was designed to
minimize IADJ and make it very
constant with line and load changes. To
do this, all quiescent operating current
27

is returned to the output establishing a minimum load current requirement. If there is


insufficient load on the output, the output will rise.

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. Most 10F capacitors have low enough internal series resistance to
deliver 20A spikes when shorted. Although the surge is short, there is enough energy to
damage parts of the IC. When an output capacitor is connected to a regulator and the input
is shorted, the output capacitor will discharge into the output of the regulator. The
discharge current depends on the value of the capacitor, the output voltage of the regulator,
and the rate of decrease of VIN. In the LM317, this discharge path is through a large
junction that is able to sustain 15A surge with no problem. This is not true of other types of

28

positive regulators. For output capacitors of 25F or less, there is no need to use diodes.

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

29

LM337

3-Terminal Adjustable Regulator:-

General Description:
The LM337 is adjustable 3-terminal negative voltage regulators capable of supplying in
excess of 1.5A over an output voltage range of 1.2V to 37V. These regulators are
exceptionally easy to apply, 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. Further, the LM337 series features internal
current limiting, thermal shutdown and safe-area compensation, making them virtually
blowout-proof against overloads. The LM337 serves a wide variety of applications
including local on-card regulation, programmable-output voltage regulation or precision
current regulation. The LM337 are ideal complements to the LM317 adjustable positive
regulators.

Pin diagram

30

Features:
1) Output voltage adjustable from 1.2V to 37V
2) 1.5A output current guaranteed, 55C to +150C
3) Line regulation typically 0.01%/V
4) Load regulation typically 0.3%
5) Excellent thermal regulation, 0.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.
These two Ic's i.e. 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, which is much sufficient to drive any electronic circuit.
31

Bench supply diagram


D2
1N 4007
2

1
L1

U5
L M 3 1 7 /TO 2 2 0
3

IN D U C T O R A U D IO _ 0
3
2
1

J7

AD J

V IN V O U T

VS

4
5
6

D3

CON3
1

R
C 11

R 14
POT

C 13

R 13

R 15

C 15

R
R 16

1K 1W

10uF 25V T A N T

C 16
CAP

U6
R 17
V IN

VOUT

L2

AD J

2200uF 50V

CAP

470uF 50V

CON3

C 14 C 17
104

1K 1W

R 12

470uF 50V

1
2
3

C 10

R 11

104
10uF 25V T A N T
C 12

J8

R9

C9

BR1
B R ID G E

R 10
POT

1N 4007

C8

-V S

R8

2200uF 50V

1N 4007
D4

L M 3 3 7 /T O 2 2 0
1

2
D5
1N 4007

32

1
2
3

6
5
4

-V S
1
2
3

IN D U C T O R A U D IO _ 0

EMBEDDED SYSTEM

What is Embedded System?


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

33

DIFFERENCE BETWEEN MICROPROCESSORS


AND MICROCONTROLLERS:
A Microprocessor is a general purpose digital computer central processing
unit(C.P.U) popularly known as CPU on the chip. The Microprocessors
contain no RAM, no ROM, and no I/P O/P ports on the chip itself.
On the other hand a Microcontroller has a C.P.U(microprocessor) in addition
to a fixed amount of RAM, ROM, I/O ports and a timer all on a single chip.
In order to make a Microprocessor functional we must add RAM, ROM, I/O
Ports and timers externally to them,i.e any amount of external memory can be
added to it.
But in controllers there is a fixed amount of memory which makes them ideal
for many applications.
The Microprocessors have many operational codes(opcodes) for moving data
from external memory to the C.P.U
Whereas Microcontrollers may have one or two operational codes.

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, Memory,
Timer/counter chip, Interrupt controller chip,etc. to make it functional.

34

Types of microcontroller architecture:


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

35

8051 Architecture Overview


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

36

Block diagram of 8051

37

Internal Architecture of 8051

38

Pin configuration of 8051

39

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

40

P1.

Dual Role of Port 0 :-Port 0 is also designated as AD0-AD7, allowing it


to be used for both address and data. When connecting an 8051/31 to an external memory,
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. When ALE = 0, it provides data
D0-D7, but when ALE =1 it has address and data with the help of a 74LS373 latch.
Port 1:- Port 1 occupies a total of 8 pins (pins 1 through 8). It can be used as input or
output. In contrast to port 0, this port does not need any pull-up resistors since it already
has pull-up resistors internally. Upon reset, Port 1 is configured as an output port. For
41

example, the following code will continuously send out to port1 the alternating values 55h
& AAh
Port 1 as input:-To make port1 an input port, it must be programmed as such by writing 1
to all its bits. In the following code port1 is configured first as an input port by writing 1s
to it, then data is received from the port and saved in R7 ,R6 & R5.
Port 2 :-Port 2 occupies a total of 8 pins (pins 21- 28). It can be used as input or
output. Just like P1, P2 does not need any pull-up resistors since it already has pull-up
resistors internally. Upon reset,Port 2 is configured as an output port. For example, 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.
Port 2 as input:- To make port 2 an input, it must programmed as such by writing 1 to all
its bits. In the following code, port 2 is configured first as an input port by writing 1s to it.
Then data is received from that port and is sent to P1 continuously.

Dual role of port 2:- In systems based on the 8751, 8951, and DS5000, P2 is used as
simple I/O. However, in 8031-based systems, port 2 must be used along with P0 to provide
the 16-bit address for the external memory. As shown in pin configuration 8051, port 2 is
also designed as A8-A15, indicating the dual function. Since an 8031 is capable of
accessing 64K bytes of external memory, it needs a path for the 16 bits of the address.
While P0 provides the lower 8 bits via A0-A7, it is the job of P2 to provide bits A8-A15 of
the address. In other words, when 8031 is connected to external memory, P2 is used for the
upper 8 bits of the 16 bit address, and it cannot be used for I/O.

42

Port 3:- port 3 occupies a total of 8 pins, pins 10 through 17. It can be used as input or
output. P3 does not need any pull-up resistors, the same as P1 and P2 did not. Although
port 3 is configured as an output port upon reset. Port 3 has the additional function of
providing some extremely important signals such as interrupts. This information applies
both 8051 and 8031 chips. There functions are as follows:PORT 3
P3.0
P3.1
P3.2
P3.3
P3.4
P3.5
P3.6
P3.7

Function
RxD
TxD
___
Int0
___
Int1
T0
T1
___
WR
___
RD

pin
10
11
12
13
14
15
16
17

P3.0 and P3.1 are


used for the RxD and
TxD serial
communications signals.
Bits P3.2 and P3.3 are set
aside for external
interrupts. Bits P3.4 and

P3.5 are used for timers 0 and 1. Finally P3.6 and P3.7 are used to provide the WR and RD
signals of external memories connected in 8031 based systems.

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

cycle, except that two PSEN activations are skipped during each access to external data
memory.
EA/VPP
External Access Enable. 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. Note,
however, that if lock bit 1 is programmed, EA will be internally latched on reset. EA
should be strapped to VCC for internal program executions. This pin also receives the 12volt programming enable voltage (VPP) during Flash programming when 12-volt
programming is selected.
XTAL1
Input to the inverting oscillator amplifier and input to the internal clock operating circuit.
XTAL2
Output from the inverting oscillator amplifier.

AT89s8252
AT89S8252 is an ATMEL controller with the core of intel MCS-51. It has same pin
configuration as give above.
The AT89S8252 is a low-power, high-performance CMOS 8-bit microcomputer with 8K
bytes of Downloadable Flash programmable and erasable read only memory and 2K bytes
of EEPROM. The device is manufactured using Atmels high density nonvolatile memory
technology and is compatible with the industry standard 80C51 instruction set and pinout.
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. By combining a versatile 8-bit CPU with Downloadable Flash on a
monolithic chip, the Atmel AT89S8252 is a powerful microcomputer which provides a
highly flexible and cost effective solution to many embedded control applications. The
AT89S8252 provides the following standard features: 8K bytes of Downloadable Flash, 2K
bytes of EEPROM, 256 bytes of RAM, 32 I/O lines, programmable watchdog timer, two
Data Pointers, three 16-bit timer/counters, a six-vector two-level interrupt architecture, a
full duplex serial port, on-chip oscillator, and clock circuitry. In addition, the AT89S8252 is
designed with static logic for operation down to zero frequency and supports two software
selectable power saving modes. The Idle Mode stops the CPU while allowing the RAM,
timer/counters, serial port, and interrupt system to continue functioning. The Power Down
Mode saves the RAM contents but freezes the oscillator, disabling all other chip functions
until the next interrupt or hardware reset.
The Downloadable Flash can be changed a single byte at a time and is accessible through
the SPI serial interface. 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.
44

Features
Compatible with MCS-51Products
8K bytes of In-System Reprogrammable Downloadable Flash Memory
- SPI Serial Interface for Program Downloading
- Endurance: 1,000 Write/Erase Cycles
2K bytes EEPROM
- Endurance: 100,000 Write/Erase Cycles
4.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, P1.4, P1.5, P1.6, and P1.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.

45

Port 1 also receives the low-order address bytes during Flash programming and
verification.

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. This pin is also the program pulse input (PROG) during Flash
programming. In normal operation, ALE is emitted at a constant rate of 1/ 6 the oscillator
frequency and may be used for external timing or clocking purposes. Note, however, that
one ALE pulse is skipped during each access to external data memory. If desired, ALE
operation can be disabled by setting bit 0 of SFR location 8EH. With the bit set, ALE is
active only during a MOVX or MOVC instruction. Otherwise, the pin is weakly pulled
high. Setting the ALE-disable bit has no effect if the microcontroller is in external
execution mode.
PSEN
Program Store Enable is the read strobe to external program memory. When the
AT89S8252 is executing code from external program memory, PSEN is activated twice
each machine
46

cycle, except that two PSEN activations are skipped during each access to external data
memory.
EA/VPP
External Access Enable. 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. Note,
however, that if lock bit 1 is programmed, EA will be internally latched on reset. EA
should be strapped to VCC for internal program executions. This pin also receives the 12volt programming enable voltage (VPP) during Flash programming when 12-volt
programming is selected.
XTAL1
Input to the inverting oscillator amplifier and input to the internal clock operating circuit.
XTAL2
Output from the inverting oscillator amplifier.
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). 8051 assembler cum simulator.
2).command prompt as a programming environment.
Introduction to programming in assembly language:
assembly
languages
were
developed that provided mnemonics for the machine code instructions, plus others features
that made programming faster and less prone to error.The term mnemonic is frequently
used in computer science and engg. literature to refer to codes and abbreviations that are
relatively easy to remember .Asssembly language programs must be translated into
47

machine code by a program called an ASSEMBLER.Assembly language is referred to as


a low-level-language .
Now we look at 8051 assembly language format and use an 8051
Assembler to create a ready-to run program.
An assembly language instruction consists of four fields:[label:]

mnemonic

[operands]

[;comment]

Brackets indicates that a field is optional,and not all lines have them.Bracket should
not be typed in.
1.The label field allows the program to refer to a line of code by name.the label field can
not exceed a certain no. of characters.
2.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.
3.The comment field begins with a ;. Comments may be at the and of a line or on a line
by themselvess .
8051 basic instructions:
we describe the basic instructions of the 8051 and
give their formats with some examples.
1).arithmetic instructions
2).logical instructions
3).jump,loop,call instructions
arithmetic instructions:
the arithmetic instructions are used to perform arithmetic
operations like addition,subtraction ,multiplication, division etc.
1)ADD:- this instruction is used to add 2 operands.the 1 operand should be in accumulator
and 2 in the other register.
eg.

MOV R0,#20
MOV A,#10
ADD A,R0
MOV P1,A
Here,# is used to load immediate value and we observe the final value on port 1.

2)MUL:-this instruction is used to multiply 2 operands. the 1 operand should be in


accumulator and 2 in the other register.
48

eg.
MOV R0,#20
MOV A,#10
MUL AB
MOV P1,A
Here,# is used to load immediate value and we observe the final value on port 1.

3)DIV:- this instruction is used to divide 2 operands. the 1 operand should be in


accumulator and 2 in the other register.
eg.
MOV R0,#20
MOV A,#10
DIV AB
MOV P1,A
Here,# is used to load immediate value and we observe the final value on port 1.
logical instructions: Apart from the input/output instructions ,logic instructions are some
of the most widely used instructions.the logical instructions are used to perform logical
operations likeAND,OR,EXOR etc.
1).

MOV A,#35H
ANL A,#0FH

;A=35H
;A AND 0FH(now A=05)

According to this operation, the content 35H gets ANDing with 0FH.
2).

MOV A,#04
ORL A,#30H

;A=04
;A=A OR 30H(now A=34H)

According to this operation, the content 35H gets ANDing with 0FH.
Jump,loop,call instructions:
the Jump,loop,call instructions are used to perform logical
operations in the sequence of instructions to be executed ,it is often necessary to transfer
program control to a different location.

49

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.

Details like register allocation and addressing of memory and data is managed by the
compiler.

Programs get a formal structure and can be divided into separate functions.

Programming and program test time is drastically reduced, this increases efficiency.

Keywords and operational functions can be used that come closer to how humans
think.

The supplied and supported C libraries contain many standard routines such as
numeric conversions.

Reusable code: Existing program parts can be more easily included into new
programs, because of the comfortable modular program construction techniques.

The C language based on the ANSI standard is very portable. Existing programs can
be quickly adapted to other processors as needed.

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. But it results in wastage of machine cycles of the micro-controller.
2) INTERRUPTS: Here every device tells the micro-controller when it needs the
services from microcontroller.
50

Actually, only 5 interrupts are available to the user in the 8051, but many manufacturers
data sheets state that there are 6 interrupts since they include reset. The 6 interrupts in the
8051 are allocated as follows:
1).Reset: when the reset pin is activated, the 8051 jumps to address location 0000.this is
the power-up reset.
2).Two interrupts are set aside for the timers:
One for timer 0 and one for timer 1.memory locations 000BH and 001BH in the interrupt
vector table belong to timer0 and timer1, respectively.
3).Two interrupts are set aside for hardware external hardware interrupts. Pin numbers
12(p3.2) and 13(p3.3) in port 3 are the external hardware interrupts INT0 and INT1,
respectively. These external interrupts are also referred to as EX1 and EX2.
4).Serial communication has a single interrupts that belongs to both receive and transmit.

ELECTROMAGNETIC RELAYS
A relay is an electrically controllable switch widely used in industrial controls, automobiles
and appliances. It allows the isolation of two separate sections of a system with two
different voltage sources. The electromechanical (or electromagnetic) relay (EMR) has 3
components: the coil, spring and contacts. When current flows through the coil, a magnetic
field is created around the coil (the coil is energized) which causes the armature to be
attracted to the coil. The armatures contact acts like a switch and closes or opens a circuit.
When the coil is not energized, a spring pulls the armature to its normal state of open or
closed.
In choosing a relay, the following characteristics need to be considered:
1)
2)
3)

The contacts can be normally open (NO) or normally closed (NC). In


the NC type, the contacts are closed when the coil is not energized.
In the NO, the contacts are open when the coil is un-energized.
There can be one or more contacts (SPST, SPDT, DPDT relays).
The voltage and current needed to energize the coil. The voltage can
vary from a few volts to 50 volts, while the current can be from few
mA to 20mA. The relay has a minimum voltage below which the coil
will not be energized. This minimum voltage is called the pull-in
voltage.

51

INTERFACING OF VARIOUS DEVICES


1) LED Interfacing
VCC
BC 547A

Q 14

R 62

VCC

31

Y8
E A /V P P

33pF C 45

U 10

1 2

4
3
33pF C 46

19
18
9
12
13
14
15

VC C

XTA L1
XTA L2
R ST

VCC

8 M hz

P 0 .0 /A D
P 0 .1 /A D
P 0 .2 /A D
P 0 .3 /A D
P 0 .4 /A D
P 0 .5 /A D
P 0 .6 /A D
P 0 .7 /A D

330E

LE D

Q 15

C 48
104

R 61
BC 547A

40

VC CVC C

D 29

0
1
2
3
4
5
6
7

P 3 .2 /IN T 0
P 3 .3 /IN T 1 P 2 .0 /A 8
P 3 .4 /T 0
P 2 .1 /A 9
P 3 .5 /T 1
P 2 .2 /A 1 0
P 2 .3 /A 1 1
P 2 .4 /A 1 2
P 2 .5 /A 1 3
P 2 .6 /A 1 4
P 2 .7 /A 1 5

39
38
37
36
35
34
33
32

D 28

330E

LE D

R 41
BC 547A

D 27

330E

LE D

VCC
Q 16

21
22
23
24
25
26
27
28

VCC
Q 17
R 40
BC 547A

D 26

VCC
C 47
1 0 u F /1 6 V

P 3 .7 /R D
P 1 .0 /T 2
P 3 .6 /W R
P 1 .1 /T 2 -E X
PSEN
P 1 .2
A L E /P R O G
P 1 .3
P 3 .1 /TXD
P 1 .4 /S S P 3 .0 /R X D
P 1 .5 /M O S I
P 1 .6 /M IS O
P 1 .7 /S C K

17
16
29
30
11
10

GND

R7
10K

1
2
3
4
5
6
7
8

330E

Q 18
BC 547A

LE D

D 25

R 63
VCC

330E

LE D

Q 19
BC 547A

D 24

20

AT89S8252

R 39
VCC

330E

LE D

Q 20
BC 547A

D 23

R 38
330E

LE D

VCC
Q 21
BC 547A
R 37

Hardware interfacing of LED with AT89s8252

330E

D 22

LE D

T it le

< T it le >

S iz e
D ocum ent N um ber
C u s to m< D o c >
D a te :

52

Tuesday , D ecem ber 26, 2006

R ev
<R ev C ode>
S heet

of

C code for Blinking LEDs connected on PORT2:


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

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

54

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

PIN NO.
1
2
3

NAME
Vss
Vdd
Vee

FUNCTION
Ground
+ve supply
contrast
55

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 this line is low, data bytes transferred to the
display are treated as commands, and data bytes read from the display indicate its
status. By setting the RS line high, character data can be transferred to and from the
module.
Pin 5 is (R/W) line. This line is pulled low in order to write commands or character data
to the module, or pulled high to read character data or status information from its
registers.
Pin 6 is Enable (E) line. This input is used to initiate the actual transfer of commands or
character data between the module and the data lines. When writing to the display, data
is transferred only on the high to low transition of this signal. However, when reading
from the display, data will become available shortly after the low to high transition and
remain available until the signal falls low again.
Pins 7 to 14 are the eight data bus lines (D0 to D7). Data can be transferred to and from
the display, either as a single 8-bit byte or as two 4-bit nibbles. In the latter case, only
the upper four data lines (D4 to D7) are used. This $-bit mode is beneficial when using
a microcontroller, as fewer I/O lines are required.

56

LC D

12

4
3
33pF

C 2

19
18
9
12
15

VC C

E A /V P P

Y 1

XTA L1
XTA L2
R ST

P 1 .0 /T2
P 1 .1 /T 2 -E X
P 1 .2
P 1 .3
P 1 .4 /S S
P 1 .5 /M O S I
P 1 .6 /M IS O
P 1 .7 /S C K

P 3 .2 /IN T 0 P 3 .3 /IN T 1
P 3 .4 /T0

P 2 .0 /A 8
P 2 .1 /A 9
P 2 .2 /A 1 0
P 2 .3 /A 1 1
P 2 .4 /A 1 2
P 2 .5 /A 1 3
P 2 .6 /A 1 4
P 2 .7 /A 1 5

P
P
P
P
P
P
P
P

0 .7 /A
0 .6 /A
0 .5 /A
0 .4 /A
0 .3 /A
0 .2 /A
0 .1 /A
0 .0 /A

AT89S52

D
D
D
D
D
D
D
D

7
6
5
4
P 3 .7 /R D
3
P 3 .6 /W R
2
PSEN
1 A L E /P R O G
0 P 3 .0 /R XD
P 3 .1 /T XD
G N D

32
33
34
35
36
37
38
39

13
14

RS
EN

21
22
23
24
25
26
27
28
17
16
29
30
10
11

20

R 1
10K

1
2
3
4
5
6
7
8

P 3 .5 /T1

VC C
C 3
10uF 16V

56E

40

U 1

31

VC C

33pF C 1

R 52

VC C

VC C

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

J2

Hardware intetrfacing of LCD with AT89s52 microcontroler

C code for LCD display


#include <at89s8252.h>
#define LCDPRT P1
#define RS P3_3
#define EN P3_4
void delay(unsigned int i);
void lcd_cmd(unsigned char a);
void display(unsigned char b);
void wait(void);
void Init_lcd(void);
void cursor_position(unsigned char c);
void main(void)
{
init_lcd();
57

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

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

void cursor_position(unsigned char c);


void main(void)
{
Init_lcd();
cursor_position(0x40);
display_string(&name_arry);
}
void display_string(unsigned char *sp)
{
while(*sp!='$')
{
display(*sp);
sp=sp+1;
}
}

void lcd_cmd(unsigned char a)


{
wait ();
LCDPRT=a;
RS=0;
EN=1;
EN=0;
}
void display(unsigned char b)
{
wait ();
LCDPRT=b;
RS=1;
EN=1;
EN=0;
}
void wait(void)
{
unsigned int count=300;
60

while(count!=0)
{
count--;
}
}
void Init_lcd(void)
{
lcd_cmd(0x3c);
lcd_cmd(0x0c);
lcd_cmd(0x06);
lcd_cmd(0x01);
}
void cursor_position(unsigned char c)
{
lcd_cmd(c+0x80);
}

3) ADC-0804 interfacing with AT89s52:


The ADC0804 family is CMOS 8-Bit, 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. These converters appear to the
processor as memory locations or I/O ports, and hence no interfacing logic is
required. The differential analog voltage input has good common mode- rejection
and permits offsetting the analog zero-input voltage value. In addition, the voltage
reference input can be adjusted to allow encoding any smaller analog voltage span
to the full 8 bits of resolution.

Features
80C48 and 80C80/85 Bus Compatible - No Interfacing Logic Required
Conversion Time < 100s
Easy Interface to Most Microprocessors
Differential Analog Voltage Inputs
61

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

62

Hardware interfacing of ADC-0804 for Temperature monitoring


C O N 16_0

1
3
2
1
1
1

1
0
9
6
0
7

D
D
D
D
D
D
D
D

VC C
VC C
R 6
220E

VC C

P
P
P
P
P
P
P
P

0 .7
0 .6
0 .5
0 .4
0 .3
0 .2
0 .1
0 .0

P
A
P
P
P
P

3 .1 /T XD
L E /P R O G
15
SEN
P 3 .5 /T 1
3 .6 /W R
P 3 .2 /IN T 0 1 2
3 .0 /R XD
3 .7 /R D

A T89S 8252

R 53
1k

7
6
5
4
3
2
1
0

U 4
AD C 0804

P
P
P2
P2
P2
P2
P2
P2

2 .0 /A
2 .1 /A
.2 /A 1
.3 /A 1
.4 /A 1
.5 /A 1
.6 /A 1
.7 /A 1

8
9
0
1
2
3
4
5

2
2
2
2
2
2
2
2

1
2
3
4
5
6
7
8

1
1
1
1
1
1
1
1

EOC

8
7
6
5
4
3
2
1
5

SOC

D
D
D
D
D
D
D
D

B
B
B
B
B
B
B
B

0
1
2
3
4
5
6
7

+ IN
-IN
V R E F /2
C LK R
C L K IN

IN T R

C S
R D
W R

C 9
C AP

6
7

P 3 .3 /IN T 1
P 3 .4 /T 0
/A
/A
/A
/A
/A
/A
/A
/A

VC C

1
R 5
10K

R ST

G N D
O U TPU T

G N D

R 2
10K

2
3
4
5
6
7
8
9

XTA L1
XTA L2

1
2
3
4
5
6
7
8

20

3
3
3
3
3
3
C 6
3
10uF 16V 3

U 2 2 L M 3 5 /S O

U 21
TL431

9
19
4
1
2
3

10

VC C

13
14

R 55
56E

V C C /V R E F

R S
EN

EN

AG N D

C 5

R S

33pF

19
18

G N D

P 1 .0 /T 2
P 1 .1 /T 2 -E X
P 1 .2
P 1 .3
P 1 .4 /S S
P 1 .5 /M O S I
P 1 .6 /M IS O
P 1 .7 /S C K

20

12

VC C

E A /V P P

33pF C 4
Y 2

VC C

U 2

31

C R Y S TA L

C 13
104

40

VC C VC C

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

LC D

C 8
1 u f /1 6 v

R 17
10K
C 7
150pF

Temprature monitoring

When interfacing is being done then

system

gets lowered then only it allows the

controller to read the data, otherwise controller can not read the data.
is always grounded.
is software controlled.

C- code For temperature monitoring system


#include <at89s8252.h>
#define LCDPRT P1
#define RS P3_3
#define EN P3_4
#define SOC P3_2
63

C 14
1 u f /16 v

#define EOC P3_5


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

void lcd_cmd(unsigned char a)


{
wait();
LCDPRT=a;
RS=0;
EN=1;
EN=0;
}
void display(unsigned char b)
{
wait ();
LCDPRT=b;
RS=1;
EN=1;
EN=0;
}
void wait(void)
{
unsigned int count=300;
while(count!=0)
{
count--;
}
}
void Init_lcd(void)
{
lcd_cmd(0x3c);
lcd_cmd(0x0c);
lcd_cmd(0x06);
lcd_cmd(0x01);
}

void cursor_position(unsigned char c)


{
lcd_cmd(c+0x80);
}
void disp_dec(unsigned int digit)
{
65

unsigned int temp;


if(digit<100)
{
temp=digit/10;
display(table[temp]);
temp=digit-temp*10;
display(table[temp]);
}
if(digit>99 && digit<1000)
{
temp=digit/100;
display(table[temp]);
digit=digit-(temp*100);
temp=digit/10;
display(table[temp]);
digit=digit-(temp*10);
temp=digit;
display(table[temp]);
}
6) Serial communication between At89s8252 and PC
a) Serial Transmission

P
P
P
P

3
3
3
3

.2
.3
.4
.5

/IN T 0
/IN T 1
/T 0
/T 1

VC C
C 18
10uF 16V
R 4
10K

1
2
3
4
5
6
7
8

P
P
P
P
P
P
P
P

1
1
1
1
1
1
1
1

.0
.1
.2
.3
.4
.5
.6
.7

P
P
P2
P2
P2
P2
P2
P2

D
D
D
D
D
D
D
D

0
1
2
3
4
5
6
7

2 .0 /A
2 .1 /A
.2 /A 1
.3 /A 1
.4 /A 1
.5 /A 1
.6 /A 1
.7 /A 1

8
9
0
1
2
3
4
5

P 3 .7 /R D
/T 2
P 3 .6 /W R
/T 2 -E X
PSEN
A L E /P R O G
P 3 .1 /TXD
/S S
P 3 .0 /R X D
/M O S I
/M IS O
/S C K

AT89S8252

39
38
37
36
35
34
33
32
21
22
23
24
25
26
27
28
17
16
29
30
11
10

U 6

C 23
104

VC C

J7

16

R ST

/A
/A
/A
/A
/A
/A
/A
/A

11
12
7
8
1 0 U F /1 6 V

C 20

1
3
2

VC C
C 21
1 0 U F /1 6 V

66

T 1 IN
R 1O U T
T2O U T
R 2 IN
C 1+
C 1V+

VC C

9
12
13
14
15

XTA L1
XTA L2

.0
.1
.2
.3
.4
.5
.6
.7

R 1 IN
T1O U T
T 2 IN
R 2O U T

G N D

19
18

0
0
0
0
0
0
0
0

15

3
C 17

P
P
P
P
P
P
P
P

G N D

12

33pF

40

E A /V P P

Y 4

VC C

U 5

C 19
104

20

C R Y S TA L
33pF C 16

31

VC C VC C

C 2+
C 2VM A X232

13
14
10
9

SPT TXD

1
2
3

SPT RXD
C 2 4 1 0 U F /1 6 V

4
5
6
1 0 U F /1 6 V

C 22

S E R IA L P O R T O F P C

C- code for serial transmission(from Microcontroller to PC)


#include<at89s8252.h>
void Init_SPT(void);
void transmit_serial(unsigned char a);
void delay(unsigned int i);
void main(void)
{
Init_SPT();
while(1)
{
delay(0XFFFF);
transmit_serial('N');
delay(0XFFFF);
transmit_serial('E');
delay(0XFFFF);
transmit_serial('T');
delay(0XFFFF);
transmit_serial('M');
delay(0XFFFF);
transmit_serial('A');
delay(0XFFFF);
transmit_serial('X');
delay(0XFFFF);
}
}
void Init_SPT(void)
{
TMOD=0x20;
TH1=0xfd;
TR1=1;
SCON=0x40;
67

}
void transmit_serial(unsigned char a)
{
SBUF=a;
delay(500);
TI=0;
}
void delay(unsigned int i)
{
while(i!=0)
{
i--;
}
}
b)Serial Reception(From PC to microcontroller)
J3

LC D

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

NETMAX
EN

R 54

VC C

R S

VC C

56E
VC C VC C

2
3
4
5
6
7
8
9

R ST
P
P
P
P
P
P
P
P
P
P
P
P

3
3
3
3
0
0
0
0
0
0
0
0

.2
.3
.4
.5
.7
.6
.5
.4
.3
.2
.1
.0

/IN T 0
/IN T 1
/T 0
/T 1
/A
/A
/A
/A
/A
/A
/A
/A

D
D
D
D
D
D
D
D

R 8
10K

7
6
5
4
3
2
1
0

P
P
P2
P2
P2
P2
P2
P2

2 .0 /A
2 .1 /A
.2 /A 1
.3 /A 1
.4 /A 1
.5 /A 1
.6 /A 1
.7 /A 1

8
9
0
1
2
3
4
5

P 3 .7 /R D
P 3 .6 /W R
PSEN
A L E /P R O G
P 3 .1 /T XD
P 3 .0 /R XD

2
2
2
2
2
2
2
2
1
1
2
3
1
1

1
2
3
4
5
6
7
8
7
6
9
0
1
0

U 12
11
12

1 0 U F /1 6 V

7
8

C 51

1
3
2

VC C

AT89S8252

C 54
104

VC C

J8

16

3
3
3
3
3
3
C 49
3
10uF 16V 3

2
3
4
5

C 52
1 0 U F /1 6 V

68

T 1 IN
R 1O U T

VC C

VC C

1
1
1
1

T2O U T
R 2 IN
C 1+
C 1V+

R 1 IN
T1O U T
T 2 IN
R 2O U T

G N D

R S
EN

XTA L1
XTA L2

1
2
3
4
5
6
7
8

15

C 35

G N D

33pF

19
18

P 1 .0 /T 2
P 1 .1 /T 2 -E X
P 1 .2
P 1 .3
P 1 .4 /S S
P 1 .5 /M O S I
P 1 .6 /M IS O
P 1 .7 /S C K

20

12

VC C

E A /V P P

33pF C 34
Y 9

40

U 11

31

C R Y S TA L

C 50
104

C 2+
C 2VM A X232

13
14
10
9

SPT TXD

1
2
3

SPT RXD
C 5 5 1 0 U F /1 6 V

4
5
6
1 0 U F /1 6 V

C 53

S E R IA L P O R T O F P C

C- code for serial reception:


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

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

count--;
}
}
void Init_lcd(void)
{
lcd_cmd(0x3c);
lcd_cmd(0x0C);
lcd_cmd(0x06);
lcd_cmd(0x14);
lcd_cmd(0x1C);
lcd_cmd(0x01);
}
void cursor_position(unsigned char d)
{
lcd_cmd(d+0x80);
}

Interfacing of seven segment display

C 48
1 0 u F /1 6 V
R 36
10K

1
2
3
4
5
6
7
8

P
P
P
P
P
P
P
P

1
1
1
1
1
1
1
1

.0
.1
.2
.3
.4
.5
.6
.7

P 3 .7 /R D
/T 2
P 3 .6 /W R
/T 2 -E X
P 3 .5 /T 1
P 3 .4 /T 0
P 3 .3 /IN T 1
/S S
P 3 .2 /IN T 0
/M O S I P 3 .1 /T XD
/M IS O P 3 .0 /R XD
/S C K

A T89S 8252

7
6
5
4
3
2
1
0

0
0
0
0
0
0

E
E
E
E
E
E

6
2
1
7

8
7
6
5
4
3
2

VC C
LT
B I/R B O
R BI
D
D
D
D

3
2
1
0

U 12
74LS47

71

c
d

VC C

1 0 k S IP

VC C
3
4
5

20
19
18
17 VC C
16
15
14
13
12
11

1
1
1
1
1
1
1
1

22
22
22
22
22
22

VC C
R 11

VC C

7
8
9
15
19
21

g
f
G /V
a
b
g
f
G /v
a
b

1
2
3
4
5
6
7
8

R
R
R
R
R
R

220E

2
2
2
2
2
2
2
2

74LS47
U 3

R 3

B
A
F
G
E
D
C

12
13
15
14
9
10
11

R 13 220E
R
R
R
R
R

1
1
2
2
2

4
6
0
4
5

R 34

22
22
22
22
22

e
d
G /V
c
dot
e
d
G /V
dot
c

2 .0 /A 8
2 .1 /A 9
.2 /A 1 0
.3 /A 1 1
.4 /A 1 2
.5 /A 1 3
.6 /A 1 4
.7 /A 1 5

3
2
1
0

8
7
6
5
4
3
2

0
1
2
3
4
5
6
7

D
D
D
D

16

P
P
P2
P2
P2
P2
A L E /P R O G P 2
PSEN
P2

D
D
D
D
D
D
D
D

6
2
1
7

1
2
3
4
5
6
7
8

12
13
15
14
9
11
10

0
0
0
0
0

E
E
E
E
E

220E

VC C
e d

c
VC C

VC C

R ST

/A
/A
/A
/A
/A
/A
/A
/A

0
0
0
0
0
0
0
0

B
A
F
G
E
C
D

1
2
3
4
5
6
7
8
9
10

30
29

XTA L1
XTA L2

.0
.1
.2
.3
.4
.5
.6
.7

P
P
P
P
P
P
P
P

G N D

0
0
0
0
0
0
0
0

9
8
7
6
5
4
3
2

20

3
33PF

19
18

P
P
P
P
P
P
P
P

3
3
3
3
3
3
3
3

VC C

4
12

C 42

E A /V P P

Y 3

VC C

C 43

G N D

40

U 16

31

8 M hz
33PF

B I/R B O
R BI
LT

4
5
3

9
8
7
6
5
4
3
2

104

G N D

C 49

VC C

16

VC C

VC C

R 37
1 0 k S IP

VC C

1 0 K S IP

VC C

VC C
R 35

U 13
D IP 2 0

C code for seven segment display


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

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

73

6) 8051 Interrupt Programming


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

74

75

Das könnte Ihnen auch gefallen