Você está na página 1de 58

1.

INTRODUCTION
1.1 Objective
The main objective of this project is to develop a fire detector which can sense
the formation of smoke and temperature then actuate the control system to extinguish
the fire. Here the system has to detect smoke so that we can detect the fire accidents
quickly and avoid the major damage.
The environmental conditions that exist in industrial facilities can present huge
challenges. High levels of dust and dirt can cause malfunctions and nuisance alarms,
smoke dilution in large volumetric enclosures influenced by air movement and
stratification make it difficult to detect the early signs of fire. Normally occurring
background levels of smoke cannot easily be distinguished from real fire conditions.
Unheated or un-cooled spaces cause temperature extremes outside of the operating
range of some smoke detectors.
To provide the best possible fire protection for an industrial application or
environment means selecting the correct technology and the most appropriate product
in the first instance. The detector must maintain its sensitivity over the life of the
detector and provide a low total cost of ownership.

1.2 High Level Design


In any closed area if any fire accidents occur then the damage will be more
sometimes even the loss of life. To avoid this we have to detect them as early as
possible and take any preventive measures. Sometimes it is not possible for a human
being to react quickly. In such cases the automated systems are very useful. In this
system we are using a smoke sensor which can detect the smoke and send a signal as
input to the micro controller. The micro controller will be continuously checking the
respective pin. When it gets a high signal at that pin it means that smoke has been
detected. At that time it first gives siren to alert any humans in that premises to vacate
and then it actuates the extinguishers. They may be the water sprinklers or the CO2
containers. At the same time control appliances based on the light sensor.

1.3 Block Diagram

Fig 1: Block Diagram


The smoke sensor senses the environmental conditions. While sensing if there
is any bad condition in a particular zone i.e, fire hazards, then it gives the commands
the sensor for its operation. At the same time, the measured physical quantity will be
displayed on the LCD. The output of LCD is given to 8051 micro controller. Micro
controller gives commands to operate Buzzer and sprinkler instantaneously. To
operate sprinkler, we require very less voltage. This voltage is obtained with the help
of opto coupler and TRIAC, such that fire is extinguished.
Light sensor senses the environmental condition. If it is dark, the output of
LDR will be high, such that the bulb glows up, else off.

2. EMBEDDED SYSTEM
2.1 INTRODUCTION
Computers have evolved from few, huge mainframes shared by many people,
and mini computers that were smaller but still shared to todays PCsmillions in
number, miniscule in size compared to the mainframes, and used by only one person
at a time. The next generation could be invisible, with billions being around and each
of us using more than one at a time. Welcome to the world of embedded systems, of
computers that will not look like computers and wont function like anything were
familiar with.

2.2 What is embedded system?


An Embedded System is a combination of computer hardware and software,
and perhaps additional mechanical or other parts, designed to perform a specific
function. An embedded system is a microcontroller-based, software driven, reliable,
real-time control system, autonomous, or human or network interactive, operating on
diverse physical variables and in diverse environments and sold into a competitive
and cost conscious market.

Fig 2.1: Embedded system design calls

An embedded system is not a computer system that is used primarily for


processing, not a software system on PC or UNIX, not a traditional business or
scientific application. High-end embedded & lower end embedded systems. High-end
embedded system - Generally 32, 64 Bit Controllers used with OS. Examples
Personal Digital Assistant and Mobile phones etc .Lower end embedded systems Generally 8,16 Bit Controllers used with an minimal operating systems and hardware
layout designed for the specific purpose.

Fig 2.2: Embedded system design cycle v diagram

2.3 Characteristics of Embedded System:

An embedded system is any computer system hidden inside a product other


than a computer.

They will encounter a number of difficulties when writing embedded system


software in addition to those we encounter when we write applications.

Throughput Our system may need to handle a lot of data in a short


period of time.

ResponseOur system may need to react to events quickly.

TestabilitySetting up equipment to test embedded software can be


difficult.

DebugabilityWithout a screen or a keyboard, finding out what the


software is doing wrong (other than not working) is a troublesome
problem.

Reliability embedded systems must be able to handle any situation


without human intervention.

Memory space Memory is limited on embedded systems, and you


must make the software and the data fit into whatever memory exists.

Program installation you will need special tools to get your software
into embedded systems.

Power consumption Portable systems must run on battery power, and


the software in these systems must conserve power.

Processor hogs computing that requires large amounts of CPU time


can complicate the response problem.

Cost Reducing the cost of the hardware is a concern in many


embedded system projects; software often operates on hardware that is
barely adequate for the job.

Embedded systems have a microprocessor/ microcontroller and a memory. Some


have a serial port or a network connection. They usually do not have keyboards,
screens or disk drives.

1)
2)
3)
4)
5)
6)
7)

APPLICATIONS
Military and aerospace embedded software applications
C o mmu n i ca t io n App l ic a t io ns
I nd us t r ia l au to ma t io n a nd p ro ce s s c on tr o l s o ft w a re
Mastering the complexity of applications.
Reduction of product design time.
Real time processing of ever increasing amounts of data.
Intelligent, autonomous sensors.

CLASSIFICATION

Real Time Systems.

RTS is one which has to respond to events within a specified deadline.

A right answer after the dead line is a wrong answer.

RTS CLASSIFICATION

Hard Real Time Systems

Soft Real Time System

HARD REAL TIME SYSTEM

"Hard" real-time systems have very narrow response time.


5

Example: Nuclear power system, Cardiac pacemaker.

SOFT REAL TIME SYSTEM

"Soft" real-time systems have reduced constrains on "lateness" but still must
operate very quickly and repeatable.

Example: Railway reservation system takes a few extra seconds the data
remains valid.

3. HARDWARE REQUIREMENTS
6

3.1 POWER SUPPLY BLOCK


The input to the circuit is applied from the regulated power supply. The a.c. input i.e.,
230V from the mains supply is step down by the transformer to 12V and is fed to a rectifier.
The output obtained from the rectifier is a pulsating d.c voltage. So in order to get a pure d.c
voltage, the output voltage from the rectifier is fed to a filter to remove any a.c components
present even after rectification. Now, this voltage is given to a voltage regulator to obtain a
pure constant dc voltage.

Fig 3.1: Power supply circuit diagram

3.1.1 Transformer
Transformers convert AC electricity from one voltage to another with a little
loss of power. Step-up transformers increase voltage, step-down transformers reduce
voltage. Most power supplies use a step-down transformer to reduce the dangerously
high voltage to a safer low voltage.

Fig 3.1.1: A Typical Transformer


The input coil is called the primary and the output coil is called the secondary.
There is no electrical connection between the two coils; instead they are linked by an
alternating magnetic field created in the soft-iron core of the transformer. The two
7

lines in the middle of the circuit symbol represent the core. Transformers waste very
little power so the power out is (almost) equal to the power in. Note that as voltage is
stepped down and current is stepped up.
The ratio of the number of turns on each coil, called the turns ratio,
determines the ratio of the voltages. A step-down transformer has a large number of
turns on its primary (input) coil which is connected to the high voltage mains supply,
and a small number of turns on its secondary (output) coil to give a low output
voltage.
TURNS RATIO :

Where,
Vp = primary (input) voltage, Vs = secondary (output) voltage
Np = number of turns on primary coil
Ns = number of turns on secondary coil
Ip = primary (input) current
Is = secondary (output) current.

