Anda di halaman 1dari 51

CONTENTS

Page-no
Abstract
List of figures
List of Tables
Abbreviations

CHAPTER1: INTRODUCTION
1.1 Introduction to the project.
1.2 Introduction to the embedded systems.
CHAPTER2: PROJECT BLOCK DIAGRAM
CHAPTER3: HARDWARE
3.1 Microcontroller..
CHAPTER4: SOFTWARE
CHAPTER5: PROJECT DESCRIPTION
CHAPTER6: RESULTS
CHAPTER7: APPLICATIONS
CHAPTER8: CONCLUSIONS AND FUTURE SCOPE
BIBLIOGRAPHY
Appendix

ABSTRACT
This project describes the development of a heart rate based on a microcontroller through
Bluetooth module .It offers the advantage of monitoring heart rate of patient through smartphone
using Bluetooth .The paper explains how a single-chip microcontroller can be used to analyse
heart beat rate signals in real-time .In addition, it allows doctors to get the heart rate of the
patient by Bluetooth terminal Application in their android smartphone every minute. The system
reads, stores and analyses the heart beat rate repetitively in real time. The hardware and software
design are oriented towards a single-chip microcontroller-based system, hence minimizing the
size. The important feature of this project is the use of pulse-time conversion process to compute
heart rate. It then processes on the real-time data, that is the information to determine whether
the heart rate is normal or abnormal.

List of figures
Chapter 2:
Project Block Diagram Fig 2.1
Chapter 3:
Pin Diagram of Micro controller AT89S52..Fig 3.1.
Circuit Diagram of AT89S52..Fig 3.1.1
Oscillator ConnectionsFig 3.2
External Clock Drive Configuration...Fig 3.2.1
Block Diagram of power supply.Fig 3.3
Bridge Rectifier...Fig 3.4
Voltage Regulator (LM 7805).Fig 3.5
Bluetooth Module (HC-05).Fig 3.6
Pulse rate sensor..Fig 3.7
Heart beat & sensor signal output graph.Fig 3.8
Liquid Crystal DisplayFig 3.9
Pin Diagram of LCD...Fig 3.10
Chapter 4:
Schematic of projectFig 4.1
Chapter 6:
Result after placing an LCDFig 6.1
Result obtained in smartphone.Fig 6.2

List of tables:
Chapter 3:
Various Special Features of Port3 in AT89S52..table 3.1
Pin Description of LCD..table 3.2
Instruction set of LCDtable 3.3

ABBREVIATIONS:
ECG: Electrocardiogram
SQL: Structured Queuing Language
PHP: Programmable Hypertext Preprocessor
APACHE: Acute Physiology Age Chronic Health Evaluation
DVD: Digital Versatile Disc
AT89S52=AT-Atmel+89=Manufacture Series +S=SiliconCMOS+52 is the family
LCD: Liquid Crystal Display
IDE: Integrated Development Environment
OR-CAD: OR(Oregon, UNITED STATES)+CAD(Computer-Aided Design)
RAM: Random Access Memory
ROM: Read Only Memory
CPU: Central Processing Unit
I/O PORTS: Input / Output ports
UV-RAM: Ultraviolet Radiation Random Access Memory
NV_RAM: Non-Volatile Random Access Memory
UART: Universal Asynchronous Receiver/Transmitter
ISP: In-System Programming
MCS: Micro Controller Series
CMOS: Complementary Metal Oxide Semiconductor
TTL: Transistor-Transistor Logic
MCU: Multipoint Control Unit
LED: Light Emitting Diode
TXD: Transmit Data
RXD: Receive Data
SMD: Surface Mounted Device
PCB: Printed Circuit Board
ANSI: American National Standard Institute

CHAPTER -1
INTRODUCTION
1.1 Introduction to the project:
Patient monitoring system is a process where a surgeon can continuously monitor more than one
patient, for more than one parameter at a time in a remote place. With the development of
Smartphone, it has performed a Smartphone based body monitoring system with a combination
of the advantages of network technology and multiple sensor fusion technology. Body
monitoring system greatly improves the operational capability of health care, such as remote
operations, wireless health care so on. There has been a growing concern with technology of
medical care which has developed rapidly and plays an increasingly important role in our life.
The advances in information and communication technologies enable technically, the continuous
monitoring of health related parameters with wireless sensor, wherever the user happens to be.
They provide valuable real time information enabling the physicians to monitor and analyze a
patients current and previous state of health. Now days there are several efforts towards the
development of system that carry out remote monitoring of patients. Traditional healthcare
technologies mostly are confined to hospitals and other specific place, which is not convenient
for the users movement. It may also take lots of money. At present, several proposals, have been
used to concentrate to this issue. But they also suffer from some limitations mainly. Concerning
single function of equipment and the potential radiation hazards by mobile phone direct
contacting with the body. In order to solve the purpose of mobile medical care, we can use
android Smartphone as a component of this system. Android mobile phone can not only receive
the data collected by our hardware device but also can transmit these data to remote server in
time. This method not only simplifies and speeds up the process of information acquisition,
processing and analysis, but also declines costs of equipment; therefore, researchers have
become more interested in wireless health care. Although many wireless standards can be used,
there are important considerations such as range, throughput, security, ease of implementation
and cost. The patient monitoring involves handling of sensitive data. These data should be
transmitted securely without any intrusion. The web-database is a system where the web server
will store the data in table format where the digital data are filled in column and then it is plotted
against the time to get ECG graph and other parameters. There are n-numbers of database

available in the market but for this system we have choose My SQL since its an open source
relational database management system. It also widely used by web application developers,
together with PHP and APACHE. My SQL is a three layer model Application layer, Logical layer
and Physical layer. In present paper, we report on development of patient monitoring system an
android platform which is an open source, to display five parameter such as E.C.G., Heart Beat,
Temperature, Pulse Oximeter, and Blood Pressure. With this module, the doctors who are not
present in hospital at time of emergency, they can also operate looking at the different parameters
on his or her smart phone or laptop. The reset of this paper is organized as follows. In section 2,
we discuss the problem definition. In section 3 we discuss system architecture and
implementation. In section 4 we discuss about the working system of an android based patient
monitoring system. In section 5 demonstrates about the procedure to access the android
application.

1.2 INTRODUCTION TO EMBEDDED SYSTEMS


An embedded system is a special-purpose system in which the computer is completely
encapsulated by or dedicated to the device or system it controls. Unlike a general-purpose
computer, such as a personal computer, an embedded system performs one or a few pre-defined
tasks, usually with very specific requirements. Since the system is dedicated to specific tasks,
design engineers can optimize it, reducing the size and cost of the product. Embedded systems
are often mass-produced, benefiting from economies of scale.
Personal digital assistants (PDAs) or handheld computers are generally considered embedded
devices because of the nature of their hardware design, even though they are more expandable in
software terms. This line of definition continues to blur as devices expand.
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.
In terms of complexity embedded systems can range from very simple with a single
microcontroller chip, to very complex with multiple units, peripherals and networks mounted
inside a large chassis or enclosure.

