You are on page 1of 86

CHAPTER 1

INTRODUCTION

CHAPTER 1
INTRODUCTION

1.1 MEASUREMENT OF RESPIRATORY RATE


Thermistor is used for the measurement of body temperature and respiratory temperature. This
thermistor is a passive transducer and its resistance depends on the beat being applied on it. We have
arranged the sensor in the potential divider circuit. This sensor exhibits a large change in resistance
with a change in body temperature. The respiratory rate is determined by holding the sensor near the
nose. The temperature sensor part is attached to the patient whose temperature has to be measured,
which changes the values and thus the corresponding change in the temperature is displayed on the
monitor graphically. Also all temperature measurements are updated in the patients database. Here
in our project we use bead temperature sensor.

1.2 SALINE MONITORING SYSTEM


For saline monitoring the infrared emitter and detector are placed in a position such that the saline
bottle passes between them. They are placed near the next of the saline bottle. As long as the saline is
present, the path of the infrared rays is blocked and the infrared detector is blocked from collecting
infrared rays from the emitter. And so the output will indicate normal saline status. The software is
written to give an audio alert when saline level falls below the safe level.

1.3 PATIENT CALLING SYSTEM


The patient calling system consists of four switches which when pressed gives display on the screen
and activities an audio alert indicating that patient is calling. These switches are placed in the
vicinity of the patient to enable medical access in an emergency.

1.4 HEART BEAT MONITOR


The patients heart beat rate is monitored using photoelectric sensor which can sense the patients
pulse rate. This method of tracking the heart rate is more efficient than the traditional method which
derives the same from ECG graph.

1.5 BLOCK DIAGRAM

Figure 1: Block Diagram

1.6 DIAGRAM OF PATIENT MONITORING SYSTEM

Figure 2: Diagram of patient monitoring


4

1.7 CIRCUIT DIAGRAM

Figure 3: Circuit diagram


5

1.8 CIRCUIT DESCRIPTION


1.8.1 Heart Beat Rate Sensor Circuit
Monitoring the heart beat rate of the patient can be easily accomplished by analyzing the ECG pulse.
Here, the ECG pulse is amplified and the average time interval or the instantaneous time interval
between two successive R peaks is measured, from which the heart beat rate is derived. But this
method fails to indicate heart blocks immediately and so photo electric pulse transducers are used.
The pulse rate monitoring method indicates a heart block immediately by sensing the cessation of
blood circulation in the limb terminals. This technique uses photoelectric transducers which are easy
to apply then the 3 ECG electrodes. Also the output signal amplitude is large with better signal to
noise ratio.
The finger probe used for pulse pick up consists of a GaAs infrared LED and a silicon NPN
phototransistor mounted in an enclosure that fits over the tip of the patients finger. The peak spectral
emission of the LED is at 0.94 mm with a 0.707 peak bandwidth of 0.04mm. The silicon
phototransistor is sensitive to radiation between 0.4 and 1.1.mm. Due to the narrow bond of the
spectrum involved the radiation heat output is minimized. The photo transistor is used as an emitter
follower configuration. The IR signal from the LED is transmitted through the finger tip of the
patients finger and the conductivity of the phototransistor depends on the amount of radiation
reaching it with each contraction of the heart, blood is forced to the extremities and amount of blood
in finger increases.

1.8.2 SALINE STATUS MONITORING CIRCUIT


The saline water injection plays a key role in the treatment and recovery of many a patient that
requires constant monitoring. This condition can be fulfilled by using IR sensors which can detect a
drop in the saline below the quantity. By means of annunciation systems, the hospital staff can be
informed and an action of replacing the saline can be easily accomplished before the bottle becomes
empty. Also the usage of the GSM modem facilitates sending of saline status to the doctor concerned
for any further action required. The circuit uses an IR emitter and an IR detector which are placed in
6

a straight line with the saline bottle in between, at the point representing the preset saline level. The
presence of saline water, in a full bottle, refracts the emitted radiation, thus generating no output at
the IR detector. When the saline level falls below the preset value; the emitted IR radiation causes a
photoelectric current from the detector. The detector output is an analog quantity which is made to
drive a switching NPN transistor BC107 to get a binary output from the collector of the transistor.
This digital output is fed to the pin 23 of the PIC micro controller, corresponding to port bit 4. The
signal is processed and the saline status is displayed on the screen. In case of the saline becoming
empty the annunciation systems are activated.

1.8.3 PATIENT CALL SWITCHES CIRCUIT


The patient calling system consists of four switches when pressed gives display on the screen and
activates an audio alert indicating that a patient is calling. These switches are placed in the vicinity
of the patient to enable medical access in an emergency.

1.8.4 BODY RESPIRATORY RATE CIRCUIT


The rate measuring circuit uses a temperature sensor for measuring the respiration rate. A thermistor
is a ceramic semiconductor which exhibits a large change in resistance with a change in its body
temperature. The thermistors have much better sensitivity than RTDs and are therefore better suited
for precision temperature measurements. The availability of high resistance values allows the
thermistors to be used with long extension leads since the lead resistance or contact resistance effects
can be greatly diminished. The non-linearity of the thermistor resistance-temperature characteristics
outs a practical limit on the temperature span over which a thermistor can be operated in
measurement or control circuit RTDs have lower sensitivity and are more linear and can therefore
be used in applications, where the temperature spans are very wide. Thermistors has other important
advantages over RTDs in that they are available in smaller sizes, with faster response times, at lower
costs and with greater resistance to shock and vibration effects

CHAPTER 2
HARDWARE COMPONENT

CHAPTER 2
HARDWARE COMPONENT

2.1 RESISTOR
Electrical resistance is a measure of the degree to which an object opposes an electric current
through it. The SI unit of electrical resistance is the ohm. Its reciprocal quantity is electric
conductance measured in seimens. Electrical resistance shares some conceptual parallels with the
mechanical notion of friction.

2.2 Types of resistor

Figure 4: Types of resistors

2.3 Ohm's law


The relationship between voltage, current, and resistance through a metal wire, and some other
materials, is given by a simple equation called Ohms law:

V
R

where V is the voltage (or potential difference) across the wire in volts, I is the current through the
wire in amperes, and R, in ohms, is a constant called the resistance in fact this is only a
simplification of the original Ohm's law Materials that obey this law over a certain voltage or current
range are said to be ohmic over that range. An ideal resistor obeys the law across all frequencies and
amplitudes of voltage or current. Superconducting materials at very low temperatures have zero
resistance. Insulators (such as air, diamond, or other non-conducting materials) may have extremely
high (but not infinite) resistance, but break down and admit a larger flow of current under
sufficiently high voltage.

2.4 Resistance of a conductor


2.4.1 DC resistance
As long as the current density is totally uniform in the conductor, the DC resistance R of a conductor
of regular cross section can be computed as

Where
l is the length of the conductor, measured in meters.
A is the cross-sectional area, measured in square meters.
(Greek: rho) is the electric sensitivity s(also called specific electrical resistance) of the
material, measured in ohm meter. Resistivity is a measure of the material's ability to oppose
the flow of electric current.
For practical reasons, almost any connections to a real conductor will almost certainly mean the
current density is not totally uniform. However, this formula still provides a good approximation for
long thin conductors such as wires.
10

2.4.2 AC resistance
If a wire conducts high-frequency alternating current then the effective cross sectional area of the
wire is reduced. This is because of the skin effect. This formula applies to isolated conductors. In a
conductor close to others, the actual resistance is higher because of the proximity effect.
What do resistors do?
Resistors limit current. In a typical application, a resistor is connected in series with an LED:

Enough current flows to make the LED light up, but not so much that the LED is damaged. Later in
this Chapter, you will find out how to calculate a suitable value for this resistor. The 'box' symbol for
a fixed resistor is popular in the UK and Europe. A 'zigzag' symbol is used in America and Japan:

Resistors are used with transducers to make sensor subsystems. Transducers are electronic
components, which convert energy from one form into another, where one of the forms of energy is
11

electrical. A light dependent resistor, or LDR, is an example of an input transducer. Changes in the
brightness of the light shining onto the surface of the LDR result in changes in its resistance. As will
be explained later, an input transducer is most often connected along with a resistor to make a circuit
called a potential divider. Most electronic circuits require resistors to make them work properly and
it is obviously important to find out something about the different types of resistor available, and to
be able to choose the correct resistor value, in

, or M

, for a particular application.

2.5 Colours code

Number

Colour

Black

Brown

Red

Orange

Yellow

Green

Blue

Violet

How can the value of a resistor be worked out from the colours of the bands? Each colour represents
a number according to the following scheme: The first band on a resistor is interpreted as the FIRST
DIGIT of the resistor value. For the resistor shown below, the first band is yellow, so the first digit is
4:

12

The second band gives the SECOND DIGIT. This is a violet band, making the second digit 7. The
third band is called the MULTIPLIER and is not interpreted in quite the same way. The multiplier
tells you how many noughts you should write after the digits you already have. A red band tells you
to add 2 noughts. The value of this resistor is therefore 4700 ohms, that is, 4700

, or 4.7

. Work

through this example again to confirm that you understand how to apply the colour code given by
the first three bands. The remaining band is called the TOLERANCE band. This indicates the
percentage accuracy of the resistor value. Most carbon film resistors have a gold-coloured tolerance
band, indicating that the actual resistance value is with + or - 5% of the nominal value. Other
tolerance colours are:

Tolerance

Colour

1%

Brown

2%

Red

5%

Gold

10%

Silver

2.6 CAPACITORS

Figure 5: Types of Capacitors


SMD ceramic at top left; SMD tantalum at bottom left; through-hole tantalum at top right; throughhole electrolytic at bottom right. Major scale divisions are cm. A capacitor is an electrical device that
13

can store energy in the electric field between a pair of closely-spaced conductors (called 'plates').
When voltage is applied to the capacitor, electric charges of equal magnitude, but opposite polarity,
build up on each plate. Capacitors are used in electrical circuits as energy-storage devices. They can
also be used to differentiate between high-frequency and low-frequency signals and this makes them
useful in electronic filters. Capacitors are occasionally referred to as condensers. This is now
considered an antiquated term. A capacitor consists of two conductive electrodes, or plates, separated
by an insulator.

2.7 Capacitance

When electric charge accumulates on the plates, an electric field is created in the region between the
plates that is proportional to the amount of accumulated charge. This electric field creates a potential
difference V = Ed between the plates of this simple parallel-plate capacitor. The capacitor's
capacitance (C) is a measure of the amount of charge (Q) stored on each plate for a given potential
difference or voltage (V) which appears between the plates:

In SI units, a capacitor has a capacitance of one farad when one coulomb of charge is stored due to
one volt applied potential difference across the plates. Since the farad is a very large unit, values of
capacitors are usually expressed in microfarads (F), nanofarads (nF), or picofarads (pF).The
capacitance is proportional to the surface area of the conducting plate and inversely proportional to
the distance between the plates. It is also proportional to the permittivity of the dielectric (that is,

14

non-conducting) substance that separates the plates. The capacitance of a parallel-plate capacitor is
given by:

Where is the permittivity of the dielectric, A is the area of the plates and d is the spacing between
them.

2.8 Stored energy


As opposite charges accumulate on the plates of a capacitor due to the separation of charge, a voltage
develops across the capacitor owing to the electric field of these charges. Ever-increasing work must
be done against this ever-increasing electric field as more charge is separated. The energy (measured
in joules, in SI) stored in a capacitor is equal to the amount of work required to establish the voltage
across the capacitor, and therefore the electric field. The energy stored is given by:

Where V is the voltage across the capacitor.

2.9 Electrical circuits

The electrons within dielectric molecules are influenced by the electric field, causing the molecules
to rotate slightly from their equilibrium positions. The air gap is shown for clarity; in a real

15

capacitor, the dielectric is in direct contact with the plates. Capacitors also allow AC current to flow
and block DC current.

2.10 Types of capacitors: 2.10.1 MICA CAPACITOR


Mica is such a material, which is available in a thin layer in the nature. Its dielectric constant is very
high. Especially for high frequency. It works as a good insulator even on high temperature. There is
very low frequency loss in it, because of these silient features it is used as dielectric material in the
capacitors. These types of capacitors are known as mica capacitor. Since winding of mica is not
possible therefore mica capacitor are always flat in shape. These capacitors are used where more
accuracy and high dielectric constant is needed.
Mica capacitors are of various types.

16

Figure 6: MICA CAPACITOR

2.10.2 PAPER CAPACITOR

Figure 7: PAPER CAPACITOR

17

It is such a capacitor which is used for high voltage DC&AC on medium loss and medium accuracy
of capacitance stability. Wrapping thin layer of aluminum with the layers of tissue paper makes it
and to remove the moisture from paper, thin layer of wax is used on it. In the matellised paper
capacitor, metal film is used in place of aluminum for electrodes. The value of paper capacitor is
generally in between 0.001 microfarad to 0.2 microfarad. Their voltage capacity is maximum up to
100 V. now- a- days; polyester plastic film is used on the tissue paper in the paper capacitors.

2.10.3 CERAMIC CAPACITORS


Such capacitors, which have ceramic material as a dielectric, are known as ceramic capacitors. The
functions of these capacitors are decided according to the electrical characteristics of the used
ceramic material. The size of the ceramic capacitors is very small as compared to the other
capacitors due to their high dielectric constant. Ceramic material is a very good insulator and high
dielectric constant can be received from it by mixing various types of silicates in it.

18

Figure 8: CERAMIC CAPACITORS

2.11 TRANSISTORS

19

Figure 9: TYPES OF TRANSISTORS

2.11.1 Assorted discrete transistors


A transistor is a semiconductor device, commonly used as an amplifier. The transistor is the
fundamental building block of the circuitry that governs the operation of computers, cellular phones,
and all other modern electronics. Because of its fast response and accuracy, the transistor may be
used in a wide variety of digital and analog functions, including amplification, switching, voltage
regulation, signal modulation, and oscillators. Transistors may be packaged individually or as part of
an integrated circuit chip, which may hold thousands of transistors in a very small area.

2.11.2 Introduction
Modern transistors are divided into two main categories: bipolar junction transistors (BJTs) and field
effect transistors (FETs). Application of current in BJTs and voltage in FETs between the input and
common terminals increases the conductivity between the common and output terminals, thereby
controlling current flow between them. The transistor characteristics depend on their type. In analog
circuits, transistors are used in amplifiers, (direct current amplifiers, audio amplifiers, radio
frequency amplifiers), and linear regulated power supplies. Transistors are also used in digital
circuits where they function as electronic switches, but rarely as discrete devices, almost always
being incorporated in monolithic Integrated Circuits. Digital circuits include logic gates, random
access memory (RAM), microprocessors, and digital signal processors (DSPs).
20

2.12 Types
2.12.1 Transistors are categorized by:

Semiconductor material: germanium, silicon, gallium arsenide, silicon carbide

Structure: BJT, JFET, IGFET (MOSFET), IGBT, "other types"

Polarity: NPN, PNP (BJTs); N-channel, P-channel (FETs)

Maximum power rating: low, medium, high

Maximum operating frequency: low, medium, high, radio frequency (RF), microwave (The
maximum effective frequency of a transistor is denoted by the term ft., an abbreviation for
"frequency of transition".

Application: switch, general purpose, audio, high voltage, super-beta, matched pair

Physical packaging: through hole metal, through hole plastic, surface mount, ball grid array,
power modules.
There are mainly two types of transistor (i) NPN (ii) PNP

2.12.2 NPN Transistors


When a positive voltage is applied to the base, the transistor begins to conduct by allowing current to
flow through the collector to emitter circuit. The relatively small current flowing through the base
circuit causes a much greater current to pass through the emitter / collector circuit. The phenomenon
is called current gain and it is measure in beta.

2.12.3 PNP Transistor


It also does exactly same thing as above except that it has a negative voltage on its collector and a
positive voltage on its emitter.
21

Both types are shown in figure, with their symbols for representation. The centre section is called the
base, one of the outside sections-the emitter and the other outside section-the collector. The direction
of the arrowhead gives the direction of the conventional current with the forward bias on the emitter.
The conventional flow is opposite in direction to the electron flow.

2.13 TRANSISTOR AMPLIFIER

Figure 10: TRANSISTOR AMPLIFIER

A switching amplifier or class-D amplifier is a power amplifier where the active devices (especially
in the output stage) are operated in on/off mode (i.e., as switches). The term "Class-D" is often
assumed to mean "digital" amplifier. The quantization of the output signal implies sampling like that
done in A/D conversion, but such amplifiers' input and output signals are still analog. Output stages
such as those used in pulse generators are examples of class D amplifiers. However, the term mostly
applies to devices intended to reproduce signals with a bandwidth well below the switching
frequency. These amplifiers use pulse width modulation (PWM), pulse density modulation
(sometimes referred to as pulse frequency modulation) or more advanced forms of modulation such
as Sigma delta modulation (see for example Analog Devices AD1990 Class-D audio power
22

amplifier). The input signal is converted to a sequence of pulses whose average value is directly
proportional to the amplitude of the signal at that time.

2.14 OSCILLATOR
Oscillators may be classified by name, such as Armstrong, Hartley, Colpitts, or by the manner in
which dc power is applied. An oscillator, in which dc power is supplied to the transistor through the
tank circuit, or a portion of the tank circuit, is said to be SERIES FED. An oscillator, which receives
its dc power for the transistor through a path separate and parallel to the tank circuit, is said to be
PARALLEL FED OR SHUNT FED. The construction depends on the characteristics of the oscillator
circuit the designer is interested in.

2.14.1 CRYSTAL OSCILLATOR


A crystal oscillator is an electronic circuit that uses the mechanical resonance of a vibrating crystal
of piezoelectric material to create an electrical signal with a very precise frequency.

Figure 11: CRYSTAL OSCILLATOR


A crystal is a solid in which the constituent atoms, molecules, or ions are packed in a regularly
ordered, repeating pattern extending in all three spatial dimensions. Almost any object made of an
elastic material could be used like a crystal, with appropriate transducers, since all objects have
natural resonant frequencies of vibration. For example, steel is very elastic and has a high speed of
sound. It was often used in mechanical filters before quartz. The resonant frequency depends on size,
23

shape, elasticity, and the speed of sound in the material. High-frequency crystals are typically cut in
the shape of a simple, rectangular plate.

2.14.2 Electrical model

2.14.3 Electronic symbol for a piezoelectric crystal resonator

Schematic symbol and equivalent circuit for a quartz crystal in an oscillator


A quartz crystal can be modelled as an electrical network with a low impedance (series) and a high
impedance (parallel) resonance point spaced closely together. Mathematically (using the Laplace
transform) the impedance of this network can be written as:

Or,

24

Where s is the complex frequency (s = j), s is the series resonant frequency in radians per second
and p is the parallel resonant frequency in radians per second. Adding additional capacitance across
a crystal will cause the parallel resonance to shift downward. This can be used to adjust the
frequency at which a crystal oscillator oscillates. Crystal manufacturers normally cut and trim their
crystals to have a specified resonant frequency with a known 'load' capacitance added to the crystal.
For example, a 6 pF 32 kHz crystal has a parallel resonance frequency of 32,768 Hz when a 6.0 pF
capacitor is placed across the crystal. Without this capacitance, the resonance frequency is higher
than 32,768 Hz.

2.14.4 Resonance modes


A quartz crystal provides both series and parallel resonance. The series resonance is a few kilohertz
lower than the parallel one. Crystals below 30 MHz are generally operated between series and
parallel resonance, which means that the crystal appears as an inductive reactance in operation. Any
additional circuit capacitance will thus pull the frequency down. For a parallel resonance crystal to
operate at its specified frequency, the electronic circuit has to provide a total parallel capacitance as
specified by the crystal manufacturer. Crystals above 30 MHz (up to >200 MHz) are generally
operated at series resonance where the impedance appears at its minimum and equal to the series
resistance.
2.14.5 Temperature effects
A crystal's frequency characteristic depends on the shape or 'cut' of the crystal. A tuning fork crystal
is usually cut such that its frequency over temperature is a parabolic curve centered around 25 C.
This means that a tuning fork crystal oscillator will resonate close to its target frequency at room
temperature, but will slow down when the temperature either increases or decreases from room
temperature. A common parabolic coefficient for a 32kHz tuning fork crystal is 0.04 ppm/C.
In a real application, this means that a clock built using a regular 32 kHz tuning fork crystal will
keep good time at room temperature, lose 2 minutes per year at 10 degrees Celsius above (or below)
room temperature and lose 8 minutes per year at 20 degrees Celsius above (or below) room
temperature due to the quartz crystal.
25

2.15 LED

Figure 12: Blue, green and red LEDs.


A light-emitting diode (LED) is a semiconductor device that emits incoherent narrow-spectrum light
when electrically biased in the forward direction of the P-n junction. This effect is a form of
electroluminescence. LEDs are small extended sources with extra optics added to the chip, which
emit a complex intensity spatial distribution. The color of the emitted light depends on the
composition and condition of the semiconducting material used, and can be infrared, visible or nearultraviolet.

2.15.1 Symbol of LED

2.15.2 Advantages of using LEDs

LEDs produce more light per watt than do incandescent bulbs; this is useful in battery
powered or energy-saving devices.
26

LEDs can emit light of an intended color without the use of color filters that traditional
lighting methods require. This is more efficient and can lower initial costs.

The solid package of an LED can be designed to focus its light. Incandescent and fluorescent
sources often require an external reflector to collect light and direct it in a usable manner.

When used in applications where dimming is required, LEDs do not change their color tint as
the current passing through them is lowered, unlike incandescent lamps, which turn yellow.

LEDs are ideal for use in applications that are subject to frequent on-off cycling, unlike
fluorescent lamps that burn out more quickly when cycled frequently.

2.15.3 Technology

Figure 13: Structure of LED

2.15.4 Parts of a LED

27

Figure 14: Inner workings of an LED

Figure 15: V-I Graph of LED


2.15.5 Colors and materials
Conventional LEDs are made from a variety of inorganic semiconductor materials, the following
table shows the available colors with wavelength range, voltage drop and material:

28

Color

Wavelength
[nm]

Voltage [V]

Semiconductor Material

> 760

V < 1.9

Gallium arsenide (GaAs)


Aluminium gallium arsenide (AlGaAs)

Red

610 < < 760

1.63 < V <


2.03

Aluminium gallium arsenide (AlGaAs)


Gallium arsenide phosphide (GaAsP)
Aluminium gallium indium phosphide (AlGaInP)
Gallium(III) phosphide (GaP)

Orange

590 < < 610

2.03 < V <


2.10

Gallium arsenide phosphide (GaAsP)


Aluminium gallium indium phosphide (AlGaInP)
Gallium(III) phosphide (GaP)

Yellow

570 < < 590

2.10 < V <


2.18

Gallium arsenide phosphide (GaAsP)


Aluminium gallium indium phosphide (AlGaInP)
Gallium(III) phosphide (GaP)

500 < < 570

2.18 < V <


4.0

Indium gallium nitride (InGaN) / Gallium(III)


nitride (GaN)
Gallium(III) phosphide (GaP)
Aluminium gallium indium phosphide (AlGaInP)
Aluminium gallium phosphide (AlGaP)

Blue

450 < < 500

2.48 < V <


3.7

Zinc selenide (ZnSe)


Indium gallium nitride (InGaN)
Silicon carbide (SiC) as substrate
Silicon (Si) as substrate (under development)

Violet

400 < < 450

2.76 < V <


4.0

Indium gallium nitride (InGaN)

Purple

multiple types

2.48 < V <


3.7

Dual blue/red LEDs,


blue with red phosphor,

Infrared

Green

29

or white with purple plastic

Ultraviolet < 400

White

diamond (C)
Aluminium nitride (AlN)
3.1 < V < 4.4 Aluminium gallium nitride (AlGaN)
Aluminium gallium indium nitride (AlGaInN)
(down to 210 nm[27])

Broad spectrum V = 3.5

Blue/UV diode with yellow phosphor

2.15.6 Ultraviolet and blue LEDs

Figure 16: Ultraviolet and blue LEDs

Blue LEDs
Blue LEDs are based on the wide band gap semiconductors GaN (gallium nitride) and InGaN
(indium gallium nitride). They can be added to existing red and green LEDs to produce the
impression of white light, though white LEDs today rarely use this principle. The first blue LEDs
were made in 1971 by Jacques Pankove (inventor of the gallium nitride LED) at RCA Laboratories.]
However, these devices had too little light output to be of much practical use. In the late 1980s, key
breakthroughs in GaN epitaxial growth and p-type doping by Isamu Akasaki and Hiroshi Amano
(Nagoya, Japan) ushered in the modern era of GaN-based optoelectronic devices. Building upon this
30

