Fire Fighting System with Microcontroller
Fire Fighting System with Microcontroller
i
ii
Abstract
This study aims to design and implementation a fire fighting system using
Atmega32 microcontroller. This system accomplished by connecting Atmega32
microcontroller to temperature sensors, push buttons, Liquid Crystal Display
(LCD) and other components. The system monitors the sensors values
continuously to warn or inform the user in abnormal situations or at fire danger.
This warning takes different ways such as the appearance of the threat type on
the system screen or the operation of different alarm sirens or by sending a Short
Message Service (SMS), at some cases the system sends command to fire
fighting unit to extinguish fire. The system also has many options that achieve
more functions.
iii
Table of Contents
Page No.
Acknowledgment i
Abstract ii
Chapter One
Introduction
1.3 Objectives 2
1.4 Methodology 2
1.5 Layout 2
2.1 Introduction 3
2.2 Sensors 3
iv
2.2.3 Smoke detectors 7
2.3 Microprocessor 10
2.3.1 Busses 11
2.4 Microcontroller 14
2.5 Buzzer 20
Chapter Three
System Hardware and Software Considerations
3.2.1 Atmega32 23
3.2.2 SIM900 28
v
3.2.3 Fire detectors 29
Chapter 4
Conclusion and Recommendations
4.1 Conclusion 52
4.2 Recommendations 52
References 53
vi
List of Figures
Figure Title Page No.
3.2 Atmega32 24
3.3 SIM900 29
vii
Chapter One
Introduction
1.1 General Concept
Fire accident is common feature in factories, houses, markets etc. in
every country. Due to poor fire protection, lack of adequate fire alarm and
emergency exit, fire increases death. With the advancement of human
civilization, fire-safety has been a prime concern. Fire hazards can be fatal and
denigrating for industrial and household security, also minatory for human life.
The best way to reduce these losses is to respond to the emergency
situation as quick as possible. So, there comes the necessity of standalone
autonomous fire detection systems. These systems render the works of quick
detection, alarm notification, and sometimes initiation of fire extinguishing. A
fire or smoke alarm system can be monitored locally in the premises, or
remotely at a distant place as prerequirement. Remote alarm system provides
the owner of the premise with the advantage of monitoring from distant location
and taking immediate actions when an emergency message is received, unlike
a manual system. Remote monitoring systems can be designed in various
waysusing wireless sensor networks, Ethernet, image processing and other
digital communication technologies.
Fire, smoke or the leak of gases threat people’s life and their properties.
Most building and facilities in Sudan free from fire alarm systems. Firefighting
system is used to prevent, extinguish, localize, or block fires in enclosed spaces.
Automatic fire-fighting system, which is very important to protect people and
properties, is installed in buildings and rooms where the fire hazard is
comparatively high.
1.2 Statement of Problem
Although The Existing Fire fighting Systems are reliable and have a
wide range of pros, they are accompanied by concerns about being complex,
incompact, non-standalone, expensive and having redundant appurtenances.
1
Therefore, there is necessity for a system which would be reliable and swift
responsive as well as simple, easy implementable and cost effective.
1.3 Objectives
The main objectives of this study are to:
1. Design a control circuit for automatic fire fighting system.
2. Simulate the proposed automatic fire fighting system control circuit.
[Link] the proposed automatic fire fighting system control circuit.
1.4 Methodology
This study develops a microcontroller based system to detect smoke and
heat at a house or facilities, by analyzing this signal and take specific action.
The system can operate at auto or manual mode in which the system acts as
detector only and the owner can activate the actuators remotely as needed.
In this study the system is divided into parts; hardware and software. The
hardware a sensor circuitry is designed to develop system awareness and
capability to detect over-temperature, smoke and flame. Microcontroller
Atmega16 is used to process the various sensor signals and control the system
actuators accordingly. A software code is developed to control the overall
system functions. The code is written in BASIC language using basic compiler
for AVR (BASCOM-AVR). A Global System Mobile (GSM) module is
interconnected to the system and used to send SMS indicating the system and
environment status. System software simulation is done using Proteus package.
1.5 Layout
This research consists of five chapters, Chapter one contains general
introduction, defines problem, objectives and methodology. Chapter two
contains a general background and general information to the main parts used
in the study. Chapter three handles the hardware and software considerations.
Chapter four deals with the system implementation and testing. Finally, chapter
five presents the conclusion and recommendations.
2
Chapter Two
Theoretical Background
2.1 Introduction
All fire alarm systems essentially operate on the same principle. If a
detector detects smoke or heat or someone operates a break glass unit (manual
break point), then alarm sounders operate to warn others in the building that
there may be a fire and to evacuate. When choosing a fire alarm system many
factors need to be considered such as the purpose, building structure and current
legislation.
Fire safety in new, extended or altered buildings is the responsibility of
the local authority who delegates the responsibility to building control
department who enforces and administers the building regulations. In existing
commercial buildings, premises are subject to the regulatory reform (fire safety)
order 2005. The order states that the ‘responsible person’ within the
organization has a legal duty to undertake a suitable and sufficient fire risk
assessment at their premises. This assessment is a detailed report of the fire risk
in your building, the adequacy of existing fire precautions and the need for any
additional fire precautions. The fire risk Assessment will determine the level of
fire alarm system required for business premises. The guidance usually
indicates appropriate British standards. The main standard for fire alarm
systems is BS5839 pt1:2013[1].
2.2 Sensors
A sensor is generally defined as an input device that provides a usable
output in response to a specific physical quantity input. The physical quantity
input that is to be measured, called the measurand, affects the sensor in a way
that causes a response represented in the output. The output of many modern
sensors is an electrical signal, but alternatively, could be a motion, pressure,
flow, or other usable type of output. Some examples of sensors include a
thermocouple pair, which converts a temperature difference into an electrical
3
output; a pressure sensing diaphragm, which converts a fluid pressure into a
force or position change; and a Linear Variable Differential Transformer
(LVDT), which converts a position into an electrical output [2].
The devices that inform the control system about what is actually
occurring are called sensors (also known as transducers). As an example, the
human body has an amazing sensor system that continually presents our brain
with a reasonably complete picture of the environment whether we need it all
or not. For a control system, the designer must ascertain exactly what
parameters need to be monitored. For example, position, temperature, and
pressure and then specify the sensors and data interface circuitry to do the
job[3].
Classification of sensors is conventionally by the convention principle,
the quantity being measured, the technology used, or the application [4]. Most
sensors work by converting some physical parameter such as temperature or
position into an electrical signal. This is why sensors are also called transducers,
which are devices that convert energy from one form to another. The various
types of sensors are the position sensors, angular velocity sensors, proximity
sensors, load sensors, pressure sensors, flow Sensors, liquid-level sensors,
vision sensors, temperature sensors, etc [3].
2.2.1 Smart and intelligent sensors
Modern definition of smart or intelligent sensors can be formulated now
by the following way: Smart sensor is an electronic device, including sensing
element, interfacing, signal processing and one or several intelligence functions
as self-testing, self-identification, self-validation or self-adaptation. The key
word in this definition is intelligence. The self-adaptation is relatively new
function of smart sensors. Novel designed self-adaptation smart sensor systems
are based on so-called adaptive algorithms, which were used at the first time in
various digital measuring systems [5].
Strong growth expected for sensors based on Microelectromechanical
system technologies (MEMS), smart sensors and sensors with bus capabilities.
4
Smart sensors’ capability to have more intelligence built into them continues to
drive their application in automotive, aerospace and defense, industrial,
medical, and most recently – homeland security applications. Proprietary
algorithms customized for specific applications analyze sensor data on key
parameters to optimize machining, processing, and other component product or
process quality [5]. Intelligent wireless sensor-based controls have drawn
industry attention on account of reduced costs, better power management, ease
in maintenance, and effortless deployment in remote and hard-to-reach areas.
They have been successfully deployed in many industrial applications such as
maintenance, monitoring, control, security, etc [6].
Because of semiconductor technologies and its Moore’s law along with
the MEMS technology, sensors are becoming more cost effective, smaller, less
power hungry, with more embedded features. The sensors not only provide
digital data but can also provide the expected information. For instance,
functions like portrait/landscape, specific tap and free fall detections can be left
to the sensor due to its capability to detect such simple information with values
preset by the device manufacturer [7].
2.2.2 Temperature sensors
Temperature is defined as a specific degree of hotness or coldness as
referenced to a specific scale. It can also be defined as the amount of heat energy
in an object or system. Heat energy is directly related to molecular energy
(vibration, friction and oscillation of particles within a molecule): the higher
the heat energy, the greater the molecular energy. Temperature sensors detect a
change in a physical parameter such as resistance or output voltage that
corresponds to a temperature change [8].
Temperature sensors give an output proportional to temperature. Most
temperature sensors have a positive temperature coefficient (desirable), which
means that the sensor output goes up as the temperature goes up, but some
sensors have a negative temperature coefficient, which means that the output
goes down as the temperature goes up. Many control systems require
5
temperature sensors, if only to know how much to compensate other sensors
that are temperature-dependent. Some common types are discussed next.
➢ Bimetallic temperature sensors: The bimetallic temperature sensor
consists of a bimetallic strip wound into a spiral. The bimetallic strip is a
laminate of two metals with different coefficients of thermal expansion. As the
temperature rises, the metal on the inside expands more than the metal on the
outside, and the spiral tends to straighten out. These sensors are typically used
for on-off control as in a household thermostat where a mercury switch is
rocked from on to off.
➢ Thermocouples: The thermocouple was developed over 100 years ago
and still enjoys wide use, particularly in high-temperature situations. The
thermocouple is based on the See beck effect, a phenomenon whereby a voltage
that is proportional to temperature can be produced from a circuit consisting of
two dissimilar metal wires.
➢ Resistance temperature detectors: The Resistance Temperature Detector
(RTD) is a temperature sensor based on the fact that metals increase in
resistance as temperature rises. RTDs have the advantage of being very accurate
and stable (characteristics do not change over time). The disadvantages are low
sensitivity (small change in resistance per degree), relatively slow response
time to temperature changes, and high cost.
➢ Thermistors: A thermistor is a two-terminal device that changes
resistance with temperature. Thermistors are made of oxide-based
semiconductor materials and come in a variety of sizes and shapes. Thermistors
are nonlinear; therefore, they are not usually used to get an accurate temperature
reading but to indicate temperature changes, for example, overheating. Also,
most thermistors have a negative temperature coefficient, which means the
resistance decreases as temperature increases.
➢ Integrated-circuit temperature sensors: Integrated circuit (IC)
temperature sensors come in various configurations. A common example is the
6
LM34 and LM35 series. The LM34 produces an output voltage that is
proportional to Fahrenheit temperature, and the LM35 produces an output that
is proportional to Celsius temperature. Notice that it has three active terminals:
supply voltage (Vs), ground, and Vout. The output voltage of the LM35 is
directly proportional to °C, that is, Vout = 10mV/°C This equation states that
for each 1° increase in temperature, the output voltage increases by 10mV. If
only positive temperatures need to be measured, then the simple circuit shown
in the spec sheet (bottom middle of datasheet) can be used. If positive and
negative temperatures must be measured, then the circuit on the bottom right
can be used, which requires a positive and negative supply voltage. The LM35
is a convenient IC to work with because the output voltage is in degrees Celsius.
Some ICs, such as the LM135, provide an output that is in degrees kelvin. One
degree of kelvin or Celsius represents the same interval of temperature, but the
Kelvin scale starts at absolute zero temperature, which is 273°C below freezing.
There is also an absolute zero temperature scale for Fahrenheit degrees, called
the Rankine scale. 2.2.3 Smoke detectors
Smoke detectors operate on two main principles: ionization detectors
which will detect the ionized air from a fire even when there is little or no visible
smoke, and the optical type, which is design to detect smoke which is present
even when there is little or no rise in temperature. In general, the ionization
types are used industrially and the optical types in domestic uses. The ionization
type of detector uses a radioactive source, usually americium241, with a low
activity level, typically 0.8µCi [4].
The gap between the source plate and the electrode is normally
conducting due to the emission of alpha particles (helium ions) by the
americium. The ion current is very small, of the order of 10pA, so that any
additional insulation leakage would be substantial in comparison. The
acceptable level of insulation leakage is of the order of 0.5pA. This implies that
the insulators must not be touched, and if the ionization chamber has to be
replaced, utmost care must be taken to avoid any contamination of the
7
insulation by, for example, solder flux. In the presence of smoke from a fire,
particles entering the ionization chamber will be struck by the alpha particles,
and the alpha particles will cling to the much larger particles of smoke. Because
the charged units are now much larger, they cannot travel so quickly in air, and
the current is reduced. By detecting the reduction in current, the detector can be
made to activate an alarm.
➢ Ionization smoke sensor: Ionization smoke sensor contains a small
amount of radioactive material, americium embedded in a gold foil matrix
within an ionization chamber. The matrix is made by rolling gold and
americium oxide ingots together to form a foil approximately one micrometer
thick. This thin gold-americium foil is then sandwiched between a thicker
(~0.25 millimeter) silver backing and a 2 micron thick palladium laminate. This
is thick enough to completely retain the radioactive material, but thin enough
to allow the alpha particles to pass.
The ionization chamber as shown in Figure 2.1 is basically two metal
plates a small distance apart. One of the plates carries a positive charge, the
other a negative charge. Between the two plates, air molecules-made up mostly
of oxygen and nitrogen atoms-are ionized when electrons are kicked out of the
molecules by alpha particles from the radioactive material (alpha particles are
big and heavy compared to electrons). The result is oxygen and nitrogen atoms
that are positively charged because they are short one electron; the free
electrons are negatively charged.
8
Figure 2.1: The ionization chamber
The Figure 2.2 illustrates how ionization technology works. The positive
atoms flow toward the negative plate, as the negative electrons flow toward the
positive plate. The movement of the electrons registers as a small but steady
flow of current. When smoke enters the ionization chamber, the current is
disrupted as the smoke particles attach to the charged ions and restore them to
a neutral electrical state. This reduces the flow of electricity between the two
plates in the ionization chamber. When the electric current drops below a certain
threshold, the sensor sends a signal telling there is a smoke.
In the smoke-free chamber, positive and negative ions create a small
current as they migrate to charged plates. Smoke particles and combustion
gases interact with the ions generated by the alpha particles, restoring them to
their neutral electronic state and decreasing the electrical current passing
through the cell Figure 2.2. As fewer ions are available to migrate to the plates,
the disrupted current causes the smoke sensor triggers the microcontroller [9].
11
parallel. The processing of bits in the microprocessor is also in parallel. The
busses can thus be viewed as data highways. The width of a bus is the number
of signal lines that constitute the bus.
The figure shows for simplicity three busses for distinct functions. Over
the address bus, the microprocessor transmits the address of that Input Output
(I/O) device or memory locations which it desires to access. This address is
received by all the devices connected to the processor, but only the device
which has been addressed responds. The data bus is used by the microprocessor
to send and receive data to and from different devices (I/O and memory)
including instructions stored in memory. Obviously the address bus is
unidirectional and the data bus is bi-directional. The control bus is used for
transmitting and receiving control signals between the microprocessor and
various devices in the system.
2.3.2 Arithmetic Logic Unit
The Arithmetic Logic Unit (ALU) is a combinational network that
performs arithmetic and logical operations on the data.
2.3.3 Internal registers
A number of registers are normally included in the microprocessor. These
are used for temporary storage of data, instructions and addresses during
execution of a program. Those in the Intel microprocessor 8085 microprocessor
are typical and are described below:
(i) Accumulator (Acc) or result register: This is an 8-bit register used in
various arithmetic and logical operations. Out of the two operands to be
operated upon, one comes from accumulator (Acc), whilst the other one may
be in another internal register or may be brought in by the data bus from the
main memory. Upon completion of the arithmetic/logical operation, the result
is placed in the accumulator (replacing the earlier operand). Because of the later
function, this register is also called as result register.
(ii) General purpose registers or scratch pad memory: There are six general
purpose 8-bit registers that can be used by the programmer for a variety of
12
purposes. These registers, labelled as B, C, D, E, H and L, can be used
individually (e.g.,when operation on 8-bit data is desired) or in pairs (e.g., when
a 16-bit address is to be stored). Only B-C, D-E and H-L pairs are allowed.
(iii) Instruction Register (IR): This 8-bit register stores the next instruction to
be executed. At the proper time this stored word (instruction) is fed to an
instruction decoder which decodes it and supplied appropriate signals to the
control unit. When the execution has been accomplished the new word in the
instruction register is processed.
(iv) Program Counter (PC): This is a 16-bit register which holds the address
of the next instruction that has to be fetched from the main memory and loaded
into the instruction register. The program controlling the operation is stored in
the main memory and instructions are retrieved from this memory normally in
order. Therefore, normally the address contained in the PC is incremented after
each instruction is fetched. However, certain classes of instruction can modify
the PC so that the programmer can provide for branching away from the normal
program flow. Examples are instructions in the “jump” and ‘call subroutine’
groups.
(v) Stack Pointer (SP): This is also a 16-bit register and is used by the
programmer to maintain a stack in the memory while using subroutines.
(vi) Status register or condition flags: A status register consisting of a few
flip-flops, called as condition flags (in 8085 the number of flags is five) is used
to provide indication of certain conditions that arise during arithmetic and
logical operations. These are:
‘zero’ Flag is set if result of instruction is 0.
‘sign’ Set if Most Significant Bit (MSB) of result is 1.
‘parity’ Set if result has even parity.
‘carry’ Set if carry or borrow resulted.
‘auxiliary carry’ Set if instruction caused a carry out of bit 3 and into bit
4 of the resulting value.
13
(vii) Dedicated registers: Several other registers are incorporated in the
microprocessor for its internal operation. They cannot be accessed by the
programmer and hence do not concern much a microprocessor user.
2.3.4 Instruction decoder and control unit
It decodes each instruction and under the supervision of a clock controls
the external and internal units ensuring correct logical operation of the
system[10].
2.4 Microcontroller
A microcontroller is a single-chip computer. Micro suggests that the
device is small, and controller suggests that it is used in control applications.
Another term for microcontroller is embedded controller, since most of the
microcontrollers are built into or embedded in the devices they control [11]. A
microcontroller is a computer with most of the necessary support chips
onboard. All computers have several things in common, namely:
1- A Central Processing Unit (CPU) that ‘executes’ programs.
2- Some Random Access Memory (RAM) where it can store data that is
variable.
3- Some Read Only Memory (ROM) where programs to be executed can
be stored.
4- I/O devices that enable communication to be established with the outside
world i.e. connection to devices such as keyboard, mouse, monitors and
other peripherals.
There are a number of other common characteristics that define
microcontrollers. If a computer matches a majority of these characteristics, then
it can be classified as a ‘microcontroller’.
2.4.1 Microcontroller features
Microcontrollers from different manufacturers have different
architectures and different capabilities. Some may suit to a particular
14
application while some others may be totally unsuitable. The hardware features
of microcontrollers in general are described below.
15
termination of one or more activities. All PIC microcontrollers are equipped
with a WDT.
➢ Interrupts: Interrupts are a very important concept in microcontrollers.
An interrupt causes a microcontroller to respond to external and internal (e.g.
timer) events very quickly. When an interrupt occurs the microcontroller leaves
its normal flow of execution and jumps directly to the Interrupt Service Routine
(ISR). The source of an interrupt can either be internal or external. Internal
interrupts are usually generated by the built-in timer circuits when the timer
count reaches a certain value. External interrupts are generated by the devices
connected external to the microcontroller and these interrupts are
asynchronous, i.e. it is not known when an external interrupt will be generated.
An example is the Analogue-to-Digital (A/D) conversion complete interrupt,
which is generated when a conversion is completed.
➢ Analogue-to-digital converter: Some microcontrollers are equipped with
A/D converter circuits. Usually these converters are 8-bits, but some
microcontrollers have 10- or even 12-bit converters. Some microcontrollers
have multiple A/D channels (e.g. PIC16F877 is equipped with eight A/D
channels). A/D converters usually generate interrupts when a conversion is
complete so that the user program can read the converted data very quickly.
A/D converters are very useful in control and monitoring applications since
most sensors produce analogue output voltages.
➢ Serial input-output: Some microcontrollers contain hardware to
implement serial asynchronous communications interface. The baud rate and
the data format can usually be selected in software by the programmer. The
built-in timer circuits are usually used to generate an accurate baud rate. If serial
I/O hardware is not provided, it is easy to develop software to implement serial
data transfer using any I/O pin of a microcontroller. Some microcontrollers
incorporate Serial Peripheral Interface (SPI), Integrated Interconnect (I2C), or
Controller Area Network (CAN) bus interfaces. These enable a microcontroller
to interface to other compatible devices easily, usually over a bus structure.
16
➢ In-circuit programming: In microcontroller development cycle, a
microcontroller is normally removed from its socket and then programmed
using a programmer device. The programmed chip is then re-inserted into its
socket, ready for testing. This is usually very tedious work, especially during
the development of complex software projects. In-circuit programming enables
a microcontroller to be programmed while the chip is in the applications circuit,
i.e. there is no need to remove the chip for programming. This feature speeds
up the program development cycle considerably.
➢ Electrically Erasable Programmable ROM (EEPROM): Data memory
EEPROM type memory is also very common in many microcontrollers. The
programmer can store non-volatile data in such memory and can also change
this data whenever required. For example, if the microcontroller is used to
measure the temperature, the maximum and minimum values during a period
can be stored in an EEPROM type memory. Some microcontroller types
provide between 64 and 256 bytes of EEPROM data memories, while some
others do not have any such memories.
➢ Pulse Width Modulation (PWM) output: Some microcontrollers provide
PWM outputs which can be used in some electronic applications. One such
application is to provide an effective analog output from a microcontroller by
varying the duty cycle of the PWM output. It is possible to modify the period
or the duty cycle of a PWM output by loading the appropriate registers [12].
2.4.2 Microcontroller architectures
Basically, two types of architectures are used in microcontrollers: Von
Neumann architecture and Harvard architecture. Von Neumann architecture is
used by a very large percentage of microcontrollers and here all memory space
is on the same bus and instruction and data are treated identically. In the
Harvard architecture (used by the PIC microcontrollers), code and data storage
are on separate buses and this allows code and data to be fetched
simultaneously, resulting in a more efficient implementation.
17
2.4.3 Microcontroller types
The predominant families of microcontrollers are 8-bit types since this
word size has proved popular for the vast majority of tasks the devices have
been required to perform. The single byte word is regarded as sufficient for
most purposes and has the advantage of easily interfacing with the variety of
IC memories and logic circuitry currently available. The serial acronym for the
American Standard Code for Information Interchange (ASCII) data is also byte
sized making data communications easily compatible with the microcontroller
devices. Because the type of application for the microcontroller may vary
enormously most manufacturers provide a family of devices, each member of
the family capable of fitting neatly into the manufacturer’s requirements. This
avoids the use of a common device for all applications where some elements of
the device would not be used; such a device would be complex and hence
expensive.
The microcontroller family would have a common instruction subset but
family members differ in the amount, and type, of memory, timer facility, port
options, etc. possessed, thus producing cost-effective devices suitable for
particular manufacturing requirements. Memory expansion is possible with
offchip RAM and/or ROM; for some family members there is no on-chip ROM,
or the ROM is either Electrically Programmable ROM (EPROM) or EEPROM
known as flash EEPROM which allows for the program to be erased and
rewritten many times. Additional on-chip facilities could include Analogue to
Digital Conversion (ADC), Digital-to-Analogue Conversion (DAC) and
analogue comparators. Some family members include versions with lower pin
count for more basic applications to minimize costs [12].
2.4.4 Comparison between microcontroller and microprocessor
Microcontrollers are general purpose microprocessors which have
additional parts that allow them to control external devices. Basically, a
microcontroller executes a user program which is loaded in its program
memory. Under the control of this program, data is received from external
18
devices (inputs), manipulated and then data is sent to external output devices.
A microcontroller is a very powerful tool that allows a designer to create
sophisticated I/O data manipulation algorithms.
22
Chapter Three
System Hardware and Software Considerations
3.1 System Description
The fire fighting system consists of: Detector group which can be a smoke,
flame or heat detector, input keys that allow the user to do different actions,
microcontroller Atmega 32, display, a group of LEDs, ULN2003A driver, and
the output relays.
3.2 System Hardware Considerations
The main hardware components used to build this system are shown in Figure
3.1.
23
Figure 3.2: Atmega32
➢ Atmega32 features
• High-performance, low-power Atmel® AVR® 8-bit microcontroller
• Advanced RISC architecture
– 131Powerful instructions – Most single-clock cycle execution
– 32 x 8 general purpose working registers
– Fully static operation
– Up to 16MIPS throughput at 16MHz
– On-chip 2-cycle multiplier
• High endurance non-volatile memory segments
– 32Kbytes of in-system self-programmable flash memory
– 1024bytes EEPROM
– 2Kbyte internal SRAM
– Write/Erase cycles: 10,000 Flash/100,000 EEPROM
– Data retention: 20 years at 85°C/100 years at 25°C (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
24
– 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.
– Programmable serial USART.
– Master/Slave SPI serial interface.
– Programmable watchdog timer, 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.
25
• Operating voltages:
– 2.7V-5.5V for ATmega32L.
– 4.5V-5.5V for ATmega32.
• Speed grades:
– 0-8MHz for ATmega32L.
– 0-16MHz for ATmega32.
• Power consumption at 1MHz, 3V, 25°C
–Active: 1.1mA
–Idle mode: 0.35mA
–Power-down mode: < 1μA ➢ Pin descriptions:
- VCC: Digital supply voltage.
- GND: 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 pullup resistors are activated. The port A pins are
tri-stated when a reset condition becomes active, even if the clock is not
running. In the current system we config a part from port A as analog
inputs (PA.0 to PA.3) to receive the signals from the different four zoon’s.
The internal A/D converts the received signal to binary system and
divided with a suitable number to achieve the real value of the signal.
PA.4 to PA.7 used as digital output.
- 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
26
source current if the pullup resistors are activated. The port B pins are
tri-stated when a reset condition becomes active, even if the clock is not
running. PB.0 to PB.6 used as a digital input and receives to input keys
status, port B.7 configured as digital output to Light Emitting Diodes
(LED).
- 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 pullup 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), PC3(TMS) and PC2(TCK) will be activated even if a reset
occurs. The TD0 pin is tri-stated unless TAP states that shift out data are
entered. This port is used with the LCD pins PC.4 to PC.7 to transfer data
to the LCD, PC.2 and PC.3 as enable and reset signals at LCD. Port C.0
and port C.1 are configured as digital outputs to LEDs.
- Port D (PD7..PD0): 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 pullup resistors are activated. The port D pins are
tri-stated when a reset condition becomes active, even if the clock is not
running. PD.1 is used as a serial transmitter to send data to GSM module,
The rest of this port is configured as a digital outputs to LEDs that
preview the zoon’s status two LEDs for each zoon represent the fault and
alarm status.
- RESET: A low level on this pin for longer than the minimum pulse
length will generate a reset, even if the clock is not running. Shorter
pulses are not guaranteed to generate a reset.
27
- 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 A/D
converter is not used. If the A/D converter 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.
3.2.2 SIM900
SIM900 offers the benefit of sending short message to the user
inform him with any change at his building, The positive edge of the
signal is used to obtained this function that any change from zero to
one at zoon’s alarm or zoon’s faults signals will send automatically in
a short massage, Also if two pair of zoon’s activate the counter of the
actuator and the actuator status.
The SIM900 is a complete quad-band GSM/General Packet Radio
Service (GPRS) solution in a Surface-Mount Device (SMT) module which can
be embedded in the customer applications. Featuring an industry-standard
interface, the SIM900 delivers GSM/GPRS 850/900/1800/1900MHz
performance for voice, SMS, data, and fax in a small form factor and with low
power consumption. With a tiny configuration of 24mmx24mmx3mm. SIM900
can fit almost all the space requirements in your M2M application, especially
for slim and compact demand of design. Figure 3.3 shows the SIM900. The
general features of SIM900 are:
- Quad-Band 850/ 900/ 1800/ 1900MHz.
- GPRS multi-slot class 10/8.
- GPRS mobile station class B.
- Compliant to GSM phase 2/2+
Class 4 (2W @850/ 900MHz).
28
Class 1 (1W @ 1800/1900MHz).
- Dimensions: 24*24*3mm.
- Weight: 3.4g.
- Control via AT commands (GSM 07.07, 07.05 and SIMCOM
enhanced AT Commands).
29
trimming and calibration at the wafer level. The low output impedance, linear
output, and precise inherent calibration of the LM35 make interfacing to
readout or control circuitry especially easy. The device is used with single
power supplies, or with plus and minus supplies. As the LM35 draws only 60μA
from the supply, it has very low self-heating of less than 0.1°C in still air. The
LM35 is rated to operate over a −55°C to +150°C temperature range, while the
LM35C is rated for a −40°C to +110°C range (−10° with improved accuracy).
The LM35 series is available packaged in hermetic TO transistor packages,
while the LM35C, LM35CA, and LM35D are also available in the plastic TO-
92 transistor package. The LM35D is also available in an 8-lead surface-mount
small outline package and a plastic TO-220 package. The main features of
LM35 are:
- Calibrated directly in ° Celsius (Centigrade).
- Linear + 10 mV/°C scale factor .
- 0.5°C ensured accuracy (at +25°C).
- Rated for full −55°C to +150°C range. - Suitable for remote applications.
- Low cost due to wafer-level trimming.
- Operates from 4 to 30V.
- Less than 60μA current drain.
- Low self-heating, 0.08°C in still air.
- Nonlinearity only ±¼°C typical.
- Low impedance output, 0.1Ω for 1mA Load.
3.2.4 Liquid crystal display
LCD screen is an electronic display module and find a wide range of
applications. A 16x2 LCD is a very basic module and is very common in various
devices and circuits. They are preferred over seven segment displays. There are
many advantages when compared to seven segment displays. They are: LCDs
can display characters, numbers and even graphics [12]. A 16x2 LCD means it
can display 16 characters per line and there are two such lines. In this LCD each
30
character is displayed in 5x7 pixel matrix. This LCD has two registers, namely,
command and data.
The command register stores the command instructions given to the LCD.
A command is an instruction given to LCD to do a predefined task like
initializing it, clearing its screen, setting the cursor position, controlling display
etc. The data register stores the data to be displayed on the LCD. The data is the
ASCII value of the character to be displayed on the LCD. The reasons being:
LCDs are economical; easily programmable; have no limitation of displaying
special and even custom characters (unlike in seven segments), animations and
so on.
32
3.3 System Software Consideration
BASCOM language is used to write the software program and that
language used because it is simple with enough capabilities to achieve the all
condition and cases required. The Proteus program used to simulate the
performance. 3.3.1 System code
The system program is written using BASCOM language is shown in
Appendix.
3.3.2 System simulation
The system is build up in the Proteus program as shown in Figure 3.7.
The overall circuit shown in Figure 3.7 contains the input bush bottoms, sensor
inputs LM35 (temperature sensors),
Code c
/*
* Project: Fire Alarm System (Dual Buzzer Edition)
* MCU: ATmega32
* Frequency: 8.000000 MHz
* Description:
* - Fire Buzzer on PA6 (Fast Beep)
* - Fault Buzzer on PA7 (Slow Beep)
* - No LCD
* - Relays on PC0, PC1
*/
34
// ================= ================= تعريف المنافذ
// Outputs (Relays)
#define RELAY_Z34 PORTC.F0 // PC0 -
#define RELAY_Z12 PORTC.F1 // PC1 -
// المتغيرات
short Fire_Alarm_Active = 0;
short Sensor_Fault_Active = 0;
short Buzzer_Muted = 0;
void System_Init() {
// PORTA: PA0-PA3 (Input ADC), PA4-PA7 (Outputs)
DDRA = 0xF0;
PORTA = 0x10;
35
// PORTB: Inputs (PB0-PB6), Output (PB7 for Zone4 Alarm)
DDRB = 0x80;
PORTB = 0x7F; //
ADC_Init();
}
void Read_Temperatures() {
for(i=0; i<4; i++) {
temp_adc[i] = ADC_Read(i);
// المعادلة: (ADC * 500) / 1024
temp_c[i] = (unsigned long)temp_adc[i] * 500 / 1024;
}
}
while(1) {
Read_Temperatures();
Fire_Alarm_Active = 0;
Sensor_Fault_Active = 0;
PORTD = 0x00;
PORTB.F7 = 0;
36
for(i=0; i<4; i++) {
// فحص الحريق
if(temp_c[i] >= THRESHOLD_ALARM) {
Fire_Alarm_Active = 1;
if (i < 3) PORTD |= (1 << (i + 5)); // Z1, Z2, Z3
else PORTB.F7 = 1; // Z4
}
// فحص العطل
else if(temp_c[i] < THRESHOLD_FAULT) {
Sensor_Fault_Active = 1;
if (i == 0) PORTD.F0 = 1;
else if (i == 1) PORTD.F2 = 1;
else if (i == 2) PORTD.F3 = 1;
else if (i == 3) PORTD.F4 = 1;
}
}
(Healthy) ---
if (Fire_Alarm_Active || Sensor_Fault_Active) {
LED_HEALTHY = 0
} else {
LED_HEALTHY = 1; /
}
if (Buzzer_Muted) {
BUZZER_FIRE = 0;
BUZZER_FAULT = 0;
Delay_ms(100); /
}
else if (Fire_Alarm_Active) {
BUZZER_FAULT = 0;
BUZZER_FIRE = 1;
LED_ACT_SND = 1;
Delay_ms(100); /
37
BUZZER_FIRE = 0; //
LED_ACT_SND = 0;
Delay_ms(100); //
}
else if (Sensor_Fault_Active) {
// ===
//
BUZZER_FIRE = 0; //
BUZZER_FAULT = 1; //
Delay_ms(500); //
BUZZER_FAULT = 0; //
Delay_ms(500); //
}
else {
BUZZER_FIRE = 0;
BUZZER_FAULT = 0;
Delay_ms(100);
}
// تشغيل يدويZ12
if (SW_UP1 == 0) RELAY_Z12 = 1;
// تشغيل يدويZ34
if (SW_DN3 == 0) RELAY_Z34 = 1;
// ( زر كتم الصوتACK)
if (SW_ACK == 0) {
Delay_ms(20); // Debounce
if (SW_ACK == 0) Buzzer_Muted = 1;
}
assmbely_code
.include "[Link]"
; ================= REGISTER DEFINITIONS =================
.def tempL = r16
.def tempH = r17
.def zone = r18
.def flags = r19
.def d1 = r20
.def d2 = r21
.equ THRESHOLD_ALARM = 60
.equ THRESHOLD_FAULT = 5
.org 0x0000
39
rjmp RESET
RESET:
; Stack
ldi r16, high(RAMEND)
out SPH, r16
ldi r16, low(RAMEND)
out SPL, r16
; PORTA
ldi r16, 0b11110000
out DDRA, r16
ldi r16, 0b00010000
out PORTA, r16
; PORTB
ldi r16, 0b10000000
out DDRB, r16
ldi r16, 0b01111111
out PORTB, r16
; PORTC
ldi r16, 0b00000011
out DDRC, r16
clr r16
out PORTC, r16
; PORTD
ldi r16, 0xFF
out DDRD, r16
clr r16
out PORTD, r16
; ADC
ldi r16, (1<<REFS0)
out ADMUX, r16
ldi r16, (1<<ADEN)|(1<<ADPS2)|(1<<ADPS1)
out ADCSRA, r16
clr flags
40
MAIN:
clr zone
clr flags
ZONE_LOOP:
cpi zone, 4
breq MAIN
; Select ADC channel
ldi r16, (1<<REFS0)
or r16, zone
out ADMUX, r16
sbi ADCSRA, ADSC
WAIT_ADC:
sbis ADCSRA, ADIF
rjmp WAIT_ADC
sbi ADCSRA, ADIF
in tempL, ADCL
in tempH, ADCH
; Fake temperature using high byte
mov r16, tempH
cpi r16, THRESHOLD_ALARM
brlo NEXT_ZONE
sbr flags, (1<<0)
NEXT_ZONE:
inc zone
rjmp ZONE_LOOP
41
]]
]]]]
]]]]]
42
Chapter Five
Conclusion and Recommendations
5.1 Conclusion
In this study a fire fighting system is build up using Atmega32
microcontroller. The system is tested and performs successfully and
achieved all required operation conditions. In addition to that there is
interactive with the system through SMS notification.
5.2 Recommendations
- Upgrade the system to be remote controlled.
- Design farther types of fire detectors.
- System development and adaptation for use as integrated
systems.
43
References
[1] Zhang, L. and Wang, “Design and Implementation of Automatic Fire Alarm
System Based on Wireless Sensor, Networks”. Proceedings of the
International
Symposium on Information Processing (ISIP’09), Huangshan, P.410-413,
August 2009.
[2] David S. Nyce, “Linear Position Sensors: Theory and Application”, John
Wiley & Sons, Inc., 2004.
[3] Kilian, “Modern Control Technology: Components and Systems”, 2nd
Edition, 2000.
[4] Ian R. Sinclair, “Sensors and transducers, third edition”, 2001.
[5] Sergey Y. Yurish, “Sensors: Smart vs. Intelligent”, International Frequency
Sensor Association, Sensors & Transducers Journal, 2007.
[6] Harish Ramamurthy, Asad M. Madni, “Smart Sensor Platform for Industrial
Monitoring and Control”, 2005.
[7] Stéphane Gervais-Ducouret, “Next Smart Sensors Generation”, Freescale
Semiconductor 134 Av. Eisenhower, 31023 Toulouse, France 2011.
[8] Jon S. Wilson, “Sensor Technology Handbook”, Elsevier Inc., 2005.
[9] Richard Wotiz, “Ionization Detectors”, Circuit Cellar Inc., November 2011
[10] A.P. Godse, “Microprocessor and Microcontroller Systems”, Technical
Publications Pune, 2007.
[11] Dogan Ibrahim, “Advanced PIC Microcontroller Projects in C – From
USB to RTOS with the PIC18F Series”, 2008.
[12] Dogan Ibrahim, “Microcontroller based temperature monitoring and
control”, Elsevier Science & Technology Books, September 2002.
[13] Kenneth J. Ayala, “The 8051 Microcontroller Architecture,
Programming and Application”, Western Carolina University, 1991.
44
45