1.4 Examples of embedded systems

Automatic teller machines (ATMs)

Avionics, such as inertial guidance systems, flight control hardware/software and other
integrated systems in aircraft and missiles

Cellular telephones and telephone switches

engine controllers and antilock brake controllers for automobiles

Home automation products, such as thermostats, air conditioners, sprinklers, and security
monitoring systems

Handheld calculators

Handheld computers

Household appliances, including microwave ovens, washing machines, television sets, DVD
players and recorders

Medical equipment

Personal digital assistant

Videogame consoles

Computer peripherals such as routers and printers

Industrial controllers for remote machine operation.

Characteristics
Embedded systems are designed to do some specific task, rather than be a generalpurpose computer for multiple tasks. Some also have real-time performance constraints that must
be met, for reason such as safety and usability; others may have low or no performance
requirements, allowing the system hardware to be simplified to reduce costs. An embedded
system is not always a separate block - very often it is physically built-in to the device it is
controlling. The software written for embedded systems is often called firmware, and is stored in
read-only memory or Flash memory chips rather than a disk drive. It often runs with limited
computer hardware resources: small or no keyboard, screen, and little memory.

Reliability
Embedded systems often reside in machines that are expected to run continuously for
years without errors and in some cases recover by them if an error occurs. Therefore the software
is usually developed and tested more carefully than that for personal computers, and unreliable
mechanical moving parts such as disk drives, switches or buttons are avoided.
Specific reliability issues may include:
1. The system cannot safely be shut down for repair, or it is too inaccessible to repair.
Solutions may involve subsystems with redundant spares that can be switched over to, or

software "limp modes" that provide partial function. Examples include space systems,
undersea cables, navigational beacons, bore-hole systems, and automobiles.
2. The system must be kept running for safety reasons. "Limp modes" are less tolerable.
Often backups are selected by an operator. Examples include aircraft navigation, reactor
control systems, safety-critical chemical factory controls, train signals, engines on singleengine aircraft.
3. The system will lose large amounts of money when shut down: Telephone switches,
factory controls, bridge and elevator controls, funds transfer and market making,
automated sales and service.

CHAPTER-2
PROJECT BLOCK DIAGRAM
BLOCK DIAGRAM:

POWER SUPPLY
MICRO

LCD DISPLAY
CONTROLLER AT89S52
(16 X 2 LINES)

SENSORS
( PULSE)

BLUETOOTH MODULE

FIG-2.1: BLOCK DIAGRAM OF THE PROJECT

CHAPTER-3
HARDWARE
3.1 MICROCONTROLLER
Microprocessors and microcontrollers are widely used in embedded systems products.
Microcontroller is a programmable device. A microcontroller has a CPU in addition to a fixed
amount of RAM, ROM, I/O ports and a timer embedded all on a single chip. 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.
The Intel 8051 is Harvard architecture, single chip microcontroller (C) which was
developed by Intel in 1980 for use in embedded systems. It was popular in the 1980s and early
1990s, but today it has largely been superseded by a vast range of enhanced devices with 8051compatible processor cores that are manufactured by more than 20 independent manufacturers
including Atmel, Infineon Technologies and Maxim Integrated Products.
8051 is an 8-bit processor, meaning that the CPU can work on only 8 bits of data at a
time. Data larger than 8 bits has to be broken into 8-bit pieces to be processed by the CPU. 8051
is available in different memory types such as UV-EPROM, Flash and NV-RAM.
The present project is implemented on Keil Uvision. In order to program the device,
Proload tool has been used to burn the program onto the microcontroller.
The features, pin description of the microcontroller and the software tools used are
discussed in the following sections.
3.1 .1FEATURES OF AT89s52:

8K Bytes of Re-programmable Flash Memory.

RAM is 256 bytes.

4.0V to 5.5V Operating Range.

Fully Static Operation: 0 Hz to 33 MHzs

Three-level Program Memory Lock.

256 x 8-bit Internal RAM.

32 Programmable I/O Lines.

Three 16-bit Timer/Counters.

Eight Interrupt Sources.

Full Duplex UART Serial Channel.

Low-power Idle and Power-down Modes.

Interrupt recovery from power down mode.

Watchdog timer.

Dual data pointer.

Power-off flag.

Fast programming time.

Flexible ISP programming (byte and page mode).

3.1.2 Description:
The AT89s52 is a low-voltage, high-performance CMOS 8-bit microcomputer with 8K
bytes of Flash programmable memory. The device is manufactured using Atmels high density
nonvolatile memory technology and is compatible with the industry-standard MCS-51
instruction set. The on chip flash allows the program memory to be reprogrammed in system or
by a conventional non volatile memory programmer. By combining a versatile 8-bit CPU with

Flash on a monolithic chip, the Atmel AT89s52 is a powerful microcomputer, which provides a
highly flexible and cost-effective solution to many embedded control applications.
In addition, the AT89s52 is designed with static logic for operation down to zero frequency and
supports two software selectable power saving modes. The Idle Mode stops the CPU while
allowing the RAM, timer/counters, serial port and interrupt system to continue functioning. The
power-down mode saves the RAM contents but freezes the oscillator disabling all other chip
functions until the next hardware reset.

Fig-3.1: Pin Diagram of Microcontroller AT89S52

Fig-3.1.1: Circuit diagram of AT89S52

3.1.2 PIN DESCRIPTION:

VCC

Pin 40 provides supply voltage to the chip. The voltage source is +5V.

GND Pin 20 is the ground.


Port 0
Port 0 is an 8-bit open drain bidirectional I/O port. As an output port, each pin can sink
eight TTL inputs. When 1s are written to port 0 pins, the pins can be used as high impedance
inputs. Port 0 can also be configured to be the multiplexed low-order address/data bus during
accesses to external program and data memory. In this mode, P0 has internal pull-ups.
Port 0 also receives the code bytes during Flash programming and outputs the code bytes during
Program verification. External pull-ups are required during program verification.
Port 1
Port 1 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 1 output buffers
can sink/source four TTL inputs. When 1s are written to Port 1 pins, they are pulled high by the
internal pull-ups and can be used as inputs. As inputs, Port 1 pins that are externally being pulled
low will source current (IIL) because of the internal pull-ups. In addition, P1.0 and P1.1 can be
configured to be the timer/counter 2 external count input (P1.0/T2) and the timer/counter 2
trigger input (P1.1/T2EX), respectively, as shown in the following table.
Port 1 also receives the low-order address bytes during Flash programming and verification.

