Project Report

advertisement
Maulik Patel
Heart Rate Meter|2008
Parul Institute of Engineering and Technology,
Limda.
Electronics & Communication Engineering Department.
CERTIFICATE
This is to certify that the project entitled “MICROCONTROLLER-BASED HEARTRATE METER” which is being submitted by
Mr.PATEL MAULIK (S-133006102)
In fulfillment of the requirement for the award of Diploma Engineering in Electronics
& Communication by Technical Education Board, Gandhinagar during the academic
year 2005-06 has been carried out by them under our supervision and guidance. The
matter embodied in this report has not been submitted for award of any other degree
or research work.
Miss. Tejal Tandel
(Lecturer)
Mr. Ravi Soni
(Lecturer)
Page 2 of 76
Mr. Nayan Trivedi
Head of Dept. (H.O.D)
Maulik Patel
Heart Rate Meter|2008
ACKNOWLEDGMENTS
We, the student of Parul Institute of Engineering & Technology feel very glad and
believe that we are very lucky for getting an opportunity to develop project entitled
Microcontroller based Heart Rate Meter.
Our special thanks to our college for providing all the facilities to complete and make
our project successful
I give my sincere thanks to my Project guide Mr.Ravi Soni, Ms. Tejal Tandel, Mr.Nayan
Trivedi who have always been guiding, encouraging and motivating force. They have provided
us with valuable guidance at each and every step of project development process. They also
drew the attention towards various other processes that were being followed in the
organization under the framework of project development.
I also extend my thanks to all the faculty members of our college who gave us valuable
guidance and help for the project.
Our obligation remains to all those people who have directly or indirectly helped in
successful completion of the project. No amount of words return here will suffice for the sense
of gratitude towards them all.
Page 3 of 76
Maulik Patel
Heart Rate Meter|2008
Index
Sr. no
Description
Pg no
1)
About the Institute
6
2)
Ch-1( Introduction)
9

Microcontroller

Definition
 About the Project
Ch-2 ( Block Diagram)
3)
14
 Simple Block Diagram
 Description of the Blocks
Ch-3( Circuit Diagram)
4)
17
 Heart Rate Meter
 Description
5)
Ch-4 ( Hardware Section)
22
 Microcontroller IC AT892051
 Current Buffer IC ULN2003
Ch-5 ( PCB Layout)
6)
 Actual Layout
 Components Layout
Page 4 of 76
33
Maulik Patel
Heart Rate Meter|2008
Sr. no
7)
Description
Pg no
Ch-6 ( Software Section)
36
 About the Software
 Using Kiel Corp.
Ch.7(Hard Ware)
8)
45
 Testing
 Trouble Shooting
9)
Ch.8(Screen Shots)
51
10)
Ch.9(About The Project)
55
11)
Conclusion
58
12)
Bibliography
59
13)
Ch-10(Software Coding for IC)
60
14)
Ch-11(Costing)
74
15)
NOTES
76
 Application
 Drawbacks
Page 5 of 76
Maulik Patel
Heart Rate Meter|2008
About the Institute
PARUL INSISTITUTE OF ENGINEEING&TECHNOLOGY
Diploma & Degree Programmers.
 Parul
