100% found this document useful (1 vote)
308 views29 pages

Heart Rate Monitoring Ir Sensor

The document discusses the design and implementation of a heart rate monitoring system using photoplethysmography (PPG) and an Arduino board. PPG uses an infrared LED and photodiode placed on the fingertip to detect changes in blood volume with each heartbeat. The signal is conditioned and amplified before being sent to the Arduino. The Arduino then processes the signal to calculate and monitor heart rate in real-time. The system provides a low-cost and non-invasive way to measure heart rate compared to traditional electrocardiogram methods.

Uploaded by

Ravi Chander
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
308 views29 pages

Heart Rate Monitoring Ir Sensor

The document discusses the design and implementation of a heart rate monitoring system using photoplethysmography (PPG) and an Arduino board. PPG uses an infrared LED and photodiode placed on the fingertip to detect changes in blood volume with each heartbeat. The signal is conditioned and amplified before being sent to the Arduino. The Arduino then processes the signal to calculate and monitor heart rate in real-time. The system provides a low-cost and non-invasive way to measure heart rate compared to traditional electrocardiogram methods.

Uploaded by

Ravi Chander
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 29

Abstract - Technological innovations in the field of disease prevention and

maintenance of patient health have enabled the evolution of fields such as monitoring
systems. Heart rate is a very vital health parameter that is directly related to the
soundness of the human cardiovascular system. Heart rate is the number of times the
heart beats per minute, reflects different physiological conditions such as biological
workload, stress at work and concentration on tasks, drowsiness and the active state of
the autonomic nervous system. It can be measured either by the ECG waveform or by
sensing the pulse - the rhythmic expansion and contraction of an artery as blood is
forced through it by the regular contractions of the heart. The pulse can be felt from
those areas where the artery is close to the skin. This paper describes a technique of
measuring the heart rate through a fingertip and Arduino. It is based on the principal
of photophelthysmography (PPG) which is non-invasive method of measuring the
variation in blood volume in tissue using a light source and detector. While the heart is
beating, it is actually pumping blood throughout the body, and that makes the blood
volume inside the finger artery to change too. This fluctuation of blood can be
detected through an optical sensing mechanism placed around the fingertip. The signal
can be amplified and is sent to arduino with the help of serial port communication.
With the help of processing software heart rate monitoring and counting is performed.
The sensor unit consists of an infrared light-emitting-diode (IR LED) and a photo
diode. The IR LED transmits an infrared light into the fingertip, a part of which is
reflected back from the blood inside the finger arteries. The photo diode senses the
portion of the light that is reflected back. The intensity of reflected light depends upon
the blood volume inside the fingertip. So, every time the heart beats the amount of
reflected infrared light changes, which can be detected by the photo diode. With a high
gain amplifier, this little alteration in the amplitude of the reflected light can be
converted into a pulse.
INTRODUCTION A heart rate monitor is a personal monitoring device that allows a
subject to measure their heart rate in realtime or record their heart rate for later study.
Early models consisted of a monitoring box with a set of electrode leads that attached
to the chest. The heart rate of a healthy adult at rest is around 72 beats per minute
(bpm) & Babies at around 120 bpm, while older children have heart rates at around 90
bpm. The heart rate rises gradually during exercises and returns slowly to the rest
value after exercise [2]. The rate when the pulse returns to normal is an indication of
the fitness of the person. Lower than normal heart rates are usually an indication of a
condition known as bradycardia, while higher is known as tachycardia. Heart rate is
simply measured by placing the thumb over the subject’s arterial pulsation, and
feeling, timing and counting the pulses usually in a 30 second period. Heart rate (bpm)
of the subject is then found by multiplying the obtained number by 2. This method
although simple, is not accurate and can give errors when the rate is high. More
sophisticated methods to measure the heart rate utilize electronic techniques. Electro-
cardiogram (ECG) is one of frequently used method for measuring the heart rate. But
it is an expensive device. Low-cost devices in the form of wrist watches are also
available for the instantaneous measurement of the heart rate. Such devices can give
accurate measurements but their cost is usually in excess of several hundred dollars,
making them uneconomical. So this heart rate monitor with a temperature sensor is
definitely a useful instrument in knowing the pulse and the temperature of the subject
or the patient.