Port 2
Port 2 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 2 output buffers
can sink/source four TTL inputs. When 1s are written to Port 2 pins, they are pulled high by the
internal pull-ups and can be used as inputs. As inputs, Port 2 pins that are externally being pulled
low will source current (IIL) because of the internal pull-ups.

Port 2 emits the high-order address byte during fetches from external program memory
and during accesses to external data memory that uses 16-bit addresses (MOVX @ DPTR). In
this application, Port 2 uses strong internal pull-ups when emitting 1s. During accesses to
external data memory that uses 8-bit addresses (MOVX @ RI), Port 2 emits the contents of the
P2 Special Function Register. The port also receives the high-order address bits and some control
signals during Flash programming and verification.
Port 3
Port 3 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 3 output buffers
can sink/source four TTL inputs. When 1s are written to Port 3 pins, they are pulled high by the
internal pull-ups and can be used as inputs. As inputs, Port 3 pins that are externally being pulled
low will source current (IIL) because of the pull-ups. Port 3 receives some control signals for
Flash programming and verification.
Port 3 also serves the functions of various special features of the AT89S52, as shown in
the following table.

Table 3.1 Special features of Port 3 in AT89S52.

RST
Reset input. A high on this pin for two machine cycles while the oscillator is running
resets the device. This pin drives high for 98 oscillator periods after the Watchdog times out. The
DISRTO bit in SFR AUXR (address 8EH) can be used to disable this feature. In the default state
of bit DISRTO, the RESET HIGH out feature is enabled.
ALE/PROG
Address Latch Enable (ALE) is an output pulse for latching the low byte of the address
during accesses to external memory. This pin is also the program pulse input (PROG) during
Flash programming.
In normal operation, ALE is emitted at a constant rate of 1/6 the oscillator frequency and
may be used for external timing or clocking purposes. Note, however, that one ALE pulse is
skipped during each access to external data memory.
If desired, ALE operation can be disabled by setting bit 0 of SFR location 8EH. With the
bit set, ALE is active only during a MOVX or MOVC instruction. Otherwise, the pin is weakly
pulled high. Setting the ALE-disable bit has no effect if the microcontroller is in external
execution mode.
PSEN
Program Store Enable (PSEN) is the read strobe to external program memory. When the
AT89S52 is executing code from external program memory, PSEN is activated twice each
machine cycle, except that two PSEN activations are skipped during each access to external data
memory.
EA/VPP
External Access Enable. EA must be strapped to GND in order to enable the device to
fetch code from external program memory locations starting at 0000H up to FFFFH. Note,
however, that if lock bit 1 is programmed, EA will be internally latched on reset.
EA should be strapped to VCC for internal program executions. This pin also receives the 12volt programming enable voltage (VPP) during Flash programming.

XTAL1
Input to the inverting oscillator amplifier and input to the internal clock operating circuit.

XTAL2
Output from the inverting oscillator amplifier.
Oscillator Connections

Fig-3.2 Oscillator Connections.


C1, C2 = 30 pF 10 pF for Crystals
= 40 pF 10 pF for Ceramic Resonators
External Clock Drive Configuration

Fig-3.2.1: External Clock drive Configuration of Oscillator.

XTAL1 and XTAL2 are the input and output, respectively, of an inverting amplifier that can be
configured for use as an on-chip oscillator. Either a quartz crystal or ceramic resonator may be
used. To drive the device from an external clock source, XTAL2 should be left unconnected
while XTAL1 is driven. There are no requirements on the duty cycle of the external clock signal,
since the input to the internal clocking circuitry is through a divide-by-two flip-flop, but
minimum and maximum voltage high and low time specifications must be observed.

HARDWARE COMPONENTS
Power Supply
There are many types of power supply. Most are designed to convert high voltage AC
mains electricity to a suitable low voltage supply for electronic circuits and other devices. A
power supply can by broken down into a series of blocks, each of which performs a particular
function.
For example a 5V regulated supply:

Fig-3.3: Block Diagram Of Power Supply.


Each of the blocks is described in more detail below:

Transformer - steps down high voltage AC mains to low voltage AC.

Rectifier - converts AC to DC, but the DC output is varying.

Smoothing - smooths the DC from varying greatly to a small ripple.

Regulator - eliminates ripple by setting DC output to a fixed voltage.


Transformer
Transformers convert AC electricity from one voltage to another with little loss of power.
Transformers work only with AC and this is one of the reasons why mains electricity is AC. Step-

up transformers increase voltage, step down transformers reduce voltage. Most power supplies
use a step-down transformer to reduce the dangerously high mains voltage (230V in UK) to a
safer low voltage.
The input coil is called the primary and the output coil is called the secondary. There is no
electrical connection between the two coils; instead they are linked by an alternating magnetic
field created in the soft-iron core of the transformer. The two lines in the middle of the circuit
symbol represent the core. Transformers waste very little power so the power out is (almost)
equal to the power in. Note that as voltage is stepped down current is stepped up.

Bridge rectifier
A bridge rectifier can be made using four individual diodes, but it is also available in
special packages containing the four diodes required. It is called a full-wave rectifier because it
uses the entire AC wave (both positive and negative sections). 1.4V is used up in the bridge
rectifier because each diode uses 0.7V when conducting and there are always two diodes
conducting, as shown in the diagram below. Bridge rectifiers are rated by the maximum current
they can pass and the maximum reverse voltage they can withstand (this must be at least three
times the supply RMS voltage so the rectifier can withstand the peak voltages). Alternate pairs of
diodes conduct, changing over the connections so the alternating directions of AC are converted
to the one direction of DC.

Fig-3.4: Bridge Rectifier

Regulator

Voltage regulator ICs are available with fixed (typically 5, 12 and 15V) or variable output
voltages. They are also rated by the maximum current they can pass. Negative voltage regulators
are available, mainly for use in dual supplies. Most regulators include some automatic protection
from excessive current ('overload protection') and overheating ('thermal protection').

Fig-

3.5: Voltage Regulator.


Many of the fixed voltage regulators ICs have 3 leads and look like power transistors,
such as the 7805 +5V 1A regulator shown on the right. They include a hole for attaching a heat
sink if necessary.

BLUETOOTH MODULE (HC 05)


HC Serial Bluetooth Products User Instructional Manual 1 Introduction HC serial Bluetooth
products consist of Bluetooth serial interface module and Bluetooth adapter, such as: (1)
Bluetooth serial interface module: Industrial level: HC-03, HC-04(HC-04-M, HC-04-S) Civil
level: HC-05, HC-06(HC-06-M, HC-06-S) HC-05-D, HC-06-D (with baseboard, for test and
evaluation) (2) Bluetooth adapter: HC-M4 HC-M6 This document mainly introduces Bluetooth
serial module. Bluetooth serial module is used for converting serial port to Bluetooth.