Arogya Seva Mandal was established in 1989 with a clear mission
set by its founder. Mission being, service to the poor and needy in fields
of physical, mental intellectual and material
Page 6 of 76
Maulik Patel
Heart Rate Meter|2008
Diploma courses:
1.
2.
3.
4.
5.
6.
7.
8.
Electronics &communication Engineering.
Computer Engineering.
Mechanical Engineering.
Electrical Engineering.
Civil Engineering.
Auto Mobile Engineering.
Architectural Assistantship.
Engineering Duration of Diploma Programmers is 3 years. Eligibility for
admission is 10th Standard Pass.
Page 7 of 76
Maulik Patel
Heart Rate Meter|2008
PARUL Institute of Engineering & Technology
Parul Arogya Seva Mandal was established in the year 1989 with an aim to serve the
needy and poor with good education, medical facilities and employment. With these three goals
in view, the mission of achieving the same spread to different parts of Gujarat by way of
charitable / free OPD's, hospitals and educational institutes.
Apart from this, the trust has created awareness in preventing HIV and AIDS in the society. It
also has conducted workshops on the grassroots level for family planning educating the public of
the menace of population. The founder of the trust,
Dr. JAYESHBHAI PATEL, a renowned
homoeopath himself is known for his compassion for the poor and needy. He set himself on the
mission to eradicate the malnourishment of the mind and body of the society. In the same
interest, it was necessary to educate the common man to the perils of ill-health and
unemployment.
To achieve this goal, the trust started medical and paramedical courses along with engineering
and management programs. The trust gives out several scholarships every year to the poor and
meritorious students encouraging more and more underprivileged people to take education.
Page 8 of 76
Maulik Patel
Heart Rate Meter|2008
CHAPTER-1
INTRODUCTION
Page 9 of 76
Maulik Patel
Heart Rate Meter|2008
Introduction:
MICROCONTROLLER
History:First types
The 4004 with cover removed (left) and as actually used (right).
Three projects arguably delivered a complete microprocessor at about the same time,
namely Intel's 4004, the Texas Instruments (TI) TMS 1000, and Garrett AiResearch's Central Air
Data Computer (CADC).
In 1968, Garrett AiResearch, with designer Ray Holt and Steve Geller, were invited to
produce a digital computer to compete with electromechanical systems then under
development for the main flight control computer in the US Navy's new F-14 Tomcat fighter.
The design was complete by 1970, and used a MOS-based chipset as the core CPU. The design
was significantly (approximately 20 times) smaller and much more reliable than the mechanical
systems it competed against, and was used in all of the early Tomcat models. This system
contained a "a 20-bit, pipelined, parallel multi-microprocessor". However, the system was
considered so advanced that the Navy refused to allow publication of the design until 1997. For
this reason the CADC, and the MP944 chipset it used, are fairly unknown even today. (see First
Microprocessor Chip Set.) TI developed the 4-bit TMS 1000, and stressed pre-programmed
embedded applications, introducing a version called the TMS1802NC on September 17, 1971,
which implemented a calculator on a chip. The Intel chip was the 4-bit 4004, released on
November 15, 1971, developed by Federico Faggin and Marcian Hoff.
TI filed for the patent on the microprocessor. Gary Boone was awarded U.S. Patent
3,757,306 for the single-chip microprocessor architecture on September 4, 1973. It may never
be known which company actually had the first working microprocessor running on the lab
bench. In both 1971 and 1976, Intel and TI entered into broad patent cross-licensing
Page 10 of 76
Maulik Patel
Heart Rate Meter|2008
agreements, with Intel paying royalties to TI for the microprocessor patent. A nice history of
these events is contained in court documentation from a legal dispute between Cyrix and Intel,
with TI as intervener and owner of the microprocessor patent.
Interestingly, a third party (Gilbert Hyatt) was awarded a patent which might cover the
"microprocessor". See a webpage claiming an invention pre-dating both TI and Intel, describing
a "microcontroller". According to a rebuttal and a commentary, the patents was later
invalidated, but not before substantial royalties were paid out.
A computer-on-a-chip is a variation of a microprocessor which combines the
microprocessor core (CPU), some memory, and I/O (input/output) lines, all on one chip. The
computer-on-a-chip patent, called the "microcomputer patent" at the time, U.S. Patent
4,074,351 , was awarded to Gary Boone and Michael J. Cochran of TI. Aside from this patent,
the standard meaning of microcomputer is a computer using one or more microprocessors as
its CPU(s), while the concept defined in the patent is perhaps more akin to a microcontroller.
According to A History of Modern Computing, (MIT Press), pp. 220–21, Intel entered
into a contract with Computer Terminals Corporation, later called Data point, of San Antonio
TX, for a chip for a terminal they were designing. Data point later decided to use the chip, and
Intel marketed it as the 8008 in April, 1972. This was the world's first 8-bit microprocessor. It
was the basis for the famous "Mark-8" computer kit advertised in the magazine RadioElectronics in 1974. The 8008 and its successor, the world-famous 8080, opened up the
microprocessor component marketplace
Page 11 of 76
Maulik Patel
Heart Rate Meter|2008
Definition:
A microcontroller (also MCU or µC) is a computer-on-a-chip. It is a type of
microprocessor emphasizing high integration, low power consumption, self-sufficiency and
cost-effectiveness, in contrast to a general-purpose microprocessor (the kind used in a PC). In
addition to the usual arithmetic and logic elements of a general purpose microprocessor, the
microcontroller typically integrates additional elements such as read-write memory for data
storage, read-only memory, such as flash for code storage, EEPROM for permanent data
storage, peripheral devices, and input/output interfaces. At clock speeds of as little as a few
MHz or even lower, microcontrollers often operate at very low speed compared to modern day
microprocessors, but this is adequate for typical applications. They consume relatively little
power (milliwatts), and will generally have the ability to sleep while waiting for an interesting
peripheral event such as a button press to wake them up again to do something. Power
consumption while sleeping may be just nano watts, making them ideal for low power and long
lasting battery applications.
Microcontrollers are frequently used in automatically controlled products and devices, such
as automobile engine control systems, remote controls, office machines, appliances, power
tools, and toys. By reducing the size, cost, and power consumption compared to a design using
a separate microprocessor, memory, and input/output devices, microcontrollers make it
economical to electronically control many more processes.
Page 12 of 76
Maulik Patel
Heart Rate Meter|2008
Introduction About the project:
 Heart rate can be measured either by the ECG wave form or by the blood flow in to
the finger(pulse method). The pulse method is simple and convenient.
 When blood flows during the systolic stroke of the heart into the body parts,the
finger gets its blood via the radial artery on the arm.
 The blood flow in to the finger can be sensed photoelectrically.
 To count the heart beats,here we use a small light source on one side of the
finger(thumb) and obserbe the change in light intensity on the other side.
 The blood flow causes variation in light intensity reaching the light dependent