The heart acts as a pump that circulates oxygen and nutrient carrying blood around the
body in order to keep it functioning. When the body is exerted the rate at which the
heart beats will vary proportional to the amount of effort being exerted. By detecting
the voltage created by the beating of the heart, its rate can be easily observed and used
for a number of health purposes. Heart pounds to pump oxygen-rich blood to your
muscles and to carry cell waste products away from your muscles. The heart rate gives
a good indication during exercise routines of how effective that routine is improving
your health.

System Description Current technology consists of optical and electrical monitors.


The electrical method provides a bulky strap around one’s chest. The optical method
does not require the strap and can be used more conveniently than the electrical
method. There are many constraints in producing a heart monitor. First, the
technology used to measure the pulse has to be determined. A cost efficient way of
measuring the pulse is the combination of a led and photo-sensor.

Electrical Method The chest strap of a heart rate monitor uses electrodes to monitor
the electric volts that occur when your heart beats. The receiver detects this
information from the electrodes via radio signal from the chest strap. The receiver,
then, uses this information to determine your heart rate. Some monitors also include a
"coded signal" which uses a special code in the radio signal, so that the receiver does
not receive radio signals from other nearby transmitters. This is not always a huge
problem, but can be annoying or corrupt your data. This method has several
disadvantages like inaccurate results hectic wired connections over the body etc .

Optical Method Optical technique exploits the fact that tiny subcutaneous blood
vessels (capillaries) in any patch of skin (fingertip, ear lobe, etc.) furnished with a
good blood supply, alternately expand and contract in time with the heartbeat. An
ordinary infrared LED/phototransistor pair can sense this rhythmic change as small
but detectable variations in skin contrast. This method uses both transmittance and
reflectance principles. It is a noninvasive method of finding heart rate i.e. no
attachments or insertions on the body. It is precise and cost effective.

Circuit Description The full circuit has been constructed in three steps: external
biasing circuit, first stage signal conditioning circuit, and second stage signal
conditioning circuit [3]. In this paper the circuit has been integrated with an Arduino
board and processing software.

Signal Conditioning Circuit The reflected IR signal detected by the photo diode is fed
to a signal conditioning circuit that filters the unwanted signals and boost the desired
pulse signal. The circuit diagrams below shows the IR LED (D1) and the photo diode
(D2) along with the signal conditioning circuit made of two stage operational
amplifiers configured as active low pass filters. The cut-off frequencies of both the
filters are set to about 2.5 Hz, and so it can measure the pulse rate up to 2.5*60 = 150
bpm. The gain of each filter is about 100, which gives the total 2-stage amplification
of 10000. This is good enough to convert the weak pulsating signal into a TTL pulse.
Note that at the input of each OpAmp filter stage, there is a 1 uF capacitor to block
any DC component in the signal. At the output is connected a LED that will blink with
heart beat. The output of the sensor is sent to arduino port for monitoring and counting
purpose.
Fig1. Circuit diagram of sensor

Include hardware photo

Fig 2. PCB connection of IR sensor

Infrared IR Sensor Circuit Diagram and Working Principle

An infrared sensor is an electronic device, that emits in order to sense some aspects of
the surroundings. An IR sensor can measure the heat of an object as well as detects the
motion.These types of sensors measures only infrared radiation, rather than emitting it
that is called as a passive IR sensor. Usually in the infrared spectrum, all the objects
radiate some form of thermal radiations. These types of radiations are invisible to our
eyes, that can be detected by an infrared sensor.The emitter is simply an IR LED
(Light Emitting Diode) and the detector is simply an IR photodiode which is sensitive
to IR light of the same wavelength as that emitted by the IR LED. When IR light falls
on the photodiode, The resistances and these output voltages, change in proportion to
the magnitude of the IR light received.
IR Sensor
IR Sensor Circuit Diagram and Working Principle
An infrared sensor circuit is one of the basic and popular sensor module in
an electronic device. This sensor is analogous to human’s visionary senses, which can
be used to detect obstacles and it is one of the common applications in real time.This
circuit comprises of the following components

o LM358 IC 2 IR transmitter and receiver pair

o Resistors of the range of kilo ohms.

o Variable resistors.

o LED (Light Emitting Diode).

IR Sensor Circuit
In this project, the transmitter section includes an IR sensor, which transmits
continuous IR rays to be received by an IR receiver module. An IR output terminal of
the receiver varies depending upon its receiving of IR rays. Since this variation cannot
be analyzed as such, therefore this output can be fed to a comparator circuit. Here
anoperational amplifier (op-amp) of LM 339 is used as comparator circuit.