3.1.2 Rectifier:
The output from the transformer is fed to the rectifier. It converts A.C. into
pulsating D.C. The rectifier may be a half wave or a full wave rectifier. In this project,
a bridge rectifier is used because of its merits like good stability and full wave
rectification.

Fig 3.1.2: Full Bridge Rectifier

3.1.3 Filter:
Capacitive filter is used in this project. It removes the ripples from the output
of rectifier and smoothens the D.C. Output received from this filter is constant until
8

the mains voltage and load is maintained constant. However, if either of the two is
varied, D.C. voltage received at this point changes. Therefore a regulator is applied at
the output stage.

Fig 3.1.3: Capacitive Filter

3.1.4 Voltage regulator


As the name itself implies, it regulates the input applied to it. A voltage
regulator is an electrical regulator designed to automatically maintain a constant
voltage level. In this project, power supply of 5V and 12V are required. In order to
obtain these voltage levels, 7805 and 7812 voltage regulators are to be used. The first
number 78 represents positive supply and the numbers 05, 12 represent the required
output voltage levels.
Features
Output Current up to 1A.
Output Voltages of 5, 6, 8, 9, 10, 12, 15, 18, 24V.
Thermal Overload Protection.
Short Circuit Protection.
Output Transistor Safe Operating Area Protection.

Fig 3.1.4: LM7805 Voltage regulator


The LM7805 is simple to use. You simply connect the positive lead of your
unregulated DC power supply (anything from 9VDC to 24VDC) to the Input pin,
connect the negative lead to the Common pin and then when you turn on the power,
you get a 5 volt supply from the Output pin.

3.2 Microcontroller AT89S52


The AT89S52 is a low-power, high-performance CMOS 8-bit microcontroller
with 8K bytes of in-system programmable Flash memory. The device is manufactured
using Atmels high-density non volatile memory technology and is compatible with
the industry standard 80C51 instruction set and pin out. The on-chip Flash allows the
program memory to be reprogrammed in-system or by a conventional non volatile
memory programmer. By combining a versatile 8-bit CPU with in-system
programmable Flash on a monolithic chip, the Atmel AT89S52 is a powerful
microcontroller which provides a highly-flexible and cost-effective solution to many
embedded control applications. The AT89S52 provides the following standard
features: 8K bytes of Flash, 256 bytes of RAM, 32 I/O lines, Watchdog timer, two
data pointers, three 16-bit timer/counters, a six-vector two-level interrupt architecture,
a full duplex serial port, on-chip oscillator, and clock circuitry.
In addition, the AT89S52 is designed with static logic for operation down to
zero frequency and supports two software selectable power saving modes. The Idle
Mode stops the CPU while allowing the RAM, timer/counters, serial port, and
interrupt system to continue functioning. The Power-down mode saves the RAM

10

contents but freezes the oscillator, disabling all other chip functions until the next
interrupt or hardware reset.
Block Diagram of AT89S52:

Fig 3.2: Block diagram of AT89S52

Features
Compatible with MCS-51 Products
8K Bytes of In-System Programmable (ISP) Flash Memory
Endurance: 10,000 Write/Erase Cycles
4.0V to 5.5V Operating Range
Fully Static Operation: 0 Hz to 33 MHz
Three-level Program Memory Lock
256 x 8-bit Internal RAM
32 Programmable I/O Lines
11

Three 16-bit Timer/Counters


Eight Interrupt Sources
Full Duplex UART Serial Channel
Low-power Idle and Power-down Modes
Interrupt Recovery from Power-down Mode
Watchdog Timer
Dual Data Pointer
Power-off Flag
Fast Programming Time
Flexible ISP Programming (Byte and Page Mode)
Green (Pb/Halide-free) Packaging Option

Pin Configurations of AT89S52

Fig 3.3: Pin diagram of AT89S52


Pin Description:
VCC:
Supply voltage.
GND:
Ground

12

Port 0:
Port 0 is an 8-bit open drain bidirectional I/O port. As an output port, each pin
can sink eight TTL inputs. When 1s are written to port 0 pins, the pins can be used as
high-impedance inputs. Port 0 can also be configured to be the multiplexed low-order
address/data bus during accesses to external program and data memory. In this mode,
P0 has internal pull-ups. Port 0 also receives the code bytes during Flash
programming and outputs the code bytes during program verification. External pullups are required during program verification.
Port 1:
Port 1 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 1
output buffers can sink/source four TTL inputs. When 1s are written to Port 1 pins,
they are pulled high by the internal pull-ups and can be used as inputs. As inputs, Port
1 pins that are externally being pulled low will source current (IIL) because of the
internal pull-ups. In addition, P1.0 and P1.1 can be configured to be the timer/counter
2 external count input (P1.0/T2) and the timer/counter 2 trigger input (P1.1/T2EX).
Port 2:
Port 2 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 2
output buffers can sink/source four TTL inputs. When 1s are written to Port 2 pins,
they are pulled high by the internal pull-ups and can be used as inputs. As inputs, Port
2 pins that are externally being pulled low will source current (IIL) because of the
internal pull-ups. Port 2 emits the high-order address byte during fetches from
external program memory and during accesses to external data memory that uses 16bit addresses (MOVX @ DPTR). In this application, Port 2 uses strong internal pullups when emitting 1s. During accesses to external data memory that uses 8-bit
addresses (MOVX @ RI), Port 2 emits the contents of the P2 Special Function
Register.
Port 3:
Port 3 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 3
output buffers can sink/source four TTL inputs. When 1s are written to Port 3 pins,
they are pulled high by the internal pull-ups and can be used as inputs. As inputs, Port

13

3 pins that are externally being pulled low will source current (IIL) because of the
pull-ups.
RST:
Reset input. A high on this pin for two machine cycles while the oscillator is
running resets the device. This pin drives high for 98 oscillator periods after the
Watchdog times out. The DISRTO bit in SFR AUXR (address 8EH) can be used to
disable this feature. In the default state of bit DISRTO, the RESET HIGH out feature
is enabled.
ALE/PROG:
Address Latch Enable (ALE) is an output pulse for latching the low byte of the
address during accesses to external memory. This pin is also the program pulse input
(PROG) during Flash programming.
In normal operation, ALE is emitted at a constant rate of 1/6 the oscillator
frequency and may be used for external timing or clocking purposes. Note, however,
that one ALE pulse is skipped during each access to external data memory.
PSEN:
Program Store Enable (PSEN) is the read strobe to external program memory.
When the AT89S52 is executing code from external program memory, PSEN is
activated twice each machine cycle, except that two PSEN activations are skipped
during each access to external data memory.
EA/VPP:
External Access Enable. EA must be strapped to GND in order to enable the
device to fetch code from external program memory locations starting at 0000H up to
FFFFH. Note, however, that if lock bit 1 is programmed, EA will be internally latched
on reset. EA should be strapped to VCC for internal program executions. This pin also
receives the 12-volt programming enable voltage (VPP) during Flash programming.
XTAL1:
Input to the inverting oscillator amplifier and input to the internal clock
operating circuit.
14