resistor (LDR), Which results in chang in signal strength due to change in the
resistance of the LDR.
Page 13 of 76
Maulik Patel
Heart Rate Meter|2008
CHAPTER-2
BLOCK DIAGRAM
OF
PROJECT
Page 14 of 76
Maulik Patel
Heart Rate Meter|2008
BLOCKDIAGRAM OF PROJECT
LIGHT
DEPENDENT
RESISTOR
(LDR)
LIGHT
SOURCE
6V BULB
IC AT89C2051
(PROGRAM COUNTER)
7-SEGMENT
DISPLAY
OP-AMP
STAGE-1
OP-AMP
STAGE-2
CURRENT BUFFER
(IC ULN2003)
Simple block diagram of Microcontroller based heart-rate meter
Page 15 of 76
Maulik Patel
Heart Rate Meter|2008
DISCRIPTION OF BLOCK DIAGRAM
 Block 1: IT the Light Source which use the 6v bulb
 Block 2: LDR light detector. The light which is generated by block 1 is detected by
LDR. We know that LDR is the light sensing element when light flows on this is
resistance very low and when light is remove it resistance is high. This phenomenon
is used to trigger the main IC.AT89C2051 through the op-Amp IC 1 and 3. Shown in
the block 3
 Block 3 And Block 4: Op-Amp is a use as Differential Amp. The sensitivity can be
adjust by block 4.
 Block 5: This is the heart of the circuit. This microcontroller has a program which is
used to generate numerical display on the 7 segments.
 Block 6: It uses IC-ULN2003. It is the simple current buffer to handle the 7 segments
display current.

