You are on page 1of 55

ABSTRACT

Gas leakages and fire outbreaks both spread widely and lead to even greater loss of life and
property if proper action is not taken on time. So here we propose a system that detects gas as
well as fire outbreaks and alert us. Accordingly so that proper action may be taken to control
it. For this system we use a gas sensor along with a FLAME sensor interfaced to the
microcontroller. The microcontroller is also connected to an LCD screen and a buzzer to
show the alerts. As soon as a fire starts the sensor detects the fire it sends a signal to the
microcontroller, the microcontroller processes the signal and displays the fire alert status on
LCD screen and also sounds the buzzer. Similarly the gas monitor also detects any gas
leakage and alerts.
CHAPTER 1

INTRODUCTION TO EMBEDDED SYSTEMS

1.1 Embedded System

An embedded system is a special-purpose computer system designed to perform one


or a few dedicated functions, sometimes with real-time computing constraints. It is usually
embedded as part of a complete device including hardware and mechanical parts. In contrast,
a general-purpose computer, such as a personal computer, can do many different tasks
depending on programming. Embedded systems have become very important today as they
control many of the common devices we use.

Since the embedded system is dedicated to specific tasks, design engineers can
optimize it, reducing the size and cost of the product, or increasing the reliability and
performance. Some embedded systems are mass-produced, benefiting from economies of
scale.

Physically, embedded systems range from portable devices such as digital watches
and MP3 players, to large stationary installations like traffic lights, factory controllers, or the
systems controlling nuclear power plants. Complexity varies from low, with a single
microcontroller chip, to very high with multiple units, peripherals and networks mounted
inside a large chassis or enclosure.

In general, "embedded system" is not an exactly defined term, as many systems have
some element of programmability. For example, Handheld computers share some elements
with embedded systems — such as the operating systems and microprocessors which power
them — but are not truly embedded systems, because they allow different applications to be
loaded and peripherals to be connected.

An embedded system is some combination of computer hardware and software, either


fixed in capability or programmable, that is specifically designed for a particular kind of
application device. Industrial machines, automobiles, medical equipment, cameras, household
appliances, airplanes, vending machines, and toys (as well as the more obvious cellular phone
and PDA) are among the myriad possible hosts of an embedded system. Embedded systems
that are programmable are provided with a programming interface, and embedded systems
programming is a specialized occupation.

Certain operating systems or language platforms are tailored for the embedded
market, such as Embedded Java and Windows XP Embedded. However, some low-end
consumer products use very inexpensive microprocessors and limited storage, with the
application and operating system both part of a single program. The program is written
permanently into the system's memory in this case, rather than being loaded into RAM
(random access memory), as programs on a personal computer are.

1.2 Applications of Embedded System

We are living in the Embedded World. You are surrounded with many embedded
products and your daily life largely depends on the proper functioning of these gadgets.
Television, Radio, CD player of your living room, Washing Machine or Microwave Oven in
your kitchen, Card readers, Access Controllers, Palm devices of your work space enable you
to do many of your tasks very effectively. Apart from all these, many controllers embedded
in your car take care of car operations between the bumpers and most of the times you tend to
ignore all these controllers.

In recent days, you are showered with variety of information about these embedded
controllers in many places. All kinds of magazines and journals regularly dish out details
about latest technologies, new devices; fast applications which make you believe that your
basic survival is controlled by these embedded products. Now you can agree to the fact that
these embedded products have successfully invaded into our world. You must be wondering
about these embedded controllers or systems. What is this Embedded System?

The computer you use to compose your mails, or create a document or analyze the
database is known as the standard desktop computer. These desktop computers are
manufactured to serve many purposes and applications.

You need to install the relevant software to get the required processing facility. So,
these desktop computers can do many things. In contrast, embedded controllers carryout a
specific work for which they are designed. Most of the time, engineers design these
embedded controllers with a specific goal in mind. So these controllers cannot be used in any
other place.

Theoretically, an embedded controller is a combination of a piece of microprocessor


based hardware and the suitable software to undertake a specific task.

These days designers have many choices in microprocessors/microcontrollers.


Especially, in 8 bit and 32 bit, the available variety really may overwhelm even an
experienced designer. Selecting a right microprocessor may turn out as a most difficult first
step and it is getting complicated as new devices continue to pop-up very often.

In the 8 bit segment, the most popular and used architecture is Intel's 8031. Market
acceptance of this particular family has driven many semiconductor manufacturers to develop
something new based on this particular architecture. Even after 25 years of existence,
semiconductor manufacturers still come out with some kind of device using this 8031 core.

[1] Military and aerospace software applications

From in-orbit embedded systems to jumbo jets to vital battlefield networks, designers of
mission-critical aerospace and defense systems requiring real-time performance, scalability,
and high-availability facilities consistently turn to the LynxOS® RTOS and the LynxOS-178
RTOS for software certification to DO-178B.

Rich in system resources and networking services, LynxOS provides an off-the-shelf


software platform with hard real-time response backed by powerful distributed computing
(CORBA), high reliability, software certification, and long-term support options.

The LynxOS-178 RTOS for software certification, based on the RTCA DO-178B
standard, assists developers in gaining certification for their mission- and safety-critical
systems. Real-time systems programmers get a boost with LynuxWorks' DO-178B RTOS
training courses.

LynxOS-178 is the first DO-178B and EUROCAE/ED-12B certifiable, POSIX®-


compatible RTOS solution.
[2] Communications applications

"Five-nines" availability, CompactPCI hot swap support, and hard real-time response—
LynxOS delivers on these key requirements and more for today's carrier-class systems.
Scalable kernel configurations, distributed computing capabilities, integrated
communications stacks, and fault-management facilities make LynxOS the ideal choice for
companies looking for a single operating system for all embedded telecommunications
applications—from complex central controllers to simple line/trunk cards.

LynuxWorks Jumpstart for Communications package enables OEMs to rapidly develop


mission-critical communications equipment, with pre-integrated, state-of-the-art, data
networking and porting software components—including source code for easy customization.

The Lynx Certifiable Stack (LCS) is a secure TCP/IP protocol stack designed especially
for applications where standards certification is required.

[3] Electronics applications and consumer devices

As the number of powerful embedded processors in consumer devices continues to rise,


the BlueCat® Linux® operating system provides a highly reliable and royalty-free option for
systems designers.

And as the wireless appliance revolution rolls on, web-enabled navigation systems,
radios, personal communication devices, phones and PDAs all benefit from the cost-effective
dependability, proven stability and full product life-cycle support opportunities associated
with BlueCat embedded Linux. BlueCat has teamed up with industry leaders to make it easier
to build Linux mobile phones with Java integration.

For makers of low-cost consumer electronic devices who wish to integrate the LynxOS
real-time operating system into their products, we offer special MSRP-based pricing to
reduce royalty fees to a negligible portion of the device's MSRP.
[4] Industrial automation and process control software