foundation, in 1993 high brightness blue LEDs were demonstrated through the work of Shuji
Nakamura at Nichia Corporation. Wavelengths down to 210 nm were obtained in laboratories using
aluminium nitride.While not an LED as such, an ordinary NPN bipolar transistor will emit violet
light if its emitter-base junction is subjected to non-destructive reverse breakdown. This is easy to
demonstrate by filing the top off a metal-can transistor (BC107, 2N2222 or similar) and biasing it
well above emitter-base breakdown ( 20 V) via a current-limiting resistor.

2.15.7 Disadvantages of using LEDs

LEDs are currently more expensive, price per lumen, on an initial capital cost basis, than
more conventional lighting technologies. The additional expense partially stems from the
relatively low lumen output and the drive circuitry and power supplies needed.

LEDs typically cast light in one direction at a narrow angle compared to an incandescent or
fluorescent lamp of the same lumen level.

The spectrum of some white LEDs differs significantly from a black-body radiator, such as
the sun or an incandescent light.

At present the spectrum of emitted light from white LEDs falls outside the natural range
provided by incandescent bulbs, making them less suited for domestic lighting.

2.16.1 Diodes

Figure 17: Types of diodes

31

Figure 18: Close-up, showing germanium crystal


In electronics, a diode is a component that restricts the direction of flow of charge carriers.
Essentially, it allows an electric current to flow in one direction, but blocks it in the opposite
direction. Thus, the diode can be thought of as an electronic version of a check valve. Circuits that
require current flow in only one direction will typically include one or more diodes in the circuit
design. Early diodes included "cat's whisker" crystals and vacuum tube devices (called thermionic
valves in British English Dialect). Today the most common diodes are made from semiconductor
materials such as silicon or germanium.Thermionic and solid state diodes developed in parallel. The
principle of operation of thermionic diodes was discovered by Frederick Guthrie in 1873. The
principle of operation of crystal diodes was discovered in 1874 by the German scientist, Karl
Ferdinand Braun.

2.16.2 Semiconductor diodes

Diode schematic symbol. Conventional current can flow from the anode to the cathode, but not the
other way around.Most modern diodes are based on semiconductor p-n junctions. In a p-n diode,
conventional current flows from the p-type side (the anode) to the n-type side (the cathode), but not
in the opposite direction. Another type of semiconductor diode, the Schottky diode, is formed from
the contact between a metal and a semiconductor rather than by a p-n junction. A semiconductor
diode's current-voltage, or I-V, characteristic curve is described to the behavior of the so-called
depletion layer or depletion zone which exists at the p-n junction between the differing
semiconductors. When a p-n junction is first created, conduction band (mobile) electrons from the
N-doped region diffuse into the P-doped region where there is a large population of holes (places for
electrons in which no electron is present) with which the electrons "recombine". When a mobile
32

electron recombines with a hole, the hole vanishes and the electron is no longer mobile. Thus, two
charge carriers have vanished. The region around the p-n junction becomes depleted of charge
carriers and thus behaves as an insulator.

Figure 19: I-V characteristics of a P-N junction diode


A diode's I-V characteristic can be approximated by two regions of operation. Below a certain
difference in potential between the two leads, the depletion layer has significant width, and the diode
can be thought of as an open (non-conductive) circuit. As the potential difference is increased, at
some stage the diode will become conductive and allow charges to flow, at which point it can be
thought of as a connection with zero (or at least very low) resistance. In a normal silicon diode at
rated currents, the voltage drop across a conducting diode is approximately 0.6 to 0.7 volts.

33

2.16.3 There are several types of semiconductor junction diodes

2.16.4 Normal (p-n) diodes