Fig-3.6: Bluetooth Module


These modules have two modes: master and slaver device. The device named after even number
is defined to be master or slaver when out of factory and cant be changed to the other mode. But
for the device named after odd number, users can set the work mode (master or slaver) of the
device by AT commands. HC-04 specifically includes: Master device: HC-04-M, M=master
Slave device: HC-04-S, S=slaver The default situation of HC-04 is slave mode. If you need
master mode, please state it clearly or place an order for HC-O4-M directly.The naming rule of
HC-06 is same. When HC-03 and HC-05 are out of factory, one part of parameters are set for
activating the device. The work mode is not set, since user can set the mode of HC-03, HC-05 as
they want. The main function of Bluetooth serial module is replacing the serial port line, such as:
1. There are two MCUs want to communicate with each other. One connects to Bluetooth master
device while the other one connects to slave device. Their connection can be built once the pair
is made. This Bluetooth connection is equivalently liked to a serial port line connection including
RXD, TXD signals. And they can use the Bluetooth serial module to communicate with each
other. 2. When MCU has Bluetooth salve module, it can communicate with Bluetooth adapter of
computers and smart phones. Then there is a virtual communicable serial port line between MCU
and computer or smart phone. 3. The Bluetooth devices in the market mostly are salve devices,
such as Bluetooth printer, Bluetooth GPS. So, we can use master module to make pair and
communicate with them. Bluetooth Serial modules operation doesnt need drive, and can
communicate with the other Bluetooth device who has the serial. But communication between
two Bluetooth modules requires at least two conditions: (1) The communication must be between
master and slave. (2) The password must be correct. However, the two conditions are not
sufficient conditions. There are also some other conditions basing on different device model.

Detailed information is provided in the following chapters. In the following chapters, we will
repeatedly refer to Linvors (Formerly known as Guangzhou HC Information Technology Co.,
Ltd.) material and photos. 2 Selection of the Module The Bluetooth serial module named even
number is compatible with each other; The salve module is also compatible with each other. In
other word, the function of HC-04 and HC-06, HC-03 and HC-05 are mutually compatible with
each other. HC-04 and HC-06 are former version that user cant reset the work mode (master or
slave). And only a few AT commands and functions can be used, like reset the name of Bluetooth
(only the slaver), reset the password, reset the baud rate and check the version number. The
command set of HC-03 and HC-05 are more flexible than HC-04 and HC-06s. Generally, the
Bluetooth of HC-03/HC-05 is recommended for the user. Here are the main factory parameters
of HC-05 and HC-06. Pay attention to the differences: HC-05 HC-06 Master and slave mode can
be switched Master and slave mode cant be switched Bluetooth name: HC-05 Bluetooth name:
linvor Password:1234 Password:1234 Master role: have no function to remember the last paired
salve device. It can be made paired to any slave device. In other words, just set AT+CMODE=1
when out of factory. If you want HC-05 to remember the last paired slave device address like
HC-06, you can set AT+CMODE=0 after paired with the other device. Please refer the command
set of HC-05 for the details. Master role: have paired memory to remember last slave device and
only make pair with that device unless KEY (PIN26) is triggered by high level. The default
connected PIN26 is low level. Pairing: The master device can not only make pair with the
specified Bluetooth address, like cell-phone, computer adapter, slave device, but also can search
and make pair with the slave device automatically. Typical method: On some specific conditions,
master device and slave device can make pair with each other automatically. (This is the default
method.) Pairing: Master device search and make pair with the slave device automatically.
Typical method: On some specific conditions, master and slave device can make pair with each
other automatically. Multi-device communication: There is only point to point communication
for modules, but the adapter can communicate with multi-modules. Multi-device
communication: There is only point to point communication for modules, but the adapter can
communicate with multi-modules. AT Mode 1: After power on, it can enter the AT mode by
triggering PIN34 with high level. Then the baud rate for setting AT command is equal to the baud
rate in communication, for example: 9600. AT mode 2: First set the PIN34 as high level, or while
on powering the module set the PIN34 to be high level, the Baud rate used here is 38400 bps.

Notice: All AT commands can be operated only AT Mode: Before paired, it is at the AT mode.
After paired its at transparent communication. when the PIN34 is at high level. Only part of the
AT commands can be used if PIN34 doesnt keep the high level after entering to the AT mode.
Through this kind of designing, set permissions for the module is left to the users external
control circuit, that makes the application of HC-05 is very flexible. During the process of
communication, the module can enter to AT mode by setting PIN34 to be high level. By releasing
PIN34, the module can go back to communication mode in which user can inquire some
information dynamically. For example, to inquire the pairing is finished or not. During the
communication mode, the module cant enter to the AT mode. Default communication baud rate:
9600, 4800-1.3M are settable. Default communication baud rate: 9600, 1200-1.3M are settable.
KEY: PIN34, for entering to the AT mode. KEY: PIN26, for master abandons memory. LED1:
PIN31, indicator of Bluetooth mode. Slow flicker (1Hz) represents entering to the AT mode2,
while fast flicker(2Hz) represents entering to the AT mode1 or during the communication
pairing. Double flicker per second represents pairing is finished, the module is communicable.
LED2: PIN32, before pairing is at low level, after the pairing is at high level. The using method
of master and slavers indicator is the same. Notice: The PIN of LED1 and LED2 are connected
with LED+. LED: The flicker frequency of slave device is 102ms. If master device already has
the memory of slave device, the flicker frequency during the pairing is 110ms/s. If not, or master
has emptied the memory, then the flicker frequency is 750m/s. After pairing, no matter its a
master or slave device, the LED PIN is at high level. Notice: The LED PIN connects to LED+
PIN. Consumption: During the pairing, the current is Consumption: During the pairing, the
current is fluctuant in the range of 30-40mA. The mean current is about 25mA. After paring, no
matter processing communication or not, the current is 8mA. There is no sleep mode. This
parameter is same for all the Bluetooth modules. fluctuant in the range of 30-40 m. The mean
current is about 25mA. After paring, no matter processing communication or not, the current is
8mA. There is no sleep mode. This parameter is same for all the Bluetooth modules. Reset:
PIN11, active if its input low level. It can be suspended in using. Reset: PIN11, active if its
input low level. It can be suspended in using. Level: Civil Level: Civil The table above that
includes main parameters of two serial modules is a reference for user selection. HC-03/HC-05
serial product is recommended. 3. Information of Package The PIN definitions of HC-03, HC-04,
HC-05 and HC-06 are kind of different, but the package size is the same: 28mm * 15mm *