Designers of industrial and process control systems know from experience that
LynuxWorks operating systems provide the security and reliability that their industrial
applications require.

From ISO 9001 certification to fault-tolerance, POSIX conformance, secure partitioning


and high availability, we've got it all. Take advantage of our 20 years of experience.

1.3 Microcontroller Versus Microprocessor

What is the difference between a Microprocessor and Microcontroller? By


microprocessor is meant the general purpose Microprocessors such as Intel's X86 family
(8086, 80286, 80386, 80486, and the Pentium) or Motorola's 680X0 family (68000, 68010,
68020, 68030, 68040, etc). These microprocessors contain no RAM, no ROM, and no I/O
ports on the chip itself. For this reason, they are commonly referred to as general-purpose
Microprocessors.

A system designer using a general-purpose microprocessor such as the Pentium or the


68040 must add RAM, ROM, I/O ports, and timers externally to make them functional.
Although the addition of external RAM, ROM, and I/O ports makes these systems bulkier
and much more expensive, they have the advantage of versatility such that the designer can
decide on the amount of RAM, ROM and I/O ports needed to fit the task at hand. This is not
the case with Microcontrollers.

A Microcontroller has a CPU (a microprocessor) in addition to a fixed amount of


RAM, ROM, I/O ports, and a timer all on a single chip. In other words, the processor, the
RAM, ROM, I/O ports and the timer are all embedded together on one chip; therefore, the
designer cannot add any external memory, I/O ports, or timer to it. The fixed amount of on-
chip ROM, RAM, and number of I/O ports in Microcontrollers makes them ideal for many
applications in which cost and space are critical.

In many applications, for example a TV remote control, there is no need for the
computing power of a 486 or even an 8086 microprocessor. These applications most often
require some I/O operations to read signals and turn on and off certain bits.
1.4 Microcontrollers For Embedded Systems

In the Literature discussing microprocessors, we often see the term Embedded


System. Microprocessors and Microcontrollers are widely used in embedded system
products. An embedded system product uses a microprocessor (or Microcontroller) to do one
task only. A printer is an example of embedded system since the processor inside it performs
one task only; namely getting the data and printing it. Contrast this with a Pentium based PC.
A PC can be used for any number of applications such as word processor, print-server, bank
teller terminal, Video game, network server, or Internet terminal. Software for a variety of
applications can be loaded and run. Of course the reason a pc can perform myriad tasks is that
it has RAM memory and an operating system that loads the application software into RAM
memory and lets the CPU run it.

In an Embedded system, there is only one application software that is typically burned
into ROM. An x86 PC contains or is connected to various embedded products such as
keyboard, printer, modem, disk controller, sound card, CD-ROM drives, mouse, and so on.
Each one of these peripherals has a Microcontroller inside it that performs only one task. For
example, inside every mouse there is a Microcontroller to perform the task of finding the
mouse position and sending it to the PC. Table 1-1 lists some embedded products.
CHAPTER 2: PIC MICROCONTROLLERS

2.1 Microcontroller

Micro controller is a true computer on a chip the design incorporates all of the features
found in a microprocessor CPU: arithmetic and logic unit, stack pointer, program counter and
registers. It has also had added additional features like RAM, ROM, serial I/O, counters and
clock circuit.

Like the microprocessor, a microcontroller is a general purpose device, but one that is
meant to read data, perform limited calculations on that data and control it’s environment
based on those calculations. The prime use of a microcontroller is to control the operation of
a machine using a fixed program that is stored in ROM and that does not change over the
lifetime of the system.

The design approach of a microcontroller uses a more limited set of single byte and
double byte instructions that are used to move code and data from internal memory to ALU.
Many instructions are coupled with pins on the IC package; the pins are capable of having
several different functions depending on the wishes of the programmer.

The microcontroller is concerned with getting the data from and on to its own pins; the
architecture and instruction set are optimized to handle data in bit and byte size.

2.2 Criteria for choosing a microcontroller

1. The first and foremost criterion for choosing a microcontroller is that it must meet
task at hands efficiently and cost effectively. In analyzing the needs of a
microcontroller based project we must first see whether it is an 8-bit, 16-bit or 32-bit
microcontroller and how best it can handle the computing needs of the task most
effectively. The other considerations in this category are:

(a) Speed: The highest speed that the microcontroller supports\

(b) Packaging: Is it 40-pin DIP or QPF or some other packaging format?

This is important in terms of space, assembling and prototyping the End product.

(c) Power Consumption: This is especially critical for battery-power Products.


(d) The amount of RAM and ROM on chip

(e) The number of I/O pins and timers on the chip.

Cost per unit: This is important in terms of final product in which a microcontroller is used.

2. The second criteria in choosing a microcontroller are how easy it is to develop


products around it. Key considerations include the availability of an assembler,
debugger, a code efficient ‘C’ language compiler, emulator, technical support and
both in house and outside expertise. In many cases third party vendor support for chip
is required.

3. The third criteria in choosing a microcontroller is it readily available in needed


quantities both now and in future. For some designers this is even more important
than first two criteria’s. Currently, of leading 8–bit microcontrollers, the 89C51
family has the largest number of diversified (multiple source) suppliers. By suppliers
meant a producer besides the originator of microcontroller in the case of the 89C51,
which was originated by Intel, several companies are also currently producing the
89C51. Viz: INTEL, PHILIPS, These companies include PHILIPS, SIEMENS, and
DALLAS-SEMICONDUCTOR. It should be noted that Motorola, Zilog and
Microchip Technologies have all dedicated massive resource as to ensure wide and
timely availability of their product since their product is stable, mature and single
sourced. In recent years they also have begun to sell the ASIC library cell of the
microcontroller.

2.3 Introduction

The PIC16F73 CMOS FLASH-based 8-bit microcontroller is upward compatible with the
PIC16C73B/74B/76/77, PIC16F873/874/876/877devices. It features 200 ns instruction
execution, self programming, an ICD, 2 Comparators, 8 channels of 8-bit Analog-to-Digital
(A/D) converter, 2 capture/compare/PWM functions, a synchronous serial port that can be
configured as either 3-wire SPI or 2-wire I2C bus, a USART, and a Parallel Slave Port.

High-Performance RISC CPU

• Only 35 single word instructions to learn


• All single cycle instructions except for program branches which are two-cycle

• Operating speed: DC - 20 MHz clock input

DC - 200 ns instruction cycle

• Up to 8K x 14 words of FLASH Program Memory, Up to 368 x 8 bytes of Data Memory


(RAM)

• Pin out compatible to the PIC16C73B/74B/76/77

• Pin out compatible to the PIC16F873/874/876/877

• Interrupt capability (up to 12 sources)

• Eight level deep hardware stack

• Direct, Indirect and Relative Addressing modes

• Processor read access to program memory

Special Microcontroller Features

• Power-up Timer (PWRT) and oscillator Start-up Timer (OST)

