Professional Documents
Culture Documents
Final REportEDITrb
Final REportEDITrb
MONITORING SYSTEM
A project report submitted in partial fulfilment of the requirement for the
award of the degree of
BACHELOR OF ENGINEERING
IN
ELECTRONICS AND INSTRUMENTATION
Submitted by
S.Mahathi Vatsal (1210611144)
LLN. Vamsi Krishna (1210611121)
V.Luke Vikas (1210611163)
G.Sai Ram Prabhu (1210611111)
Under the esteemed guidance of
Mr.L.Srinivasa Rao, M.Tech
Assistant Professor
Dept. of Electronics and Instrumentation Engineering
BATCH 2011-2015
CERTIFICATE
This is to certify that the project report titled ANDROID BASED PORTABLE
MULTIPARAMETER MONITORING SYSTEM that is being submitted by the Batch
No.5 consisting of S.MAHATHI VATSAL (1210611144), LLN.VAMSI KRISHNA
(1210611121), V.LUKE VIKAS (1210611163) and G.SAI RAM PRABHU (1210611111)
is in partial fulfilment of the requirements for the Award of BACHELOR OF
ENGINEERING IN ELECTRONICS AND INSTRUMENTATION ENGINEERING, is a
record of bonafide work done on that under my guidance. The contents of this project
work, in full or in parts, have neither been taken from any other sources nor have been
submitted to any other institute or university for the award of any degree or diploma and
the same is certified.
Project guide:
Dr.D.ElizabethRani,
Assistant professor
Professor , HOD
Dept. of EIE,
Dept. Of EIE,
Gitam University.
Gitam University.
ACKNOWLEDGEMENT
We would like to express our deep sense of gratitude towards Dr.D.Elizabeth Rani,
Professor, HOD, Department of Electronics and Instrumentation, GITAM
UNIVERSITY for her administrative support during the project work.
We would like to express our deep sense of gratitude to Mr.L.Srinivasa Rao, Assistant
Professor for his valuable guidance rendered to us in the completion of this project.
We also wish to express our sincere gratitude to Ms.M.Grace Mercy, Project
Coordinator, Department of Electronics and Instrumentation, GITAM University for
her constant support and guidance.
We are thankful to all the faculty and non-teaching staff of Department of Electronics
and Instrumentation Engineering, GITAM University, who have supported us during
the project work.
.
S. Mahathi Vatsal
1210611144
1210611121
V. Luke Vikas
1210611163
1210611111
ABSTRACT
Mobile devices (in particular Smartphones and tablets) can be used to monitor quality of
life parameters. Today mobile devices use embedded sensors such as accelerometers,
compasses, GPSs, microphones, and cameras without considering, for example, the air
quality or the pollutants of the environment. This project presents the possibility to use the
Smartphones capabilities to gather data from other phones or sensors. . In this project, a
novel interface by applying a Bluetooth-based sensor to sense monitored are light,
temperature, smoke, motion and fire for monitoring of the environmental conditions using
the android-based Smartphone is introduced.
The Bluetooth-based parameter acquisition system consists of a device comprising a
sensor and a microcontroller that wirelessly transmits these climatic parameters to a
receiver using the Bluetooth communication system. An application called a Bluetooth
SPP Tools Pro by Android is used to acquire data from the parameters that has described
before. The android application has two parts. The first part, display, illustrates the
parametric values that are read from the Bluetooth-based acquisition system from the kit,
and the second part involves the movement of the kit.
The preliminary aim in this project is to build a Mobile operated ARM7 based device,
which could be able to move in forward, backward, right and left directions. By using keys
on the Mobile. The device can be moved in all the above specified directions. And the
transmission of wireless signals can be carried by using Bluetooth communication. The
device is fitted with 2 DC geared motors and to control its operation LPC2148 is being
used as controller. In this project, LPC2148, DC Geared motors, and Bluetooth is used to
for the navigation of device. ARM7TDMI is an advanced version of microprocessors and
forms the heart of the system.
TABLE OF CONTENTS
CHAPTER
1
CONTENTS
PAGE
INTRODUCTION
1.1 OVERVIEW
ARM7 MICROCONTROLLER
5
7
7
8
8
10
11
12
12
12
SENSORS
14
15
15
15
16
17
3.1.5 WORKING OF LM 35
4
4.1
4.2
17
18
18
18
19
20
20
3.3LIGHT SENSOR-LDR
3.3.1 GENERAL DESCRIPTION OF LDR
3.3.2 FEATURESAND PRINCIPLE OF LDR
3.3.3 DIAGRAM OF LDR
3.3.4 WORKING OF LDR
3.3.5 APPLICATIONS OF LDR
20
20
21
22
22
22
23
23
23
25
25
25
25
25
25
26
26
27
CONTROL CIRCUITORY
28
29
29
29
31
32
32
4.4
4.5
4.6
4.7
34
34
34
35
36
37
37
37
38
39
39
40
43
44
44
44
45
45
45
46
46
46
47
47
48
6. SOFTWARE USED
49
50
50
51
51
52
64
OBSERVATIONS
CONCLUSION AND FUTURE SCOPE
REFERENCES
65
67
68
LIST OF FIGURES
Page
CHAPTER 1
1.1 BLOCK DIAGRAM USED IN THIS PROJECT
CHAPTER 2
2.1 BLOCK DIAGRAM FOR POWER SUPPLY
2.7
LPC 2148
2.8
10
2.9
11
13
CHAPTER 3
3.1
IMAGE OF LM 35
16
3.2
17
3.3
IMAGE OF LDR
19
3.4
IMAGE OF PHOTODIODE
20
3.5
PASSIVE IR SENSOR
24
8
CHAPTER 4
4.1 STEP DOWN TRANSFORMER
29
30
31
32
33
33
34
35
4.9
FAN
36
4.10 BUZZER
37
38
40
41
41
CHAPTER 5
5.1 PIN DIAGRAM OF RS-232
45
47
48
CHAPTER 6
6.1 FLOW CHART OF THE PROJECT
64
65
66
66
67
67
10
CHAPTER 1:
INTRODUCTION
1.1 OVERVIEW:
A wireless
sensor
network
or
(WSN) of
environmental
spatially
conditions,
distributed
such
as
autonomous
temperature,
sound, pressure, etc. and to cooperatively pass their data through the network to a main
location. The more modern networks are bi-directional, also enabling control of sensor
activity. The development of wireless sensor networks was motivated by military
applications such as battlefield surveillance; today such networks are used in many
industrial and consumer applications, such as industrial process monitoring and control,
machine health monitoring, and so on.
The WSN is built of "nodes" from a few to several hundreds or even thousands, where
each node is connected to one (or sometimes several) sensors. Each such sensor network
node has typically several parts: radio transceiver with an internal antenna or connection to
an external antenna, a microcontroller, an electronic circuit for interfacing with the sensors
and an energy source, usually a battery or an embedded form of energy harvesting.
A sensor node might vary in size from that of a shoebox down to the size of a grain of
dust, although functioning "motes" of genuine microscopic dimensions have yet to be
created. The cost of sensor nodes is similarly variable, ranging from a few to hundreds of
dollars, depending on the complexity of the individual sensor nodes. Size and cost
constraints on sensor nodes result in corresponding constraints on resources such as
energy, memory, computational speed and communications bandwidth. The topology of
the WSNs can vary from a simple star network to an advanced multi-hop wireless mesh
network. The propagation technique between the hops of the network can
be routing or flooding.
The main aim of this project is to monitor temperature, light, motion, fire and smoke and
control temperature and light. Using relative low cost and low power components and the
Bluetooth communication system for the transmission of the acquired data to an android
based Smartphone. A Robotic platform was developed using 2 DC geared motors of
100rpm each and an IC L293D motor driver. An application in android mobile called
Bluetooth SPP Tools Pro was used for displaying information and controlling the robotic
platform by moving it in all directions-forward, backward, right, left and stop.
2
CHAPTER 2:
ARM7 MICROCONTROLLER
2.1.5 UART:
LPC 2148 has inbuilt ISP which means we can program it within the system using serial
communication on COM0. It has also COM1 for serial communication. MAX 232/233 IC
must be used for voltage logic conversion.
10
11
Name
RESET
UNDEF
SWI
Address
0X00000000
0X00000004
0X00000008
High Address
0Xffff0000
0Xffff0004
0Xffff0008
Pre-fetch Abort
Data Abort
PABT
DABT
0X0000000C
0X00000010
0Xffff000c
0Xffff0010
12
Reserved
Interrupt Request
--IRQ
0X00000014
0X00000018
0Xffff0014
0Xffff0018
FIQ
0X0000001C
0Xffff001c
The exception Vector table shown above gives the address of the subroutine program to be
executed when the exception or interrupt occurs. Each vector table entry contains a form
of branch instruction pointing to the start of a specific routine.Reset vectoris the location
of the first instruction executed by the processor when power is applied. This instruction
branches to the initialization code.
13
CHAPTER 3:
SENSORS
for1mAload
The voltage that is read across the diode is actually the working base for the sensor. When
the voltage increases, the temperature also rises. There is a voltage drop between the
emitter and base of the transistor which is recorded. If the voltage difference is amplified,
an analog signal is generated. This signal and the temperature are proportional. Even
though the technique has improved, this remains the basic working principle of the
temperature sensors.
16
The Block Diagram of the LM-35 consists of the three pins and a plastic TO-220 package.
The three pins are associated as the Vcc, output and GND (Ground). The Vcc is the input
voltage supplied to the sensor (LM-35). It draws only 60 A from the supply. The output
is in the form of the voltage. It causes Linear +10mV/C Scale Factor. The ground is used
for the safety purpose of the sensor.
17
Principle: Catalytic-type gas sensor consist of two elements: a detector element (D) which
contains catalytic material and is sensitive to combustible gases, and a compensator
element (C) which is inert. Combustible gases will burn only on the detector element,
causing a rise in its temperature and, as a consequence, a rise in its resistance.
Combustible gases will not burn on the compensatorits temperature and resistance
remain unchanged in the presence of combustible gases.
Normally a Wheatstone bridge circuit is formed with both elements as shown in Figure 2.
A variable resistor (VR) is adjusted to maintain a state of balance of the bridge circuit in
clean air free of combustible gases. When combustible gases are present, only the
resistance of the detector element will rise, causing an imbalance in the bridge circuit, thus
producing an output voltage signal (Vout). The output voltage signal is proportional to the
concentration of combustible gases. Gas concentration can be determined by measuring
the output voltage.
3.2.3 DIAGRAM OF MQ-2 SENSOR:
19
In order to manage above listed functions efficiently, the steel mesh is made into two
layers. The mesh is bound to rest of the body via a copper plated clamping ring.
3.2.4 WORKING OF MQ-2 SENSOR:
The top of the gas sensor is removed off to see the internals parts of the sensor: sensing
element and connection wiring. The hexapod structure is constituted by the sensing
element and six connecting legs that extend beyond the Bakelite base.
Image shows the hollow sensing element which is made up from Aluminum Oxide based
ceramic and has a coating of tin oxide. Using a ceramic substrate increases the heating
efficiency and tin oxide, being sensitive towards adsorbing desired gas components (in
this case methane and its products) suffices as sensing coating.
The leads responsible for heating the sensing element are connected through NickelChromium, well known conductive alloy. Leads responsible for output signals are
connected using platinum wires which convey small changes in the current that passes
through the sensing element. The platinum wires are connected to the body of the sensing
element while Nickel-Chromium wires pass through its hollow structure.
3.2.5 APPLICATIONS OF MQ-2 SENSOR:
1) Domestic gas leakage detector
20
resistor (LDR)
or photocell is
light-controlled
variable resistor. The resistance of a photoresistor decreases with increasing incident light
intensity; in other words, it exhibits photoconductivity. A photoresistor can be applied in
light-sensitive detector circuits, and light- and dark-activated switching circuits.
A photoresistor is made of a high resistance semiconductor. In the dark, a photoresistor
can have a resistance as high as a few megaohms (M), while in the light, a photoresistor
can have a resistance as low as a few hundred ohms. If incident light on a photoresistor
exceeds
by
the
semiconductor
give
bound electrons enough energy to jump into the conduction band. The resulting free
electrons (and their hole partners) conduct electricity, thereby lowering resistance. The
resistance range and sensitivity of a photoresistor can substantially differ among dissimilar
devices. Moreover, unique photoresistors may react substantially differently to photons
within certain wavelength bands.
3.3.2 FEATURES AND EXPERIMENTAL PRINCIPAL OF LDR:
Photoresistors are less light-sensitive devices than photodiodes or phototransistors: the two
latter components are true semiconductor devices, while a photoresistor is a passive
component and does not have a PN-junction. The photo resistivity of any photoresistor
may vary widely depending on ambient temperature, making them unsuitable for
applications requiring precise measurement of or sensitivity to light.
21
Photoresistors also exhibit a certain degree of latency between exposure to light and the
subsequent decrease in resistance, usually around 10 milliseconds. The lag time when
going from lit to dark environments is even greater than, often as long as one second. This
property makes them unsuitable for sensing rapidly flashing lights, but is sometimes used
to smooth the response of audio signal compression.
LDRs are light dependent devices whose resistance decreases when light falls on them
and increases in the dark. When a light dependent resistor is kept in dark, its resistance is
very high. This resistance is called as dark resistance. It can be as high as 1012 . And if
the device is allowed to absorb light its resistance will decrease drastically. If a
constantvoltage is applied to it and intensity of light is increased the current starts
increasing.
A light dependent resistor works on the principle of photo conductivity. Photo
conductivity is an optical phenomenon in which the materials conductivity (Hence
resistivity) reduces when light is absorbed by the material.
An LDR has a zigzag cadmium sulphide track. It is a bilateral device, i.e., conducts in both
directions in same fashion.
22
are
also
used
in
some dynamic
compressors together
with
23
time as their surface area increases. The common, traditional solar cell used to generate
electric solar power is a large area photodiode.
Photodiodes are similar to regular semiconductor diodes except that they may be either
exposed (to detect vacuum UV or X-rays) or packaged with a window or optical
fibre connection to allow light to reach the sensitive part of the device. Many diodes
designed for use specifically as a photodiode use a PIN junction rather than a pn junction,
to increase the speed of response. A photodiode is designed to operate in reverse bias.
3.4.2
24
A passive infrared sensor (PIR sensor) is an electronic sensor that measures infrared (IR)
light radiating from objects in its field of view. They are most often used in PIR-based
motion detectors.The IR Sensor-Single is a general purpose proximity sensor. Here we use
it for collision detection. The module consist of an IR emitter and IR receiver pair. The
high precision IR receiver always detects an IR signal. The module consists of 358
comparator IC. The output of sensor is high whenever it IR frequency and low otherwise.
The on-board LED indicator helps user to check status of the sensor without using any
additional hardware. The power consumption of this module is low. It gives a digital
output.
They
are
commonly
used
in burglar
alarms and
automatically-
activated lighting systems. They are commonly called simply "PIR", or sometimes "PID",
for "passive infrared detector". The PIR sensor is typically mounted on a printed circuit
board containing the necessary electronics required to interpret the signals from the sensor
itself. The complete assembly is usually contained within a housing, mounted in a location
where the sensor can cover area to be monitored.
The term passive in this instance refers to the fact that PIR devices do not generate or
radiate any energy for detection purposes. They work entirely by detecting the energy
given off by other objects.[1] PIR sensors don't detect or measure "heat"; instead they detect
the infrared radiation emitted or reflected from an object.
26
Infrared radiation enters through the front of the sensor, known as the 'sensor face'. At the
core of a PIR sensor is a solid state sensor or set of sensors, made from pyroelectric
materialsmaterials which generate energy when exposed to heat. Typically, the sensors
are approximately 1/4 inch square (40 mm2), and take the form of a thin film. Materials
commonly
used
in
PIR
sensors
fluorides,
include gallium
derivatives
pyridine,
but different surface characteristics may also have a different infrared emission pattern,
and thus sometimes trigger the detector.
PIRs come in many configurations for a wide variety of applications. The most common
models have numerous Fresnel lenses or mirror segments, an effective range of about ten
meters (thirty feet), and a field of view less than 180 degrees. Models with wider fields of
view, including 360 degrees, are availabletypically designed to mount on a ceiling.
Some larger PIRs are made with single segment mirrors and can sense changes in infrared
energy over one hundred feet away from the PIR. There are also PIRs designed with
reversible orientation mirrors which allow either broad coverage (110 wide) or very
narrow "curtain" coverage, or with individually selectable segments to "shape" the
coverage.
3.5.5 APPLICATIONS OF PASSIVE INFRARED SENSOR:
When used as part of a burglar alarm, the electronics in the PIR typically control a
small relay. This relay completes the circuit across a pair of electrical contacts connected
to a detection input zone of the burglar alarm control panel. The system is usually
designed such that if no motion is being detected, the relay contact is closeda 'normally
closed' (NC) relay. If motion is detected, the relay opens, triggering the alarm.
28
CHAPTER 4:
CONTROL CIRCUITORY
Step down transformers are designed to reduce electrical voltage. Their primary voltage is
greater than their secondary voltage. This kind of transformer "steps down" the voltage
applied to it. For instance, a step down transformer is needed to use an 110v product in a
country with a 220v supply.
Step down transformers convert electrical voltage from one level or phase configuration
usually down to a lower level. They can include features for electrical isolation, power
distribution, and control and instrumentation applications. Step down transformers
typically rely on the principle of magnetic induction between coils to convert voltage
and/or current levels.
Step down transformers are made from two or more coils of insulated wire wound around
a core made of iron. When voltage is applied to one coil (frequently called the primary or
input) it magnetizes the iron core, which induces a voltage in the other coil, (frequently
called the secondary or output). The turns ratio of the two sets of windings determines the
amount of voltage transformation.
4.1.2 BRIDGE RECTIFIER:
A diode bridge is an arrangement of four (or more) diodes in a bridge circuit configuration
that provides the same polarity of output for either polarity of input.
When used in its most common application, for conversion of an alternating current (AC)
input into a direct current (DC) output, it is known as a bridge rectifier. A bridge rectifier
30
provides full-wave rectification from a two-wire AC input, resulting in lower cost and
weight as compared to a rectifier with a 3-wire input from a transformer with a centertapped secondary winding.
Basic operation:
In the diagrams below, when the input connected to the left corner of the diamond is
positive, and the input connected to the right corner is negative, current flows from the
upper supply terminal to the right along the red (positive) path to the output, and returns to
the lower supply terminal via the blue (negative) path.
When the input connected to the left corner is negative, and the input connected to the
right corner is positive, current flows from the lower supply terminal to the right along the
red (positive) path to the output, and returns to the upper supply terminal via the blue
(negative) path.
When the input connected to the left corner is negative, and the input connected to the
right corner is positive, current flows from the lower supply terminal to the right along the
red (positive) path to the output, and returns to the upper supply terminal via the blue
(negative) path.
In each case, the upper right output remains positive and lower right output negative.
Since this is true whether the input is AC or DC, this circuit not only produces a DC
output from an AC input, it can also provide what is sometimes called "reverse polarity
31
A regulated power supply is very much essential for several electronic devices due to the
semiconductor material employed in them have a fixed rate of current as well as voltage.
The device may get damaged if there is any deviation from the fixed rate. The AC power
supply gets converted into constant DC by this circuit. By the help of a voltage regulator
DC, unregulated output will be fixed to a constant voltage. The circuit is made up of linear
voltage regulator 7805 along with capacitors and resistors with bridge rectifier made up
from diodes. From giving an unchanging voltage supply to building confident that output
reaches uninterrupted to the appliance, the diodes along with capacitors handle elevated
efficient signal conveyed.
32
Features:
1. 500-mA-Rated Collector Current (Single Output)
2.
High-Voltage Outputs: 50 V
3.
4.
5.
Relay-Driver Applications
Working:
Applications:
1.
2.
3.
Drive Relays
Lamp and LED displays
Stepper motors
34
Many
relays
use
an electromagnet to
mechanically operate a switch, but other operating principles are also used, such as solidstate relays. Relays are used where it is necessary to control a circuit by a low-power
signal (with complete electrical isolation between control and controlled circuits), 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.
4.3.2 BASIC DESIGN AND RELAY OPERATION:
When an electric current is passed through the coil it generates a magnetic field that
activates the armature, and the consequent movement of the movable contact(s) either
makes or breaks (depending upon construction) a connection with a fixed contact. If the
set of contacts was closed when the relay was de-energized, then the movement opens the
contacts and breaks the connection, and vice versa if the contacts were open. When the
current to the coil is switched off, the armature is returned by a force, approximately half
as strong as the magnetic force, to its relaxed position. Usually this force is provided by a
spring, but gravity is also used commonly in industrial motor starters. Most relays are
manufactured to operate quickly. In a low-voltage application this reduces noise; in a high
voltage or current application it reduces arcing.
When the coil is energized with direct current, a diode is often placed across the coil to
dissipate the energy from the collapsing magnetic field at deactivation, which would
otherwise generate a voltage spike dangerous to semiconductor circuit components. Some
automotive relays include a diode inside the relay case. Alternatively, a contact protection
network consisting of a capacitor and resistor in series (snubbed circuit) may absorb the
surge. If the coil is designed to be energized with alternating current (AC), some method is
used to split the flux into two out-of-phase components which add together, increasing the
minimum pull on the armature during the AC cycle. Typically this is done with a small
35
copper "shading ring" crimped around a portion of the core that creates the delayed, outof-phase component.[1]
4.3.3 JQC-3FC/T73 SUGAR CUBE RELAY:
1.
2.
3.
4.
5.
6.
7.
8.
SPECIFICATIONS:
MAX. SWITCHING CURRENT:7A, 10A
MAX. SWITCHING VOLTAGE:28V DC/ 250V AC
DIELECTRIC STRENGTH VR.M.S: BETWEEN OPEN CONTACTS =750VAC;
BETWEEN COIL AND CONTACTS =1000VAC;
BETWEEN CONTACTS FORM =1000VAC;
AMBIENT TEMPERATURE: -40-+85oC;
OPERATION/RELEASE TIME:=10/8MS
CONTACT CAPACITY: 10A 125V, 7A 250V
4.4 FAN:
A fan is any fan inside, or attached to, a computer case used for active cooling, and may
refer to fans that draw cooler air into the case from the outside, expel warm air from
inside, or move air across a heat sink to cool a particular component. As processor,
sensors and other components in ARM board emit a lot of heat when overheated, these
36
4.5 BUZZER
A buzzer or beeper is
an audio Signaling
device, which
may
37
They are of three kinds. Mechanical, electrical and piezoelectric respectively. In the
project, we are using an electrical buzzer. In this project, buzzer is used as an alarm when
there occurs a fire, or a thief or when smokes reaches 200mV.
2.
3.
4.
5.
6.
7.
8.
9.
38
39
states (respectively: Down | Long-press | Up), each state can send commands event.
3. Command Line: Set the command terminator for communication debugging.
If the connected Bluetooth device is not paired, the system will automatically prompt you
for pairing. Bluetooth pairing is successful, try to connect again.
This can only connect Bluetooth serial module devices, Bluetooth devices are generally
used for MCU serial communication.
System using the Bluetooth pairing means: [menu-> Settings -> Wireless and Network ->
Bluetooth Settings], open the Bluetooth feature, and to search for Bluetooth devices to
pair, paired with a device only once.
System Configuration (includes keyboard mode button settings) file can be found in the
SD card Bluetooth spp pro directory. You can back up the configuration file, or copy the
configuration file to another terminal equipment, covering his profile to complete
recovery.
2.
3.
4.
5.
40
6.
7.
8.
180gm weight
9.
35kgcm torque
41
4. The logical low in the IC is set to 1.5V. This means the pin is set high only if the
voltage across the pin crosses 1.5V which makes it suitable for use in high
frequency applications like switching applications (up to 5KHz)
Fig.4.13 IC L293D
H-bridges can be built from scratch using relays, mosfets, field effect transistors
(FET), bi-polar junction transistors (BJT), etc.
As in the image, the circuit has four switches A, B, C and D. Turning these switches ON
and OFF can drive a motor in different ways.
1. Turning on Switches A and D makes the motor rotate clockwise
42
43
CHAPTER 5:
SERIAL COMMUNICATION AND DISPLAY
44
45
mandatory the D-sub miniature 25-pin connector. According to the standard, male
connectors have DTE pin functions, and female connectors have DCE pin functions. Other
devices may have any combination of connector gender and pin definitions. Many
terminals were manufactured with female connectors but were sold with a cable with male
connectors at each end; the terminal with its cable satisfied the recommendations in the
standard. The standard specifies 20 different signal connections. Since most devices use
only a few signals, smaller connectors can often be used.
5.1.3 RANGE OF RS-232:
Cable length is one of the most discussed items in RS232 world. The standard has a clear
answer, the maximum cable length is 50 feet, or the cable length equal to a capacitance of
2500 pF. The latter rule is often forgotten. This means that using a cable with low
capacitance allows you to span longer distances without going beyond the limitations of
the standard.
5.1.4 COMMUNICATION METHODS OF RS-232:
To implement RS232 software handshaking, it is necessary to send codes along the lines to
establish communications and control the data flow. There are a number of control codes
used for RS232 (and other) links under these circumstances. However they are normally
used with older legacy equipment.
5.1.5 PIN DIAGRAM OF THE RS-232:
46
up to 25 volts. Some computer equipment ignores the negative level and accepts a zero
voltage level as the OFF state. The output signal level usually swings between +12V and
-12V.
48
displayed on the LCD. The data is the ASCII value of the character to be displayed on the
LCD. Click to learn more about internal structure of a LCD.
Function
Name
Ground (0V)
Supply voltage; 5V (4.7V 5.3V)
Contrast adjustment; through a variable resistor
Selects command register when low; and data register when
high
Low to write to the register; High to read from the register
Sends data to data pins when a high to low pulse is given
8-bit data pins
Ground
Vcc
VEE
49
Register Select
Read/write
Enable
DB0
DB1
DB2
DB3
11
12
13
14
15
16
50
DB4
DB5
DB6
DB7
Led+
Led-
CHAPTER 6:
SOFTWARE USED
2.
Project Manager
3.
Simulator
4.
Debugger
5.
Keil Software provides you with software development tools for the 8051 family of
microcontrollers. With these tools, you can generate embedded applications for the
multitude of 8051 derivatives. Keil provides following tools for 8051 development
1.
2.
3.
4.
Source-Level Debugger/Simulator,
5.
6.3 C COMPILER:
In this project a C-Compiler called Turbo C is used for compilation process.
A compiler is a computer program (or set of programs) that transforms source code written
in a programming language (the source language) into another computer language (the
target language, often having a binary form known as object code). The most common
reason for converting a source code is to create an executable program. Turbo C is
an Integrated
Development
the C
programming
language from Borland. First introduced in 1987, it was noted for its integrated
development environment, small size, fast compile speed, comprehensive manuals and
low price.
#include<string.h>
#include<stdio.h>
///////////////////////////////////////////////////////////////
#define Fosc
12000000
#define Fcclk
(Fosc * 5)
#define Fcco
(Fcclk * 4)
#define Fpclk
(Fcclk / 4) * 1
////////////////////////////////////////////////////////////////
unsigned int C [6]={0x20,0x28,0x01,0x0e,0x06,0x80};
unsigned int RS=0X01000000;
unsigned int EN=0X00400000;
unsigned int PORT=0X00003C00;
////////////////////////////////////////////////////////////////
void LCD_INIT(void);
void LCD_CMD(unsigned char );
void LCD_DATA(unsigned char );
void LCD_DAISPLAY(unsigned char * );
////////////////////////////////////////////////////////////////
unsigned int ADC_Data1=0;
unsigned int ADC_Data2=0;
unsigned int ADC_Data4=0;
unsigned int ADC_Data5=0;
void send_bcd1(int);
void ascii(unsigned int);
void send_bcd(int);
void ADC_Init(void);
////////////////////////////////////////////////////////////////
void DELAY(unsigned int);
////////////////////////////////////////////////////////////////unsigned int aaa;
unsigned char rc;
void Init_UART0(void);
void UART0_SendByte(unsigned char data);
void UART0_SendStr(const unsigned char *str);
54
////////////////////////////////////////////////////////////
main()
{
PINSEL0 = 0x00050005;
// UART 1 and 0
PINSEL1=0x15440000;
IODIR0|=0X00003c00; /*(pin p0.10, 11, 12, 13 are used for LCD data line)*/
IODIR1=0XF3000000; /*(pin p1.24, p1.25 are used for reg: select and Enable)*/
/*(0/P P1.28 TO P1.31 DEVICES) */
ADC_Init();
Init_UART0();
LCD_INIT();
DELAY(100);
LCD_CMD(0x01);
//title 1line
LCD_CMD(0x80);
LCD_DISPLAY(ANDROID MULTI ");
LCD_CMD(0xC0);
LCD_DISPLAY("SENSOR MONITORING");
DELAY(1000);
DELAY(1000);
LCD_CMD (0x01);
LCD_CMD (0x80);
LCD_DISPLAY ("T: F: S: ");
LCD_CMD (0xC0);
LCD_DISPLAY ("I: L:
");
DELAY (1000);
while (1)
{
UART0_SendStr ("********************************* ");
UART0_SendByte ('\r');
UART0_SendByte ('\n');
////////////////////////TEMP////////////////////////////////////
AD0CR = (AD0CR&0xFFFFFF00)|0x02;
//Trigger conversion
55
while ((AD0DR1&0x80000000)==0);
be completed
ADC_Data1 = AD0DR1;
//Store converted
data
ADC_Data1 = (ADC_Data1>>8) & 0x00FF;
ADC_Data5 = ADC_Data1+4;
//DELAY (2000);
LCD_CMD (0x82);
send_bcd (ADC_Data5);
//DELAY(1000);
UART0_SendStr("TEMP : ");
UART0_SendByte((ADC_Data5/10) + 0x30);
UART0_SendByte((ADC_Data5%10) + 0x30);
UART0_SendStr("deg");
UART0_SendByte('\r');
UART0_SendByte('\n');
/////////////////////////////////////////////////////
if(ADC_Data1>45)
{
UART0_SendStr("High Temperature");
UART0_SendStr("TEMP: ");
UART0_SendByte((ADC_Data5/10) + 0x30);
UART0_SendByte((ADC_Data5%10) + 0x30);
UART0_SendStr("deg");
UART0_SendByte('\r');
UART0_SendByte('\n');
DELAY(1000);
}
///////////////////////LIGHT////////////////////////////////////
/*DELAY(1000);
aaa=IOPIN0;
aaa=aaa & 0X00400000;
//p0.22 light
if(aaa==0X00400000)
{
56
LCD_CMD(0xc2);
LCD_DISPLAY("Y");
UART0_SendStr("Light: YES");
UART0_SendByte('\r');
UART0_SendByte('\n');
DELAY(100);
}
else
{
LCD_CMD(0xC2);
LCD_DISPLAY("N");
UART0_SendStr("Light: NO");
UART0_SendByte('\r');
UART0_SendByte('\n');
DELAY(100);
}
////////////////////////SMOKE//////////////////////////////////
DELAY(1000);
AD0CR = (AD0CR&0xFFFFFF00)|0x08;
//P0.30
AD0CR|=(1 << 24);
while((AD0DR3&0x80000000)==0);
ADC_Data2 = AD0DR3;
ADC_Data2 = (ADC_Data2>>8) & 0x03FF;
DELAY(200);
LCD_CMD(0x8c);
send_bcd1(ADC_Data2);
DELAY(100);
UART0_SendStr("SMOKE: ");
UART0_SendByte((ADC_Data2/100) + 0x30);
UART0_SendByte(((ADC_Data2/10)%10) + 0x30);
UART0_SendByte((ADC_Data2%10) + 0x30);
UART0_SendStr("mV");
UART0_SendByte('\r');
57
UART0_SendByte('\n');
if(ADC_Data2>200)
{
DELAY(100);
UART0_SendStr("Smoke Detected ");
UART0_SendByte('\r');
UART0_SendByte('\n');
UART0_SendStr("SMOKE: ");
UART0_SendByte((ADC_Data2/100) + 0x30);
UART0_SendByte(((ADC_Data2/10)%10) + 0x30);
UART0_SendByte((ADC_Data2%10) + 0x30);
UART0_SendStr("mV");
UART0_SendByte('\r');
UART0_SendByte('\n');
DELAY(100);
}
////////////////////////MOTION//////////////////////////////////
DELAY(100);
aaa=IOPIN0;
aaa=aaa & 0X00100000;
if(aaa==0X00100000)
{
LCD_CMD(0xCE);
LCD_DISPLAY("Y");
DELAY(100);
UART0_SendStr("MOTION: YES");
UART0_SendByte('\r');
UART0_SendByte('\n');
DELAY(100);
}
else
{
LCD_CMD(0xCE);
LCD_DISPLAY("N");
58
DELAY(100);
UART0_SendStr("MOTION: NO");
UART0_SendByte('\r');
UART0_SendByte('\n');
DELAY(100);
} */
DELAY(1000);
AD0CR = (AD0CR&0xFFFFFF00)|0x04;
//P0.29
AD0CR|=(1 << 24);
while((AD0DR2&0x80000000)==0);
ADC_Data4 = AD0DR2;
ADC_Data4 = (ADC_Data4>>8) & 0x03FF;
DELAY(200);
//LCD_CMD(0xC2);
//send_bcd(ADC_Data4);
//DELAY(1000);
//UART0_SendStr("HMDTY: ");
//UART0_SendByte((ADC_Data4/10) + 0x30);
//UART0_SendByte((ADC_Data4%10) + 0x30);
//UART0_SendStr("%RH");
UART0_SendByte('\r');
UART0_SendByte('\n');
DELAY(1000);
//////////////////////////FIRE//////////////////////////////////
DELAY(1000);
aaa=IOPIN0;
aaa=aaa & 0X00200000;
//p0.21 fire
if(aaa==0X00200000)
{
LCD_CMD(0x8E);
LCD_DISPLAY("N");
DELAY(1000);
UART0_SendStr("FIRE : NO ");
59
UART0_SendByte('\r');
UART0_SendByte('\n');
DELAY(1000);
}
else
{
LCD_CMD(0x8E);
LCD_DISPLAY("Y");
DELAY(1000);
UART0_SendStr("FIRE : YES ");
UART0_SendByte('\r');
UART0_SendByte('\n');
DELAY(1000);
}
///////////////////////////////////////////////////
DELAY(1000);
DELAY(1000);
DELAY(1000);
DELAY(1000);
}
}
////////////////////////////////////////////////////////////////
void LCD_INIT()
{
unsigned int i;
IODIR0|=PORT;
IODIR1|=0X01400000;
for(i=0;i<6;i++)
{
LCD_CMD(C[i]);
}
}
////////////////////////////////////////////////////////////////
void LCD_CMD(unsigned char x)
60
{
unsigned int data;
IOCLR0=PORT;
data=x;
data=data & 0xf0;
data=data<<6;
IOCLR1=RS;
IOSET0=data;
IOSET1=EN;
DELAY(100);
IOCLR1=EN;
IOCLR0=PORT;
DELAY(100);
data=x;
data=data & 0x0F;
data=data<<10;
IOCLR1=RS;
IOSET0=data;
IOSET1=EN;
DELAY(100);
IOCLR1|=EN;
IOCLR0|=PORT;
}
void LCD_DATA(unsigned char x)
{
unsigned int data;
IOCLR0=PORT;
data=x;
data=data & 0xf0;
data=data<<6;
IOSET1=RS;
IOSET0=data;
IOSET1=EN;
DELAY(100);
61
DELAY(5000);
IOCLR1=EN;
IOCLR0=PORT;
DELAY(100);
data=x;
data=data & 0x0F;
data=data<<10;
IOSET1=RS;
IOSET0=data;
IOSET1=EN;
DELAY(100);
IOCLR1=EN;
IOCLR0=PORT;
}
////////////////////////////////////////////////////////////////
void LCD_DISPLAY(unsigned char *data)
{
while(*data)
{
LCD_DATA(*data);
data++;
}
LCD_CMD(0x80);
}
////////////////////////////////////////////////////////////////
void DELAY(unsigned int val)
{
unsigned int i;
while(val--)
for (i=0; i<200; i++);
}
////////////////////////////////////////////////////////////////
void Init_UART0(void)
{
62
// DLAB = 1
data=data+0x30;
LCD_DATA(data);
DELAY(1000);
}
void send_bcd1(int value)
{
int d1=0,d2=0,d3=0,d4=0;
//aaa=0;
while(value>=1000)
{
value=value-1000;
d4++ ;
}
//ascii(d4);
while(value>=100)
{
value=value-100;
d3++ ;
}
ascii(d3);
while(value>=10)
{
value=value-10;
d2++ ;
}
ascii(d2);
d1=value;
ascii(d1);
}
void ADC_Init()
{
AD0CR=0x00200E00;
// SEL = 1
ADC0 channel 1
Channel 1
UART1
{
U0THR = data;
while( (U0LSR&0x40)==0 );
}
void UART0_SendStr(const unsigned char *str)
on UART1
{
while(1)
{
if( *str == '\0' ) break;
UART0_SendByte(*str++);
}
}
65
66
OBSERVATIONS:
67
68
69
70
REFRENECES:
1. Codeproject.com
2. Wikipedia.com
3. Engineers garage.com
4. Microcontrollers.blogspot.com
5. https://www.sparkfun.com/datasheets/sensors
6. IIT Kharagpur study materials
7. www.arm.com
8. www.keil.com
9. www.datasheetarchive.com
10. ebooksgenius.com
71