When the IR receiver does not receive a signal, the potential at the inverting input
goes higher than that non-inverting input of the comparator IC (LM339). Thus the
output of the comparator goes low, but the LED does not glow. When the IR receiver
module receives signal to the potential at the inverting input goes low. Thus the output
of the comparator (LM 339) goes high and the LED starts glowing. Resistor R1
(100 ), R2 (10k ) and R3 (330) are used to ensure that minimum 10 mA current passes
through the IR LED Devices like Photodiode and normal LEDs respectively. Resistor
VR2 (preset=5k ) is used to adjust the output terminals. Resistor VR1 (preset=10k ) is
used to set the sensitivity of the circuit Diagram. Read more about IR sensors.

Different Types of IR Sensors and Their Applications


IR sensors are classified into different types depending on the applications. Some of
the typical applications of different types of sensors are
The speed sensor is used for synchronizing the speed of multiple motors.
The temperature sensor is used for industrial temperature control. PIR sensor is used
for automatic door opening system and Ultrasonic sensor are used for distance
measurement.

IR Sensor Applications
IR sensors are used in various Sensor based projects and also in various electronic
devices which measures the temperature that are discussed in the below.

Radiation Thermometers
IR sensors are used in radiation thermometers to measure the temperature depend
upon the temperature and the material of the object and these thermometers have some
of the following features

o Measurement without direct contact with the object

o Faster response

o Easy pattern measurements

Flame Monitors
These types of devices are used for detecting the light emitted from the flames and to
monitor how the flames are burning. The Light emitted from flames extend from UV
to IR region types. PbS, PbSe, Two-color detector, pyro electric detector are some of
the commonly employed detector used in flame monitors.

Moisture Analyzers
Moisture analyzers use wavelengths which are absorbed by the moisture in the IR
region. Objects are irradiated with light having these wavelengths(1.1 µm, 1.4 µm, 1.9
µm, and 2.7µm) and also with reference wavelengths. The Lights reflected from the
objects depend upon the moisture content and is detected by analyzer to measure
moisture (ratio of reflected light at these wavelengths to the reflected light at reference
wavelength). In GaAs PIN photodiodes, Pbs photoconductive detectors are employed
in moisture analyzer circuits.

Gas Analyzers
IR sensors are used in gas analyzers which use absorption characteristics of gases in
the IR region. Two types of methods are used to measure the density of gas such as
dispersive and non dispersive.

Dispersive: An Emitted light is spectroscopically divided and their absorption


characteristics are used to analyze the gas ingredients and the sample quantity.

Non dispersive: It is most commonly used method and it uses absorption


characteristics without dividing the emitted light. Non dispersive types use discrete
optical band pass filters, similar to sunglasses that are used for eye protection to filter
out unwanted UV radiation.

This type of configuration is commonly referred to as non dispersive infrared (NDIR)


technology. This type of analyzer is used for carbonated drinks, whereas non
dispersive analyzer is used in most of the commercial IR instruments, for an
automobile exhaust gas fuel leakages.

IR Imaging Devices
IR image device is one of the major applications of IR waves, primarily by virtue of
its property that is not visible. It is used for thermal imagers, night vision devices, etc.

For examples Water, rocks, soil, vegetation, an atmosphere, and human tissue all
features emit IR radiation. The Thermal infrared detectors measure these radiations in
IR range and map the spatial temperature distributions of the object/area on an image.
Thermal imagers usually composed of a Sb (indium antimonite), Gd Hg (mercury-
doped germanium), Hg Cd Te (mercury-cadmium-telluride) sensors.

Working:

The proposed system comprises of pic16f877a microcontroller to take input samples


of heart beat from finger tip and process the signal to provide numerical heart beat
value The hardware details are explained below. The compiler used to program
microcontroller was ccs pic c compiler. The details of compiler are also explained.

Power supply Unit