• Watchdog Timer (WDT) with its own on-chip RC oscillator for reliable operation

• Programmable code protection

• Power saving SLEEP mode

• Selectable oscillator options

• In-Circuit Serial Programming (ICSP) via two Pins

Peripheral Features

• Timer0: 8-bit timer/counter with 8-bit prescaler

• Timer1: 16-bit timer/counter with prescaler, can be incremented during SLEEP via

external crystal/clock

• Timer2: 8-bit timer/counter with 8-bit period register, prescaler and postscaler
• Two Capture, Compare, PWM modules

- Capture is 16-bit, max resolution is 12.5 ns

- Compare is 16-bit, max resolution is 200 ns

- PWM max resolution is 10-bit

• 8-bit, up to 8-channel Analog-to-Digital converter

• Synchronous Serial Port (SSP) with SPI (Master mode) and I2C (Slave)

• Universal Synchronous Asynchronous Receiver Transmitter (USART/SCI)

• Parallel Slave Port (PSP), 8-bits wide with external RD, WR and CS controls (40/44-pin

Only)

• Brown-out detection circuitry for Brown-out Reset (BOR)

Analog Comparator module

 2 analog comparators

 Programmable on-chip voltage reference module

 Programmable input multiplexing from device inputs and internal VREF

 Comparator outputs are externally accessible

CMOS Technology:

• Low power, high speed CMOS FLASH technology

• Fully static design

• Wide operating voltage range: 2.0V to 5.5V

• High Sink/Source Current: 25 mA

• Industrial temperature range

• Low power consumption:


- < 2 mA typical @ 5V, 4 MHz

- 20 μA typical @ 3V, 32 kHz

- < 1 μA typical standby current

Following are the major blocks of PIC Microcontroller.

Program memory (FLASH) is used for storing a written program. 


Since memory made in FLASH technology can be programmed and cleared more than once,
it makes this microcontroller suitable for device development. 

EEPROM - data memory that needs to be saved when there is no supply.


It is usually used for storing important data that must not be lost if power supply suddenly
stops. For instance, one such data is an assigned temperature in temperature regulators. If
during a loss of power supply this data was lost, we would have to make the adjustment once
again upon return of supply. Thus our device looses on self-reliance. 

RAM - Data memory used by a program during its execution.


In RAM are stored all inter-results or temporary data during run-time.

PORTS are physical connections between the microcontroller and the outside world.
PIC16F73 has 22 I/O. 

FREE-RUN TIMER is an 8-bit register inside a microcontroller that works independently of


the program. On every fourth clock of the oscillator it increments its value until it reaches the
maximum (255), and then it starts counting over again from zero. As we know the exact
timing between each two increments of the timer contents, timer can be used for measuring
time which is very useful with some devices. 

CENTRAL PROCESSING UNIT has a role of connective element between other blocks in
the microcontroller. It coordinates the work of other blocks and executes the user program.
 

CISC, RISC

It has already been said that PIC16F73 has RISC architecture. This term is often found in
computer literature, and it needs to be explained here in more detail. Harvard architecture is a
newer concept than von-Neumann. It rose out of the need to speed up the work of a
microcontroller. In Harvard architecture, data bus and address bus are separate. Thus a
greater flow of data is possible through the central processing unit, and of course, a greater
speed of work. Separating a program from data memory makes it further possible for
instructions not to have to be 8-bit words. PIC16F73 uses 14 bits for instructions which
allows for all instructions to be one word instructions. It is also typical for Harvard
architecture to have fewer instructions than von-Neumann's, and to have instructions usually
executed in one cycle. 

Microcontrollers with Harvard architecture are also called "RISC microcontrollers". RISC
stands for Reduced Instruction Set Computer. Microcontrollers with von-Neumann's
architecture are called 'CISC microcontrollers'. Title CISC stands for Complex Instruction Set
Computer.

Since PIC16F73 is a RISC microcontroller, that means that it has a reduced set of
instructions, more precisely 35 instructions. (Ex. Intel's and Motorola's microcontrollers have
over hundred instructions) All of these instructions are executed in one cycle except for jump
and branch instructions. According to what its maker says, PIC16F73 usually reaches results
of 2:1 in code compression and 4:1 in speed in relation to other 8-bit microcontrollers in its
class.
Crystal oscillator:

The crystal oscillator speed that can be connected to the PIC microcontroller range
from DC to 20Mhz. Using the CCS C compiler normally 20Mhz oscillator will be used and
the price is very cheap. The 20 MHz crystal oscillator should be connected with about 22pF
capacitor. Please refer to my circuit schematic.

There are 5 input/output ports on PIC microcontroller namely port A, port B, port C,
port D and port E. Each port has different function. Most of them can be used as I/O port. 

Applications

PIC16F73 perfectly fits many uses, from automotive industries and controlling home
appliances to industrial instruments, remote sensors, electrical door locks and safety devices.
It is also ideal for smart cards as well as for battery supplied devices because of its low
consumption.

EEPROM memory makes it easier to apply microcontrollers to devices where permanent


storage of various parameters is needed (codes for transmitters, motor speed, receiver
frequencies, etc.). Low cost, low consumption, easy handling and flexibility make PIC16F73
applicable even in areas where microcontrollers had not previously been considered
(example: timer functions, interface replacement in larger systems, coprocessor applications,
etc.).

In System Programmability of this chip (along with using only two pins in data transfer)
makes possible the flexibility of a product, after assembling and testing have been completed.
This capability can be used to create assembly-line production, to store calibration data
available only after final testing, or it can be used to improve programs on finished products.

Clock / instruction cycle

Clock is microcontroller's main starter, and is obtained from an external component called an


"oscillator". If we want to compare a microcontroller with a time clock, our "clock" would
then be a ticking sound we hear from the time clock. In that case, oscillator could be
compared to a spring that is wound so time clock can run. Also, force used to wind the time
clock can be compared to an electrical supply. 
Clock from the oscillator enters a microcontroller via OSC1 pin where internal circuit of a
microcontroller divides the clock into four even clocks Q1, Q2, Q3, and Q4 which do not
overlap. These four clocks make up one instruction cycle (also called machine cycle) during
which one instruction is executed.

Execution of instruction starts by calling an instruction that is next in string. Instruction is


called from program memory on every Q1 and is written in instruction register on Q4.
Decoding and execution of instruction are done between the next Q1 and Q4 cycles. On the
following diagram we can see the relationship between instruction cycle and clock of the
oscillator (OSC1) as well as that of internal clocks Q1-Q4. Program counter (PC) holds
information about the address of the next instruction.

Pipelining

Instruction cycle
consists of cycles Q1, Q2, Q3 and Q4. Cycles of calling and executing instructions are
connected in such a way that in order to make a call, one instruction cycle is needed, and one
more is needed for decoding and execution. However, due to pipelining, each instruction is
effectively executed in one cycle. If instruction causes a change on program counter, and PC
doesn't point to the following but to some other address (which can be the case with jumps or
with calling subprograms), two cycles are needed for executing an instruction. This is so
because instruction must be processed again, but this time from the right address. Cycle of
calling begins with Q1 clock, by writing into instruction register (IR). Decoding and
executing begins with Q2, Q3 and Q4 clocks.
 

