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.
Avionics, such as inertial guidance systems, flight control hardware/software and other
integrated systems in aircraft and missiles
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
Videogame consoles
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
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:
Watchdog timer.
Power-off flag.
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.
VCC
Pin 40 provides supply voltage to the chip. The voltage source is +5V.
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.
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
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:
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.
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-
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
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.
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
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.
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.
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.
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
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.
Chapter-4
SOFTWARE
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.
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
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.
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++;
if(m==3623)
// 3623*276
{
1.085 u sec
if(n==60)
{
flagd=1;
}
}
m=0;
n++;
u sec
}
/*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
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;
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;
d=x%10;
cmd_lcd(0xCA);
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)
{
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;
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;
while(TI==0);
TI=0;
}
void Trans_Str(unsigned char *_data)
{
while (*_data)
{
SBUF =*_data++;
While (TI ==0);
T1=0;
}
}