The AC mains are fed to the transformer, which steps down the 230 Volts to the
desired voltage. The bridge rectifier follows the transformer thus converting AC
voltage into a DC output and through a filtering capacitor feeds it directly into the
input (Pin 1) of the voltage regulator. The common pin (Pin 2) of the voltage regulator
is grounded. The output (Pin 3) of the voltage regulator is first filtered by a capacitor,
and then the output is taken.
Make the circuit on a general purpose PCB and use a 2 Pin (5A) plug to connect
the transformer input to the AC mains via insulated copper wires.
If you want to power up a device you bought from the market, you need to solder
your Power supply output to an adapter jack. This adapter jack comes in a variety of
shapes and sizes and completely depends on your device. I have included a picture of
the most common type of adapter jack.
An important thing to note is that you will need to take care of the polarities, while
using this supply, as most of the devices you will power up will only work on forward
bias, and will not have an inbuilt rectifier to correct wrong polarities. Almost all of the
devices will need positive on the tip, and ground on the sleeve, except a few, for
example, in the music industry, almost all the devices will need ground on the tip, and
positive on the sleeve.
additionally an LED with a current limiting resistor in series as indication of the
power supply working. The resistance value is calculated as follows:
R = (Vout – 3)/0.02 Ω
Where, R is the series resistance value, and Vout is the output voltage of the voltage
regulator (and the power supply as well).
You can also use a Heat Sink, which is a metallic heat conductor attached to the
voltage regulator with a bolt. It is used in case we need high current outputs from the
power supply and the voltage regulator heats up. Here a 12 Volt Power supply, to
power up microcontroller board.

4.1 PIC16F877AMICROCONTROLLER:
PIC stands for Peripheral Interface Controller. It encodes and decodes
the data. It has flash memory so we can rewrite up to 100,000 times. It is a 28
pin DIP package. The architecture of the PIC is HARVARD. It has three ports
for the input/output operation. The analog signal can be directly given to the
PIC hence there is no need for external analog to digital converter.

MICROCONTROLLER CORE FEATURES


 High performance RISC CPU.
 Only 35 single word instructions to learn.
 Selectable oscillator options.
 Interrupt capability (up to 11 sources).
 Operating speed: DC – 20 MHz clock input.
 Eight level deep hardware stack.
 Direct, Indirect and relative addressing modes.
 Programmable code protection.
 2K x 14 words of Flash memory.
 128 x 8 bytes of Data memory (RAM).
 64 x 8 bytes of EEPROM Data Memory.
 Fully static design.
 Power saving SLEEP mode.
PIN DETAILS OF PIC16F877a:

Fig. 4.1 Pin Diagram of PIC16F877a


BLOCK DIAGRAM OF PIC16F877a
The PIC16F877Ais a 28 pin DIP package. The architecture of PIC is
HARVARD architecture. It consists of 3 ports such as Port A, Port B and Port
C. The Port A has 6 pins and the analog signal is given to this. The Port B and
Port C have 8 pins each. It has 3 types of instructions set such as Bit type, Byte
type and Literal type instructions. In this the Accumulator is referred as
Working Register or 1 and the registers are referred as Files or 0.
The PIC has three memory blocks.
 The Program memory.
 Data memory.
 Flash memory.
The data memory is partitioned into multiple banks which contain
General Purpose Register and the Special Function Registers. There are two
banks such as Bank0 and Bank1. The PIC has two Timers such as Timer0 and
Timer1.
Fig. 4.2 Block Diagram of PIC16F877a

PERIPHERAL FEATURES
 Timer0: 8 bit timer/counter with 8 bit prescaler.
 Timer1: 16 bit timer/counter with prescaler can be incremented during
sleep.
 Timer2: 8 bit timer/counter with 8 bit period register, prescaler and
postscaler.
 10 bit multi channel Analog to Converter.
 USART with 9 bit address detection.

ADVANTAGES
 Very low power consumption.
 Flash memory (rewrite up to 100,000 times).
 Easily writable.
 Easily changeable.
 Easily debuggable.
 Low cost.
 Good availability of parts.

4.2 INTERFACING IC MAX 232


The MAX232 is a dual RS232 receiver/transmitter that meets all EIA
RS232 specification while using only a 5V power supply. It has two charge
pump voltage converters which generate +10V and -10V power supplies from a
single 5V power supply. It has four level of translation, two of which are
RS232 transmitters that convert TTL/CMOS input levels into +9V RS232
outputs .The other level of translation are RS232 receivers that convert RS232
inputs to 5V.

TTL/CMOS output level. These receivers have nominal threshold of


1.3V, a typical hysteresis of 0.5V and can operate up to +30V.
 Suitable for all RS232 communication.
 +12V power supplies required.
 Voltage quadrapular for input voltage up to 5.5V (used in power
supply section of computer, peripherals and modem).

FEATURES
 Operate from Single +5V Power Supply (+5V and +12V)
 Low-Power Receive Mode in Shutdown (MAX232/MAX242)
 Meet All EIA/TIA-232E and V.28 Specifications
 Multiple Drivers and Receivers
 3-State Driver and Receiver Outputs