Which operate as described above. Usually made of doped silicon or, more rarely, Germanium.
Before the development of modern silicon power rectifier diodes, cuprous oxide and later selenium
was used; its low efficiency gave it a much higher forward voltage drop (typically 1.41.7 V per
"cell," with multiple cells stacked to increase the peak inverse voltage rating in high voltage
rectifiers), and required a large heat sink (often an extension of the diode's metal substrate), much
larger than a silicon diode of the same current ratings would require.

2.16.5 Schottky diodes


Schottky diodes are constructed from a metal to semiconductor contact. They have a lower forward
voltage drop than a standard PN junction diode. Their forward voltage drop at forward currents of
about 1 mA is in the range 0.15 V to 0.45 V, which makes them useful in voltage clamping
applications and prevention of transistor saturation. They can also be used as low loss rectifiers
although their reverse leakage current is generally much higher than non Schottky rectifiers.
Schottky diodes are majority carrier devices

2.16.6 'Gold doped' diodes


As a dopant, gold (or platinum) acts as recombination centers, which help a fast recombination of
minority carriers. This allows the diode to operate at signal frequencies, at the expense of a higher
forward voltage drop. A typical example is the 1N914.

2.16.7 Snap-off or Step recovery diodes


The term 'step recovery' relates to the form of the reverse recovery characteristic of these devices.
After a forward current has been passing in an SRD and the current is interrupted or reversed, the
34

reverse conduction will cease very abruptly (as in a step waveform). SRDs can therefore provide
very fast voltage transitions by the very sudden disappearance of the charge carriers.

2.16.8 Point-contact diodes


These work the same as the junction semiconductor diodes described above, but its construction is
simpler. A block of n-type semiconductor is built, and a conducting sharp-point contact made with
some group-3 metal is placed in contact with the semiconductor. Some metal migrates into the
semiconductor to make a small region of p-type semiconductor near the contact. The long-popular
1N34 germanium version is still used in radio receivers as a detector and occasionally in specialized
analog electronics.

2.16.9 Cat's whisker or crystal diodes


These are a type of point contact diode. The cat's whisker diode consists of a thin or sharpened metal
wire pressed against a semiconducting crystal, typically galena or a lump of coal. The wire forms the
anode and the crystal forms the cathode.

2.16.10 PIN diodes


A PIN diode has a central un-doped, or intrinsic, layer, forming a p-type / intrinsic / n-type
structure.They are used as radio frequency switches, similar to varactor diodes but with a more
sudden change in capacitance. They are also used as large volume ionizing radiation detectors and as
photodetectors. PIN diodes are also used in power electronics, as their central layer can withstand
high voltages. Furthermore, the PIN structure can be found in many power semiconductor devices,
such as IGBTs, power MOSFETs, and thyristors.

2.16.11 Varicap or varactor diodes


These are used as voltage-controlled capacitors. These are important in PLL (phase-locked loop) and
FLL (frequency-locked loop) circuits, allowing tuning circuits, such as those in television receivers,
35

to lock quickly, replacing older designs that took a long time to warm up and lock. A PLL is faster
than a FLL, but prone to integer harmonic locking (if one attempts to lock to a broadband signal).
They also enabled tunable oscillators in early discrete tuning of radios, where a cheap and stable, but
fixed-frequency

2.16.12 Zener diodes


Diodes that can be made to conduct backwards. This effect, called Zener breakdown, occurs at a
precisely defined voltage, allowing the diode to be used as a precision voltage reference. In practical
voltage reference circuits Zener and switching diodes are connected in series and opposite directions
to balance the temperature coefficient to near zero.
2.16.13 Avalanche diodes
Diodes that conduct in the reverse direction when the reverse bias voltage exceeds the breakdown
voltage. These are electrically very similar to Zener diodes, and are often mistakenly called Zener
diodes, but break down by a different mechanism, the avalanche effect. This occurs when the reverse
electric field across the p-n junction causes a wave of ionization, reminiscent of an avalanche,
leading to a large current..

2.16.14 Switching diodes


Switching diodes, sometimes also called small signal diodes are a diode applied voltage it has high
resistance similar to an open switch, while above that voltage it suddenly changes to the low
resistance of a closed switch.

2.16.15 Photodiodes
Semiconductors are subject to optical charge carrier generation and therefore most are packaged in
light blocking material. If they are packaged in materials that allow light to pass, their
photosensitivity can be utilized. Photodiodes can be used as solar cells, and in photometry.
36

2.16.16 Light-emitting diodes (LEDs)


In a diode formed from a direct band-gap semiconductor, such as gallium arsenide, carriers that cross
the junction emit photons when they recombine with the majority carrier on the other side.
Depending on the material, wavelengths (or colors) from the infrared to the near ultraviolet may be
produced. The forward potential of these diodes depends on the wavelength of the emitted photons:
1.2 V corresponds to red, 2.4 to violet. The first LEDs were red and yellow, and higher-frequency
diodes have been developed over time.

2.16.17 Laser diodes


When an LED-like structure is contained in a resonant cavity formed by polishing the parallel end
faces, a laser can be formed. Laser diodes are commonly used in optical storage devices and for high
speed optical communication.

2.16.18 Esaki or tunnel diodes


These have a region of operation showing negative resistance caused by quantum tunneling, thus
allowing amplification of signals and very simple bistable circuits. These diodes are also the type
most resistant to nuclear radiation.

2.16.19 Gunn diodes


These are similar to tunnel diodes in that they are made of materials such as GaAs or InP that exhibit
a region of negative differential resistance. With appropriate biasing, dipole domains form and travel
across the diode, allowing high frequency microwave oscillators to be built.

37

2.17 RELAYS

Figure 20: Automotive style miniature relay


A relay is an electrical switch that opens and closes under the control of another electrical circuit. In
the original form, the switch is operated by an electromagnet to open or close one or many sets of
contacts. It was invented by Joseph Henry in 1835. Because a relay is able to control an output
circuit of higher power than the input circuit, it can be considered, in a broad sense, to be a form of
an electrical amplifier. When a current flows through the coil, the resulting magnetic field attracts an
armature that is mechanically linked to a moving contact. The movement either makes or breaks a
connection with a fixed contact. When the current to the coil is switched off, the armature is returned
by a force approximately half as strong as the magnetic force to its relaxed position. Usually this is a
spring, but gravity is also used commonly in industrial motor starters. Most relays are manufactured
to operate quickly. In a low voltage application, this is to reduce noise. In a high voltage or high
current application, this is to reduce arcing.

2.17.1 Relays are used:

To control a high-voltage circuit with a low-voltage signal, as in some types of modems,

To control a high-current circuit with a low-current signal, as in the starter solenoid of an


automobile,

To isolate the controlling circuit from the controlled circuit when the two are at different
potentials, for example when controlling a mains-powered device from a low-voltage switch.
The latter is often applied to control office lighting as the low voltage wires are easily

38

installed in partitions, which may be often moved as needs change. They may also be
controlled by room occupancy detectors in an effort to conserve energy,

To perform logic functions. For example, the Boolean AND function is realised by
connecting NO relay contacts in series, the OR function by connecting NO contacts in
parallel.

2.18 TRANSFORMER
A transformer is a device that transfers energy from one electrical circuit to another by magnetic
coupling without requiring relative motion between its parts. A transformer comprises two or more
coupled windings, and, in most cases, a magnetic core to concentrate magnetic flux. A voltage
applied to one winding creates a time-varying magnetic flux in the core, which induces a voltage in
the other windings. Varying the relative number of turns in the windings determines the ratio of their
voltages, thus transforming the voltage from one circuit to another.

2.18.1 Coupling by mutual induction

Figure 21: Coupling by mutual induction


An ideal step-down transformer showing magnetic flux in the core
An electromotive force (EMF) is induced across each winding, an effect known as mutual
inductance..The windings in the ideal transformer have no resistance and so the EMFs are equal in
39

magnitude to the measured terminal voltages. In accordance with Faraday's law of induction, they
are proportional to the rate of change of flux:

and
Where:

and
and

are the induced EMFs across primary and secondary windings,


are the numbers of turns in the primary and secondary windings,
and

are the time derivatives of the flux linking the primary and secondary

windings.
All flux produced by the primary winding also links the secondary, and so

, from which

the well-known transformer equation follows:

The ratio of primary to secondary voltage is therefore the same as the ratio of the number of turns
alternatively, that the volts-per-turn is the same in both windings.

2.18.2 Under load


If a load impedance is connected to the secondary winding, creating a secondary circuit, a current
will flow in it. The current forms an MMF over the secondary winding in opposition to that of the
primary winding, so acting to cancel the flux in the core. The now reduced flux decreases the
primary EMF, causing current in the primary circuit to increase to exactly offset the effect of the
secondary MMF, and returning the flux to its former value. In this way, the electrical energy fed into
the primary circuit is delivered to the secondary circuit. The primary and secondary MMFs are equal,
and so:

from which the transformer current relationship emerges:

40

2.18.3 Transformer universal EMF equation


If the flux in the core is sinusoidal, the relationship for either winding between its root mean square
EMF E, and the supply frequency f, number of turns N, core cross-sectional area a and peak
magnetic flux density B is given by the universal EMF equation:

Classifications
Transformers are adapted to numerous engineering applications and may be classified in many ways:

By power level (from fraction of a volt-ampere(VA) to over a thousand MVA),

By application (power supply, impedance matching, circuit isolation),

By frequency range (power, audio, radio frequency(RF))

By voltage class (a few volts to about 750 kilovolts)

By cooling type (air cooled, oil filled, fan cooled, water cooled, etc.)

By purpose (distribution, rectifier, arc furnace, amplifier output, etc.).

However, transformers are components of the systems that perform all these functions.

2.18.4 Energy losses


An ideal transformer would have no losses, and would therefore be 100% efficient. In practice,
energy is dissipated due both to the resistance of the windings known as copper loss or I2R loss, and
to magnetic effects primarily attributable to the core (known as iron loss). Transformers are, in
general, highly efficient: large power transformers (over 50 MVA) may attain efficiency as high as
99.75%. Small transformers, such as a plug-in "power brick" used to power small consumer
electronics, may be less than 85% efficient.
41

2.18.5 Uses of transformers

Electric power transmission over long distances.

Large, specially constructed power transformers are used for electric arc furnaces used in
steelmaking.

Rotating transformers are designed so that one winding turns while the other remains
stationary. A common use was the video head system as used in VHS and Beta video tape
players. These can pass power or radio signals from a stationary mounting to a rotating
mechanism, or radar antenna.

Transformer-like device is used for position measurement. See linear variable differential
transformer.

Some rotary transformers are used to couple signals between two parts which rotate in
relation to each other.

2.19 16 x 2 Alphanumeric LCD Module


This module includes a connector to plug directly into the STK200 and STK300 starter kits. It
features a transflective STN type LCD, which provides excellent viewing angles and high contrast.

Figure 22: 16 x 2 Alphanumeric LCD Module

2.19.1 16 x 2 Alphanumeric LCD Module Features


42

Intelligent, with built-in Hitachi HD44780 compatible LCD controller and RAM providing simple
interfacing 61 x 15.8 mm viewing area 5 x 7 dot matrix format for 2.96 x 5.56 mm characters, plus
cursor line Can display 224 different symbols Low power consumption (1 mA Typical) Powerful
command set and user-produced characters TTL and CMOS compatible Connector for standard 0.1pitch pin headersumeric LCD Module

2.19.2 Block Diagram


43

2.19.3 Keypad
A keypad is a set of buttons arranged in a block which usually bear digits and other symbols but not
a complete set of alphabetical letters. If it mostly contains numbers then it can also be called a
numeric keypad. Keypads are found on many alphanumeric keyboards and on other devices such as
calculators, combination locks and telephones which require largely numeric input.

2.19.4 A telephone keypad


A computer keyboard usually contains a small numeric keypad with a calculator-style arrangement
of buttons duplicating the numeric and arithmetic keys on the main keyboard to allow efficient entry
of numerical data. This number pad (commonly abbreviated to "numpad") is usually positioned on
the right side of the keyboard because most people are right-handed. Many laptop computers have
special function keys which turn part of the alphabetical keyboard into a numerical keypad as there
is insufficient space to allow a separate keypad to be built into the laptop's chassis. Separate plug-in
keypads can be purchased.

2.19.5 A calculator
By convention, the keys on calculator-style keypads are arranged such that 123 is on the bottom row.
In contrast, a telephone keypad has the 123 keys at the top. It also has buttons labeled * (star) and #
(octothorpe, number sign, "pound" or "hash") either side of the zero. Most of the keys also bear
letters which have had several auxiliary uses, such as remembering area codes or whole telephone
numbers.
44

Keypads are a part of mobile phones that are replaceable and sit on a sensor board. Some multimedia
mobile phones have a small joystick which has a cap to match the keypad.

2.19.6 EEPROM
EEPROM (electrically erasable programmable read-only memory) is user-modifiable read-only
memory (ROM) that can be erased and reprogrammed (written to) repeatedly through the application
of higher than normal electrical voltage. Unlike EPROM chips, EEPROMs do not need to be
removed from the computer to be modified. However, an EEPROM chip has to be erased and
reprogrammed in its entirety, not selectively. It also has a limited life - that is, the number of times it
can be reprogrammed is limited to tens or hundreds of thousands of times. In an EEPROM that is
frequently reprogrammed while the computer is in use, the life of the EEPROM can be an important
design consideration.

2.19.7 Functions of EEPROM


There are different types of electrical interfaces to EEPROM devices. Main categories of these
interface types are:
Serial bus
Parallel bus
How the device is operated depends on the electrical interface.

2.19.8 Serial bus devices


Most common serial interface types are SPI, IC, Micro wire, UNI/O, and 1-Wire. These interfaces
require between 1 and 4 control signals for operation, resulting in a memory device in an 8 pin (or
less) package. The serial EEPROM typically operates in three phases: OP-Code Phase, Address
Phase and Data Phase. The OP-Code is usually the first 8-bits input to the serial input pin of the
EEPROM device (or with most IC devices, is implicit); followed by 8 to 24 bits of addressing
depending on the depth of the device, then data to be read or written. Each EEPROM device

45

typically has its own set of OP-Code Instructions to map to different functions. Some of the common
operations on SPI EEPROM devices are:
Write Enable (WREN)
Write Disable (WRDI)
Read Status Register (RDSR)
Write Status Register (WRSR)
Read Data (READ)
Write Data (WRITE)
Other operations supported by some EEPROM devices are:
Program
Sector Erase
Chip Erase commands

2.19.9 Parallel bus devices


Parallel EEPROM devices typically have an 8-bit data bus and an address bus wide enough to cover
the complete memory. Most devices have chip select and write protect pins. Some microcontrollers
also have integrated parallel EEPROM. Operation of a parallel EEPROM is simple and fast when
compared to serial EEPROM, but these devices are larger due to the higher pin count (28 pins or
more) and have been decreasing in popularity in favor of serial EEPROM or Flash.

2.19.10 Flash Memory


Flash memory is a later form of EEPROM. In the industry, there is a convention to reserve the term
EEPROM to byte-wise erasable memories compared to block-wise erasable flash memories.
EEPROM takes more die area than flash memory for the same capacity because each cell usually
needs both a read, write and erase transistor, while in flash memory the erase circuits are shared by
large blocks of cells.
46

2.20 MICROCONTROLLER FEATURES:


2.20.1 Fabrication techniques
2.20.1.1 CMOS - Complementary Metal Oxide Semiconductor
This is the name of a common technique used to fabricate most (if not all) of the newer
microcontrollers. CMOS requires much less power than older fabrication techniques, which permits
battery operation. CMOS chips also can be fully or near fully static, which means that the clock can
be slowed up (or even stopped) putting the chip in sleep mode. CMOS has a much higher immunity
to noise (power fluctuations or spikes) than the older fabrication techniques.

2.20.1.2 PMP - Post Metal Programming (National Semiconductor)


PMP is a high-energy implantation process that allows microcontroller ROM to be programmed
AFTER final metallization. Usually ROM is implemented in the second layer die, with nine or ten
other layers then added on top. That means the ROM pattern must be specified early in the
production process , and complete prototypes devices won't be available typically for six to
eight weeks. With PMP, however, dies can be fully manufactured through metallization

and

electrical tests (only the passivation layer need to be added), and held in inventory. This means
that ROM can be

programmed

late in

production cycle, making prototypes available in only

two weeks.

2.20.2 Architectural features


2.20.2.1 Von-Neumann Architecture
Microcontrollers based on the Von-Neumann architecture have single "data" bus that is
fetch

both

used to

instructions and data. Program instructions and data are stored in a common main

memory. When such a controller addresses main memory, it first fetches an instruction, and then

47

it fetches the data to support the

instruction. The

two separate

fetches

slows

up

the

controller's operation.

2.20.2.2 Harvard Architecture


Microcontrollers based on the Harvard Architecture have span data bus and an instruction bus. This
allows execution to occur in parallel. As an instruction
instruction is executing

is being "pre-fetched" the current

on the data bus. Once the current instruction is complete, the next

instruction is ready to go. This pre-fetch theoretically allows for much faster execution than VonNeumann architecture, but there is some added silicon complexity.

2.20.2.3 CISC
Almost all of today's microcontrollers are based on the CISC (Complex Instruction Set Computer)
concept. The typical CISC microcontroller has well over 80 instructions, many of them very
powerful and very specialized for specific control tasks. It is quite common for the instructions to all
behave quite differently. Some might only operate on certain address spaces or registers and others
might only recognize certain addressing modes. The advantages of the CISC architecture are that
many of the instructions are macro-like, allowing the programmer to use one instruction in place of
many simpler instructions.

2.20.2.4 RISC
The industry

trend for

microprocessor design is for Reduced Instruction Set Computers (RISC)

designs. This is beginning to spill over into the microcontroller market. By implementing fewer
instructions, the chip designed is able to dedicate some of the precious

silicon real-estate for

performance enhancing features The benefits of RISC design simplicity are a smaller chip, smaller
pin count, and very low power consumption.

48

2.20.2.5 SISC
Actually a microcontroller is by definition a Reduced Instruction Set
opinion).