XTAL2:
Output from the inverting oscillator amplifier.
Oscillator Characteristics:
XTAL1 and XTAL2 are the input and output, respectively, of an inverting
amplifier which can be configured for use as an on-chip oscillator, as shown in Figure
1. Either a quartz crystal or ceramic resonator may be used. There are no requirements
on the duty cycle of the external clock signal, since the input to the internal clocking
circuitry is through a divide-by-two flip-flop, but minimum and maximum voltage
high and low time specifications must be observed.
Idle Mode
In idle mode, the CPU puts itself to sleep while all the on chip peripherals
remain active. The mode is invoked by software. The content of the on-chip RAM and
all the special functions registers remain unchanged during this mode. The idle mode
can be terminated by any enabled interrupt or by a hardware reset.
Power down Mode
In the power down mode the oscillator is stopped, and the instruction that
invokes power down is the last instruction executed. The on-chip RAM and Special
Function Registers retain their values until the power down mode is terminated. The
only exit from power down is a hardware reset. Reset redefines the SFRs but does not
change the on-chip RAM. The reset should not be activated before VCC is restored to
its normal operating level and must be held active long enough to allow the oscillator
to restart and stabilize.

3.3 LDR (Light Dependent Resistor)


A photo resistor or light dependent resistor (LDR) is a resistor whose
resistance decreases with increasing incident light intensity; in other words, it exhibits
photoconductivity. A photo resistor is made of a high resistance semiconductor. If
light falling on the device is of high enough frequency, photons absorbed by the
semiconductor give bound electrons enough energy to jump into the conduction band.
The resulting free electron (and its hole partner) conduct electricity, thereby lowering
resistance. A photoelectric device can be either intrinsic or extrinsic. An intrinsic
15

semiconductor has its own charge carriers and is not an efficient semiconductor, for
example, silicon. In intrinsic devices the only available electrons are in the valence
band, and hence the photon must have enough energy to excite the electron across the
entire band gap.

Fig 3.4: LDR


Extrinsic devices have impurities, also called do pants, added whose ground
state energy is closer to the conduction band; since the electrons do not have as far to
jump, lower energy photons (that is, longer wavelengths and lower frequencies) are
sufficient to trigger the device. If a sample of silicon has some of its atoms replaced
by phosphorus atoms (impurities), there will be extra electrons available for
conduction. This is an example of an extrinsic semiconductor. Photo resistors are
basically photocells.
Key Specifications/Special Features:
Specifications:

Maximum power consumption: 500V DC

Maximum peak value: 500mW

Spectrum peak value: 540nm

Light resistance: 5 to 10k

Dark resistance: 0.6M


Performances and features:

Coated with epoxy

Good reliability

Small volume

High sensitivity
16

Fast response

Good spectrum characteristic


Typical applications:

Camera automatic photometry

Photoelectric controls

Indoor ray controls

Annunciation

Industrial controls

Light control switches

Light control lamps

Electronic toys
Measuring conditions:

Light resistance: measured at 10 lux with standard light A (2854K

color temperature) and 2hrs illumination at 400 to 600 lux prior to testing.
o

Dark resistance: measured 10 seconds after closed 10 lux.

Gamma characteristic: between 10 lux and 100 lux and given by = lg


(R10/R100) R10, R100 Cell resistance at 10 lux and 100 lux

The error of is 0.1.

Pmax: maximum power dissipation at ambient temperature of 25 C.

Vmax: maximum voltage in darkness that may be applied to the cell


continuously.

3.4 LM35
The LM35 series are precision integrated-circuit temperature sensors, whose
output voltage is linearly proportional to the Celsius (Centigrade) temperature. The
LM35 thus has an advantage over linear temperature sensors calibrated in Kelvin, as
the user is not required to subtract a large constant voltage from its output to obtain
convenient Centigrade scaling. The LM35 does not require any external calibration or
trimming to provide typical accuracies of 14C at room temperature and 34C
over a full 55 to +150C temperature range.
Low cost is assured by trimming and calibration at the wafer level. The
LM35s low output impedance, linear output, and precise inherent calibration make
interfacing to readout or control circuitry especially easy. It can be used with single
17

power supplies, or with plus and minus supplies. As it draws only 60 A from its
supply, it has very low self-heating, less than 0.1C in still air. The LM35 is rated to
operate over a 55 to +150C temperature range.

Features:

Calibrated directly in Celsius (Centigrade)

Linear + 10.0 mV/C scale factor

0.5C accuracy guarantee able (at +25C)

Rated for full 55 to +150C range

Suitable for remote applications

Low cost due to wafer-level trimming

Operates from 4 to 30 volts

Less than 60 A current drain

Low self-heating, 0.08C in still air

Nonlinearity only 14C typical

Low impedance output, 0.1 W for 1 mA load

Typical Applications

Fig 3.5: Basic Centigrade Temperature Sensor

3.4.1 MQ-2 GAS SENSOR


It can detect: LPG, i-butane, propane, methane, alcohol, Hydrogen, smoke
18

Fig 3.6: MQ-2 Gas Sensor


Description:
MQ-2 Semiconductor Sensor for Combustible Gas Sensitive material of MQ-2
gas sensor is SnO2, which with lower conductivity in clean air. When the target
combustible gas exist, the sensors conductivity is more high along with the gas
concentration rising. Please use simple electro circuit, Convert change of conductivity
to correspond output signal of gas concentration. MQ-2 gas sensor has high sensitivity
to LPG, Propane and Hydrogen, also could be used to Methane and other combustible
steam,

it

is

with

low

cost

and

suitable

for

different

application.

Characteristics:
1. High sensitivity to Combustible gas in wide range
2. High sensitivity to LPG, Propane & Hydrogen
3. Fast response
4. Wide detection range
5. Stable performance long life low cost
6. Simple drive circuit
Applications:
1. Domestic gas leakage detector
2. Industrial Combustible gas detector
3. Portable gas detector
4. They are used in gas leakage detecting equipments in family and industry, are
suitable for detecting of LPG, i-butane, propane, methane, alcohol, Hydrogen, smoke.

3.5 ADC0808/09

19

The ADC0808, ADC0809 data acquisition component is a monolithic CMOS


device with an 8-bit analog-to-digital converter, 8-channel multiplexer and
microprocessor compatible control logic. The 8-bit A/D converter uses successive
approximation as the conversion technique. The converter features a high impedance
chopper stabilized comparator, a 256R voltage divider with analog switch tree and a
successive approximation register. The 8-channel multiplexer can directly access any
of 8-single-ended analog signals.

Fig 3.7: Pin diagram

FUNCTIONAL DESCRIPTION
Multiplexer:
The device contains an 8-channel single-ended analog signal multiplexer. A particular
input channel is selected by using the address decoder. The below table shows the input states
for the address lines to select any channel. The address is latched into the decoder on the lowto-high transition of the address latch enable signal.
CONVERTER CHARACTERISTICS
The Converter
The heart of this single chip data acquisition system is its 8-bit analog-to-digital
converter. The converter is designed to give fast, accurate, and repeatable conversions over a
wide range of temperatures. The converter is partitioned into 3 major sections: the 256R
ladder network, the successive approximation register, and the comparator. The converters

20