Block 7: It indicates the heart beat average in between 60 to 100. IT is the 7 segment
common cathode display.
Page 16 of 76
Maulik Patel
Heart Rate Meter|2008
CHAPTER-3
CIRCUIT DIAGRAM
OF
PROJECT
Page 17 of 76
Maulik Patel
Heart Rate Meter|2008
CIRCUIT DIAGRAM
Circuit Diagram of Microcontroller based heart-rate mete
Page 18 of 76
Maulik Patel
Heart Rate Meter|2008
CIRCUIT DIAGRAM DISCRIPTION
1. As shown in the figure, the circuit of microcontroller based heart rate meter.
2. The setup uses a 6V electric bulb for light illumination of flesh on the thumb behind the
nail and the LDR as detector of change in the light intensity due to the flow of blood.
3. The photo-current is converted into voltage and amplified by operational amplifier IC
LM358 (IC1) .the detected signal is given to the non – inverting input (pin3).
4. The output is fed to another non-inverting input (pin5) for squaring and amplification.
Output pin 7 provides detected heartbeats to pin 12 of the micro controller. Preset VR1
is used for sensitivity and preset VR2 for trigger level settings.
5. Microcontroller IC AT89 C2051 (IC 2) is at the heart of the circuit. It is a 20-pin,8-bit
microcontroller with 2 KB of flash programmable and erasable read-only memory
(PEROM),128 bytes of RAM,15 Inputs/output(I/O) lines, two 16-bit timer/counters, a
five-vector two-level interrupt architecture, a full-duplex serial port .
6. Precision analogue comparator, on-chip oscillator and clock circuitry.
7. Port-1 pins P 1.7 through p1.2, and port 3 pin P3.7 are connected to input pins 1
through 7 of IC ULN2003 (IC3), respectively.
8. These pins are pulled- up with 10-kilo-ohm resistor network RNW1. They drive all the
segments of the 7-segments display with the help of inverting buffer IC 3.
9. The displays are selected through port pins P3.0, P3.1 and P 3.2 of the
microcontroller(IC 2).pore pins P3.0 down through P3.2 are connected to the base of
transistors T3 through T1, respectively.
10. Pin 6 of IC 2 goes low to drive transistor T1 into saturation and provide supply to the
common-anode pin (either pin3 or pin8) of DIS 1.
Page 19 of 76
Maulik Patel
Heart Rate Meter|2008
11. Similarly, transistors T2 and T3 drive common-anode pin 3 or 8 of 7-segment displays
DIS2 and DIS3, respectively. Only three 7-Segment displays are used.
12. IC2 provides segment-data and display-enable signals simultaneously in time-divisionmultiplexed mode for displaying a particular number on the 7-Segment display unit.
13. Segment-data and display-enable pulses for the display are refreshed every 5 milli sec.
Thus the display appears to be continuous, even though it lights up one by one.
14. Switch S2 is used to manually reset the microcontroller, while the power on reset signal
for the microcontroller is derived from the combination of capacitor C4 and resistor R8.
15. An 11.0592 MHZ crystal is used to generate the basic clock frequency for the
microcontroller, the circuit is powered by a 6 V battery.
16. Port pin P3.6 of the microcontroller is internally available for software checking. This pin
is actually the output of the internal analogue comparator, which is available internally
for comparing the two analogue levels at pins 12 and 13.
17. As pins 12 and 13 of IC2 can work as an analogue comparator, these are use for sensing
the rise and fall of the pulse waveform and thereby evaluate the time between two
peaks and hence the beat rate.
18. The output of the pulse pick-up preamplifier is fed to Pin 12 of the micro controller; pin
13 of the microcontroller is connected to the preset for reference-level setting of the
comparator.
19. Thus voltages at pins 12 and 13 are always compared. The signal rise and the fall at pin
12 are sensed by the program.
20. The internal timer of the microcontroller is used to find the time taken for one
wavelength. This time is converted into the heart beat rate in beats per minute by a precalculated look-up table.
Page 20 of 76
Maulik Patel
Heart Rate Meter|2008
21. The program notes the time between the high to low and low to high transitions of the
wave.
22. This time in micro seconds is converted in steps of 4 ms for comparison with the values
already stored in the look-up table.
23. This number is used to find (from the look-up table) the heart rate in beats per minute.
24. The number so obtained is converted into a 3-digit number in binary=coded decimal
(BCD) form. The same is output to the 7-segment LED displays in a multiplexed manner.
25. The display shows the rate for a while and proceeds to another measurement.
26. Thus beat rates obtained from time to time are visible on the display.
Page 21 of 76
Maulik Patel
Heart Rate Meter|2008
CHAPTER-4
HARDWARE
SECTION
Page 22 of 76
Maulik Patel
Heart Rate Meter|2008
Component List:
Semiconductor
IC2
- AT89C2051 MICROCONTROR
IC3
- ULN2003 Current AMPLIFIER
IC1
-LM358 Operational amplifier
T1-T3
- BC557 PNP transistor
D1
-1N4007 rectifier diode
D1S1-DIS3
- LTS542 common anode, 7-SEGMANT DISPLAY
LED1, LED2
- 5mm LED
Resistor (all ¼ watt, ± 5% carbon)
R1, R8
- 10-KILO-OHM
R3
-100 kilo-ohms
R4, R5
-1-Kilo-ohm
R6.R7
-330-ohm
R9-R11
- 1.2-KILO-OHM
RNW1
- 10-KILO-OHM RESISTOR NETWORK
R2
- 4.7-KILO-OHM PRE
Page 23 of 76
Maulik Patel
Heart Rate Meter|2008
Capacitor:
C1
C4
- 470nF ceramic disk
- 10 mF, 16V ELECTLYITC
C2, C5, C8
- 0.1 mF CERAMIC disk
C6, C7
- 22pF ceramic disk
C3, C9
- 470mf, 16V electrolytic
Miscellaneous:
S2
S1, S3
XTAL
BATT1, BATT2
- Tactile switch
- on/off switch
- 11.0592MHz crystal
- 6V battery
Page 24 of 76
Maulik Patel
Heart Rate Meter|2008
Microcontroller Main IC AT89C2051
Pin Configuration:
IC : FIG 1.5 Pin configuration of AT89C2051
Page 25 of 76
Maulik Patel
Heart Rate Meter|2008
Dimensional drawing AT89C2051
FIG 1.6 Dimensional Drawing of 89C2051 IC
Page 26 of 76
Maulik Patel
Heart Rate Meter|2008
Pin Description of AT89C2051 IC:
Pin Number
Description
1
RESET - Reset
2
P3.0 - Port 3 - RXD
3
P3.1 - Port 3 - TXD
4
XTAL2 - Crystal
5
XTAL1 - Crystal
6
P3.2 - Port 3 - INT0
7
P3.3 - Port 3 - INT1
8
P3.4 - Port 3 - TO
9
P3.5 - Port 3 - T1
10
GND - Ground
11
P3.7 - Port 3
12
P1.0 - Port 1 - AIN0
13
P1.1 - Port 1 - A1N1
14
P1.2 - Port 1
15
P1.3 - Port 1
16
P1.4 - Port 1
17
P1.5 - Port 1
18
P1.6 - Port 1
19
P1.7 - Port 1
20
Vcc - Positive Power Supply
Table:1 Pin Description of AT89C2051
\
Page 27 of 76
Maulik Patel
Heart Rate Meter|2008
Description
 The AT89C2051is aloe voltage ,high performance cmos 8-bit microcomputer with 2k
bytes of flash programmable and erasable read-only memory the device is
manufactured using atmel’s high-density nonvolatile memory technology and is
compatible with industry –standard msc-51 instruction set.
 By combining a vesatitle 8-bit cpu wiyh flash on a monolithic chip , the amtel AT89C2051
is a powerful microcomputer which provides a highly-flexible and cost-effective solution
to many embedded control application
 The AT89C2051 provides the following standard features: 2K bytes of Flash, 128 bytes
of RAM, 15I/O lines, two 16-bit timer/counters, a five vecter two-level interrupt
architecture, a full duplex serial port, a precision analog comparator, on-chip oscillator
and clock circuitry.
 In addition, the AT89C2051 is designed with static logic for operation down to zero
frequency and supports two software selectable power saving modes.
 The ldle 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 oscillater disabling all
other chip functions until the next hardware reset.
Page 28 of 76
Maulik Patel
Heart Rate Meter|2008
Feature
 Compatible with msc@-51 products
 2k bytes of reprogrammable flash memory-endurance:1,000 write/erase cycles
 2.7v to 6v operating range
 Fully static operation:0hz to 24mhz
 Two-level program memory lock
 126*8-bit internal ram
 15 programmable i/o lines
 Two 16-bit timer/counter
 Six interrupt sources
 Programmable serial uart channel
 Direct led drive outputs
 On-chip analog comparator
 Low-power idle and power-down modes
 Green packaging option