Pin description

PIC16F73 has a total of 28 pins. It is most frequently found in a DIP28 type of case but can
also be found in SMD case which is smaller from a DIP. DIP is an abbreviation for Dual In
Package. SMD is an abbreviation for Surface Mount Devices suggesting that holes for pins to
go through when mounting aren't necessary in soldering this type of a component.
Pins on PIC16F73 microcontroller have the following meaning:

There are 28 pins on PIC16F73. Most of them can be used as an IO pin. Others are already
for specific functions. These are the pin functions.

1. MCLR – to reset the PIC

2. RA0 – port A pin 0

3. RA1 – port A pin 1

4. RA2 – port A pin 2

5. RA3 – port A pin 3

6. RA4 – port A pin 4

7. RA5 – port A pin 5

8. VSS – ground

9. OSC1 – connect to oscillator

10. OSC2 – connect to oscillator

11. RC0 – port C pin 0 VDD – power supply

12. RC1 – port C pin 1

13. RC2 – port C pin 2

14. RC3 – port C pin 3

15. RC4 - port C pin 4

16. RC5 - port C pin 5

17. RC6 - port C pin 6

18. RC7 - port C pin 7

19. VSS – ground

20. VDD – power supply

21. RB0 - port B pin 0

22. RB1 - port B pin 1


23. RB2 - port B pin 2

24. RB3 - port B pin 3

25. RB4 - port B pin 4

26. RB5 - port B pin 5

27. RB6 - port B pin 6

28. RB7 - port B pin 7

By utilizing all of this pin so many application can be done such as:

1. LCD – connect to Port B pin.

2. LED – connect to any pin declared as output.

3. Relay and Motor - connect to any pin declared as output.

4. External EEPROM – connect to I2C interface pin – RC3 and RC4 (SCL and
SDA)

5. LDR, Potentiometer and sensor – connect to analogue input pin such as RA0.

6. GSM modem dial up modem – connect to RC6 and RC7 – the serial
communication interface using RS232 protocol.

For more detail function for each specific pin please refer to the device datasheet from
Microchip. 

Ports

Term "port" refers to a group of pins on a microcontroller which can be accessed


simultaneously, or on which we can set the desired combination of zeros and ones, or read
from them an existing status. Physically, port is a register inside a microcontroller which is
connected by wires to the pins of a microcontroller. Ports represent physical connection of
Central Processing Unit with an outside world. Microcontroller uses them in order to monitor
or control other components or devices. Due to functionality, some pins have twofold roles
like PA4/TOCKI for instance, which is in the same time the fourth bit of port A and an
external input for free-run counter. Selection of one of these two pin functions is done in one
of the configuration registers. An illustration of this is the fifth bit T0CS in OPTION register.
By selecting one of the functions the other one is disabled.

All port pins can be designated as input or output, according to the needs of a device that's
being developed. In order to define a pin as input or output pin, the right combination of
zeros and ones must be written in TRIS register. If the appropriate bit of TRIS register
contains logical "1", then that pin is an input pin, and if the opposite is true, it's an output pin.
Every port has its proper TRIS register. Thus, port A has TRISA, and port B has TRISB. Pin
direction can be changed during the course of work which is particularly fitting for one-line
communication where data flow constantly changes direction. PORTA and PORTB state
registers are located in bank 0, while TRISA and TRISB pin direction registers are located in
bank 1.

PORTB and TRISB

PORTB has adjoined 8 pins. The appropriate register for data direction is TRISB. Setting a
bit in TRISB register defines the corresponding port pin as input, and resetting a bit in TRISB
register defines the corresponding port pin as output.
Each PORTB pin has a weak internal pull-up resistor (resistor which defines a line to logic
one) which can be activated by resetting the seventh bit RBPU in OPTION register. These
'pull-up' resistors are automatically being turned off when port pin is configured as an output.
When a microcontroller is started, pull-ups are disabled.

Four pins PORTB, RB7:RB4 can cause an interrupt which occurs when their status changes
from logical one into logical zero and opposite. Only pins configured as input can cause this
interrupt to occur (if any RB7:RB4 pin is configured as an output, an interrupt won't be
generated at the change of status.) This interrupt option along with internal pull-up resistors
makes it easier to solve common problems we find in practice like for instance that of matrix
keyboard. If rows on the keyboard are connected to these pins, each push on a key will then
cause an interrupt. A microcontroller will determine which key is at hand while processing an
interrupt It is not recommended to refer to port B at the same time that interrupt is being
processed

PORTA and TRISA

PORTA has 5 adjoining pins. The corresponding register for data direction is TRISA at
address 85h. Like with port B, setting a bit in TRISA register defines also the corresponding
port pin as input, and clearing a bit in TRISA register defines the corresponding port pin as
output.

It is important to note that PORTA pin RA4 can be input only. On that pin is also situated an
external input for timer TMR0. Whether RA4 will be a standard input or an input for a
counter depends on T0CS bit (TMR0 Clock Source Select bit). This pin enables the timer
TMR0 to increment either from internal oscillator or via external impulses on RA4/T0CKI
pin.
Memory organization

PIC16F73 has two separate memory blocks, one for data and the other for program.
EEPROM memory with GPR and SFR registers in RAM memory make up the data block,
while FLASH memory makes up the program block. 

Program memory

Program memory has been carried out in FLASH technology which makes it possible to
program a microcontroller many times before it's installed into a device, and even after its
installment if eventual changes in program or process parameters should occur. The size of
program memory is 1024 locations with 14 bits width where locations zero and four are
reserved for reset and interrupt vector.
CHAPTER 3: HARDWARE IMPLEMENTATION

Block diagram:

POWER
SUPPLY

FIRE I LCD
SENSOR
C

1
LED indication
GAS SENSOR 6
0
F

7
BUZZER
3

Power supply:
Every electrical and electronic device that we use in our day-to-day life will require a
power supply. In general, we use an AC supply of 230V 50Hz, but this power has to be
changed into the required form with required values or voltage range for providing power
supply to different types of devices. There are various types of power electronic converters
such as step-down converter, step-up converter, voltage stabilizer, AC to DC converter, DC
to DC converter, DC to AC converter, and so on. For example, consider the microcontrollers
that are used frequently for developing many embedded systems’ based projects and kits
used in real-time applications. These microcontrollers require a 5V DC supply, so the AC
230V needs to be converted into 5V DC using the step-down converter in their power supply
circuit.
Power supply circuit, the name itself indicates that this circuit is used to supply the
power to other electrical and electronic circuits or devices. There are different types of
power supply circuits based on the power they are used to provide for devices. For example,
the micro-controller based circuits, usually the 5V DC regulated power supply circuits, are
used, which can be designed using different techniques for converting the available 230V AC
power to 5V DC power. Generally the converters with output voltage less than the input
voltage are called as step-down converters.