The Applications of MAX IC’ are:


 Portable Computers
 Low-Power Modems
 Interface Translation
 Battery-Powered RS-232 Systems
 Multidrop RS-232 Networks

PIN DIAGRAM OF MAX232

MAX232 is used to convert TTL logic to CMOS logic

Figure 4.3 Pin diagram of MAX 232


RS 232
The most common communication interface for short distance is
RS232.It defines a serial communication for one device to computer
communication port with speed upto19,200 baud. Typically 7 or 8 bits signal
are transmitted to represent a character or a digit. The nine pin connector is
used. The pin details are given below

CARRIER DETECTTRANSMIT DATA


RECEIVE DATA
DTE READYSIGNAL GROUND

1 2 3 4 5

6 7 8 9

DCE READY
REQUEST TO SEND CLEAR RING INDICATOR
TO SEND

Fig. 4.4 Pin Diagram of RS232


Table 4.3 Pin Description of DB-9 Connector
9-pin
Description Signal
DTE
Carrier Detect CD 1
Receive Data RD 2
Transmit Data TD 3
Data Terminal Ready DTR 4
Signal Ground SG 5
Data Set Ready DSR 6
Request to Send RTS 7
Clear to Send CTS 8
Ring Indicator RI 9
LCD INTERFACING WITH MICROCONTROLLER:
It is a very simple and easy to understand project for the beginners and is commonly
used in several electronic products. LCD (Liquid Crystal Display)provides user
interface and can be very useful for debugging purpose. After completion of this
tutorial, you will be able to display data on an LCD using mikro C compiler.
TASK
To interface LCD with PIC16F877A and display the text ‘LCD INTERFACE’ on
it.LCDs comes in different sizes and shapes. For this project, we have selected a 16×2
character, alphanumericLCD. It contains 2 rows of 16 character.

Its pin configuration is given as follows:

Pin
Number Name Use
1 Vss Ground
2 Vdd Power
3 Vee To adjust the contrast
1=Data input
4 RS 0=Instruction input
1=Read from LCD
5 R/W 0=Write to LCD
6 Enable (EN) From 1 to 0 = Data is written to the LCD
7 DB0 Data Bus Lines
8 DB1
9 DB2
10 DB3
11 DB4
12 DB5
13 DB6
14 DB7
15 LED+
16 LED- Backlight

The LCD can work in two modes, 4-bit and 8-bit. In this tutorial, we have used the 4-
bit mode which uses only 4 data lines, thus saving pins of the microcontroller.

LCD Connections
 Connect pin1 of LCD to ground and pin2 to Vdd.
 Pin3 of LCD is used to adjust the contrast of the display. Leave it unconnected.
 RS (pin4) of LCD is connected to RB2 of PORTB. It distinguishes between
data input and command input.
 RW (pin5) is grounded, since we have to write the data on LCD.
 E (pin6) is connected to RB3 of PORTB. It is a control line to inform the LCD
that data has been sent.
 D0-D3 of the LCD are grounded, since we are using a 4-bit mode. D4-D7 are
connected to the PORTB pins (RB4-RB7) of the controller.

APPLICATIONS
Programmed LCDs are vastly used for industrial as well as commercial
applications. LCDs are used in UPSs or inverters, where voltage and current readings
are displayed on the screen. Instructions to be followed are displayed on an LCD
screen in airports, banks, hospitals etc.

Processing Software Processing is a programming language, development


environment, and online community. Since 2001, Processing has promoted software
literacy within the visual arts and visual literacy within technology. Initially created to
serve as a software sketchbook and to teach computer programming fundamentals
within a visual context, Processing evolved into a development tool for professionals.
Today, there are tens of thousands of students, artists, designers, researchers, and
hobbyists who use Processing for learning, prototyping, and production. Interactive
programs with 2D, 3D or PDF output OpenGL integration for accelerated 3D For
GNU/Linux, Mac OS X, and Windows Over 100 libraries extend the core software
The Processing 2.0 release focuses on faster graphics, new infrastructure for working
with data, and enhanced video playback and capture. It also expands the potential of
the programming environment. The new Modes feature allows other programming
systems, such as JavaScript and Android, to be easily used from within the
development environment. The new Contributions Manager makes it simple to
distribute and install extensions developed by the community. Its open source status
encourages the community participation and collaboration that is vital to Processing’s
growth. Contributors share programs, contribute code, and build libraries, tools, and
modes to extend the possibilities of the software. The Processing community has
written more than a hundred libraries to facilitate computer vision, data visualization,
music composition, networking, 3D file exporting, and programming electronics.