Page 29 of 76
Maulik Patel
Heart Rate Meter|2008
Pin configuration of ULN2003
Fig1.7 pin configuration of ULN2003
Page 30 of 76
Maulik Patel
Heart Rate Meter|2008
Pin connection of ULN2003:
Fig1.8 pin connection of ULN2003
Page 31 of 76
Maulik Patel
Heart Rate Meter|2008
Description:
1. The ULN2003 is a high voltage ,high current darlington arrays each containg
seven
open collector darlington at 500MA and can withstand peak currents of 600ma.
Suppression diodes are included for inductive load driving and the inputs are pinned
opposite the outputs to simplfy board layout
2. The four versions interface to all common logic families:
 ULN2001A-general purpose , dtl ,ttl, pmos, cmos
 ULN2002A-14-25v pmos
 ULN2003A-5v ttl,cmos
 ULN2004A-6-15v cmos,pmos
3. These versatile devices are useful for driving a wide range of loads including
solenoids,relays dc motor led displays filament lamps , thermal print heads and high
power buffers
4. The ULN2001A/2002A/2003A and 2004A are suppliedin 16 pin plastic dip packages with
a copper lead frame to reduce thermal resistance. They are available also in small
outline package (so-16)as ULN2001D/2002D/2003D/2004D.
Page 32 of 76
Maulik Patel
Heart Rate Meter|2008
CHAPTER-5
PCB
LAYOUT
Page 33 of 76
Maulik Patel
Heart Rate Meter|2008
Actual-size PCB layout:
Page 34 of 76
Maulik Patel
Heart Rate Meter|2008
Components Lay Out for the PCB
Page 35 of 76
Maulik Patel
Heart Rate Meter|2008
CHAPTER-6
SOFTWARE
SECTION
Page 36 of 76
Maulik Patel
Heart Rate Meter|2008
ABOUT THE SOFTWARE
1. The software is written in assembly language and assembled using ASM51 crossassembler.
2. The Intel hex code is generated and burnt into the microcontroller chip by using a
suitable programmer. The software is well commented and easy to understand.
3. The timer does the job of finding the time between two successive pulse waveform
points.
4. Since the comparator within the microcontroller IC knows the point of crossings of the
wave with the DC line determined by preset VR3.
5. The three crossing follows one after another and at the end of the third crossing the
time is read from the time-count register.
6. This time is then converted in terms of the number of 4ms intervals.
7. From the number of such 4ms units, the number of beats per minute is determined
from the look-up table already stored in the same memory.
Page 37 of 76
Maulik Patel
Heart Rate Meter|2008
OVERVIEW OF SOFTWARE USED
1. VPB full name is visual program builder
2. A VPB is used for taking the hex code of the program which is in assembly language
3. By the help of the VPB software I am able to take the hex code an load it into the IC
4. Type the program in VPB as given in following example
ORG 0H
MOV A, #55H
AGAIN:
MOV P1, A
MOV P2, A
ACALL DELAY
CPL A
SJMP AGAIN
DELAY:
MOV R3, #200
OUTER: MOV R2, #0255
INNER: DJNZ
R2, INNER
DJNZ R3, OUTER
RET
END
Page 38 of 76
Maulik Patel
Heart Rate Meter|2008
5. Now save the program as the name .asm in th
6. Then there will be so many file formed in the /d such as asm,binthex,location,hex.
7. Then assemble it
8. After assembling the program if there is no error the program will give correct hex code
9. The hex code will be available in the /d.
10. If the error is effected then the two windows comes then in first window you have to
select y option for overwrite.
11. The second window will be of the error and there will be written that how much error is
affected.
12. Because of the error the coming hex code will not be correct.
13. So that we have to solve the error for getting the correct hex code.
14. The main advantage of using VPB is that we can easily use this software and we can
easily take the hex code of any program written in assembly language.
15. Now for loading the code in the hex code in IC I have used keil software
Page 39 of 76
Maulik Patel
Heart Rate Meter|2008
A Quick Guide to uVision from Keil Corp
1. Start the uVision Program
2. After the program has started:
3. Select File, open… from the program menu
4. Copy the program from the vpb.. it will be as shown in following example
ORG 0H
MOV A, #55H
AGAIN:
MOV P1, A
MOV P2, A
ACALL DELAY
CPL A
SJMP AGAIN
DELAY:
MOV R3, #200
OUTER: MOV R2, #0255
INNER: DJNZ
R2, INNER
DJNZ R3, OUTER
RET
END
5. Select File, Save… from the program menu
6. The first time you save the program a dialog box will popup and allow you to name your
file and file type.
Page 40 of 76
Maulik Patel
Heart Rate Meter|2008
7. Save program with filename: Toggle.a51
8. Change the file type: Assembler (*.a51)
9. Select Project, New Project… from the program menu
10. Give project name: Toggle.prj
11. Click on the Add button
12. A dialog box will popup, allowing you to add files to the project
13. Change the file type to Assembly.
14. Select your assembly file.
15. Click on the Add button then close the Add dialog box.
16. Click on Save in your Project dialog box.
17. Select Project, Make: Build Project from the program menu
18. This creates the HEX file you need for the 8051 then verify the hex code you get is same
has get in the VPB
Page 41 of 76
Maulik Patel
Heart Rate Meter|2008
Using the Keil Debugger
1. Select Run, dScope debugger… from the program menu
2. The debug program will start a new session
3. Select File, load CPU driver from the program menu
4. Choose the 8051.dll from the drop down list box, you can also select this directly.
5. Select File, load object file from the program menu.
6. Change the file type to HEX
7. Select your hex file, eg. Toggle.hex
8. Click OK
9. You should now see the source code of the file typed in earlier
10. Select Peripherals, I/O Ports from the program menu.
11. Select Port 0, Port 1, Port 2 and Port 3
12. This will bring up 4 box that display the status of the ports on the microcontroller.
13. Click on go to see the real time update of the I/O ports.
14. Click on stop when you are finished.
You can also single step through you program or set break points at locations that you want the
debugger to stop at. To set a breakpoint double clicks on the line.
Page 42 of 76
Maulik Patel
Heart Rate Meter|2008
What is uVision2?
uVision2 is an IDE (Integrated Development Environment) that helps you write, compile, and
debug embedded programs. It encapsulates the following components:
 A project manager.
 A make facility.
 Tool configuration.
 Editor.
 A powerful debugger.