2.35mm. The following figure 1 is a picture of HC-06 and its main PINs. Figure 2 is a picture of
HC-05 and its main PINs. Figure 3 is a comparative picture with one coin. Figure 4 is their
package size information. When user designs the circuit, you can visit the website of Guangzhou
HC Information Technology Co., Ltd. (www.wavesen.com) to download the package library of
protle version. Figure 1 HC-06 Figure 2 HC-05 Figure 3 Comparative picture with one coin
Figure 4 Package size information 4. The Using and Testing Method of HC-06 for the First Time
This chapter will introduce the using method of HC-06 in detail. User can test the module
according to this chapter when he or she uses the module at the first time. PINs description: PIN1
UART_TXD , TTL/CMOS level, UART Data output PIN2 UART_RXD, TTL/COMS level, s
UART Data input PIN11 RESET, the reset PIN of module, inputting low level can reset the
module, when the module is in using, this PIN can connect to air. PIN12 VCC, voltage supply
for logic, the standard voltage is 3.3V, and can work at 3.0-4.2V PIN13 GND PIN22 GND
PIN24 LED, working mode indicator Slave device: Before paired, this PIN outputs the period of
102ms square wave. After paired, this PIN outputs high level. Master device: On the condition of
having no memory of pairing with a slave device, this PIN outputs the period of 110ms square
wave. On the condition of having the memory of pairing with a slave device, this PIN outputs the
period of 750ms square wave. After paired, this PIN outputs high level. PIN26 For master
device, this PIN is used for emptying information about pairing. After emptying, master device
will search slaver randomly, then remember the address of the new got slave device. In the next
power on, master device will only search this address. (1) The circuit 1 (connect the module to
3.3V serial port of MCU) is showed by figure 5. Figure 5 The circuit 1 In principle, HC-06 can
work when UART_TXD, UART_RXD, VCC and GND are connected. However, for better
testing results, connecting LED and KEY are recommended (when testing the master). Where,
the 3.3V TXD of MCU connects to HC-06s UART_RXD, the 3.3V RXD of MCU connects to
HC-06s UART_TXD, and 3.3V power and GND should be connected. Then the minimum
system is finished. Note that, the PIN2:UART_RXD of Bluetooth module has no pull-up resistor.
If the MCU TXD doesnt have pull-up function, then user should add a pull-up resistor to the
UART_RXD. It may be easy to be ignored. If there are two MCU which connect to master and
slave device respectively, then before paired(LED will flicker) user can send AT commands by
serial port when the system is power on. Please refer to HC-04 and HC-06s data sheet for
detailed commands. In the last chapter, the command set will be introduced. Please pay attention

to that the command of HC-04/HC-06 doesnt have terminator. For example, consider the call
command, sending out AT is already enough, need not add the CRLF (carriage return line feed).
If the LED is constant lighting, it indicates the pairing is finished. The two MCUs can
communicate with each other by serial port. User can think there is a serial port line between two
MCUs. (2) The circuit 2 (connect the module to 5V serial port of MCU) is showed by figure 6.
Figure 6 is the block diagram of Bluetooth baseboard. This kind of circuit can amplify Bluetooth
modules operating voltage to 3.1-6.5V. In this diagram, the J1 port can not only be connected
with MCU system of 3.3V and 5V, but also can be connected with computer serial port. Figure 6
The circuit 2 (3) AT command test Before paired, the mode of HC-04 and HC-06 are AT mode.
On the condition of 9600N81, OK will be received when user send the two letters AT. Please
refer to the last chapter of datasheet for other commands of HC-06. Please pay attention to that
sending out AT is already enough, need not add the CRLF (carriage return line feed). The
command set of Version V1.4 doesnt include parity. The version V1.5 and its later version have
parity function. Moreover, there are three more commands of V1.5 than V1.4. They are: No
parity (default) AT+PN Odd parity AT+PO Even parity AT+PE Do not let the sending frequency
of AT command of HC-06 exceed 1Hz, because the command of HC-06 end or not is determined
by the time interval. (4) Pairing with adapter User can refer to the download center of the
companys website for The Introduction of IVT that introduces the Bluetooth module makes
pair with computer adapter. That document taking HC-06-D for example introduces how the
serial module makes pair with the adapter. That method is like to make pair with cell-phone. But
the difference is that cell-phone need a third-party communication software to help. Its liked the
kind of PC serial helper of and the hyper terminal. A software named PDA serial helper
provided by our company is suitable for WM system. It has been proven that this serial module is
supported by many smart phone systems Bluetooth, such as, sybian , android, windows mobile
and etc. (5) Pairing introduction HC-06 master device has no memory before the first use. If the
password is correct, the mater device will make pair with the slave device automatically in the
first use. In the following use, the master device will remember the Bluetooth address of the last
paired device and search it. The searching wont stop until the device is found. If master devices
PIN26 is input high level, the device will lose the memory. In that occasion, itll search the
proper slave device like the first use. Based on this function, the master device can be set to
make pair with the specified address or any address by user. (6) Reset new password introduction

User can set a new password for the HC-06 through AT+PINxxxx command. But the new
password will become active after discharged all the energy of the module. If the module still has
any energy, the old one is still active. In the test, for discharging all the system energy and
activating the new password, we can connect the power supply PIN with GND about 20 seconds
after the power is cut off. Generally, shutting down the device for 30 minutes also can discharge
the energy, if there is no peripheral circuit helps discharge energy. User should make the proper
way according to the specific situation. (7) Name introduction If the device has no name, its
better that user doesnt try to change the master device name. The name should be limited in 20
characters. Summary: The character of HC-06: 1 not many command 2 easy for application 3
low price. Its good for some specific application. HC-04 is very similar with HC-06. Their only
one difference is HC-04 is for industry, HC-06 is for civil. Except this, they dont have
difference. The following reference about HC-04 and HC-06 can be downloaded from company
website www.wavesen.com: HC-06 datasheet .pdf (the command set introduction is included)
HC-04 datasheet .pdf (the command set introduction is included) IVT BlueSoleil-2.6 (IVT
Bluetooth drive test version) Bluetooth FAQ.pdf HC-04-D(HD-06-D)datasheet(English).pdf HC06-AT command software (test version) (some commands in V1.5 is not supported by V1.4) PCB
package of Bluetooth key modules (PCB package lib in protel) IVT software manual.pdf
(introduce how to operate the modern and make pair with Bluetooth module) PDA serial test
helper.exe (serial helper used for WM system) 5 manual for the first use of HC-05 This chapter
will introduce how to test and use the HC-05 if its the first time for user to operate it. (1) PINs
description PIN1 UART_TXD, Bluetooth serial signal sending PIN, can connect with MCUs
RXD PIN PIN2 UART_RXD, Bluetooth serial signal receiving PIN, can connect with the
MCUs TXD PIN, there is no pull-up resistor in this PIN. But It needs to be added an eternal
pull-up resistor. PIN11 RESET, the reset PIN of module, inputting low level can reset the
module, when the module is in using, this PIN can connect to air. PIN12 VCC, voltage supply
for logic, the standard voltage is 3.3V, and can work at 3.0-4.2V PIN13 GND PIN31 LED1,
indicator of work mode. Has 3 modes: When the module is supplied power and PIN34 is input
high level, PIN31 output 1Hz square wave to make the LED flicker slowly. It indicates that the
module is at the AT mode, and the baud rate is 38400; When the module is supplied power and
PIN34 is input low level, PIN31 output 2Hz square wave to make the LED flicker quickly. It
indicates the module is at the pairable mode. If PIN34 is input high level, then the module will