digital outputs are positive true. The 256R ladder network approach (Figure 1) was chosen
over the conventional R/2R ladder because of its inherent monotonicity, which guarantees no
missing digital codes. Monotonicity is particularly important in closed loop feedback control
systems. A non-monotonic relationship can cause oscillations that will be catastrophic for the
system. Additionally, the 256R network does not cause load variations on the reference
voltage.
The A/D converters successive approximation register (SAR) is reset on the positive
edge of the start conversion (SC) pulse. The conversion is begun on the falling edge of the
start conversion pulse. A conversion in process will be interrupted by receipt of a new start
conversion pulse. Continuous conversion may be accomplished by tying the end of
conversion (EOC) output to the SC input. If used in this mode, an external start conversion
pulse should be applied after power up. End-of-conversion will go low between 0 and 8 clock
pulses after the rising edge of start conversion. The most important section of the A/D
converter is the comparator. It is this section which is responsible for the ultimate accuracy of
the entire converter. It is also the comparator drift which has the greatest influence on the
repeatability of the device. A chopper-stabilized comparator provides the most effective
method of satisfying all the converter requirements.

I/O Pins

ADDRESS LINE A, B, C

The device contains 8-channels. A particular channel is selected by using the address
decoder line. The above table shows the input states for address lines to select any channel.

Address Latch Enable ALE

The address is latched on the Low High transition of ALE.

21

START

The ADCs Successive Approximation Register (SAR) is reset on the positive edge i.e.
Low- High of the Start Conversion pulse. Whereas the conversion is begun on the falling
edge i.e. high Low of the pulse.

Output Enable

Whenever data has to be read from the ADC, Output Enable pin has to be pulled high thus
enabling the TRI-STATE outputs, allowing data to be read from the data pins D0-D7.

End of Conversion (EOC)

This Pin becomes high when the conversion has ended, so the controller comes to know
that the data can now be read from the data pins.

Clock

External clock pulses are to be given to the ADC; this can be given either from LM 555 in
Astable mode or the controller can also be used to give the pulses.
ALGORITHM
1. Start.
2. Select the channel.
3. A Low High transition on ALE to latch in the address.
4. A Low High transition on Start to reset the ADCs SAR.
5. A High Low transition on ALE.
6. A High Low transition on start to start the conversion.
7. Wait for End of cycle (EOC) pin to become high.
8. Make Output Enable pin High.

22

9. Take Data from the ADCs output


10. Make Output Enable pin Low.
11. Stop
The clock can also be provided through the controller thus eliminating the need of external
circuit for clock.
Calculating Step Size
ADC 0808 is an 8 bit ADC i.e. it divides the voltage applied at Vref+ & Vref- into 28 i.e. 256
steps.
Step Size = (Vref+ - Vref-)/256
Suppose Vref+ is connected to Vcc i.e. 5V & Vref- is connected to the ground, then the step size
will be
Step size= (5 - 0)/256= 19.53 mv.
Calculating Dout
The data we get at the D0 - D7 depends upon the step size & the Input voltage i.e. V in.
Dout = Vin /step Size.

ADC INTERFACING WITH MICROCONTROLLER

Fig 3.8: ADC interfacing with microcontroller

23

The address and data pins of ADC can be connected to any of the ports of 8051.

3.6 TRIAC (Triode for Alternating Current)


The triac is a three terminal semiconductor device for controlling current. It is
effectively a development of the SCR or thyristor, but unlike the thyristor which is
only able to conduct in one direction, the triac is a bidirectional device. As such the
triac is an ideal device to use for AC switching applications because it can control the
current flow over both halves of an alternating cycle. A thyristor is only able to
control them over one half of a cycle. During the remaining half no conduction occurs
and accordingly only half the waveform can be utilized.
TRIAC Basics
There are three terminal on a triac. These are the Gate and two other terminals.
These other triac terminals are often referred to as an "Anode" or "Main Terminal"

Fig 3.9: TRIAC circuit symbol


The gate, that acts as the trigger to turn the device ON. The current then flows
between the two anodes or main terminals. These are usually designated Anode 1 and
Anode 2 or Main Terminal 1 and Main Terminal 2 (MT1 and MT2).
It can be imagined from the circuit symbol that the triac consists of two
thyristors back to back. The operation of the triac can be looked on in this fashion,
although the actual operation at the semiconductor level is rather complicated. When
the voltage on the MT1 is positive with regard to MT2 and a positive gate voltage is
applied, one of the SCRs conducts. When the voltage is reversed and a negative
24

voltage is applied to the gate, the other SCR conducts. This is provided that there is
sufficient voltage across the device to enable a minimum holding current to flow.
TRIAC Operation
The structure of a triac may be considered as a p-n-p-n structure and the triac
may be considered to consist of two conventional SCRs fabricated in an inverse
parallel configuration.
In operation, when terminal A2 is positive with respect to A1, then a positive
gate voltage will give rise to a current that will trigger the part of the triac consisting
of p1 n1 p2 n2 and it will have an identical characteristic to an SCR. When terminal
A2 is negative with respect to A1 a negative current will trigger the part of the triac
consisting of p2 n1 p1 n3. In this way conduction on the triac occurs over both halves
an alternating cycle.

Fig 3.10: TRIAC


TRIAC Structure
Triac do not fire symmetrically as a result of slight differences between the
two halves of the device. This results in harmonics being generated and the less
symmetrical the triac fires, the greater the level of harmonics produced. It is generally
undesirable to have high levels of harmonics in a power system and as a result triacs
are not favoured for high power systems. Instead two thyristors may be used as it is
easier to control their firing.
To help in overcoming this problem, a device known as a diac (diode AC
switch) is often placed in series with the gate. This device helps make the switching
more even for both halves of the cycle. This results from the fact that the diac
switching characteristic is far more even than that of the triac. Since the diac prevents
25

any gate current flowing until the trigger voltage has reached a certain voltage in
either direction, this makes the firing point of the triac more even in both directions.

3.7 Crystal Oscillator (11.0592MHz)


It provide clock pulses of 11.0592 Mhz frequency. It can be used as
UART clock (61.8432 MHz). It allows integer division to common baud rates
(96115200 baud or 96961,200 baud).
It

is

a common

clock

for Intel

8051 microprocessors. It uses

the

mechanical resonance of a vibrating crystal of piezoelectric material to create an


electrical signal with a very precise frequency. This frequency is commonly used to
keep track of time, to provide a stable clock signal for digital integrated circuits, and
to stabilize frequencies for radio transmitters and receivers. The most common type of
piezoelectric resonator used is the quartz crystal, so oscillator circuits incorporating
them became known as crystal oscillators.

Fig 3.11: Crystal oscillator


The crystal oscillator circuit sustains oscillation by taking a voltage signal
from the quartz resonator, amplifying it, and feeding it back to the resonator. The rate
of expansion and contraction of the quartz is the resonant frequency, and is
determined by the cut and size of the crystal.
When the energy of the generated output frequencies matches the losses in the
circuit, an oscillation can be sustained. One of the most important traits of the crystal
oscillator is that it exhibits very low phase noise. In the crystal oscillator, the crystal
mostly vibrates in one axis, therefore only one phase is dominant. This property of
low phase noise makes them particularly useful in telecommunications where stable
signals are needed and in scientific equipment where very precise time references are
needed. The result is that a quartz crystal behaves like a circuit composed of
an inductor,

capacitor and resistor