To help you get started, several example programs (located in the \C51\EXAMPLES,
\C251\EXAMPLES, and \C166\EXAMPLES) are provided.
 HELLO is a simple program that prints the string "Hello World" using the Serial Interface.
 MEASURE is a data acquisition system for analog and digital systems.
 TRAFFIC is a traffic light controller with the RTX Tiny operating system.
 SIEVE is the SIEVE Benchmark.
 DHRY is the Dhrystone Benchmark.
 WHET is the Single-Precision Whetstone Benchmark.
Page 43 of 76
Maulik Patel
Heart Rate Meter|2008
Building an Application in uVision2
To build (compile, assemble, and link) an application in uVision2, you must:
 Select Project - Open Project (for example, \C166\EXAMPLES\HELLO\HELLO.UV2).
 Select Project - Rebuild all target files or Build target.
Page 44 of 76
Maulik Patel
Heart Rate Meter|2008
CHAPTER-7
HARDWARE
TESTING AND
TROUBLE
SHOOTING
Page 45 of 76
Maulik Patel
Heart Rate Meter|2008
HARDWARE TESTING:
The source code of this article is available at http://www.electronicsforu.com/efycodes/efycodes.zip at code file ‘tacho.hex’. Using a programmer, load the code into the new chip
AT89C2051. (Refer the May 2008 issue of EFY for article on programmer for 89C51 and 2051).
Then, fit it into the circuit board and after powering up the circuit, test it.
Page 46 of 76
Maulik Patel
Heart Rate Meter|2008
Testing
Page 47 of 76
Maulik Patel
Heart Rate Meter|2008
Page 48 of 76
Maulik Patel
Heart Rate Meter|2008
Page 49 of 76
Maulik Patel
Heart Rate Meter|2008
Troubleshooting
1. Problem
There was a problem in finding a disk capacitor
Reason of occurrence
To provide a capacitance to the circuit
Solution of the problem
It was founded from Pune
2. Problem
Circuit not working
Solution of the problem
Due To loose connection
Low or no power Supply
IC Programming
Page 50 of 76
Maulik Patel
Heart Rate Meter|2008
CHAPTER-8
SCREEN SHOTS
Page 51 of 76
Maulik Patel
Heart Rate Meter|2008
Original view of the circuit
Page 52 of 76
Maulik Patel
Heart Rate Meter|2008
Original Inverse PCB layout
Page 53 of 76
Maulik Patel
Heart Rate Meter|2008
Seven segment display of the circuit
Page 54 of 76
Maulik Patel
Heart Rate Meter|2008
CHAPTER-9
ABOUT
THE PROJECT
Page 55 of 76
Maulik Patel
Heart Rate Meter|2008
Applications:
 This Project will be mainly us for measuring the heart beats.
 IT will be very useful for the cardiac diseases patients
 It is also used for the measuring the blood pressure.
 As it consumes low power it is very cheap.
 It basically works on the photo electric effect
 It is simple and convenient
 The blood can be senesced photo electrically
Page 56 of 76
Maulik Patel
Heart Rate Meter|2008
Drawback:
 Since it is a beat to beat, a variation is accepted after the one minute
measurements.
 It is not used for long period due to variation get into it.