enter to AT mode, but the output of PIN31 is still 2Hz square wave. After the pairing, PIN31
output 2Hz square ware. Note: if PIN34 keep high level, all the commands in the AT command
set can be in application. Otherwise, if just excite PIN34 with high level but not keep, only some
command can be used. More information has provided at chapter 2. PIN32 Output terminal.
Before paired, it output low level. Once the pair is finished, it output high level. PIN34 Mode
switch input. If it is input low level, the module is at paired or communication mode. If its input
high level, the module will enter to AT mode. Even though the module is at communication, the
module can enter to the AT mode if PIN34 is input high level. Then it will go back to the
communication mode if PIN34 is input low level again. (2) Application circuit 1 (connect to the
3.3V system) Figure 7 Application 1 (3) Application circuit 2 (connect to 5V serial system or PC
serial) Figure 8 Application circuit 2 (4) AT command test This chapter introduces some common
commands in use. The detail introduction about HC-05 command is in HC-0305 AT command
set. Enter to AT mode: Way1: Supply power to module and input high level to PIN34 at the same
time, the module will enter to AT mode with the baud rate-38400. Way2: In the first step, supply
power to module; In the second step, input high level to PIN34. Then the module will enter to AT
mode with the baud rate-9600. Way1 is recommended. Command structure: all command should
end up with \r\n (Hex: 0X0D X0A) as the terminator. If the serial helper is installed, user just
need enter ENTER key at the end of command. Reset the master-slave role command:
AT+ROLE=0 ----Set the module to be salve mode. The default mode is salve. AT+ROLE=1
----Set the module to be master mode. Set memory command: AT+CMODE=1 Set the module to
make pair with the other random Bluetooth module (Not specified address). The default is this
mode. AT+CMODE=1 Set the module to make pair with the other Bluetooth module (specified
address). If set the module to make pair with random one first, then set the module to make pair
with the Bluetooth module has specified address. Then the module will search the last paired
module until the module is found. Reset the password command AT+PSWD=XXXX Set the
module pair password. The password must be 4-bits. Reset the baud rate AT+UART== ,,. More
information is provided at HC-0305 command set Example: AT+UART=9600,0,0 ----set the
baud rate to be 9600N81 Reset the Bluetooth name AT+NAME=XXXXX

Pulse rate Sensor

Fig-3.7: Pulse Rate Sensor

SMART DOCTORS ANDROID

Heart beat sensor is designed to give digital output of heat beat when a finger is placed on it.
When the heart beat detector is working, the beat LED flashes in unison with each heart beat.
This digital output can be connected to microcontroller directly to measure the Beats per Minute
(BPM) rate. It works on the principle of light modulation by blood flow through finger at each
pulse. A simple heart -beat transducer can be made from an infrared LED and an infrared
phototransistor. It works because skin acts as a reflective surface for infrared light. The IR
reflectivity of skin depends on the density of blood in it. Blood density rises and falls with the
pumping action of the heart. So the intensity of infrared reflected by the skin (and thus
transmitted to the phototransistor) rises and falls with each heartbeat.
Features
1.
2.
3.
4.
5.

Microcontroller based SMD design


Heat beat indication by LED
Instant output digital signal for directly connecting to microcontroller
Compact Size
Working Voltage +5V DC

Applications
1. Digital Heart Rate monitor
2. Patient Monitoring System
3. Bio-Feedback control of robotics and applications

Specification
1.
2.
3.
4.
5.
6.

Parameter Value
Operating Voltage +5V DC regulated
Operating Current 100 mA
Output Data Level 5V TTL level
Heart Beat detection Indicated by LED and Output High Pulse
Light source 660nm Super Red LED

Pin Details
Board has 3-pin connector for using the sensor. Details are marked on PCB as below.
Pin Name Details
1 +5V Power supply Positive input
2 OUT Active High output

SMART DOCTORS ANDROID

3 GND Power supply Ground

Using the Sensor


1. Connect regulated DC power supply of 5 Volts. Black wire is Ground, Next middle wire
is Brown which is output and Red wire is positive supply. These wires are also marked on
PCB.
2. To test sensor you only need power the sensor by connect two wires +5V and GND. You
can leave the output wire as it is. When Beat LED is off the output is at 0V.
3. Put finger on the marked position, and you can view the beat LED blinking on each heart
beat.
4. The output is active high for each beat and can be given directly to microcontroller for
interfacing applications. Heart beat output signal
5V level
0V level

Working Principle:
The sensor consists of a super bright red LED and light detector. The LED needs to be super
bright as the maximum light must pass spread in finger and detected by detector. Now, when the
heart pumps a pulse of blood through the blood vessels, the finger becomes slightly more opaque
and so less light reached the detector. With each heart pulse the detector signal varies. This
variation is converted to electrical pulse. This signal is amplified and triggered through an
amplifier which outputs +5V logic level signal. The output signal is also indicated by a LED
which blinks on each heart beat. FIGURE 1 SENSOR PRINCIPLE following figure shows
signal of heart beat and sensor signal output graph.
Fig.2 shows actual heart beat received by detector (Yellow) and the trigger point of sensor (Red)
after which the sensor outputs digital signal (Blue) at 5V level.

SMART DOCTORS ANDROID

Fig-3.8: Heart beat &Sensor signal Output.

LIQUID CRYSTAL DISPLAY (LCD)


INTRODUCTION
LCD is a type of display used in digital watches and many portable computers. LCD
displays utilize to sheets of polarizing material with a liquid crystal solution between them. An
electric current passed through the liquid causes the crystals to align so that light cannot pass
through them. LCD technology has advanced very rapidly since its initial inception over a
decade ago for use in laptop computers. Technical achievement has resulted in brighter displace,
higher resolutions, reduce response times and cheaper manufacturing process.

SMART DOCTORS ANDROID