Counting the PPG Signal The PC application first reads 600 consecutive samples sent
by Arduino. Since the sampling rate was 5ms, it takes 3 sec to read the 6000 samples.
The DC component (minima of 600 samples) is subtracted out from the samples.
Next, the range of the samples is computed. If the range is less than 50 counts, the
received PPG waveform is very weak, and is considered to be a noise. This could
happen when no PPG signal is detected through fingertip (sensor is faulty or
disconnected) or the gain of the amplifier on Easy Pulse board is set very low. The
gain can be increased through potentiometer P1 on the Easy Pulse board. If the range
of ADC samples is greater than 50, it is considered as a valid PPG signal and is
displayed on the PC screen. The samples are scaled to 1-1023 for full swing of
display. Next, a 21-point moving average filter is applied to remove the unnecessary
high frequency components (usually noise) in the PPG signal. The resulting samples
are plotted against time to obtain a clean and smooth PPG waveform. Note that we
lose 10 samples at the beginning and 10 samples at the end while applying the moving
average filter. The heart beat rate can be computed by knowing the time period of the
PPG waveform. For this, we identify three consecutive peaks in the waveform based
on where the slope of the curve changes from positive to negative, and the magnitude
of the signal is greater than 80% of the maxima of all the samples. Since two
consecutive samples are 5ms apart, time difference between any two peaks can be
easily computed from their indices (or sequence numbers). Two heart rates are
computed from the three consecutive PPG peaks and their average value is displayed
as an instantaneous heart rate. The identified peaks are also marked on the display
with a cross (X) symbol (see the PPG waveform plotted by the PC application on the
computer screen) .

Reflective photoplethysmography
Counting pulse in BPM

CCS PIC C compiler:

Introduction

In the example project we will look at the development and simulation of a complete
program using FED PIC C. Purchasers of WIZ C are recommended to run through the
tutorial of that program before running this example for which the Application
Designer should be disabled (once the project has been opened use the Project | Use
Application Designer menu option to turn it off). The program we will look at is
designed for a 16F84 processor (although in practice any 18 pin PIC could be used
with the same program), and is intended as a simple serial to parallel converter utility.

The project is designed to communicate with another computer system such as a PC or


a Mac, using a 3-wire serial interface. Simple commands will be accepted on the serial
link. 8 of the I/O ports on the 16F84 will be configured as inputs or outputs. The
program operates on a processor running at 4MHz and the serial link runs at 9600bps.

The circuit of the application is shown below:


Although we are going to simulate this circuit it may also be tested by building on the
demonstration board shown in the tutorial section.

Note that if a PIC which does not have PORTB pull ups is used then Port B pins must
be pulled up with an external resistor array (Nearly all PIC’s have this capability). Port
A bit 2 is the received data bit,

Port A bit 3 is the transmitted data bit. The commands that will be accepted on the link
will be:

A This character forces the PIC to send a K character back on the serial link to
confirm that the PIC is present.

W This character is followed by another byte, the second byte is written to Port B as
an output, whilst bit 1 of Port A is set low and then high again as a clock signal.

R This forces the PIC to read Port B, whilst it strobes Port A, bit 0 low.

In either event a K character is sent back on the serial interface. If any other character
is received then an F character is sent back on the link.

Start the program and open a new project

Start FED PIC C by double clicking the icon.

To open the new project then use the Project | Open/New Project menu item (on the
professional version this will be Open/New Project Group). A File dialog box will be
brought up. Create a new directory by using the small icon of a folder with a star in
the right hand corner. Call the directory

"SerialToParallel" or whatever name is meaningful. Select the new directory, double


click to enter it, and then select the project file name "StoP". Press OK. If you are a
WIZ-C user then now is the time to use the Project | Use Application Designer menu
option to turn off the front end.

Initially this project consists of one C file. Use File | New to create a blank file, now
use File | Save As to select a file name. This will bring up a file open dialog box. No
files will be present so enter the filename “SToP” and click on OK.

Select the project window which has the title StoP and will be blank and press the
insert key. This will bring up a file open dialog box. One file "STop.C" will be present
so select this file and click on OK. A dialog box will now appear with this file name
and a number of options, we can define files as being C files, or as a comment file. In
this case the file is used for compilation, so make sure that the file type C is selected
and click OK.