Step Down the Voltage Level


The step-down converters are used for converting the high voltage into low voltage.
The converter with output voltage less than the input voltage is called as a step-down
converter, and the converter with output voltage greater than the input voltage is called as
step-up converter. There are step-up and step-down transformers which are used to step up or
step down the voltage levels. 230V AC is converted into 12V AC using a step-down
transformer. 12V output of stepdown transformer is an RMS value and its peak value is given
by the product of square root of two with RMS value, which is approximately 17V.

Step-down Transformer

Step-down transformer consists of two windings, namely primary and secondary


windings where primary can be designed using a less-gauge wire with more number of turns
as it is used for carrying low-current high-voltage power, and the secondary winding using a
high-gauge wire with less number of turns as it is used for carrying high-current low-voltage
power. Transformers works on the principle of Faraday’s laws of electromagnetic induction.
Convert AC to DC
230V AC power is converted into 12V AC (12V RMS value wherein the peak value
is around 17V), but the required power is 5V DC; for this purpose, 17V AC power must be
primarily converted into DC power then it can be stepped down to the 5V DC. But first and
foremost, we must know how to convert AC to DC? AC power can be converted into DC
using one of the power electronic converters called as Rectifier. There are different types of
rectifiers, such as half-wave rectifier, full-wave rectifier and bridge rectifier. Due to the
advantages of the bridge rectifier over the half and full wave rectifier, the bridge rectifier is
frequently used for converting AC to DC.

Bridge rectifier consists of four diodes which are connected in the form a bridge. We
know that the diode is an uncontrolled rectifier which will conduct only forward bias and will
not conduct during the reverse bias. If the diode anode voltage is greater than the cathode
voltage then the diode is said to be in forward bias. During positive half cycle, diodes D2 and
D4 will conduct and during negative half cycle diodes D1 and D3 will conduct. Thus, AC is
converted into DC; here the obtained is not a pure DC as it consists of pulses. Hence, it is
called as pulsating DC power. But voltage drop across the diodes is (2*0.7V) 1.4V; therefore,
the peak voltage at the output of this retifier circuit is 15V (17-1.4) approx.

Smoothing the Ripples using Filter


15V DC can be regulated into 5V DC using a step-down converter, but before this, it
is required to obtain pure DC power. The output of the diode bridge is a DC consisting of
ripples also called as pulsating DC. This pulsating DC can be filtered using an inductor filter
or a capacitor filter or a resistor-capacitor-coupled filter for removing the ripples. Consider a
capacitor filter which is frequently used in most cases for smoothing.
Filter

We know that a capacitor is an energy storing element. In the circuit, capacitor stores


energy while the input increases from zero to a peak value and, while the supply voltage
decreases from peak value to zero, capacitor starts discharging. This charging and
discharging of the capacitor will make the pulsating DC into pure DC, as shown in figure.

Regulating 12V DC into 5V DC using Voltage Regulator


15V DC voltage can be stepped down to 5V DC voltage using a DC step-down
converter called as voltage regulator IC7805. The first two digits ‘78’ of IC7805 voltage
regulator represent positive series voltage regulators and the last two digits ‘05’ represents
the output voltage of the voltage regulator.

The block diagram of IC7805 voltage regulator is shown in the figure consists of an
operating amplifier acting as error amplifier, zener diode used for providing voltage
reference, as shown in the figure.
Zener Diode as Voltage Reference

Transistor as a series pass element used for dissipating extra energy as heat; SOA
protection (Safe Operating Area) and heat sink are used for thermal protection in case of
excessive supply voltages. In general, an IC7805 regulator can withstand voltage ranging
from 7.2V to 35V and gives maximum efficiency of 7.2V voltage and if the voltage exceeds
7.2V, then there is loss of energy in the form of heat. To protect the regulator from over heat,
thermal protection is provided using a heat sink. Thus, a 5V DC is obtained from 230V AC
power.

Block Diagram
Relay:

A relay is an electrically operated switch. Many relays use an electromagnet to


mechanically operate a switch, but other operating principles are also used, such as solid-state
relays. Relays are used where it is necessary to control a circuit by a separate low-power
signal, or where several circuits must be controlled by one signal. The first relays were used
in long distance telegraph circuits as amplifiers: they repeated the signal coming in from one
circuit and re-transmitted it on another circuit. Relays were used extensively in telephone
exchanges and early computers to perform logical operations.
The heart of a relay is an electromagnet (a coil of wire that becomes a
temporary magnet when electricity flows through it). You can think of a relay as a kind of
electric lever: switch it on with a tiny current and it switches on ("leverages") another
appliance using a much bigger current. Why is that useful? As the name suggests, many
sensors are incredibly sensitive pieces of electronic equipment and produce only small
electric currents. But often we need them to drive bigger pieces of apparatus that use bigger
currents. Relays bridge the gap, making it possible for small currents to activate larger ones.
That means relays can work either as switches (turning things on and off) or as amplifiers
(converting small currents into larger ones).
Here are two simple animations illustrating how relays use one circuit to switch on a
second circuit.
When power flows through the first circuit (1), it activates the electromagnet (brown),
generating a magnetic field (blue) that attracts a contact (red) and activates the second circuit
(2). When the power is switched off, a spring pulls the contact back up to its original position,
switching the second circuit off again.
This is an example of a "normally open" (NO) relay: the contacts in the second circuit
are not connected by default, and switch on only when a current flows through the magnet.
Other relays are "normally closed" (NC; the contacts are connected so a current flows
through them by default) and switch off only when the magnet is activated, pulling or
pushing the contacts apart. Normally open relays are the most common.
Here's another animation showing how a relay links two circuits together. It's
essentially the same thing drawn in a slightly different way. On the left side, there's an input
circuit powered by a switch or a sensor of some kind. When this circuit is activated, it feeds
current to an electromagnet that pulls a metal switch closed and activates the second, output
circuit (on the right side). The relatively small current in the input circuit thus activates the
larger current in the output circuit:

The input circuit (black loop) is switched off and no current flows through it until
something (either a sensor or a switch closing) turns it on. The output circuit (blue loop) is
also switched off.
When a small current flows in the input circuit, it activates the electromagnet (shown
here as a red coil), which produces a magnetic field all around it.
The energized electromagnet pulls the metal bar in the output circuit toward it, closing
the switch and allowing a much bigger current to flow through the output circuit.
The output circuit operates a high-current appliance such as a lamp or an electric
motor.
A type of relay that can handle the high power required to directly control an electric
motor or other loads is called a contactor. Solid-state relays control power circuits with
no moving parts, instead using a semiconductor device to perform switching. Relays with
calibrated operating characteristics and sometimes multiple operating coils are used to protect
electrical circuits from overload or faults; in modern electric power systems these functions
are performed by digital instruments still called "protective relays".
Magnetic latching relays require one pulse of coil power to move their contacts in one
direction, and another, redirected pulse to move them back. Repeated pulses from the same
input have no effect. Magnetic latching relays are useful in applications where interrupted
power should not be able to transition the contacts.
Magnetic latching relays can have either single or dual coils. On a single coil device,
the relay will operate in one direction when power is applied with one polarity, and will reset
when the polarity is reversed. On a dual coil device, when polarized voltage is applied to the
reset coil the contacts will transition. AC controlled magnetic latch relays have single coils
that employ steering diodes to differentiate between operate and reset commands.