Fig-3.9: Liquid Crystal Display


The liquid crystals can be manipulated through an applied electric voltage so that light is
allowed to pass or is blocked. By carefully controlling where and what wavelength (color) of
light is allowed to pass, the LCD monitor is able to display images. A back light provides LCD
monitors brightness. Just as there are many varieties of solids and liquids, there is also a variety
of liquid crystal substances. Depending on the temperature and particular nature of a substance,
liquid crystals can be in one of several distinct phases.
One feature of liquid crystals is that they're affected by electric current. A particular sort
of nematic liquid crystal, called twisted nematics (TN), is naturally twisted. Applying an electric
current to these liquid crystals will untwist them to varying degrees, depending on the current's
voltage. LCDs use these liquid crystals because they react predictably to electric current in such
a way as to control light passage.
Over the years many improvements have been made to LCD to help enhance resolution,
image, sharpness and response times.. This has been particularly important for improving LCDs
ability to display small-sized fonts and image clearly.
LCD interfacing with 8051 is a real-world application. In recent years the LCD is finding
widespread use replacing LEDs (seven segment LEDs or other multi segment LEDs). This is due
to following reasons:
1. The declining prices of LCDs.

SMART DOCTORS ANDROID

2. The ability to display numbers, characters and graphics. This is in contrast to LEDs,
which are limited to numbers and a few characters. An intelligent LCD display of two
lines, 20 characters per line, which is interfaced to the 8051.
3. Incorporation of a refreshing controller into the LCD, thereby relieving the CPU to keep
displaying the data.
4. Ease of programming for characters and graphics.
PIN DIAGRAM
Most
of the LCD modules conform to a standard interface specification. A 14pin access is provided
having eight data lines, three control lines and three power lines. The connections are laid out in
one of the two common configurations, either two rows of seven pins, or a single row of 14 pins.

FIG-3.10: 16 PIN DIAGRAM OF LCD DISPLAY


PIN DESCRIPTIONS
Vcc, Vss and Vee
While Vcc and Vss provide +5V and ground respectively, Vee is used for controlling LCD
contrast.
RS, register select
There are two very important registers inside the LCD. The RS pin is used for their selection
as follows.
a) If RS=0, the instruction command code register is selected, allowing the user to send a
command such as clear display, cursor at home, etc.,

SMART DOCTORS ANDROID

b) If RS=1 the data register is selected, allowing the user to send data to be displayed on the
LCD.
R/W, read/write
R/W input allows the user to write information to the LCD or read information from it. R/W=1
when reading; R/W=0 when writing.
EN, Enable
The enable pin is used by the LCD to latch information presented to its data pins. When
data is supplied to data pins, a high-to-low pulse must be applied to this pin in order for the LCD
to latch in the data present at the data pins. This pulse must be a minimum of 450ns wide.
D0-D7
The 8-bit data pins, D0-D7, are used to send information to the LCD or read the contents
of the LCDs internal registers. To display letters and numbers, we send ASCII codes for the
letters A-Z, a-z, and numbers 0-9 to these pins while making RS=1.
There are also instruction command codes that can be sent to the LCD to clear the display or
force the cursor to the home position or blink the instruction command codes.
We also use RS=0 to check the busy flag bit to see if the LCD is ready to receive information.
The busy flag is D7 and can be read when R/W=1 and RS=0, as follows: if R/W=1, RS=0. When
D7=1 (busy flag=1), the LCD is busy taking care of internal operations and will not accept any
information.

SMART DOCTORS ANDROID

TABLE-3.2 : PIN DESCRIPTIONS OF LCD

SMART DOCTORS ANDROID

TABLE-3.3: INSTRUCTION SET OF LCD


Basic commands of LCD:
Set Cursor Move Direction:
04h Shift cursor to the left
06h Shift cursor to the right
80h force cursor to the beginning of the first line
C0h force cursor to the beginning of second line
02h return home
Enable Display/Cursor:
0Ch - Turn Display On, cursor off
0ah - Turn Cursor On, Display off
08h - Cursor off, Display off
0eh/0fh- display on, cursor blinking
Shift Display:
18h 1Ch - Display Shift to left, right respectively
Set Interface Length:
38h Initialize LCD as 2 lines, 5*7 matrixes
Reading Data back is used in this application, which requires data to be moved back and
forth on the LCD. The "Busy Flag" is polled to determine whether the last instruction that has
been sent has completed processing. Before we send commands or data to the LCD module, the
Module must be initialized. For eight bit mode, this is done using the following series of
operations:

SMART DOCTORS ANDROID

Wait more than 15 msecs after power is applied.

Write 0x030 to LCD and wait 5 msecs for the instruction to complete

Write 0x030 to LCD and wait 160 usecs for instruction to complete

Write 0x030 AGAIN to LCD and wait 160 usecs or Poll the Busy Flag

Set the Operating Characteristics of the LCD

Write "Set Interface Length"

Write 0x010 to turn off the Display

Write 0x001 to Clear the Display

Write "Set Cursor Move Direction" Setting Cursor Behaviour Bits

Write "Enable Display/Cursor" & enable Display and Optional Cursor

When LCD is powered up, the display should show a series of dark squares, possibly only on
part of display. These characters are actually in their off state, so the contrast control should be
adjusted anti-clockwise until the squares are just visible. The display module resets itself to an
initial state when power is applied, which curiously the display has blanked off so that even if
characters are entered, they cannot be seen. It is therefore necessary to issue a command at this
point, to switch the display on.

SMART DOCTORS ANDROID

Chapter-4
SOFTWARE

4.1 Overview of KEIL CROSS C COMPILER


It is possible to create the source files in a text editor such as Notepad, run the Compiler
on each C source file, specifying a list of controls, run the Assembler on each Assembler source
file, specifying another list of controls, run either the Library Manager or Linker (again
specifying a list of controls) and finally running the Object-HEX Converter to convert the Linker
output file to an Intel Hex File. Once that has been completed the Hex File can be downloaded to
the target hardware and debugged. Alternatively KEIL can be used to create source files;
automatically compile, link and covert using options set with an easy to use user interface and
finally simulate or perform debugging on the hardware with access to C variables and memory.
Unless you have to use the tolls on the command line, the choice is clear. KEIL Greatly
simplifies the process of creating and testing an embedded application.
4.2 Projects
The user of KEIL centers on projects. A project is a list of all the source files required
to build a single application, all the tool options which specify exactly how to build the
application, and if required how the application should be simulated. A project contains
enough information to take a set of source files and generate exactly the binary code required for
the application. Because of the high degree of flexibility required from the tools, there are many
options that can be set to configure the tools to operate in a specific manner. It would be tedious
to have to set these options up every time the application is being built; therefore they are stored
in a project file. Loading the project file into KEIL informs KEIL which source files are required,
where they are, and how to configure the tools in the correct way. KEIL can then execute each
tool with the correct options. It is also possible to create new projects in KEIL. Source files are
added to the project and the tool options are set as required. The project can then be saved to
preserve the settings. The project also stores such things as which windows were left open in the