It could really be called a Specific Instruction

Computer (at least in my

Set Computer (SISC). Microcontrollers

now come with a mind boggling array of features that aid the control engineer - watchdog timers,
sleep/wakeup modes, power management, powerful I/O channels, and so on. By keeping
instruction

set specific (and reduced),

and thus saving

the

valuable real estate, more and more of

these features can be added, while maintaining the economy of the microcontroller

2.21 Advanced Memory options


EEPROM - Electrically Erasable Programmable Read Only Memory Many microcontrollers have
limited amounts of EEPROM on the chip.EEPROM seems more suited

( because of its

economics) for small Amounts of memory that hold a limited number of parameters that May
have to be changed from time to time. This type of memory is relatively slow, and the number
of erase/write cycles allowed in its lifetime is limited.

2.21.1 FLASH (EPROM)


Flash provides a better solution than regular EEPROM when there is a requirement for large
amounts of non-volatile program memory. It is both faster and permits more erase/write cycles than
EEPROM.

2.21.2 Battery backed-up static RAM


Battery backed-up static RAM is useful when a large non-volatile program and DATA space is
required. A major advantage of static RAM is that it is much faster than other types of nonvolatile memory so it is well

suited for high performance

limits as to the number of times that it may be Written to so it


that

keep

and manipulate large amounts of data locally.


49

application. There also are no


is perfect for applications

2.21.3 Field programming/reprogramming


Using nonvolatile memory as a place to store program memory allows the device

to be

reprogrammed in the

that it

controls.

One

field without removing the microcontroller

such application is in automotive

engine

from

the

system

controllers. Reprogrammable non-

volatile program memory on the engine's microcontroller allows the engine controller program
to be modified
for such

factors

Reprogramming
up. Almost

during

routine service to incorporate the latest features or to compensate

as engine aging and changing emissions control laws (or even to fix bugs).
of

every

the

microcontroller could become a standard part the routine engine tune-

application could benefit from this type of program memory - If a modem's

hardware supported it, you could remotely upgrade your modem from V fast to V.34, or incorporate
new features such as voice control or a digital answering machine.

2.21.4 OTP - One Time Programmable


An OTP is a PROM (Programmable Read-Only-Memory) device. Once your program is written
in to the device with a standard EPROM Programmer, it can not be erased or modified. This
is usually used for limited production runs before a ROM mask is done in order to test code.
An OTP (One Time Programmable) part uses standard EPROM, but the Package has no window for
erasing. Once your program is written into the device with a standard EPROM programmer, it
cannot be erased or modified. ( Well, sort of - any bit that is a one can be changed to a zero but a bit that is a zero cannot be changed into a one).As product design cycles get
shorter, it is more important for micro manufacturers to offer OTPs as an option.

2.21.5 Software protection


Either by encryption or fuse protection, the programmed software Is

protected

against

unauthorized snooping (reverse engineering, modifications, piracy, etc.). This is only an option on
OTPs and Windowed devices. On Masked ROM devices, security is not needed - the only way

50

to read your Code would

be to

rip

the microcontroller apart with a scanning Electron

microscope and how many people really have one of Those.

2.21.6 Power Management and Low Voltage Low voltage parts


Since automotive applications have been the driving force behind most

microcontrollers, and 5

Volts is very easy to do in a car, most microcontrollers have only supported 4.5 - 5.5 V operation. In
the recent past, as consumer goods are beginning to drive major Segments of the microcontroller
market, and as consumer goods Become portable and lightweight, the requirement for 3 volt (and
lower) microcontrollers

has

become urgent (3 volts = 2 battery solution /

longer battery life). Most low voltage parts in


were modified

to

operate

at

the market

are simply 5 volt parts that

volts (usually at a performance loss).Some micros being

released now are designed from the ground up operate


which

today

lower voltage =

properly at

3.0 (and lower) voltages,

offer comparable performance of the 5 volt devices.

2.21.7 Brownout Protection


Brownout protection is usually an on-board protection circuit that resets the device when

the

operating voltage (Vcc) is lower than the brownout voltage. The device is held in reset and will
remain in reset when Vcc stays below the Brownout voltage. The device will

resume execution

(from reset) after Vcc has risen above the brownout Voltage.

2.21.8 Idle/Halt/Wakeup
The device can be placed into IDLE/HALT mode by software control. In both

Halt and Idle

conditions the state of the microcontroller remains. RAM is not cleared and any outputs are not
changed. The terms idle and halt often have different definitions, depending on the manufacturer.
What some call idle, others may call halt, and vice versa. It can be confusing, so check the data
sheet for the device in question to be sure.

51

2.21.9 Multi-Input Wakeup (National Semiconductor)

The Multi-Input Wake up (MIWU) feature is used to return (wakeup) the microcontroller from either
HALT or IDLE modes. Alternately MIWU may also be used to generate up to 8 edge selectible
external interrupts. The user can select whether the

trigger condition on the pins is going to be

either a positive edge (low to high) or a negative edge (high to low).

2.22 I/O UART

A UART (Universal Asynchronous Receiver Transmitter) is a serial port adapter for asynchronous serial
communications.

2.22.1 USART

A USART (Universal Synchronous/Asynchronous Receiver Transmitter) is a serial port adapter for


either asynchronous or synchronous serial communications. Communications using a USART are
typically much faster (as much as 16 times) than with a UART.

2.22.2 Synchronous serial port

A synchronous serial port doesn't require start/stop bits and can Operate at much higher clock rates than
an

asynchronous serial port. Used to communicate with high speed devices such as memory servers,

display drivers, additional A/D ports, etc. Can also be used to implement a simple microcontroller
network.

52

2.22.3 I2C bus - Inter-Integrated Circuit bus (Philips)

The I2C bus is a simple 2 wire serial interface developed by Philips. It was developed for 8 bit
applications and is widely used in consumer electronics, automotive and industrial applications. In
addition to microcontrollers, several peripherals also exist that support the I2C bus. The I2C bus is a two
line, multi-master, multi-slave network Interface with collision detection. Up to 128 devices can exist O
the network and they can be spread out over 10 meters. Each node (microcontroller or peripheral) may
initiate a message, and then transmit or receive data.

2.22.4 Analog to Digital Conversion (A/D)

Converts an external analog signal (typically relative to voltage) and converts it to a digital
representation. Microcontrollers that have this

feature

can

be

used for

instrumentation,

environmental data logging, or any application that lives in an analog world successive approximation
A/D converters. This is the most common type of A/D and is used in the majority of microcontrollers.
In this technique, the converter figures out each bit at a time (most significant first) and finds if the next
step is higher or lower.

2.22.5 D/A (Digital to Analog) Converter

This feature takes a

Digital

number and converts it to a analog output. The number 50 would be

changed to the analog output of (50/256 * 5Volts) = .9765625V on an 8-bit / 5 Volt system.

2.22.6 Pulse width modulator

Often used as a digital-to-analog conversion technique. A pulse train is generated and regulated with
a low-pass filter to generate a voltage proportional to the duty cycle.
53

2.22.7 Pulse accumulator

A pulse accumulator is an event counter. Each pulse increments the pulse accumulator register,
recording the number of times this event has occurred.

2.22.8 Input Capture


Input Capture can measure external frequencies or time intervals by copying the value from a free
running timer into a register when an external event occurs.

2.22.9 Comparator
One or more standard comparators can sometimes be placed on a microcontroller die. These
comparators operate much like standard comparators however the input and output signals are
available on the microcontroller bus.

2.22.10 Mixed (Analog-Digital) Signal


We live in an analog world where the information we see, hear process, and exchange with
each other, and with our mechanical and electronic

systems, is always an analog

quantity

pressure temperature, voltage , current, air and water flow are always analog entities. They
can be

digitized

for

more efficient sorting,

the input and output - is almost always

storage

and transmittal, but the interface -

analog. Thus the essence of analog electronics lies in

sensing continuously varying information, shaping and converting it for the efficiency of digital
processing and transmission.

2.23 Interrupts
2.23.1 Polling
Polling is not really a "feature"-it's what you have to do if your

microcontroller of choice does not

have interrupts. Polling is a software technique whereby the controller continually asks a peripheral
54

if it needs servicing. The peripheral sets a flag when it has data ready for transferring to the
controller, which the controller notices on its next poll.

2.22.2 Interrupts
Rather

than

have the

(timers

/ UARTS

microcontroller
A/Ds /

continually

polling that is,

asking

peripherals

external components) whether they have any data available (and

finding most of the time they do not), a more efficient method is to have the peripherals tell
the

controller

normal
of an

when they have data

function, only responding


interrupt,

peripheral,

then

ready. The controller

to

the controller

peripherals

can

be

carrying

out

its

when there is data to respond to. On receipt

suspends its current operation, identifies the interrupting

jumps (vectors) to the appropriate interrupt service routine. The

interrupts, compared with polling, is the speed of

response

advantage of

to external events and reduced

software overhead (of continually asking peripherals if they have any data ready).

2.22.3 Maskable Interrupts


A maskable

interrupt is one that you can disable or enable (masking

the interrupt), whereas non-maskable


interrupts

is

that

you

interrupts

it out means

you can't disable. The

disabling

benefit of maskable

can turn off a particular interrupts (for example a UART) during some

time critical task. Then, those particular interrupts will be ignored thus allowing the microcontroller
to deal with the task at hand. Most microcontrollers (as well as most microprocessors) have some
type of Global Interrupt Enable (GIE).

2.22.4 Vectored Interrupts


Simple (non-vectored) interrupts is one of the simplest interrupt schemes there is (Simple = less
silicon = more software = slower). Whenever there is an interrupt, the program counter (PC)
branches to one

specific address .At this address, the

interrupts (one at a time)


be very

system designer needs to check

the

to see which peripheral has caused the interrupt to occur. This can

slow - and the time

between the interrupt happening and the time the service routine
55

is entered, depends on how the system designer sets up their ranking In ROM location 01F8 01F9 (2bytes x 8 bits = 16bit address) the system designer enters the ROM location of where they
want the service routine (of the Timer T0 underflow) to be. And so on for the rest of the addresses.

2.22.5 Interrupt arbitration and priority


Interrupt

arbitration

and

priority - These are two of the most misused words when it comes to

microcontrollers (microprocessors too for that matter)


the difference

between

them.

Priority

is

and
not

it's generally because no one knows


Arbitration. Arbitration

is

not

Priority. Lets see if we can sort out the differences. Arbitration - If you look at the above chart of
the COP888CG, you May
They do

have rank, but they are not prioritized. What happens is that (in an arbitration scheme)

when an interrupt occurs, the


means

think the interrupts are prioritized because they have some ranking.
GIE

(Global Interrupt Enable)

is

cleared. This effectively

that all future interrupts will be delayed until the GIE is set. The GIE becomes set only if

the system designer sets it in service routines, or on a RETI (Return from Interrupt).

2.22.6 Special microcontroller features Watchdog timer


A watchdog timer provides a means of graceful recovery from a system problem. This could be a
program that goes into an endless loop, or a hardware problem

that

prevents

the program from

operating correctly. If the program fails to reset the watchdog at some predetermined

interval, a

hardware reset will be initiated. The bug may still exist, but at least the system has a way recover.
This is especially useful for unattended systems.

2.22.7 Digital Signal Processors (DSP)


Microcontrollers reach to and control events - DSPs execute Repetitive math-intensive algorithms.
Today many embedded applications require both types of processors, and semiconductor
manufacturers have responded by introducing microcontrollers with on-chip DSP capability and
DSPs with on-chip microcontrollers. The most basic
56

thing a

DSP will do is a MACC (Multiply

and Accumulate). The number

of data bits a DSP can multiply and Accumulate will determine

the dynamic range (and therefore the application).

2.22.8 Clock Monitor


A clock monitor can shut the microcontroller down (by holding the microcontroller in reset) if the
input clock is too slow. This can usually be turned on or off under software control.

2.22.9 Resident program loader


Loads a program by Initializing program/data memory from either serial or parallel port.
Convenient for prototyping or trying out new features, eliminates the erase/burn/program cycle
typical with EPROMs, and allows convenient updating of system even from an offsite location.

2.23 Monitor
A monitor is a program installed in the microcontroller which provides
debug capabilities. Typical capabilities of a

basic

microcontroller monitor include: loading object files

in system RAM, executing programs, examining and modifying memory


disassembly,

development and

and registers, code

setting breakpoints, and single-stepping through code. Some simple monitors only

allow basic functions such as memory inspection, and the more sophisticated

monitors are capable

of a full range of debug functions.

2.24 MIL transducer


An MIL transducer is a sophisticated and expensive device that detects the presence of your motherin-law. Sensitivity settings are possible for a full range of stimuli such as: snarling, stomping, nasty
faces, and others.Techno-Wimp (address withheld upon request), the sole manufacture of the MIL
transducer has recently announced a major new version which is sensitive enough to detect less-

57

tangible stimuli. This breakthrough product is dubbed the MIL-WOMF ("Whoa, outta my face")
transducer.

2.25 PCB DESIGN


The connections on the PCB should be identical to the circuit diagram, but while the circuit diagram
is arranged to be readable, the PCB layout is arranged to be functional, so there is rarely any visible
correlation between the circuit and the layout. PCB layout can be performed manually (using CAD)
or in combination with an Autorouter. The best results are usually still achieved using atleast some
manual routing - simply because the design engineer has a far better judgement of how to arrange
circuitry. Surprisingly, many autorouted boards are often completely illogical in their track routing the program has optimised the connections, and sacrificed any small amount of order that may have
been put in place by manual routing. These days most circuit boards are automatically assembled
and tested - but you will still have people working on your circuit boards.

58

Chapter 3
SOFTWARE REQUIREMENT

59

Chapter 3
SOFTWARE REQUIREMENT
3.1 CODE VISION AVR:Code Vision AVR is a C cross compiler, Integrated Development Environment and Automatic
Program generator designed for Atmel AVR family of microcontrollers. The program is designed to
run under the Widows 98,200, XP and Vista 32 bit operating system. The C cross compiler
implements all the elements of the ANSI C language, as allowed by the AVR architecture with some
features added to take advantage of specificity of the AVR architecture and the embedded system
needs. The combined COFF file can be C source level debugged with variable watching using the
Atmel AVR studio debugger. The Integrated Development Environment (IDE) has built in AVR chip
in system programmer software that enables the automatically transfer of the program to the
microcontroller chip after the successful compilation/assembly. The In-system programmer software
is designed to work in conjunction with the Atmel STK500 and other development boards. For
debugging embedded systems, which employee serial communication, the IDE has a built in
terminal.
Besides the standard C libraries, the Code Vision AVR compiler has dedicated libraries for: Alphanumeric LCD modules.
National semiconductor LM75 sensor.
Power management.
Delays.
Gray code conversion.
Code Vision AVR also contains the Code Wizard AVR Automatic program generator, that allows us
to write, in a matter of minutes, all the code needed for implementing the following functions: External memory access setup.
Chip reset source identification.
Input/output port initialization.
External interrupt initialization.
Timers/counters initializations.
Watchdog timer initialization.
Analog comparator initialization.
ADC initialization.
Two wire interface initialization.
60

LCD module initialization.

In Code Vision AVR we write the required coding of our project. The steps involved in this process
are explained below:-

3.2 Working with projects:- The project groups the source file(s) and compiler setting that we
use for a building a particular program.
3.3 1- Creating a New Project: - We can create a new project using the File New menu
command by pressing the specified button on the toolbar. A dialog box appears, in which we must
select File Type Project and press OK button.

Figure 23: Create new file


A dialog will open asking us to confirm if we would like to use the CodeWizardAVR to create the
new project.

61

Figure 24: Creating A New Project

If we select NO then the Create New Project dialog window will open. We must specify the new
Project file name and its location.

The Project file will have the .prj extension.We can

configure the Project by using the

Project|Configure menu command or by pressing the

toolbar button.

2-Opening an Existing Project:- We can open an existing project file using the File| Open
menu command. An Open dialog window appears.

62

Chapter 4
MICROCONTROLLER AT mega 16

63

Chapter 4
MICROCONTROLLER AT mega 16

The AVR core combines a rich instruction set with 32 general purpose working registers. All the
32registers are directly connected to the Arithmetic Logic Unit (ALU), allowing two independent
registers to be accessed in one single instruction executed in one clock cycle. The resulting
architecture is more code efficient while achieving throughputs up to ten times faster than
conventional CISC microcontrollers.
The ATmega16A provides the following features: 16K bytes of In-System Programmable Flash
Program memory with Read-While-Write capabilities, 512 bytes EEPROM, 1K byte SRAM, 32
general purpose I/O lines, 32 general purpose working registers, a JTAG interface for Boundary
scan, On-chip Debugging support and programming, three flexible Timer/Counters with compare
modes, Internal and External Interrupts, a serial programmable USART, a byte oriented Two-wire
Serial Interface, an 8-channel, 10-bit ADC with optional differential input stage with programmable
gain (TQFP package only), a programmable Watchdog Timer with Internal Oscillator, an SPI serial
port, and six software selectable power saving modes. The Idle mode stops the CPU while allowing
the USART, Two-wire interface, A/D Converter, SRAM, Timer/Counters, SPI port, and interrupt
system to continue functioning. The Power-down mode saves the register contents but freezes the
Oscillator, disabling all other chip functions until the next External Interrupt or Hardware Reset. In
Power-save mode, the Asynchronous Timer continues to run, allowing the user to maintain a timer
base while the rest of the device is sleeping. The ADC Noise Reduction mode stops the CPU and all
I/O modules except Asynchronous Timer and ADC, to minimize switching noise during ADC
conversions.

4.1 Features
High-performance, Low-power AVR 8-bit Microcontroller
64

Advanced RISC Architecture


131 Powerful Instructions Most Single-clock Cycle Execution
32 x 8 General Purpose Working Registers
Fully Static Operation
Up to 16 MIPS Throughput at 16 MHz
On-chip 2-cycle Multiplier
High Endurance Non-volatile Memory segments
16K Bytes of In-System Self-programmable Flash program memory
512 Bytes EEPROM
1K Byte Internal SRAM
Write/Erase Cycles: 10,000 Flash/100,000 EEPROM
Data retention: 20 years at 85C/100 years at 25C(1)
Optional Boot Code Section with Independent Lock Bits
In-System Programming by On-chip Boot Program
True Read-While-Write Operation
Programming Lock for Software Security
JTAG (IEEE std. 1149.1 Compliant) Interface
Boundary-scan Capabilities According to the JTAG Standard
Extensive On-chip Debug Support
Programming of Flash, EEPROM, Fuses, and Lock Bits through the JTAG

Interface

Peripheral Features
Two 8-bit Timer/Counters with Separate Prescalers and Compare Modes
One 16-bit Timer/Counter with Separate Prescaler, Compare Mode, and Capture
Mode
Real Time Counter with Separate Oscillator
Four PWM Channels
8-channel, 10-bit ADC
8 Single-ended Channels
7 Differential Channels in TQFP Package Only
2 Differential Channels with Programmable Gain at 1x, 10x, or 200x
Byte-oriented Two-wire Serial Interface
65

Programmable Serial USART


Master/Slave SPI Serial Interface
Programmable Watchdog Timer with Separate On-chip Oscillator
On-chip Analog Comparator
Special Microcontroller Features
Power-on Reset and Programmable Brown-out Detection
Internal Calibrated RC Oscillator
External and Internal Interrupt Sources
Six Sleep Modes: Idle, ADC Noise Reduction, Power-save, Power-down, Standby
and Extended Standby
I/O and Packages
32 Programmable I/O Lines
40-pin PDIP, 44-lead TQFP, and 44-pad QFN/MLF
Operating Voltages
2.7 - 5.5V for ATmega16A
Speed Grades
0 - 16 MHz for ATmega16A
Power Consumption 1 MHz, 3V, and 25C for ATmega16A
Active mode: 0.6 mA
Idle Mode: 0.2 mA

66

4.2 Pin Descriptions

Figure 25: Pin Diagram of ATmega16

VCC
Digital supply voltage.

GND
67

Ground.

Port A (PA7:PA0)
Port A serves as the analog inputs to the A/D Converter. Port A also serves as an 8-bit bi-directional
I/O port, if the A/D Converter is not used. Port pins can provide internal pull-up resistors (selected
for each bit). The Port A output buffers have symmetrical drive characteristics with both high sink
and source capability. When pins PA0 to PA7 are used as inputs and are externally pulled low, they
will source current if the internal pull-up resistors are activated. The Port A pins are tri-stated when a
reset condition becomes active, even if the clock is not running.

Port B (PB7:PB0)
Port B is an 8-bit bi-directional I/O port with internal pull-up resistors (selected for each bit). The
Port B output buffers have symmetrical drive characteristics with both high sink and source
capability. As inputs, Port B pins that are externally pulled low will source current if the pull-up
resistors are activated. The Port B pins are tri-stated when a reset condition becomes active, even if
the clock is not running.

Port C (PC7:PC0)
Port C is an 8-bit bi-directional I/O port with internal pull-up resistors (selected for each bit). The
Port C output buffers have symmetrical drive characteristics with both high sink and source
capability. As inputs, Port C pins that are externally pulled low will source current if the pull-up
resistors are activated. The Port C pins are tri-stated when a reset condition becomes active, even if
the clock is not running. If the JTAG interface is enabled, the pull-up resistors on pins PC5 (TDI).

Port D (PD7:PD0)

68

Port D is an 8-bit bi-directional I/O port with internal pull-up resistors (selected for each bit). The
Port D output buffers have symmetrical drive characteristics with both high sink and source
capability. As inputs, Port D pins that are externally pulled low will source current if the pull-up
resistors are activated. The Port D pins are tri-stated when a reset condition becomes active, even if
the clock is not running. Port D also serves the functions of various special features of the
ATmega16A.

RESET
Reset Input. A low level on this pin for longer than the minimum pulse length will generate a reset,
even if the clock is not running. The minimum pulse length is given in. Shorter pulses are not
guaranteed to generate a reset.

XTAL1
Input to the inverting Oscillator amplifier and input to the internal clock operating circuit.

XTAL2
Output from the inverting Oscillator amplifier.

AVCC
AVCC is the supply voltage pin for Port A and the A/D Converter. It should be externally connected
to VCC, even if the ADC is not used. If the ADC is used, it should be connected to VCC through a
low-pass filter.

AREF
AREF is the analog reference pin for the A/D Converter.
69

Chapter 5
EXPRESS PCB SOFTWARE

70

Chapter 5
EXPRESS PCB SOFTWARE

There are different tools available for making circuit schematic, simulation, circuit layout
etc. Electronic design automation (EDA) is the category of tools for designing and producing
electronic systems ranging from printed circuit boards (PCBs) to integrated circuits. This is
sometimes referred to as ECAD (Electronic Computer-Aided Design) or just CAD.

5.1 Procedure for Making Schematic of Circuit


Step1: Inserting

components Select Component-Component

&Symbol

Manger. Begin

your

schematic by placing the components. Select the parts from the Component and Symbol Manager
Dialog box. Express SCH includes a large library with hundreds of component symbols (ICs,
resistors, capacitors) that we can use to draw our electronic circuits. Check Component and
click Insert to schematic. After doing with all necessary components click done.
Step 2: Position the components. Drag each component to the desired location on the page. The snap
to grid feature makes it easy to neatly align the symbols. If all of the components do not fit on a
single page, add additional sheets. All the sheets of a schematic are linked together and saved in one
file.

71

Figure 26: Select the component process

Figure 27: Arranging the components


Step 3: Inserting Wires Connect all components using the option Place a Wire available in the left
menu. Add each wire by clicking on a components pin, then dragging the wire to the pin it connects
to.
Step 4: Edit Schematic Making changes to a schematic is simple by using standard commands such
as Copy, Cut and Paste. Rearranging the components is easy by dragging them with the mouse.
Wires always stay connected to their pins, even when you move things around. Explore for the other
options available from the left bar menu and menu bar.

72

Figure 28: Rearranging the component


Step 5: Naming the components double clicking on any component opens a dialog box. In
the component ID box give unique name to components such as R1,R2... for resistors, C1,C2... for
capacitors , D1,D2.. for diodes etc. In the Part ID box, give component values.
Step 6: Check for errors Select File-Check schematic for enlist errors. It will pop a box with errors,
if any.

5.2 Procedure for Making Layout of Circuit:Step1: Linking schematic to PCB Select the Component - Component Manager. Begin your layout
by adding the components. Select the parts from the Component Manager dialog box.
Step 2: Position the Components - Drag each component to the desired location on your board. The
Snap to grid feature makes it easy to neatly align the parts.

73

Figure 29: Making Layout

74

Step 3: Link the schematic to the PCB. File - Link schematic to the PCB Add the Traces (Place a
trace). Now add each trace by clicking on the pin of a component and dragging the trace to another
pin. If you link your schematic file to the PCB, then the Express PCB program highlights the
pins that should be wired together in blue by clicking highlight net connections.

75

Chapter 6
PROGRAM

76

Chapter 6
PROGRAM

/*******************************************************
This program was created by the
CodeWizardAVR V3.17 Evaluation
Automatic Program Generator
Copyright 1998-2014 Pavel Haiduc, HP InfoTech s.r.l.
http://www.hpinfotech.com
Project :
Version :
Date
: 3/24/2015
Author :
Company :
Comments:
Chip type
: ATmega16A
Program type
: Application
AVR Core Clock frequency: 8.000000 MHz
Memory model
: Small
External RAM size
: 0
Data Stack size
: 256
*******************************************************/
#include <io.h>
#include <stdlib.h>
#include <delay.h>
// Alphanumeric LCD functions
#include <alcd.h>
// Declare your global variables here
// Voltage Reference: AREF pin
#define ADC_VREF_TYPE ((0<<REFS1) | (0<<REFS0) | (0<<ADLAR))
// Read the AD conversion result
unsigned int read_adc(unsigned char adc_input)
{
ADMUX=adc_input | ADC_VREF_TYPE;
// Delay needed for the stabilization of the ADC input voltage
77

delay_us(10);
// Start the AD conversion
ADCSRA|=(1<<ADSC);
// Wait for the AD conversion to complete
while ((ADCSRA & (1<<ADIF))==0);
ADCSRA|=(1<<ADIF);
return ADCW;
}
void main(void)
{ float a,b,c,d,E;
int X=0;
char ch[10];
// Declare your local variables here
// Input/Output Ports initialization
// Port A initialization
// Function: Bit7=In Bit6=In Bit5=In Bit4=In Bit3=In Bit2=In
Bit1=In Bit0=In
DDRA=(0<<DDA7) | (0<<DDA6) | (0<<DDA5) | (0<<DDA4) | (0<<DDA3) |
(0<<DDA2) | (0<<DDA1) | (0<<DDA0);
// State: Bit7=T Bit6=T Bit5=T Bit4=T Bit3=T Bit2=T Bit1=T Bit0=T
PORTA=(0<<PORTA7) | (0<<PORTA6) | (0<<PORTA5) | (0<<PORTA4) |
(0<<PORTA3) | (0<<PORTA2) | (0<<PORTA1) | (0<<PORTA0);
// Port B initialization
// Function: Bit7=In Bit6=In Bit5=In Bit4=In Bit3=In Bit2=In
Bit1=In Bit0=In
DDRB=(0<<DDB7) | (0<<DDB6) | (0<<DDB5) | (0<<DDB4) | (0<<DDB3) |
(0<<DDB2) | (0<<DDB1) | (0<<DDB0);
// State: Bit7=T Bit6=T Bit5=T Bit4=T Bit3=T Bit2=T Bit1=T Bit0=T
PORTB=(0<<PORTB7) | (0<<PORTB6) | (0<<PORTB5) | (0<<PORTB4) |
(0<<PORTB3) | (0<<PORTB2) | (0<<PORTB1) | (0<<PORTB0);
// Port C initialization
// Function: Bit7=In Bit6=In Bit5=In Bit4=In Bit3=In Bit2=In
Bit1=In Bit0=In
DDRC=(0<<DDC7) | (0<<DDC6) | (0<<DDC5) | (0<<DDC4) | (0<<DDC3) |
(0<<DDC2) | (0<<DDC1) | (0<<DDC0);
// State: Bit7=T Bit6=T Bit5=T Bit4=T Bit3=T Bit2=T Bit1=T Bit0=T
PORTC=(0<<PORTC7) | (0<<PORTC6) | (0<<PORTC5) | (0<<PORTC4) |
(0<<PORTC3) | (0<<PORTC2) | (0<<PORTC1) | (0<<PORTC0);
// Port D initialization
// Function: Bit7=In Bit6=In Bit5=In Bit4=In Bit3=In Bit2=In
Bit1=In Bit0=In

78

DDRD=(0<<DDD7) | (0<<DDD6) | (0<<DDD5) | (0<<DDD4) | (0<<DDD3) |


(0<<DDD2) | (0<<DDD1) | (0<<DDD0);
// State: Bit7=T Bit6=T Bit5=T Bit4=T Bit3=T Bit2=T Bit1=T Bit0=T
PORTD=(0<<PORTD7) | (0<<PORTD6) | (0<<PORTD5) | (0<<PORTD4) |
(0<<PORTD3) | (0<<PORTD2) | (0<<PORTD1) | (0<<PORTD0);
// Timer/Counter 0 initialization
// Clock source: System Clock
// Clock value: Timer 0 Stopped
// Mode: Normal top=0xFF
// OC0 output: Disconnected
TCCR0=(0<<WGM00) | (0<<COM01) | (0<<COM00) | (0<<WGM01) | (0<<CS02)
| (0<<CS01) | (0<<CS00);
TCNT0=0x00;
OCR0=0x00;
// Timer/Counter 1 initialization
// Clock source: System Clock
// Clock value: Timer1 Stopped
// Mode: Normal top=0xFFFF
// OC1A output: Disconnected
// OC1B output: Disconnected
// Noise Canceler: Off
// Input Capture on Falling Edge
// Timer1 Overflow Interrupt: Off
// Input Capture Interrupt: Off
// Compare A Match Interrupt: Off
// Compare B Match Interrupt: Off
TCCR1A=(0<<COM1A1) | (0<<COM1A0) | (0<<COM1B1) | (0<<COM1B0) |
(0<<WGM11) | (0<<WGM10);
TCCR1B=(0<<ICNC1) | (0<<ICES1) | (0<<WGM13) | (0<<WGM12) |
(0<<CS12) | (0<<CS11) | (0<<CS10);
TCNT1H=0x00;
TCNT1L=0x00;
ICR1H=0x00;
ICR1L=0x00;
OCR1AH=0x00;
OCR1AL=0x00;
OCR1BH=0x00;
OCR1BL=0x00;
// Timer/Counter 2 initialization
// Clock source: System Clock
// Clock value: Timer2 Stopped
// Mode: Normal top=0xFF
// OC2 output: Disconnected
ASSR=0<<AS2;
79

TCCR2=(0<<PWM2) | (0<<COM21) | (0<<COM20) | (0<<CTC2) | (0<<CS22) |


(0<<CS21) | (0<<CS20);
TCNT2=0x00;
OCR2=0x00;
// Timer(s)/Counter(s) Interrupt(s) initialization
TIMSK=(0<<OCIE2) | (0<<TOIE2) | (0<<TICIE1) | (0<<OCIE1A) |
(0<<OCIE1B) | (0<<TOIE1) | (0<<OCIE0) | (0<<TOIE0);
// External Interrupt(s) initialization
// INT0: Off
// INT1: Off
// INT2: Off
MCUCR=(0<<ISC11) | (0<<ISC10) | (0<<ISC01) | (0<<ISC00);
MCUCSR=(0<<ISC2);
// USART initialization
// USART disabled
UCSRB=(0<<RXCIE) | (0<<TXCIE) | (0<<UDRIE) | (0<<RXEN) | (0<<TXEN)
| (0<<UCSZ2) | (0<<RXB8) | (0<<TXB8);
// Analog Comparator initialization
// Analog Comparator: Off
// The Analog Comparator's positive input is
// connected to the AIN0 pin
// The Analog Comparator's negative input is
// connected to the AIN1 pin
ACSR=(1<<ACD) | (0<<ACBG) | (0<<ACO) | (0<<ACI) | (0<<ACIE) |
(0<<ACIC) | (0<<ACIS1) | (0<<ACIS0);
// ADC initialization
// ADC Clock frequency: 1000.000 kHz
// ADC Voltage Reference: AREF pin
// ADC Auto Trigger Source: ADC Stopped
ADMUX=ADC_VREF_TYPE;
ADCSRA=(1<<ADEN) | (0<<ADSC) | (0<<ADATE) | (0<<ADIF) | (0<<ADIE) |
(0<<ADPS2) | (1<<ADPS1) | (1<<ADPS0);
SFIOR=(0<<ADTS2) | (0<<ADTS1) | (0<<ADTS0);
// SPI initialization
// SPI disabled
SPCR=(0<<SPIE) | (0<<SPE) | (0<<DORD) | (0<<MSTR) | (0<<CPOL) |
(0<<CPHA) | (0<<SPR1) | (0<<SPR0);
// TWI initialization
// TWI disabled
TWCR=(0<<TWEA) | (0<<TWSTA) | (0<<TWSTO) | (0<<TWEN) | (0<<TWIE);
80

// Alphanumeric LCD initialization


// Connections are specified in the
// Project|Configure|C Compiler|Libraries|Alphanumeric LCD menu:
// RS - PORTB Bit 0
// RD - PORTB Bit 1
// EN - PORTB Bit 2
// D4 - PORTB Bit 4
// D5 - PORTB Bit 5
// D6 - PORTB Bit 6
// D7 - PORTB Bit 7
// Characters/line: 16
lcd_init(16);
lcd_putsf("
BNCET");
delay_ms(300);
lcd_clear();
lcd_putsf("Neonatal intensive care unit");
delay_ms(100);
lcd_clear();
lcd_putsf("BABY INCUBATOR");
delay_ms(200);
lcd_clear();
lcd_putsf("PATIENT MONITORING SYSTEM");
delay_ms(100);
lcd_clear();
lcd_putsf("MADE BY:");
delay_ms(100);
lcd_clear();
lcd_putsf("RADAA GROUP"); delay_ms(100);
lcd_clear();
DDRD.0=0;DDRD.1=0; DDRD.2=0; DDRD.3=0;
DDRD.4=1; DDRD.5=1; DDRD.6=1; DDRD.7=1;
while (1)
{
if(PIND.0==1 && PIND.1==0 && PIND.2==0)
{ a=read_adc(0);
lcd_clear();
delay_ms(100);
lcd_putsf(" HUMIDITY SENSOR
DEVICE: ON");
delay_ms(100);
lcd_clear();
delay_ms(100);
if(a>450)
{
lcd_clear();
lcd_putsf(" HUMIDITY INCREASING");
PORTD.6=1;
81

a=read_adc(0);
itoa(a,ch);
lcd_puts(ch);
delay_ms(100);
lcd_clear();
delay_ms(100);
}
else
{lcd_putsf(" HUMIDITY");
PORTD.6=0;
b=read_adc(0);
itoa(a,ch);
delay_ms(100);
lcd_puts(ch);
delay_ms(100);
lcd_clear();
delay_ms(100);
}
}
if(PIND.0==0 && PIND.1==1 && PIND.2==0)
{
lcd_clear();
delay_ms(100);
lcd_putsf(" TEMPRATURE SENSOR
DEVICE: ON");
delay_ms(100);
c=read_adc(0);
d=c-485;
ftoa(d,3,ch);
lcd_puts(ch);
delay_ms(100);
lcd_clear();
c=read_adc(1);
lcd_clear();
delay_ms(100);
if(d>40)
{
lcd_clear();
X=X+1;
lcd_putsf("TEMPERATURE INCREASING");
PORTD.6=1;
delay_ms(100);
lcd_clear();
lcd_putsf("COOLING ON");
delay_ms(100);
82

lcd_clear();
c=read_adc(0); //use of adc0 interchanging method
d=c/10-15;
ftoa(d,3,ch);
lcd_puts(ch);
delay_ms(100);
lcd_clear();
delay_ms(100);
if(X==1)
{ PORTD.4=1;
lcd_putsf("CALLING......");
delay_ms(200);
PORTD.4=0;
lcd_clear();
}
}
else
{lcd_putsf(" TEMPERATURE");
PORTD.4=0;
c=read_adc(0);
d=c/10-15;
ftoa(d,3,ch);
delay_ms(100);
lcd_puts(ch);
delay_ms(100);
lcd_clear();
delay_ms(100);
PORTD.6=0;
lcd_putsf("COOLING OFF");
delay_ms(100);
lcd_clear();
}
}
if(PIND.0==0 && PIND.1==0 && PIND.2==1)
{
lcd_clear();
delay_ms(100);
lcd_putsf(" GAS SENSOR
DEVICE: ON");
delay_ms(100);
b=read_adc(2);
itoa(b,ch);
lcd_puts(ch);
lcd_clear();
delay_ms(100);

83

if(b>900)
{
lcd_clear();
lcd_putsf("GAS LEVEL INCREASING:");
PORTD.5=1;
b=read_adc(2);
itoa(b,ch);
lcd_puts(ch);
delay_ms(100);
lcd_clear();
delay_ms(100);
}
else
{lcd_putsf("
GAS");
PORTD.5=0;
b=read_adc(2);
itoa(b,ch);
delay_ms(100);
lcd_puts(ch);
delay_ms(100);
lcd_clear();
delay_ms(100);
}
}
if(PIND.0==0 && PIND.1==0 && PIND.2==0 && PIND.3==1)
{
lcd_clear();
delay_ms(100);
lcd_putsf(" PIZZO SENSOR
DEVICE: ON");
delay_ms(100);
E=read_adc(3);
E=1000-E;
itoa(E,ch);
lcd_puts(ch);
lcd_clear();
delay_ms(100);
if(E>900)
{
lcd_clear();
lcd_putsf("PRESSURE LEVEL
PORTD.7=1;
E=read_adc(3);
E=1000-E;
itoa(E,ch);
lcd_puts(ch);
delay_ms(100);
84

INCREASING:");

lcd_clear();
delay_ms(100);
}
else
{lcd_putsf("
PRESSURE");
PORTD.7=0;
E=read_adc(3);
E=1000-E;
itoa(E,ch);
delay_ms(100);
lcd_puts(ch);
delay_ms(100);
lcd_clear();
delay_ms(100);
}
}

} }

85

REFRENCE
WEBSITE REFRENCES
a) www.efymag.com
b) www.geocities.com
c) www.microchip.com
d) www.alldatasheets.com
e) www.wikipedia.com

BOOK REFRENCES
a) Microcontroller (D.S.YADAV)
b) Microprocessor Architecture Program And Application (R.S. GAONKAR)
c) Digital Fundamentals (THOMAS. I. FLAYD)
d) Microcontroller & Embedded System (SAMPATH. K. VENKATESH)
e) Microcontrollers Theory and Application (AJAY. V. DESSHMUKH)
f) Electronics for U (magazine) EFY
g) Digital Design (MORRIS MANO)
h) Microcontroller (P. RAJA)

86

You might also like