Buzzer:
Buzzer is an electronic device commonly used to produce sound. Light weight,
simple construction and low price make it usable in various applications like car/truck
reversing indicator, computers, call bells etc. Piezo buzzer is based on the inverse principle of
piezo electricity discovered in 1880 by Jacques and Pierre Curie. It is the phenomena of
generating electricity when mechanical pressure is applied to certain materials and the vice
versa is also true. Such materials are called piezo electric materials. Piezo electric materials
are either naturally available or manmade. Piezoceramic is class of manmade material, which
poses piezo electric effect and is widely used to make disc, the heart of piezo buzzer. When
subjected to an alternating electric field they stretch or compress, in accordance with the
frequency of the signal thereby producing sound.

Fire sensor:
Fire sensor is a sensor designed to detect and respond to the presence of
a flame or fire. Responses to a detected flame depend on the installation, but can include
sounding an alarm, deactivating a fuel line (such as a propane or a natural gas line), and
activating a fire suppression system. When used in applications such as industrial furnaces,
their role is to provide confirmation that the furnace is properly lit; in these cases they take no
direct action beyond notifying the operator or control system. A flame detector can often
respond faster and more accurately than a smoke or heat detector due to the mechanisms it
uses to detect the flame.

Fire detectors sense one or more of the products or phenomena resulting from fire,
such as smoke, heat, infrared and/or ultraviolet light radiation, or gas.
In dwellings, smoke detectors are often stand-alone devices. In non-domestic buildings, fire
detection will typically take the form of a fire alarm system, incorporating one or more of the
following automatic devices:
 Heat detector
 Smoke detector
 Flame detector
 Fire gas detector

Gas Sensor:
Gas sensors need to be calibrated and periodically checked to ensure sensor accuracy and
system integrity. It is important to install stationary sensors in locations where the calibration
can be performed easily. The intervals between calibrations can be different from sensor to
sensor. Generally, the manufacturer of the sensor will recommend a time interval between
calibrations. However, it is good general practice to check the sensor more closely during the
first 30 days after installation. During this period, it is possible to observe how well the
sensor is adapting to its new environment. Also, factors that were not accounted for in the
design of the system might surface and can affect the sensor’s performance.

If the sensor functions properly for 30 continuous days, this provides a good degree of
confidence about the installation. Any possible problems can be identified and corrected
during this time. Experience indicates that a sensor surviving 30 days after the initial
installation will have a good chance of performing its function for the duration expected.
Most problems—such as an inappropriate sensor location, interference from other gases, or
the loss of sensitivity—will surface during this time.
Fig: Diagram of Gas sensor

Working of Gas sensor:

During the first 30 days, the sensor should be checked weekly. Afterward, a maintenance
schedule, Hazardous Gas Monitors including calibration intervals, should be established.
Normally, a monthly calibration is adequate to ensure the effectiveness and sensibility of
each sensor; this monthly check will also afford you the opportunity to maintain the system’s
accuracy. The method and procedure for calibrating the sensors should be established
immediately. The calibration procedure should be simple, straightforward, and easily
executed by regular personnel. Calibration here is simply a safety check, unlike laboratory
analyzers that require a high degree of accuracy. For area air quality and safety gas monitors,
the requirements need to be simple, repeatable, and economical. The procedure should be
consistent and traceable. The calibration will be performed in the field where sensors are
installed so it can occur in any type environment. Calibration of the gas sensor involves two
steps. First the “zero” must be set and then the “span” must be calibrated.
The sensing material in TGS gas sensors is metal oxide, most typically SnO2. When a metal
oxide Crystal such as SnO2 is heated at a certain high temperature in air, oxygen is adsorbed
on the crystal surface with a negative charge. Then donor electrons in the crystal surface are
transferred to the adsorbed oxygen, resulting in leaving positive charges in a space charge
layer. Thus, surface potential is formed to serve as a potential barrier against electron flow.
Inside the sensor, electric current flows through the conjunction parts (grain boundary) of
SnO2 micro crystals. At grain boundaries, adsorbed oxygen forms a potential barrier which
prevents carriers from moving freely. The electrical resistance of the sensor is attributed to
this potential barrier. In the presence of a deoxidizing gas, the surface density of the
negatively charged oxygen decreases, so the barrier height in the grain boundary is reduced.
The reduced barrier height decreases sensor resistance.
Sensor resistance will drop very quickly when exposed to gas, and when removed from gas
its resistance will recover to its original value after a short time. The speed of response and
reversibility will vary according to the model of sensor and the gas involved.
Feature
- Power requirements: 5 VDC @ ~160mA

Interface Type: Resistive

Dimensions: 0.75" diameter x 0.65" tall excluding leads (19.1mm diameter x 16.55mm tall
excluding leads)

Operating temp range: -4 to +122 °F (-20 to +50 °C)

Connections
Connecting five volts across the heating (H) pins keeps the sensor hot enough to function
correctly. Connecting five volts at either the A or B pins causes the sensor to emit an analog
voltage on the other pins. A resistive load between the output pins and ground sets the
sensitivity of the detector. Please note that the picture in the datasheet for the top
configuration is wrong. Both configurations have the same pinout consistent with the bottom
configuration. The resistive load should be calibrated for your particular application using the
equations in the datasheet, but a good starting value for the resistor is 10 kΩ.
LCD Display:

LCD Background:

One of the most common devices attached to a micro controller is an LCD display. Some of
the most common LCD’s connected to the many microcontrollers are 16x2 and 20x2
displays. This means 16 characters per line by 2 lines and 20 characters per line by 2 lines,
respectively.

Basic 16x 2 Characters LCD

Figure 1: LCD Pin diagram

Pin description:

Pin No. Name Description

Pin no. 1 VSS Power supply (GND)

Pin no. 2 VCC Power supply (+5V)

Pin no. 3 VEE Contrast adjust

0 = Instruction input
Pin no. 4 RS
1 = Data input
0 = Write to LCD module
Pin no. 5 R/W
1 = Read from LCD module

Pin no. 6 EN Enable signal

Pin no. 7 D0 Data bus line 0 (LSB)

Pin no. 8 D1 Data bus line 1

Pin no. 9 D2 Data bus line 2

Pin no. 10 D3 Data bus line 3

