Professional Documents
Culture Documents
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
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.
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.
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.
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.
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.
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.
"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.
The Lynx Certifiable Stack (LCS) is a secure TCP/IP protocol stack designed especially
for applications where standards certification is required.
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.
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 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.
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:
This is important in terms of space, assembling and prototyping the End product.
Cost per unit: This is important in terms of final product in which a microcontroller is used.
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.
• Watchdog Timer (WDT) with its own on-chip RC oscillator for reliable operation
Peripheral Features
• 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
• Synchronous Serial Port (SSP) with SPI (Master mode) and I2C (Slave)
• Parallel Slave Port (PSP), 8-bits wide with external RD, WR and CS controls (40/44-pin
Only)
2 analog comparators
CMOS Technology:
PORTS are physical connections between the microcontroller and the outside world.
PIC16F73 has 22 I/O.
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.
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.
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.
8. VSS – ground
By utilizing all of this pin so many application can be done such as:
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
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 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 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 Transformer
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.
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:
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
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
Dimensions: 0.75" diameter x 0.65" tall excluding leads (19.1mm diameter x 16.55mm tall
excluding leads)
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.
Pin description:
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
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
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.
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
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.
For PIC microcontroller, PIC C compiler is used for compilation. The compilation steps are
as follows:
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.
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.
Applications:
1. Used in shopping malls, residences factories etc.
2. Detects and alerts the flame and Gas caused automatically.
CONCLUSION:
[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
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);
}
}
}