with
26

precise

resonant

frequency.

FEATURES:
- The crystal oscillator circuit sustains oscillation by taking a voltage signal from the
quartz resonator, amplifying it, and feeding it
back to the resonator
- It provides clock pulses of 11.0592 MHz frequency.
- The popularity of the crystals is due to low cost.

3.8 OPTO Coupler


An optical coupler, also called opto-isolator, opto coupler, opto coupler, photo
coupler or optical isolator, is a passive optical component that can combine or split
transmission data (optical power) from optical fibers. It is an electronic device which
is designed to transfer electrical signals by using light waves in order to provide
coupling with electrical isolation between its input and output. The main purpose of
an opto coupler is to prevent rapidly changing voltages or high voltages on one side of
a circuit from distorting transmissions or damaging components on the other side of
the circuit. An opto coupler contains a light source often near an LED which converts
electrical input signal into light, a closed optical channel and a photo sensor, which
detects incoming light and either modulates electric current flowing from an external
power supply or generates electric energy directly. The sensor can either be a photo
resistor, a silicon-controlled rectifier, a photodiode, a phototransistor or a triac.

Fig 3.12: Optocoupler


27

The opto coupler application or function in the circuit is to:

Monitor high voltage

Output voltage sampling for regulation

System control micro for power on/off

Ground isolation

3.9 Electronic Buzzer


A buzzer is a mechanical, electromechanical, magnetic, electromagnetic,
electro-acoustic or piezoelectric audio signalling device. A piezo electric buzzer can
be driven by an oscillating electronic circuit or other audio signal source. A click,
beep or ring can indicate that a button has been pressed.

Fig 3.13: Buzzer


FEATURES
The PS series are high-performance buzzers that employ uni morph piezoelectric
elements and are designed for easy incorporation into various circuits.
They feature extremely low power consumption in comparison to electromagnetic
units.
Because these buzzers are designed for external excitation, the same part can serve
as both a musical tone oscillator and a buzzer.
They can be used with automated inserters. Moisture-resistant models are also
available.
The lead wire type(PS1550L40N) with both-sided adhesive tape installed easily is
prepared.
APPLICATIONS
Electric ranges, washing machines, computer terminals, various devices that
require speech synthesis output.
28

3.10 LIQUID CRYSTAL DISPLAY (LCD)


Liquid crystal display (LCD) has material which combines the properties of
both liquid and crystals. They have a temperature range within which the molecules
are almost as mobile as they would be in a liquid, but are grouped together in an order
form similar to a crystal.

Fig 3.14: LCD Display

FEATURES
* HIGH CONTRAST LCD SUPERTWIST DISPLAY
* EA DIP162-DNLED: YELLOW/GREEN WITH LED BACKLIGHT
* EA DIP162-DN3LW AND DIP162J-DN3LW WITH WHITE LED B/L.,
LOPOWER
* INCL. HD 44780 OR COMPATIBLE CONTROLLER
* INTERFACE FOR 4- AND 8-BIT DATA BUS
* POWER SUPPLY +5V OR 2.7V OR 3.3V
* OPERATING TEMPERATURE 0~+50C (-DN3LW, -DHNLED: -20~+70C)
* LED BACKLIGHT Y/G max. 150mA@+25C
* LED BACKLIGHT WHITE max. 45mA@+25C
* SOME MORE MODULES WITH SAME MECHANIC AND SAME PINOUT:
-DOTMATRIX 1x8, 4x20
-GRAPHIC 122x32
* NO SCREWS REQUIRED: SOLDER ON IN PCB ONLY
* DETACHABLE VIA 9-PIN SOCKET EA B200-9 (2 PCS. REQUIRED)
Liquid crystal display is very important device in embedded system. It offers
high flexibility to user as he can display the required data on it. But due to lack of
proper approach to LCD interfacing many of them fail. Many people consider LCD
interfacing a complex job but according to me LCD interfacing is very easy task, you
29

just need to have a logical approach. This page is to help the enthusiast who wants to
interface LCD with through understanding. Copy and Paste technique may not work
when an embedded system engineer wants to apply LCD interfacing in real world
projects.
You will be known about the booster rockets on space shuttle. Without these
booster rockets the space shuttle would not launch in geosynchronous orbit. Similarly
to understand LCD interfacing you need to have booster rockets attached! To get it
done right you must have general idea how to approach any given LCD. This page
will help you develop logical approach towards LCD interfacing.
Major task in LCD interfacing is the initialization sequence. In LCD
initialization you have to send command bytes to LCD. Here you set the interface
mode, display mode, address counter increment direction, set contrast of LCD,
horizontal or vertical addressing mode, color format. This sequence is given in
respective LCD driver datasheet. Studying the function set of LCD lets you know the
definition of command bytes. It varies from one LCD to another. If you are able to
initialize the LCD properly 90% of your job is done.
Next step after initialization is to send data bytes to required display data
RAM memory location. Firstly set the address location using address set command
byte and than send data bytes using the DDRAM write command. To address specific
location in display data RAM one must have the knowledge of how the address
counter is incremented.
No. Instruction Hex Decimal

1 Function Set: 8-bit, 1 Line, 5x7 Dots 0x30 48


2 Function Set: 8-bit, 2 Line, 5x7 Dots 0x38 56
3 Function Set: 4-bit, 1 Line, 5x7 Dots 0x20 32
4 Function Set: 4-bit, 2 Line, 5x7 Dots 0x28 40
5 Entry Mode 0x06 6
6Display off Cursor off(clearing display without clearing DDRAM content)0x088
7 Display on Cursor on 0x0E 14
8 Display on Cursor off 0x0C 12
9 Display on Cursor blinking 0x0F 15
30

10 Shift entire display left 0x18 24


12 Shift entire display right 0x1C 30
13 Move cursor left by one character 0x10 16
14 Move cursor right by one character 0x14 20
15 Clear Display (also clear DDRAM content) 0x01 1
16 Set DDRAM address or coursor position on display 0x80+add* 128+add*
17 Set CGRAM address or set pointer toCGRAM location 0x40+add** 64+add
LCD pin diagram
A liquid crystal display (LCD) is an electronically-modulated optical device
shaped into a thin, flat panel made up of any number of color or monochrome pixels
filled with liquid crystals and arrayed in front of a light source (backlight) or reflector.
It is often used in battery-powered electronic devices because it requires very small
amounts of electric power.

Fig 3.15: LCD Panel pin diagram


Above is the quite simple schematic. The LCD panel's Enable and Register
Select is connected to the Control Port. The Control Port is an open collector / open
drain output. While most Parallel Ports have internal pull-up resistors, there are a few
which don't. Therefore by incorporating the two 10K external pull up resistors, the
31

circuit is more portable for a wider range of computers, some of which may have no
internal pull up resistors.
We make no effort to place the Data bus into reverse direction. Therefore we
hard wire the R/W line of the LCD panel, into write mode. This will cause no bus
conflicts on the data lines. As a result we cannot read back the LCD's internal Busy
Flag which tells us if the LCD has accepted and finished processing the last
instruction. This problem is overcome by inserting known delays into our program.
The 10k Potentiometer controls the contrast of the LCD panel. Nothing fancy
here. As with all the examples, I've left the power supply out. You can use a bench
power supply set to 5v or use a onboard +5 regulator. Remember a few de-coupling
capacitors, especially if you have trouble with the circuit working properly.
The 2 line x 16 character LCD modules are available from a wide range of
manufacturers and should all be compatible with the HD44780. The one I used to test
this circuit was a Power tip PC-1602F and an old Philips LTN211F-10 which was
extracted from a Poker Machine! The diagram to the right shows the pin numbers for
these devices. When viewed from the front, the left pin is pin 14 and the right pin is
pin 1.