Double click the file to open it, now enter the following code to start the program:

//

// Example program - Serial to Parallel converter

//

#include <pic.h> // Processor header

#include <datalib.h> // Data Library header

void main(void)

PORTA=0x1f; TRISA=4; // Drive port A except the read bit

This code includes the header file for the PIC16F84, and the header file which
includes the definitions for the serial interface routines. It also initialises Port A to be
all outputs except for bit 2 which is an input used for serial receive data.

Compile and complete the project


Now use the menu option Compile | Compile (or press Ctrl+F9) to compile the
project. An options dialog box will appear. Ignore all the options in the box except for
the processor type, select the type PIC16F84 and press OK. This box will not be
shown again unless the menu option Project | Set Options for Project is used. The
information window should show the progress of the compilation, all being well the
project will compile OK.

Now finish the project by entering the following code (alternatively clear the edit
window by selecting all the text and press delete, and then use File | Insert to enter
the file "STop.C" which is in the home directory for FED PIC C).

// Example program - Serial to Parallel converter

//

#include <pic.h>

#include <datalib.h>

char grx; // Holds received value

//

// Functions

//

void main(void);

void ReadPort(void);

void WritePort(void);

const int SERIAL_RATE=9600; // Set serial port rate

const int BITTIME_IN=PROCFREQ*1000/SERIAL_RATE/4;

const int BITTIME_OUT=PROCFREQ*1000/SERIAL_RATE/4;

const int SERIALPORT_IN=&PORTA; // Port for serial i/f

const int SERIALBIT_IN=2; // Bit for serial i/f

const int SERIALPORT_OUT=&PORTA; // Port for serial i/f

const int SERIALBIT_OUT=3; // Bit for seiral i/f

void main(void)