SMART DOCTORS ANDROID

simulator/debugger, so when a project is reloaded and the simulator or debugger started, all the
desired windows are opened. KEIL project files have the extension
4.3 Simulator/Debugger
The simulator/ debugger in KEIL can perform a very detailed simulation of a micro
controller along with external signals. It is possible to view the precise execution time of a single
assembly instruction, or a single line of C code, all the way up to the entire application, simply
by entering the crystal frequency. A window can be opened for each peripheral on the device,
showing the state of the peripheral. This enables quick trouble shooting of miss-configured
peripherals. Breakpoints may be set on either assembly instructions or lines of C code, and
execution may be stepped through one instruction or C line at a time. The contents of all the
memory areas may be viewed along with ability to find specific variables. In addition the registers
may be viewed allowing a detailed view of what the microcontroller is doing at any point in time.

The Keil Software 8051 development tools listed below are the programs you use to compile
your C code, assemble your assembler source files, link your program together, create HEX files,
and debug your target program.

Vision2 for Windows Integrated Development

Environment: combines Project Management, Source Code Editing, and Program Debugging in
one powerful environment.
C51 ANSI Optimizing C Cross Compiler: creates re locatable object modules from your C source
code,
A51

Macro Assembler:

creates

re locatable

object

modules

from

your 8051 assembler

source code,
BL51 Linker/Locator: combines re locatable object modules created by the compiler and assembler
into the final absolute object module,
LIB51 Library Manager: combines object modules into a library, which may be used by the linker,
OH51 Object-HEX Converter: creates Intel HEX files from absolute object modules.

SMART DOCTORS ANDROID

Software Design Snap Shot:

Fig-4.1 : Schematic of the Project

SMART DOCTORS ANDROID

CHAPTER-5
PROJECT DESCRIPTION
Program Code:
#include <reg52.h>
#include <intrins.h>
#include <lcd.h>
sbit pulse=P1^1;
unsigned int counts=0,loop_count,q,a,b,c,d,x,y,z;
unsigned int m=0,n=0;
void serial_init();
void Trans_Char(unsigned char );
void Trans_Str(unsigned char *);
//unsigned
char k[]="abnormal heart beat",l[]="nrmal heart beat",j;
bit flagd=0;
timer0()interrupt 1
{
m++;

//inc for every 255 machine cycles, 255 * 1.085 = 276

if(m==3623)

// 3623*276

{
1.085 u sec

if(n==60)
{
flagd=1;
}
}

10,00,000 u secs // approx

// for one interval it takes 255 machine cycles, 1 machine cycle =

m=0;
n++;

u sec

//inc seconds value


// 60 sec = 1 min

SMART DOCTORS ANDROID

}
/*void serial_init()
{
SCON=0X50;
TMOD=0X20;
TH1=0XFD;
TR1=1;
//EA=1;
//ES=1;
}*/
void main()
{
init_lcd();
init_lcd();
init_lcd();
serial_init();
serial_init();
TMOD=TMOD|0x02;
TH0=0x00;
IE|=0x82;
TR0=1;
Trans_Str(" HeartBeat");
cmd_lcd(0x01);
cmd_lcd(0x80);
display_lcd("Pulse");
cmd_lcd(0xC0);
display_lcd("Time");
delay_ms(100);

//9600

SMART DOCTORS ANDROID

while(1)
{
while(pulse==1);
counts++;
while(pulse==0);
delay_ms(1);
q=counts/2;
a=q/1000;//to get thousands num
y=q%1000;
b=y/100; //to get hundreds num
x=y%100;
c=x/10;

//to get tens num

d=x%10;
cmd_lcd(0x8A);
write_lcd(a+0x30);
write_lcd(b+0x30);
write_lcd(c+0x30);
write_lcd(d+0x30);
delay_ms(20);
//////////display time////////////////
q=n;
a=q/1000;//to get thousands num
y=q%1000;
b=y/100; //to get hundreds num
x=y%100;
c=x/10;

//to get tens num

d=x%10;
cmd_lcd(0xCA);

SMART DOCTORS ANDROID

write_lcd(a+0x30);
write_lcd(b+0x30);
write_lcd(c+0x30);
write_lcd(d+0x30);
delay_ms(50);
////////
if(flagd==1)
{
cmd_lcd(0x01);
IE=0x00;
display_lcd("Pulse Rate");
q=counts/2;
a=q/1000;
y=q%1000;
b=y/100;
x=y%100;
c=x/10;
d=x%10;
cmd_lcd(0xC0);
write_lcd(a+0x30);
write_lcd(b+0x30);
write_lcd(c+0x30);
write_lcd(d+0x30);
delay_ms(50);
cmd_lcd(0xc5);
display_lcd("Pulses/Min");
//delay_ms(20);
if((counts/1)>100||(counts/1)<40)

SMART DOCTORS ANDROID

{
cmd_lcd(0x01);
cmd_lcd(0x80);
display_lcd("ABNORMAL HRTBT ");
Trans_Str("\r\nAbNormal HeartBeat");
delay_ms(100)
}
else
if((counts/1)<100&&(counts/1)>40)
{
cmd_lcd(0x01);
cmd_lcd(0x80);
display_lcd("NORMAL HEARTBEAT ");
Trans_Str("\r\nNormal HeartBeat");
TI=1;
delay_ms(100);
/*for(j=0;j<16;j++)
{
SBUF=l[j];
while(TI==0);
TI=0;
}
delay_ms(20);
cmd_lcd(0x01);
}*/
counts=0;
flagd=0;
m=0;

SMART DOCTORS ANDROID

n=0;
q=0;
cmd_lcd(0x01);
TMOD=TMOD|0x02;
TH0=0x00;
IE|=0x82;
TR0=1;
cmd_lcd(0x80);
display_lcd("Pulse");
cmd_lcd(0xc0);
display_lcd("Time");
delay_ms(20);
}
}
cmd_lcd(0x01);
}
}
void serial_init()
{
TMOD=0x20;
SCON=0x50;
TH1=0xFD;
TR1=1;
//EA=1;ES=1;
}
void Trans_Char(unsigned char tx_data)
{
SBUF=tx_data;

SMART DOCTORS ANDROID

while(TI==0);
TI=0;
}
void Trans_Str(unsigned char *_data)
{
while (*_data)
{
SBUF =*_data++;
While (TI ==0);
T1=0;
}
}

Anda mungkin juga menyukai