Pin no. 11 D4 Data bus line 4

Pin no. 12 D5 Data bus line 5

Pin no. 13 D6 Data bus line 6

Pin no. 14 D7 Data bus line 7 (MSB)

Table 1: Character LCD pins with Microcontroller

The LCD requires 3 control lines as well as either 4 or 8 I/O lines for the data bus. The
user may select whether the LCD is to operate with a 4-bit data bus or an 8-bit data bus. If a
4-bit data bus is used the LCD will require a total of 7 data lines (3 control lines plus the 4
lines for the data bus). If an 8-bit data bus is used the LCD will require a total of 11 data lines
(3 control lines plus the 8 lines for the data bus).

The three control lines are referred to as EN, RS, and RW.

The EN line is called "Enable." This control line is used to tell the LCD that we are sending it
data. To send data to the LCD, our program should make sure this line is low (0) and then set
the other two control lines and/or put data on the data bus. When the other lines are
completely ready, bring EN high (1) and wait for the minimum amount of time required by
the LCD datasheet (this varies from LCD to LCD), and end by bringing it low (0) again.

The RS line is the "Register Select" line. When RS is low (0), the data is to be treated
as a command or special instruction (such as clear screen, position cursor, etc.). When RS is
high (1), the data being sent is text data which should be displayed on the screen. For
example, to display the letter "T" on the screen we would set RS high.

The RW line is the "Read/Write" control line. When RW is low (0), the information on
the data bus is being written to the LCD. When RW is high (1), the program is effectively
querying (or reading) the LCD. Only one instruction ("Get LCD status") is a read command.
All others are write commands--so RW will almost always be low.

Finally, the data bus consists of 4 or 8 lines (depending on the mode of operation
selected by the user). In the case of an 8-bit data bus, the lines are referred to as DB0, DB1,
DB2, DB3, DB4, DB5, DB6, and DB7.

Schematic:

Circuit Description:

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 is a few which don't.
Therefore by incorporating the two 10K external pull up resistors, the 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. We can use a bench power supply set
to 5v or use an onboard +5 regulator. Remember a few de-coupling capacitors, especially if
we have trouble with the circuit working properly.

SETB RW

Handling the EN control line:

As we mentioned above, the EN line is used to tell the LCD that we are ready for it to
execute an instruction that we've prepared on the data bus and on the other control lines. Note
that the EN line must be raised/ lowered before/after each instruction sent to the LCD
regardless of whether that instruction is read or write text or instruction. In short, we must
always manipulate EN when communicating with the LCD. EN is the LCD's way of knowing
that we are talking to it. If we don't raise/lower EN, the LCD doesn't know we're talking to it
on the other lines.

Thus, before we interact in any way with the LCD we will always bring the EN line
low with the following instruction:

CLR EN

And once we've finished setting up our instruction with the other control lines and data
bus lines, we'll always bring this line high:

SETB EN

The line must be left high for the amount of time required by the LCD as specified in
its datasheet. This is normally on the order of about 250 nanoseconds, but checks the
datasheet. In the case of a typical microcontroller running at 12 MHz, an instruction requires
1.08 microseconds to execute so the EN line can be brought low the very next instruction.
However, faster microcontrollers (such as the DS89C420 which executes an instruction in 90
nanoseconds given an 11.0592 MHz crystal) will require a number of NOPs to create a delay
while EN is held high. The number of NOPs that must be inserted depends on the
microcontroller we are using and the crystal we have selected.

The instruction is executed by the LCD at the moment the EN line is brought low with
a final CLR EN instruction.

Checking the busy status of the LCD:

As previously mentioned, it takes a certain amount of time for each instruction to be


executed by the LCD. The delay varies depending on the frequency of the crystal attached to
the oscillator input of the LCD as well as the instruction which is being executed.

While it is possible to write code that waits for a specific amount of time to allow the
LCD to execute instructions, this method of "waiting" is not very flexible. If the crystal
frequency is changed, the software will need to be modified. A more robust method of
programming is to use the "Get LCD Status" command to determine whether the LCD is still
busy executing the last instruction received.

The "Get LCD Status" command will return to us two tidbits of information; the
information that is useful to us right now is found in DB7. In summary, when we issue the
"Get LCD Status" command the LCD will immediately raise DB7 if it's still busy executing a
command or lower DB7 to indicate that the LCD is no longer occupied. Thus our program
can query the LCD until DB7 goes low, indicating the LCD is no longer busy. At that point
we are free to continue and send the next command.

Applications:

 Medical equipment
 Electronic test equipment
 Industrial machinery Interface
 Serial terminal
 Advertising system
 EPOS 
 Restaurant ordering systems
 Gaming box
 Security systems
 R&D Test units
 Climatizing units
 PLC Interface
 Simulators
 Environmental monitoring
 Lab development
 Student projects
 Home automation
 PC external display
 HMI operator interface.
CHAPTER 4
SOFTWARE IMPLEMENTATION

This project is implemented using following software’s:


 PIC C compiler - for compilation part
 PICKIT3 – for uploading part

4.1 PIC Compiler:

PIC compiler is software used where the machine language code is written and
compiled. After compilation, the machine source code is converted into hex code which is to
be dumped into the microcontroller for further processing. PIC compiler also supports C
language code.
It’s important that you know C language for microcontroller which is commonly
known as Embedded C. As we are going to use PIC Compiler, hence we also call it PIC C.
The PCB, PCM, and PCH are separate compilers. PCB is for 12-bit opcodes, PCM is for 14-
bitopcodes, and PCH is for 16-bit opcode PIC microcontrollers. Due to many similarities, all
three compilers are covered in this reference manual. Features and limitations that apply to
only specific microcontrollers are indicated within. These compilers are specifically designed
to meet the unique needs of the PIC microcontroller. This allows developers to quickly
design applications software in a more readable, high-level language. When compared to a
more traditional C compiler, PCB, PCM, and PCH have some limitations. As an example of
the limitations, function recursion is not allowed.
This is due to the fact that the PIC has no stack to push variables onto, and also
because of the way the compilers optimize the code. The compilers can efficiently implement
normal C constructs, input/output operations, and bit twiddling operations. All normal C data
types are supported along with pointers to constant arrays, fixed point decimal, and arrays of
bits.
PIC C is not much different from a normal C program. If you know assembly, writing
a C program is not a crisis. In PIC, we will have a main function, in which all your
application specific work will be defined. In case of embedded C, you do not have any
operating system running in there. So you have to make sure that your program or main file
should never exit. This can be done with the help of simple while (1) or for (;;) loop as they
are going to run infinitely.
We have to add header file for controller you are using, otherwise you will not be able
to access registers related to peripherals.

#include <16F72.h> // header file for PIC 16F72//

4.2 Procedural steps for compilation, simulation and dumping:

4.2.1 Compilation and simulation steps:

For PIC microcontroller, PIC C compiler is used for compilation. The compilation steps are
as follows:

 Open PIC C compiler.


 You will be prompted to choose a name for the new project, so create a separate
folder where all the files of your project will be stored, choose a name and click save.
 Click Project, New, and something the box named 'Text1' is where your code should
be written later.
 Now you have to click 'File, Save as' and choose a file name for your source code
ending with the letter '.c'. You can name as 'project.c' for example and click save.
Then you have to add this file to your project work.
 You can then start to write the source code in the window titled 'project.c' then before
testing your source code; you have to compile your source code, and correct eventual
syntax errors.
 By clicking on compile option .hex file is generated automatically.
 This is how we compile a program for checking errors and hence the compiled
program is saved in the file where we initiated the program.
After compilation, next step is simulation. Here first circuit is designed in Express PCB using
Proteus 7 software and then simulation takes place followed by dumping. The simulation
steps are as follows:
 Open Proteus 7 and click on IS1S6.
 Now it displays PCB where circuit is designed using microcontroller. To design
circuit components are required. So click on component option.
10. Now click on letter ’p’, then under that select PIC16F73 ,other components related to the
project and click OK. The PIC 16F73 will be called your “'Target device”, which is the final
destination of your source code.

4.2.2 Dumping steps:


The steps involved in dumping the program edited in proteus 7 to microcontroller are shown
below:
1. Initially before connecting the program dumper to the microcontroller kit the window
is appeared as shown below.
Fig 4.6: Picture of program dumper window

2. Select Tools option and click on Check Communication for establishing a connection
as shown in below window

Fig 4.7: Picture of checking communications before dumping program into microcontroller
3. After connecting the dumper properly to the microcontroller kit the window is appeared as
shown below.
Fig 4.8: Picture after connecting the dumper to microcontroller
4. Again by selecting the Tools option and clicking on Check Communication the
microcontroller gets recognized by the dumper and hence the window is as shown
below.

Fig 4.9: Picture of dumper recognition to microcontroller


5. Import the program which is ‘.hex’ file from the saved location by selecting File option
and clicking on ‘Import Hex’ as shown in below window.
Fig 4.10: Picture of program importing into the microcontroller

6. After clicking on ‘Import Hex’ option we need to browse the location of our program and
click the ‘prog.hex’ and click on ‘open’ for dumping the program into the microcontroller.

7. After the successful dumping of program the window is as shown below.


Fig 4.12: Picture after program dumped into the microcontroller
CHAPTER 5: APPLICATIONS AND CONCLUSION

Applications:
1. Used in shopping malls, residences factories etc.
2. Detects and alerts the flame and Gas caused automatically.

CONCLUSION:

The project “AUTOMATIC FIRE AND GAS DETECTING AND


ALERTING SYSTEM” has been successfully designed and tested. It has been
developed by integrating features of all the hardware components used. Presence of every
module has been reasoned out and placed carefully thus contributing to the best working of
the unit.
Secondly, using highly advanced IC’s and with the help of growing technology the
project has been successfully implemented.
REFERENCES

[1] Kavitha.B.C, Vallikannu.R, “IoT based Intelligent Industry Monitoring System”, 2019 on
Signal Processing and Integrated Networks (SPIN) 6th International Conference.
[2] Rohan Chandra Pandey, Manish Varma, Lumesh Kumar Sahu, “Internet of Things based
Gas Leakage Monitoring and Alerting System with MQ-2 Sensor”, IJEDR, Volume-5,
Issue2, ISSN: 23219939(Journal).
[3] Gagan Parmar, Sagar Lakhani, Manju K. Chattopadhyay, “An IoT Based Low Cost Air
Pollution Monitoring System” , Proceeding International conference on Recent Innovations is
Signal Processing and Embedded Systems (RISE-2017) 27- 29 October,2017
[4] A. Banik, B. Aich and S. Ghosh, "Microcontroller based lowcost gas leakage detector
with SMS alert”, Emerging Trend in Electronic Devices and Computational
Techniques(EDCT),Kolkata,2018.
[5] Arpitha .T, Divya Kiran, V. S.N. Sitaram Gupta and Punithavathi Duraiswamy “FPGA-
GSM based Gas Leakage Detection System”, 2016 IEEE
[6] R. Angeline, Adithya S, Abishek Narayanan, “Fire Alarm System Using IOT”,
International Journal of Innovative Technology and Exploring Engineering (IJITEE) ISSN:
2278- 3075, Volume-8, Issue-6S3, April 2019
[7] Ashish Srivasthava, Rathnesh Prabhakar, Rajeev Kumar, “GSM based Gas Leakage
Detection System”, International Journal of Technical Research and Applications, Volume-1,
Issue-2.
[8] Abdhulla al Noman, Rubel Kanti Das, “Detection of Fire and Gas Leakage in Industry to
Ensure Safety Condition”, 4th National Conference on Natural Science and Technology
2017.

PROGRAM:
//PIN CONNECTIONS
//-----------------------------------------
//GAS SENSOR = A0 pin
//FLAME SENSOR = A1 pin

//LCD R/W pin to ground


//Enable pin = B6
//RS pin = B7
//D4 pin = B5
//D5 pin = B4
//D6 pin = B3
//D7 pin = B2

#include <16F73.h> //Microcontroller Used


#fuses HS,NOWDT,PROTECT,brownout,put
#use delay(clock=20M) // operating Clock freequency
#include "flex_lcd.c"

void main()
{

int gas = 0;

lcd_init();
lcd_gotoxy(1,1);
printf(lcd_putc,"Fire and Gas");
lcd_gotoxy(1,2);
printf(lcd_putc,"Dtctn system..");

output_high(pin_C3);
output_low(pin_C4);
delay_ms(500);
output_low(pin_C3);
output_high(pin_C4);
delay_ms(500);
output_high(pin_C3);
output_low(pin_C4);
delay_ms(500);
output_low(pin_C3);
output_high(pin_C4);
delay_ms(500);
lcd_putc('\f');

while(1)
{

if(!input(pin_C0))
{
lcd_putc('\f');
lcd_gotoxy(1,1);
printf(lcd_putc,"***ALERT*** ");
lcd_gotoxy(1,2);
printf(lcd_putc,"GAS DETECTED");
output_high(pin_C3);
output_low(pin_C4);
delay_ms(200);
output_low(pin_C3);
output_high(pin_C4);
delay_ms(200);

else if (!input(pin_C1))
{
lcd_putc('\f');
lcd_gotoxy(1,1);
printf(lcd_putc,"***ALERT*** ");
lcd_gotoxy(1,2);
printf(lcd_putc,"FIRE DETECTED");
output_high(pin_C3);
output_low(pin_C4);
delay_ms(500);
}

else
{
lcd_putc('\f');
lcd_gotoxy(1,1);
printf(lcd_putc,"Monitoring...");
output_low(pin_C3);
output_high(pin_C4);

delay_ms(500);
}

}
}

You might also like