3.11 LED
A light-emitting diode (LED) is a semiconductor light source. LEDs are used
as indicator lamps in many devices, and are increasingly used for lighting. When a
light-emitting diode is forward biased (switched on), electrons are able to recombine
with holes within the device, releasing energy in the form of photons.

Fig 3.16: symbol of LED


This effect is called electroluminescence and the color of the light
(corresponding to the energy of the photon) is determined by the energy gap of the
semiconductor. An LED is often small in area (less than 1 mm2), and integrated
32

optical components may be used to shape its radiation pattern. LEDs present many
advantages over incandescent light sources including lower energy consumption,
longer lifetime, improved robustness, smaller size, faster switching, and greater
durability and reliability.
Light-emitting diodes are used in applications as diverse as replacements for
aviation lighting, automotive lighting as well as in traffic signals. The compact size,
the possibility of narrow bandwidth, switching speed, and extreme reliability of LEDs
has allowed new text and video displays and sensors to be developed, while their high
switching rates are also useful in advanced communications technology.

3.12 1N4007
Diodes are used to convert AC into DC these are used as half wave rectifier or full
wave rectifier. Three points must he kept in mind while using any type of diode.
1. Maximum forward current capacity
2. Maximum reverse voltage capacity
3. Maximum forward voltage capacity

Fig 3.17: 1N4007 diodes


The number and voltage capacity of some of the important diodes available in the
market are as follows:

Diodes of number IN4001, IN4002, IN4003, IN4004, IN4005, IN4006 and


IN4007 have maximum reverse bias voltage capacity of 50V and maximum
forward current capacity of 1 Amp.

33

Diode of same capacities can be used in place of one another. Besides this
diode of more capacity can be used in place of diode of low capacity but diode
of low capacity cannot be used in place of diode of high capacity. For
example, in place of IN4002; IN4001 or IN4007 can be used but IN4001 or
IN4002 cannot be used in place of IN4007.The diode BY125made by
company BEL is equivalent of diode from IN4001 to IN4003. BY 126 is
equivalent to diodes IN4004 to 4006 and BY 127 is equivalent to diode
IN4007.

PN JUNCTION OPERATION
Now that you are familiar with P- and N-type materials, how these
materials are joined together to form a diode, and the function of the diode, let
us continue our discussion with the operation of the PN junction. But before
we can understand how the PN junction works, we must first consider current
flow in the materials that make up the junction and what happens initially
within the junction when these two materials are joined together.

Current Flow in the N-Type Material


Conduction in the N-type semiconductor, or crystal, is similar to
conduction in a copper wire. That is, with voltage applied across the material,
electrons will move through the crystal just as current would flow in a copper
wire. This is shown in figure 1-15. The positive potential of the battery will
attract the free electrons in the crystal. These electrons will leave the crystal
and flow into the positive terminal of the battery. As an electron leaves the
crystal, an electron from the negative terminal of the battery will enter the
crystal, thus completing the current path. Therefore, the majority current
carriers in the N-type material (electrons) are repelled by the negative side of
the battery and move through the crystal toward the positive side of the
battery.

34

Current Flow in the P-Type Material


Current flow through the P-type material is illustrated. Conduction in
the P material is by positive holes, instead of negative electrons. A hole moves
from the positive terminal of the P material to the negative terminal. Electrons
from the external circuit enter the negative terminal of the material and fill
holes in the vicinity of this terminal. At the positive terminal, electrons are
removed from the covalent bonds, thus creating new holes. This process
continues as the steady stream of holes (hole current) moves toward the
negative terminal.

3.13 RESISTOR
A resistor is a two-terminal electronic component designed to oppose an
electric current by producing a voltage drop between its terminals in proportion to the
current, that is, in accordance with Ohm's law:
V = IR
Resistors are used as part of electrical networks and electronic circuits.
They are extremely commonplace in most electronic equipment. Practical resistors
can be made of various compounds and films, as well as resistance wire (wire made of
a high-resistivity alloy, such as nickel/chrome).

Fig 3.18: Resistor


The primary characteristics of resistors are their resistance and the power
they can dissipate. Other characteristics include temperature coefficient, noise, and
inductance. Less well-known is critical resistance, the value below which power
dissipation limits the maximum permitted current flow, and above which the limit is
35

applied voltage. Critical resistance depends upon the materials constituting the
resistor as well as its physical dimensions; it's determined by design. Resistors can be
integrated into hybrid and printed circuits, as well as integrated circuits. Size, and
position of leads (or terminals) are relevant to equipment designers; resistors must be
physically large enough not to overheat when dissipating their power.

A resistor is a two-terminal passive electronic component which implements


electrical resistance as a circuit element. When a voltage V is applied across the
terminals of a resistor, a current I will flow through the resistor in direct proportion to
that voltage. The reciprocal of the constant of proportionality is known as the
resistance R, since, with a given voltage V, a larger value of R further "resists" the
flow of current I as given by Ohm's law:

Resistors are common elements of electrical networks and electronic circuits


and are ubiquitous in most electronic equipment. Practical resistors can be made of
various compounds and films, as well as resistance wire (wire made of a highresistivity alloy, such as nickel-chrome). Resistors are also implemented within
integrated circuits, particularly analog devices, and can also be integrated into hybrid
and printed circuits.
The electrical functionality of a resistor is specified by its resistance: common
commercial resistors are manufactured over a range of more than 9 orders of
magnitude. When specifying that resistance in an electronic design, the required
precision of the resistance may require attention to the manufacturing tolerance of the
chosen resistor, according to its specific application. The temperature coefficient of
the resistance may also be of concern in some precision applications. Practical
resistors are also specified as having a maximum power rating which must exceed the
anticipated power dissipation of that resistor in a particular circuit: this is mainly of
concern in power electronics applications. Resistors with higher power ratings are
physically larger and may require heat sinking. In a high voltage circuit, attention
must sometimes be paid to the rated maximum working voltage of the resistor.
36

The series inductance of a practical resistor causes its behaviour to depart from
ohms law; this specification can be important in some high-frequency applications for
smaller values of resistance. In a low-noise amplifier or pre-amp the noise
characteristics of a resistor may be an issue. The unwanted inductance, excess noise,
and temperature coefficient are mainly dependent on the technology used in
manufacturing the resistor. They are not normally specified individually for a
particular family of resistors manufactured using a particular technology. A family of
discrete resistors is also characterized according to its form factor, that is, the size of
the device and position of its leads (or terminals) which is relevant in the practical
manufacturing of circuits using them.

Units
The ohm (symbol: ) is the SI unit of electrical resistance, named after Georg
Simon Ohm. An ohm is equivalent to a volt per ampere. Since resistors are specified
and manufactured over a very large range of values, the derived units of milliohm (1
m = 103 ), kilohm (1 k = 103 ), and megohm (1 M = 106 ) are also in
common usage.
The reciprocal of resistance R is called conductance G = 1/R and is measured
in Siemens (SI unit), sometimes referred to as a mho. Thus a Siemens is the reciprocal
of an ohm: S =