Page 57 of 76
Maulik Patel
Heart Rate Meter|2008
Conclusion:
After made this project we can study about the microcontroller based Heart beat
meter. In this how the heart meter will measure heart beat rate using pulse method
can be understood simple construction of the circuit
Page 58 of 76
Maulik Patel
Heart Rate Meter|2008
Bibliography
www.efymag.com
www.alldatasheet.com
www.datasheetcatalog.com
www.parul.ac.in
www.electronicsforu.com
www.national.com
www.fairchildsemi.com
www.atmel.com
www.google.com
www.ee.latrobe.edu.au/iternal/workshop/datasheet.html
Page 59 of 76
Maulik Patel
Heart Rate Meter|2008
Chapter 10
Software for the project using
Assembly Language.
Page 60 of 76
Maulik Patel
Heart Rate Meter|2008
Heart.ASM
$mod51
ORG 0H
AJMP 30H
ORG 0BH
;TIMER
0
INTERRUT
VECTOR
AJMP TIM0ISR
;Timer 0 In-
terrupt service routine address
ORG 30H
MOV SP,#60H
;set stack
MOV P3,#0FFH
;set all
pointer
port 3 bits high to enable inputs also
MOV P1,#03
;set port 1
to all zero accept bits 0,1
MOV TMOD,#01100001B
;TIMER 1 - MODE 2 COUNTER , TIMER-0 TO MODE
1
BEG:
MOV TH0,#0f0H
;T I M E R
REG.0 IS SET TO foo0 , GIVES 4ms
MOV TL0,#0
; timer low
reg. is also so
mov r6,#255
clr 20h
; flag to
kno time between beats exceeded
Page 61 of 76
Maulik Patel
Heart Rate Meter|2008
mov r2,#0
setb et0
setb ea
PULSESECHK:
jb p3.6,$
; look for
pulse at lowlevel____
call delay2
jnb p3.6,$
;look for pulse high ---setb tr0
;yes, pulse gone up, start timer
call delay2
back1:
jb p3.6,$
; let waveform go low ____
call delay2
jnb p3.6,$
look for next pulse high ---clr tr0 ; stop timer
mov a,r2
cjne r2 ,#0,brady ;
too low rate! brady-cardia
read_time: mov a,r6
cpl a
mov dptr,#table ;
table for rate calculated and kept
; read value
Page 62 of 76
Maulik Patel
Heart Rate Meter|2008
in R6 which gives in steps of 4ms
clr c
sub a,#80
jc tachy
;rate too fast so tachy-cardia
lookup.
mov a,r6
Cpl a
movc A, @a+dptr ;
table looked up
Mov R2,A
;
rate is now in r2
Mov R1,#0
;
high byte is zero
call hex2bcd
;
make it in BCD formate
call displ
;
show the value on LED
mov 50h,#100
;
refresh a 100 times (.5 sec)
REFER :
CALL REFRESH1
djnz 50h,REFER
;
so many times
clrint :
clr et0
clr ea
;no
Page 63 of 76
Maulik Patel
Heart Rate Meter|2008
more interrupts
jmp beg
tachy:
; to show
clr p3.4
on LED pin 8 that rate is too high
Jmp beg
Brady :
Clr p3.3
; show too low beat at p3.3 LED
JMP beg
;16 Bit Hex to BCD Conversion for 8051 Microcontroller
; This routine is for 16 bit Hex to BCD conversion; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;
;Accepts a 16 bit binary number in R1,R2
and returns 5 digit BCD in
;R7;R6;R5;R4;R3;(upto 64K )
Hex2BCD: ;r1=high byte
; r7 most significant digit
;r2 = LSByte
MOV R3,#00D
MOV R4,#00D
MOV R5,#00D
Page 64 of 76
Maulik Patel
Heart Rate Meter|2008
MOV R6,#00D
MOV R7,#00D
MOV B,#10D
MOV A,R2
DIV AB
MOV R3,B
MOV B,#10
;
R7;R6;R5;R4;R3
DIV AB
MOV R4,B
MOV R5,A
CJNE R1 ,#0H,HIGH_BYTE ; CHECK
FOR HIGH BYTE
SJMP ENDD
HIGH_BYTE: MOV A, #6
ADD A,R3
MOV B,#10
DIV AB
MOV R3,B
Page 65 of 76
Maulik Patel
Heart Rate Meter|2008
ADD A,#5
ADD A,R4
MOV B,#10
DIV AB
MOV R4,B
ADD A,#2
ADD A,R5
MOV B,#10
DIV AB
MOV R5,B
CJNE R6 ,#00D,ADD_IT
SJMP CONTINUE
ADD_IT: ADD A,R6
CONTINUE: MOV R6,A
DJNZ R1 ,HIGH_BYTE
MOV B, #10D
MOV A,R6
DIV AB
MOV R6,B
Page 66 of 76
Maulik Patel
Heart Rate Meter|2008
MOV R7,A
ENDD: ret
DISP1:
REFRESH: ; content of 18 to 1B memory location are
output on LEDs
; only numbers 0 to 9 and A to F are valid data in these
locations
MOV 18H,r3
;
Least significant digit
MOV 19H,r4
;
next significant digit
MOV 1AH,r5
MOV 1BH,R6
;
Most
;
significant digit
refresh1:
(max:9999)
mov R0,#18h
1b,1a,19,18, holds values for 4 digits
mov R4,#4
;
Page 67 of 76
;
Maulik Patel
Heart Rate Meter|2008
pin p3.2_ 0 mode low one by one starts wth 18
; mov r7 ,#2
; decimal
Pt.on third digit from left (2 nd from-right )
PQ2:
CALL SEGDISP
INC R0
Clr c
mov a ,r4
rrc a
mov r4,a
jnc pq2
PV3:
SEGDISP:
mov dptr,#ledcode
Mov A,@R0
ANL A,#0FH
MOVC A,@A+dptr
; k: djnz r7,segcode
;yesDP:
; orl a,#01
; add a dec . pt.
Page 68 of 76
Maulik Patel
Heart Rate Meter|2008
Where it sould be
Segcode:
MOV R5,A
ORL A,#03H
;
WE WANT TO USE PORT 1 BITS 0 AND 1 FOR INPUT
ANALOG
; so retain them high
S3:
MOV P1,A
S1:
; SEGMENT_
; MOV A, R4
; get digit
Code from r4
; rrc a
; jc s6
Mov a,r5
rrc a
rrc a
mov p3.7,c
;
segment’ a on p3.7 pin
mov a,r4
Page 69 of 76
Maulik Patel
Heart Rate Meter|2008
; mov r4,a
cpl a
rrc a
mov p3.0,c
rrc a
mov p3.1,c
rrc a
mov p3.2,c
S5:
S4:
ACALL DELAY1
; let it burn for some time
;MOV A,#07H
MOV P3,A;
setb p3.0
;extinguish the digit after time
setb p3.1
;to prevent shadow
setb p3.2
s6:
RET
ledcode:
DB 7EH,0CH,0B6H,9EH,0CCH,0DAH,0FAH
Page 70 of 76
Maulik Patel
Heart Rate Meter|2008
DB 0EH,0FEH, 0CEH, 0EEH, 0F8H,72H,0BCH,0F6H,0E2H
; these are
Code for numbers 0 to 9 and A to F
DELAY2: mov 51h,#80
;80ms
delaywait: call till20ms
Djnz 51h, delaywait
Ret
delay1:
till20ms:
N:
MOV R1,#0ffH
NOP
nop
DJNZ R1,N
ret
tim0isr:
push psw
push acc
MOV TH0,#0f0H
;AUTO RELOAD VALUE
mov t10,0
DJNZ R6,K1A
;r6
Page 71 of 76
Maulik Patel
Heart Rate Meter|2008
WAS FFH, SO 256 TIMES 4 ms GIVES 1 s
MOV A,R2
ADD A,#1
;ADD 1 TO SECONDS
DA A
MOV R2,A
Setb 20h
;seconds over
KIA :
pop acc
pop psw
RETI
;INTERRUPT RETURN INSTRUCTION
table:
db 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 ;
db 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 ;
db 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 ;
db 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 255;
db 251,246,242,237,233,229,226,222,218,215,211,208,205,202;
Page 72 of 76
Maulik Patel
db
Heart Rate Meter|2008
199,196,193,190,188,185,180,178,176,173,171 ;
db 169,167,165,163,161,159,157,155,154,152,150,149;
db 147 , 145 , 144 142 , 141 , 139 , 138 , 136 , 135 , 134 ,
132 , 131 ;
db 130 , 129 , 127 , 126 , 125 , 124 , 123 , 122 , 121 ,120 ,
118 , 117 ;
db 116 , 115 , 114 , 113 , 113 , 112 , 111 , 110 , 109 , 108 , 107 , 106;
db 105 , 105 , 104 , 103 , 102 , 101 , 101 , 100 , 99 , 98 , 98 , 97;
db 96 , 96 , 95 , 94 , 94 , 93 , 92 , 92 , 91 , 91 , 90 , 89;
db 89 , 88 , 88 , 87 , 86 , 86 , 85 , 85 , 84 , 84 , 83 , 83;
db 82 , 82 , 81 , 81 , 80 , 80 , 79 , 79 , 78 , 78 , 77 , 77;
db 77 , 76 , 76 , 75 , 75 , 74 , 74 , 74 , 73 , 73 , 72 , 72;
db 72 , 71 , 71 , 70 , 70 , 70 , 69 , 69 , 69 , 68 , 68 , 68;
db 67 , 67 , 67 , 66 , 66 , 66 , 65 , 65 , 65 , 64 , 64 , 64;
db 63 , 63 , 63 , 63 , 62 , 62 , 62 , 61 , 61 , 61 , 61 , 60;
db 60 , 60 , 60 , 59 , 59 , 59 , 58 , 58 , 58 , 58 , 57 , 57;
db 57 , 57 , 56 , 56 , 56 , 56 , 56 , 55 , 55 , 55 , 55 , 54;
db 54 , 54 , 54 , 54 , 53 , 53 , 53 , 53;
END
Page 73 of 76
Maulik Patel
Heart Rate Meter|2008
Chapter 11
Costing
Page 74 of 76
Maulik Patel
Heart Rate Meter|2008
Cost of project
Components
600/-
Printed circuit board
500/-
Program loading
300/-
Soldering maintenance
200/-
Other cost
500/-
Total
2100/-
Page 75 of 76
Maulik Patel
Heart Rate Meter|2008
Notes
Page 76 of 76
Download