{
char rx;

PORTA=0x1f; TRISA=4; // Drive port A except the read bit

while(1)

grx=rx=pSerialIn();

if (rx=='A') {pSerialOut('K'); continue;}

if (rx=='R') {ReadPort(); pSerialOut('K'); continue;}

if (rx=='W') {WritePort(); pSerialOut('K'); continue;}

pSerialOut('F');

//

// Read port whilst read bit is low

//

void ReadPort(void)

char tx;

PORTA^=1; // Read bit high

tx=PORTB; // Read data

PORTA^=1; // Read bit low

SerialOut(tx); // Send the byte

//

// Write data to port and clock write bit

//

void WritePort(void)
{

char rx;

rx=pSerialIn(); // Read data for port

PORTB=rx; TRISB=0; // Drive Port B

PORTA^=2; // Clock the write bit

PORTA^=2; // Clock the write bit

TRISB=0xff; // Read PORT B

Note that this program contains an error. Save it using the file menu, save option.
Compile it again and this time the error will be shown in the error window. Double
click the error and the edit window will be moved to show the line with the error -
SerialOut(tx) should read pSerialOut. Put the cursor on the word SerialOut and press
Control and F1, the help file will be bought up at the right entry for both functions.
You can see here that we are trying to use the pSerialOut function, the help file also
explains the need for the constants defined at the top of the file to tell the serial
routines which port and bits to be used. Correct the error and compile again, this time
the program will compile successfully and will be assembled into a hex file ready for
debugging.

We also now have an assembly language file which has been assembled into PIC Hex
code for programming into a real device.

Assembling the code into a hex file


Standard PIC assembler code is created by FED PIC C. If you prefer to use a different
type of assembler there is a single file generated called Stop_MPL.asm which contains
the full assembler for the program in a single file. If you wish to use MPLAB see the
section Use with MPLAB There will now be a hex file called "Stop.hex", this could be
used directly to program the PIC and test it, however we will simulate the file within
the C Compiler.

Initial simulation
Now we need to show the debugging window. Press ALT+D. This will rearrange the
windows to show the debugging window. Note that you can edit and assemble quite
happily in this view, its just that for initial work the edit view (press ALT+E) gives
more screen to the editor.
When the program is first assembled the program counter is reset and the edit window
will show the initial word of the program in the first C file. Now we can test program
operation for the first few lines.Press F7 which executes each line of the program
within the C file. The program should have set PORT A to output 1's on all pins except
for the receive serial data pin. However Port A will still hold thevalue 1F hex so we
cannot tell by looking at the debugging window.

To check add the TRIS A register (TRISA) to the variables window. Use the Simulate
| Watch | Add Watch menu option (which has the same effect as pressing the insert
key in the variables window). Click on the browse button and select the TRISA line
from the list box, and click on the >> button.

Press the OK button to add this file variable to the list. You may want to adjust the
width of the fields in the debugging window, do this by selecting and dragging the
headers in the window. Check that TRISA holds the value 4.

Professional Version

If the professional version is in use there is another option on the Debug Watch dialog
box which allows the variable to be examined by using the C definition. This option
(“Use C Definition”) is set by default and allows the debugger to decompose
structures and arrays when displaying their contents.

CONCLUSION: Biomedical engineering (BME) combines the design and problem


solving skill of engineering with medical and biological sciences to improve patient’s
health care and the quality of life of individuals. Cardiovascular disease is one of the
major causes of untimely deaths in world, heart beat readings are by far the only
viable diagnostic tool that could promote early detection of cardiac events[13].By
using this we can measure ones heart rate through fingertip. This paper focuses on the
heart rate monitoring and alert which is able to monitor the heart beat rate condition of
patient. The system determines the heart beat rate per minute and shows it in lcd
screen . It is portable and cost effective. It is a very efficient system and very easy to
handle and thus provides great flexibility and serves as a great improvement over
other conventional monitoring and alert systems.
FUTURE WORK: The current version of the Processing application displays the
near-real-time PPG waveform and heart rate but does not record anything. There is a
lot of room for improvements. ---Logging heart rate measurements and PPG samples
along with the time-stamp information available from the PC ---Beeping sound alarm
for heart rates below or above threshold ---Heart rate trend over time, etc.
REFERENCES

[1] Matina Kiourexidou , Konstantinos Natsis , Panagiotis Bamidis , Nikos


Antonopoulos , Efthymia Papathanasiou , Markos Sgantzos , Andreas Veglis
“Augmented Reality for the Study of Human Heart Anatomy” International Journal of
Electronics Communication and Computer Engineering 2015.

[2] Souvik Das “The Development of a Microcontroller Based Low Cost Heart Rate
Counter for Health Care Systems” International Journal of Engineering Trends and
Technology- Volume4Issue2- 2013.

[3] Embedded Lab. Introducing Easy Pulse: A DIY photoplethysmographic sensor for
measuring heart rate. http://embedded-lab.com/blog/?p=5508, 2012.

[4] Sankar Kumar S, Gayathri N , Nivedhitha D , Priyanka A S “A Cost effective


Arduino Module for Bedridden patient’s Respiratory Monitor and Control”
International Journal of advanced research trends in engineering and technology
(IJARTET) VOL. II, SPECIAL ISSUE XXI, MARCH 2015.

[5] Ch.Sandeep Kumar Subudhi,’Intelligent Wireless Patient Monitoring and Tracking


System (Using Sensor Network and Wireless Communication)”,2014.

[6] Bhagya Lakshmi.J.M1 Hariharan.R2 Udaya Sri.C3 Nandhini Devi.P4 Sowmiya.N


“Heart Beat Detector using Infrared Pulse Sensor” IJSRD - International Journal for
Scientific Research & Development| Vol. 3, Issue 09, 2015.

[7] Nazmus Saquib, Md. Tarikul Islam Papon, Ishtiyaque Ahmad, and Ashikur
Rahman “Measurement of Heart Rate Using Photoplethysmography” .

[8] Embedded Lab. PC-based heart rate monitor using Arduino and Easy Pulse sensor.
http://embeddedlab.com/blog/?p=7485, 2013.

[9] R. Raj and S.J. Jothi. Estimation of Heart Rate from Photoplethysmographic
Signal Using SVR Method. The International Journal of Science & Technoledge,
Volume 2, Issue 2, 2014.

[10] Hashem et al., ―Design and Development of a Heart Rate Measuring Device
using Fingertip‖, IEEE International Conference on Computer and Communication
Engineering (ICCCE), ISBN: 978-1- 4244-6235-3, 2010.

[11] Embedded Lab”Arduino measures heart beat rate from fingertip”

[12] Sagar C. Chhatrala, 2Mitul R. Khandhedia” Ubiquitous Physiological Monitoring


of SPO2& Heart Rate” International Journal for Research in Technological Studies
Vol. 1, Issue 2, January 2014
[13] Ufoaroh S.U , Oranugo C.O, Uchechukwu M.E “Heartbeat monitoring &alert
system using GSM technology” International Journal of Engineering Research and
General Science Volume 3, Issue 4, JulyAugust, 2015

You might also like