. Although the concept of conductance is often used in circuit

analysis, practical resistors are always specified in terms of their resistance (ohms)
rather than conductance.

3.14 CAPACITOR
A capacitor or condenser is a passive electronic component consisting of a
pair of conductors separated by a dielectric. When a voltage potential difference exists
between the conductors, an electric field is present in the dielectric. This field stores

37

energy and produces a mechanical force between the plates. The effect is greatest
between wide, flat, parallel, narrowly separated conductors.
An ideal capacitor is characterized by a single constant value, capacitance,
which is measured in farads. This is the ratio of the electric charge on each conductor
to the potential difference between them. In practice, the dielectric between the plates
passes a small amount of leakage current. The conductors and leads introduce an
equivalent series resistance and the dielectric has an electric field strength limit
resulting in a breakdown voltage.
The properties of capacitors in a circuit may determine the resonant
frequency and quality factor of a resonant circuit, power dissipation and operating
frequency in a digital logic circuit, energy capacity in a high-power system, and many
other important aspects.

Fig 3.19: capacitor


A capacitor (formerly known as condenser) is a device for storing electric
charge. The forms of practical capacitors vary widely, but all contain at least two
conductors separated by a non-conductor. Capacitors used as parts of electrical
systems, for example, consist of metal foils separated by a layer of insulating film.
Capacitors are widely used in electronic circuits for blocking direct current
while allowing alternating current to pass, in filter networks, for smoothing the output
of power supplies, in the resonant circuits that tune radios to particular frequencies
and for many other purposes.
A capacitor is a passive electronic component consisting of a pair of
conductors separated by a dielectric (insulator). When there is a potential difference
(voltage) across the conductors, a static electric field develops in the dielectric that
38

stores energy and produces a mechanical force between the conductors. An ideal
capacitor is characterized by a single constant value, capacitance, measured in farads.

4. SOFTWARE REQUIREMENTS

4.1 Introduction to Keil micro vision (IDE)


Keil an ARM Company makes C compilers, macro assemblers, real-time
kernels, debuggers, simulators, integrated environments, evaluation boards, and
emulators for ARM7/ARM9/Cortex-M3, XC16x/C16x/ST10, 251, and 8051 MCU
families.
Keil development tools for the 8051 Microcontroller Architecture support
every level of software developer from the professional applications engineer to the
student just learning about embedded software development. When starting a new
39

project, simply select the microcontroller you use from the Device Database and the
Vision IDE sets all compiler, assembler, linker, and memory options for you.
Keil is a cross compiler. So first we have to understand the concept of
compilers and cross compilers. After then we shall learn how to work with keil.

4.2 CONCEPT OF COMPILER


Compilers are programs used to convert a High Level Language to object
code. Desktop compilers produce an output object code for the underlying
microprocessor, but not for other microprocessors. I.E the programs written in one of
the HLL like C will compile the code to run on the system for a particular processor
like x86 (underlying microprocessor in the computer). For example compilers for Dos
platform is different from the Compilers for Unix platform So if one wants to define
a compiler then compiler is a program that translates source code into object code.
The compiler derives its name from the way it works, looking at the entire
piece of source code and collecting and reorganizing the instruction. See there is a bit
little difference between compiler and an interpreter. Interpreter just interprets whole
program at a time while compiler analyses and execute each line of source code in
succession, without looking at the entire program.
The advantage of interpreters is that they can execute a program immediately.
Secondly programs produced by compilers run much faster than the same programs
executed by an interpreter. However compilers require some time before an
executable program emerges. Now as compilers translate source code into object
code, which is unique for each type of computer, many compilers are available for the
same language.

4.3 CONCEPT OF CROSS COMPILER

40

A cross compiler is similar to the compilers but we write a program for the
target processor (like 8051 and its derivatives) on the host processors (like computer
of x86). It means being in one environment you are writing a code for another
environment is called cross development. And the compiler used for cross
development is called cross compiler. So the definition of cross compiler is a compiler
that runs on one computer but produces object code for a different type of computer.

4.4 KEIL C CROSS COMPILER


Keil is a German based Software development company. It provides several
development tools like

IDE (Integrated Development environment)

Project Manager

Simulator

Debugger

C Cross Compiler, Cross Assembler, Locator/Linker

The Keil ARM tool kit includes three main tools, assembler, compiler and
linker. An assembler is used to assemble the ARM assembly program. A compiler is
used to compile the C source code into an object file. A linker is used to create an
absolute object module suitable for our in-circuit emulator.

4.5 Building an Application in Vision2


To build (compile, assemble, and link) an application in Vision2, you must:
1

Select Project -(forexample,166\EXAMPLES\HELLO\HELLO.UV2).

Select Project - Rebuild all target files or Build target.Vision2 compiles,


assembles, and links the files in your project.

41

4.6 Creating Your Own Application in Vision2


To create a new project in Vision2, you must:
1

Select Project - New Project.

Select a directory and enter the name of the project file.

Select Project - Select Device and select an 8051, 251, or C16x/ST10 device
from the Device Database.

Create source files to add to the project.

Select Project - Targets, Groups, Files. Add/Files, select Source Group1, and
add the source files to the project.

Select Project - Options and set the tool options. Note when you select the
target device from the Device Database all special options are set
automatically. You typically only need to configure the memory map of your
target hardware. Default memory model settings are optimal for most
applications.

Select Project - Rebuild all target files or Build target.

4.7 Debugging an Application in Vision2


To debug an application created using Vision2, you must:
1

Select Debug - Start/Stop Debug Session.

Use the Step toolbar buttons to single-step through your program. You may
enter G, main in the Output Window to execute to the main C function.

Open the Serial Window using the Serial #1 button on the toolbar.

Debug your program using standard options like Step, Go, Break, and so on.

4.8 Starting Vision2 and Creating a Project


Vision2 is a standard Windows application and started by clicking on the
program icon. To create a new project file select from the Vision2 menu Project
New Project. This opens a standard Windows dialog that asks you for the new
project file name. We suggest that you use a separate folder for each project. You can
simply use the icon Create New Folder in this dialog to get a new empty folder. Then
select this folder and enter the file name for the new project, i.e. Project1. Vision2
creates a new project file with the name PROJECT1.UV2 which contains a default
target and file group name. You can see these names in the Project.
42

4.9 Window Files.


Now use from the menu Project Select Device for Target and select a CPU
for your project. The Select Device dialog box shows the Vision2 device data base.
Just select the microcontroller you use. We are using for our examples the Philips
80C51RD+ CPU. This selection sets necessary tool Options for the 80C51RD+ device
and simplifies in this way the tool Configuration.

4.10 Building Projects and Creating a HEX Files


Typical, the tool settings under Options Target are all you need to start a new
application. You may translate all source files and line the application with a click on
the Build Target toolbar icon. When you build an application with syntax errors,
Vision2 will display errors and warning messages in the Output Window Build
page. A double click on a message line opens the source file on the correct location in
a Vision2 editor window. Once you have successfully generated your application
you can start debugging.
After you have tested your application, it is required to create an Intel HEX
file to download the software into an EPROM programmer or simulator. Vision2
creates HEX files with each build process when Create HEX files under Options for
Target Output is enabled. You may start your PROM programming utility after the
make process when you specify the program under the option Run User Program #1.

4.11 CPU Simulation


Vision2 simulates up to 16 Mbytes of memory from which areas can be
mapped for read, write, or code execution access. The Vision2 simulator traps
and reports illegal memory accesses. In addition to memory mapping, the simulator
also provides support for the integrated peripherals of the various 8051 derivatives.
The on-chip peripherals of the CPU you have selected are configured from the
Device.

4.12 Database selection

43

You have made when you create your project target. Refer to page 58 for more
Information about selecting a device. You may select and display the on-chip
peripheral components using the Debug menu. You can also change the aspects of
each peripheral using the controls in the dialog boxes.

4.13 Start Debugging


You start the debug mode of Vision2 with the Debug Start/Stop Debug
Session Command. Depending on the Options for Target Debug Configuration,
Vision2 will load the application program and run the startup code Vision2 saves
the editor screen layout and restores the screen layout of the last debug session. If the
program execution stops, Vision2 opens an editor window with the source text or
shows CPU instructions in the disassembly window. The next executable statement is
marked with a yellow arrow. During debugging, most editor features are still
available.
For example, you can use the find command or correct program errors.
Program source text of your application is shown in the same windows. The Vision2
debug mode differs from the edit mode in the following aspects:
_ The Debug Menu and Debug Commands described on page 28 are available. The
additional debug windows are discussed in the following.
_ The project structure or tool parameters cannot be modified. All build commands
are disabled.

4.14 Disassembly Window


The Disassembly window shows your target program as mixed source and
assembly program or just assembly code. A trace history of previously executed
instructions may be displayed with Debug View Trace Records. To enable the trace
history, set Debug Enable/Disable Trace Recording.
If you select the Disassembly Window as the active window all program step
commands work on CPU instruction level rather than program source lines. You can
select a text line and set or modify code breakpoints using toolbar buttons or the
context menu commands.
You may use the dialog Debug Inline Assembly to modify the CPU
instructions. That allows you to correct mistakes or to make temporary changes to the
44

target program you are debugging. Numerous example programs are included to help
you get started with the most popular embedded 8051 devices.
The Keil Vision Debugger accurately simulates on-chip peripherals (IC,
CAN, UART, SPI, Interrupts, I/O Ports, A/D Converter, D/A Converter, and PWM
Modules) of your 8051 device. Simulation helps you understand hardware
configurations and avoids time wasted on setup problems. Additionally, with
simulation, you can write and test applications before target hardware is available.

4.15 EMBEDDED C
Use of embedded processors in passenger cars, mobile phones, medical
equipment, aerospace systems and defense systems is widespread, and even everyday
domestic appliances such as dish washers, televisions, washing machines and video
recorders now include at least one such device.
Because most embedded projects have severe cost constraints, they tend to
use low-cost processors like the 8051 family of devices considered in this book. These
popular chips have very limited resources available most such devices have around
256 bytes (not megabytes!) of RAM, and the available processor power is around
1000 times less than that of a desktop processor. As a result, developing embedded
software presents significant new challenges, even for experienced desktop
programmers. If you have some programming experience - in C, C++ or Java - then
this book and its accompanying CD will help make your move to the embedded world
as quick and painless as possible.

45

5. CODING

5.1 Program Code


#include<reg51.h>
#include<intrins.h>
#include<lcd_busy.h>
#include"adc0808.h"
sbit ldr=P3^7;
sbit pump=P3^6;
sbit light=P3^5;
sbit buzz=P3^4;
void main()
{
lcd_init();
lcd_init();
message(0x80,"Industrial Protection");
delay(500);
while(1)
{
adcdata();
delay(500);
46

if(C1>50)
{
init(0x01);
message(0x80,"High temparature");
buzz=0;
pump=0;
delay(300);
}
if(C2>4000)
{
init(0x01);
message(0x80,"High Smoke");
buzz=0;
pump=0;
delay(300);
}
if(C1<50 && C2<3500)
{
init(0x01);
message(0x80,"Normal conditions");
buzz=1;
pump=1;
delay(300);
}
if(ldr==0)
47

{
init(0x01);
message(0x80,"Bad light");
light=0;
delay(300);
}
else
light=1;
}//while(1)
}//main

5.2 COMPILER PROCEDURE

1.

Click on the Keil Vision Icon on Desktop

2.

The following fig will appear

48

3.

Click on the Project menu from the title bar

4.

Then Click on New Project

5.

Save the Project by typing suitable project name with no extension in u r


own folder sited in either C:\ or D:\

49

6.

Then Click on Save button above.

7.

Select the component for u r project. i.e. Atmel

8.

Click on the + Symbol beside of Atmel

9.

Select AT89C51 as shown below

10.

Then Click on OK

11.

The Following fig will appear


50

12.

Then Click either YES or NOmostly NO.

13.

Now your project is ready to USE.

14.

Now double click on the Target1, you would get another option Source
group 1 as shown in next page.

15.

Click on the file option from menu bar and select new.

51

16.

The next screen will be as shown in next page, and just maximize it by
double clicking on its blue boarder.

17.

Now start writing program in either in EMBEDDED C or ASM.

18.

For a program written in Assembly, then save it with extension . asm


and for EMBEDDED C based program save it with extension .C
52

19.

Now right click on Source group 1 and click on Add files to Group
Source.

20.

Now you will get another window, on which by default EMBEDDED C


files will appear.
53

21.

Now select as per your file extension given while saving the file

22.

Click only one time on option ADD.

23.

Now Press function key F7 to compile. Any error will appear if so happen.

24.

If the file contains no error, then press Control+F5 simultaneously.


54

25.

The new window is as follows

26.

Then Click OK.

27.

Now click on the Peripherals from menu bar, and check your required port
as shown in fig below.

55

28.

Drag the port a side and click in the program file

29.

Now keep Pressing function key F11 slowly and observe.

30.

You are running your program successfully.

56

CONCLUSION
This project is used to develop industrial protection over smoke, temperature
and LDR (fire sensor). In this project, we are using a smoke sensor, temperature and
LDR which can detect and send a signal as input to the micro controller. The micro
controller will be continuously checking the respective pin.

Upon reception of

positive signal to the microcontroller from both the sensors that continuously
monitors them, a signal is sent to the buzzer that sounds alarm confirming fire, and
simultaneously a signal is sent to the LCD display. The sensitivity of the heat and
smoke sensor can be increased and decreased manually here by making the alarm
system more or less sensitive.
When it gets a high signal at that pin it means that smoke has been detected.
At that time it first gives siren to alert any humans in that premises to vacate and then
it actuates the extinguishers. They may be the water sprinklers or the CO2 containers.
At the same time control appliances based on the light sensor.

57

REFERENCES
The 8051 Microcontroller and Embedded Systems
- M.A Mazidi & J.G Mazidi
The Microcontroller Idea Book
- John Axelson
The Microcontroller Application Cookbook
Matt Gilliland
Digital design by Morris Mano
Linear integrated circuits by Roy choudary

58

Você também pode gostar