Heart Rate

Published on December 2016 | Categories: Documents | Downloads: 50 | Comments: 0 | Views: 460
of 26
Download PDF   Embed   Report

Comments

Content

1 Abstract
The aim of this project is to implement an ECG and Digital Heart Rate counter. The main challenges include amplifying the desired weak signal in the presence of noise from other muscles and electrical sources. A display of the heart rate will be obtained by measuring the time between signal peaks and then calculating the frequency of the peaks in units of beats per minute. The device is most useful if it is portable. This requires a battery to be able to power all of the necessary components as well as the power output of the battery to be regulated. Our implementation of the heart monitor involves low cost amplifier and filter components coupled with a sophisticated microcontroller and LCD screen. Results were successful for the amplifier filter stage of the implementation with an ECG successfully detected and recorded but variability of the voltage points complicated the calculation and display of the actual rate.

2 Introduction/Background
The heart is one of the most vital organs within the human body. It acts as a pump that circulates oxygen and nutrient carrying blood around the body in order to keep it functioning. The circulated blood also removes waste products generated from the body to the kidneys. 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 An electrocardiogram (ECG) is a graphical trace of the voltage produced by the heart. A sample trace of a typical ECG output for a single beat is shown below. There are 5 identifiable features in an ECG trace which corresponds to different polarisation stages that makes up a heart beat. These deflections are denoted by the letters P, Q, R, S and T.

Figure 1 - ECG Plot

1

By detecting the R peaks and measuring the time between them the heart rate can be calculated and then displayed. A persons heart rate before, during and after exercise is the main indicator of their fitness. Measuring this manually requires a person to stop the activity they are doing in order to count the number of heart beats over a period of time. Measuring the heart rate using an electrical circuit can be done much quicker and more accurately.

3 Theory/Design
We will be implementing an ECG and Digital Heart Rate counter. The main challenge of the project would be to amplify the desired weak signal in the presence of noise from other muscles and electrical sources. A display of the heart rate will be obtained by measuring the time between signal peaks and then calculating the frequency of the peaks in units of beats per minute. The device is most useful if it is portable. This requires a battery to be able to power all of the necessary components as well as the power output of the battery to be regulated.

3.1 Desired signal
The heart pulse received on the skin by electrodes is a result of traveling electrical activity from the heart. At the skin, this signal has a relative potential in the range of about ~2mV. This pulse as depicted in Figure 1 has a pulse length of about 20ms and therefore has a very low bandwidth of 50Hz.

3.2 Noise
Noise from the environment will easily swamp the tiny pulse signal from the heart. The leads connecting the electrode to the amplifier will act like an antenna which will inadvertently receive unwanted radiated signals. Such signals are for example the 50Hz from power lines and emf’s from fluorescent lights will add a tiny sinusoidal wave which is generally quite difficult to filter away. Muscles other than the heart also produce voltage potentials and these can also be detected although the large relative size and regularity of the heart muscles help to differentiate it from the rest.

3.3 Enhancements
To address the issues above, the following measure will be taken: • A high gain amplifier with a high Common Mode Rejection Ratio (CMRR) will be used to receive the desired signal. Also having a frequency response of at least 50Hz to detect the heart pulse. • A low pass filter will be implemented to remove the noise. Because most of the noise types discussed are of high frequency while the desired signal is relatively low a single pole filter will suffice. • The final circuit will be implemented in a Printed Circuit Board (PCB) to reduce the number of “radiating and transmitting” sources on the device (loose wires and exposed long component legs). • Necessarily long wires for the contacts will be shielded.

2

An initial design was constructed using a modular based approach for ease of testing and construction.

Figure 2 - Heart Rate Monitor System Diagram

3.4 Amplification Stage
An instrumentation amplifier is usually the very first stage in an instrumentation system. This is because of the very small voltages usually received from the probes need to be amplified significantly to be proceeding stages. An instrumentation amplifier (IA) is a difference amplifier where the difference between the two input terminals is amplified and the common signals between the inputs are rejected (Common Mode Rejection (CMR)). The latter function is the device characteristic, termed the Common Rejection Ratio (CMRR). As depicted in Figure 3, it typically consists of three op-amps.

Figure 3- Typical IA Three Op-Amp design

The IA circuit can be decomposed into two parts. Referring to Figure 3, XOP1 and XOP 2 are in a buffered amplifier configurations and XOP 3 is a basic differential amplifier. The buffered amplifiers while providing first stage amplification to the inputs also isolates the resistor resistance from being affected by the biasing (high potential or at noise floor) at the input terminals. The differential amplifier XOP 3 compensates for the bias by only considering the difference between the input terminals and generally has a differential gain of 1. For a bio-signals amplifier once of the important characteristics of the Op-amps to be used are its CMRR and Gain. 3

CMRR is generally affected by the matching of the resistance values throughout the circuit. Therefore the use of resistors with accuracies of 0.1% is highly desirable. The overall gain of the IA circuit is given by Equation 1 below. V0 R ⎞ R ⎛ = ⎜1 + 2 1 ⎟ 5 VS ⎝ R2 ⎠ R 4
Equation 1

3.5 Processing & Display
An 8-bit microcontroller was chosen to process the output signal produced by the amplification stage. The Microchip PIC16F877A was selected due to its additional output and processing power, and also its onboard 10-bit analogue to digital converter and in-circuit debugging features. Using this highly integrated microcontroller allowed for a simpler design and trouble shooting debugging process. Due to the use of a microcontroller to calculate the beats per minute (BPM), it was decided that a liquid crystal display (LCD) module would be the most flexible way of displaying this numerical output. It was originally planned that several seven segment displays could be used, but again it was deemed worthwhile to integrate the display unit together and limit the number of components required. In addition, the information which the LCD could convey was greater. Below is a block diagram of the microcontroller and LCD process: Initialise LCD Display

< Compare Value to Predetermined Conditions ≥ Use Time Difference to Estimate BPM Display BPM on LCD

Sample ADC Port

Regarding the actual BPM calculation (assuming that it was possible to translate each R part (the blip/spike peak) into singular events occurring in a timely fashion of course) it was originally going to be done by measuring the total number of spikes within a certain amount of time and then multiplying this count by a factor (as it is done when using a clock and your hand). With the use of the microcontroller however more precise measurements were able to be made resulting in an output of greater accuracy and speed.

3.6 Power
To power the circuit, the system will be divided into two sections. The system will be powered via a 9V battery with the required the 5V in section two obtained via a LM7805 5V voltage regulator. The sections are designed such that both sections can be powered via a single 9V battery or through two 9V dedicated battery for each section. For the amplifier stage, the op-amps require dual polarity rails to operate. To generate a negative voltage from a single 9V battery a virtual ground has to be created. 4

Referring to Figure 4, the resistors in the op-amp forms a voltage divider so that half the applied voltage VCC forms at the output However, it is important to note that a virtual ground has only limited output current therefore the op-amp should be used in the inverting configuration. This is because in this it requires no ground current.

Figure 4 - Generating a virtual ground

4 Implementation
4.1 Amplification Stage
To test the gain of the amplification circuit, a sinusoidal signal was attenuated to around the expected value to be amplified. The attenuation was achieved via the function generator and even further through a voltage divider circuit.

4.2 Display and Processing
The following two images are port names taken from the datasheets of the microcontroller and LCD used. The table details the corresponding pin connections between these two elements. The order in which these were connected was chosen to preserve the bit order of the microprocessor.

5

LCD PIN # 1 2 3 4 5 6 7 8 9 10 11 12 13 14

Microcontroller pin

8 10 9 19 20 21 22 27 28 29 30

Pin 3 on the LCD is a contrast adjustment and will require a potentiometer attachment Note that a 5V is required to power both the LCD and microcontroller, so a voltage regulator was added before the node where the tracks split off to power, the LCD pin 2 and the microcontroller pin 11 (Vdd) and pin 32 (Vdd). It was realized part way through the implementation stage that the output signal waveform from the amplification stage had a voltage bias that was highly dependant on the skin resistance and signal strength. As a direct result of this, complete implementation of the display unit became a real challenge as this relied on finding a variable voltage point. The expected output of the LCD is “HEART RATE: XXX” with XXX being a number between 0 and 999, which will be the users BPM. This will update frequently as new calculations are made. A complete photographic view of the system can be seen in the appendix section.

4.3 Data Acquisition
In order to acquire the ECG signal care was required not to overwhelm it with noise during the initial stages. This was achieved by both maximizing the signal strength before the amplifier stages as well as minimizing the added noise. As previously mentioned the long lengths of cable required to reach the person having their heart rate measured are quite long and are easily susceptible to added noise. This is minimized by using shielded core audio cable to carry this signal. The amount of the signal detected is maximized by using electrodes with a larger surface area. This is further increased by lowering the resistance of the junction between the skin and the electrode by using a conductive lubricant such as hand lotion or shampoo.

4.4 PCB Implementation
Using the Eagle PCB software provided the schematic of the amplifier and filter stages was replicated from the original PSpice implementation. This was then 6

converted into a PCB layout. A separate schematic and layout was also created to simplify connections to the microcontroller. As a precaution all integrated circuits (IC) were not directly soldered to the PCB. Taking their spot was IC socket holders. This was to allow for the possibility to change between Op-amp types (Precision or General) and to allow for allowance for ease of replacement of damaged ICs as well as to prevent damage from poor soldering. The PCB implementation can be found in Appendix A

5 Results
Figure 5 below illustrates the gain, CMR and filter ability of the amplifier. A gain of about 200 was achieved in this instance. In addition to this, the CMR and filter resulted in a clean sinusoid with amplitude of 6.19V. By varying the input frequency the frequency response of this stage was obtained as shown in Figure 6. The cut off frequency was located at 10 kHz with a drop of -20 dB/decade. This was ample for the purpose of detecting the heart pulse.

Figure 5 - Test waveform (thick) and Amplified waveform (thin)

Figure 6 - Frequency Response of Amplification Stage

7

Figure 7 - Actual Trace of Amplified ECG Received

The above waveform is the ECG waveform collected from a ‘patient’. The capture from the CRO shows the frequency and amplitude of the ECG signal. It had a frequency of 1.25 Hz, which corresponds to 80 BPM. The gain was adjusted via the two potentiometers to obtain a suitable trace.

6 Discussion
It was observed that the PCB implementation produced a cleaner output signal than that of the breadboard implementation. Comparing Figure 10 and Figure 12, the connections of the former are achieved through wires. In any circuit output which is sensitive to noise, the length of wires will contribute to noise receiving signals like an antenna. In using the electrodes to receive signals from the body, it was observed that the quality of the ECG signal was strongly related to that of the amount of conductive lubricant. This is expected as the resistance of the skin isolates the detection potential. Hence the quality of the signal will degrade over time at which point more lubricant will need to be added. As mentioned in the design and theoretical section, CMR and gain is a highly desirable feature. The downfalls of the current design are the number of individual components which are sources of errors. Alternatively a single 8pinDIP chip can replace the 3 op-amp IA configuration. This chip AD620 by Analogue Electronics is specifically designed for medical instrumentation. Figure 8 illustrates the superior accuracy and current efficiency of a dedicated IA over a 3 precision op-amps in an IA configuration.

Figure 8 - Three Op-amp IA configurations Vs. AD620 (left) and AD620 (right)

8

Figure 9 - Example of AD620 Implementation

For additional safety to the user, an isolation amplifier or circuit protection can be implemented between the input terminals of the amplification stage and the probes instead of the current limiters in the circuit as shown in Figure 9. Isolation of currents is usually achieved optically or inductively to prevent coupling. Examples of such are the AD202 by Analogue Devices. Inclusion of a specific IA and isolation amplifier represents another step up in cost. Due to the educational nature of this project, specialized components was not used but can be applied to replace existing components.

Hardware Used

• Microcontroller  AT89S52(8052 derivative)



IC’S 

1. DS 1820 (Temperature Sensor) 2. LM 7805 (Regulator IC for 5 volts constant D.C supply)

• • •

LCD  For display at remote station.

Crystal Oscillator  To produce 11.0592 MHz Frequency for microcontroller General Purpose PCB’s.

clock.

A BRIEF INTRODUCTION TO 8051 MICROCONTROLLER:
When we have to learn about a new computer we have to familiarize about the machine capability we are using, and we can do it by studying the internal hardware design (devices architecture), and also to know about the size, number and the size of the registers. A microcontroller is a single chip that contains the processor (the CPU), non-volatile memory for the program (ROM or flash), volatile memory for input and output (RAM), a clock and an I/O control unit. Also called a "computer on a chip," billions of microcontroller units (MCUs) are embedded each year in a myriad of products from toys to appliances to automobiles. For example, a single vehicle can use 70 or more microcontrollers. The following picture describes a general block diagram of microcontroller. The AT89S52 is a low-power, high-performance CMOS 8-bit microcontroller with 8K bytes of in-system programmable Flash memory. The device is manufactured using Atmel’s high-density nonvolatile memory technology and is compatible with the industrystandard 80C51 instruction set and pinout. The on-chip Flash allows the program memory to be reprogrammed in-system or by a conventional nonvolatile memory programmer. By combining a versatile 8-bit CPU with in-system programmable Flash on a monolithic chip, the Atmel's AT89S52 is a powerful microcontroller which provides a highly-flexible and costeffective solution to many embedded control applications. The AT89S52 provides the following standard features: 8K bytes of Flash, 256 bytes of RAM, 32 I/O lines, Watchdog timer, two data pointers, three 16-bit timer/counters, a six-vector two-level interrupt architecture, a full duplex serial port, on-chip oscillator, and clock circuitry. 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 con-tents but freezes the oscillator, disabling all other chip functions until the next interrupt

89s52:

The hardware is driven by a set of program instructions, or software. Once familiar with hardware and software, the user can then apply the microcontroller to the problems easily. The pin diagram of the 8051 shows all of the input/output pins unique to microcontrollers:

The following are some of the capabilities of 8051 microcontroller.     Internal ROM and RAM I/O ports with programmable pins Timers and counters Serial data communication

The 8051 architecture consists of these specific features:            16 bit PC &data pointer (DPTR) 8 bit program status word (PSW) 8 bit stack pointer (SP) Internal ROM 4k Internal RAM of 128 bytes. 4 register banks, each containing 8 registers 80 bits of general purpose data memory 32 input/output pins arranged as four 8 bit ports:P0-P3 Two 16 bit timer/counters: T0-T1 Two external and three internal interrupt sources Oscillator and clock circuits

For any electronics project the power supply plays a very important role in its proper functioning. In this project we are using external A.C supply (220 v) as input , this high voltage is converted into 12 Volts A.C by step down transformer , then we use voltage regulators and filters with bridge rectifier to convert the A.C into D.C voltage .

For voltage regulation we are using LM 7805 and 7812 to produce ripple free 5 and 12 volts D.C constant supply.

DS 1820 Temperature Sensor:
The DS18S20 digital thermometer provides 9-bit Celsius temperature measurements and has an alarm function with nonvolatile user-programmable upper and lower trigger points. The DS18S20 communicates over a 1-Wire bus that by definition requires only one data line (and ground) for communication with a central microprocessor. It has an operating temperature range of –55°C to +125°C and is accurate to ±0.5°C over the range of –10°C to +85°C. In addition, the DS18S20 can derive power directly from the data line (“parasite power”), eliminating the need for an external power supply.

Each DS18S20 has a unique 64-bit serial code, which allows multiple DS18S20s to function on the same 1-Wire bus. Thus, it is simple to use one microprocessor to control many DS18S20s distributed over a large area. Applications that can benefit from this feature include HVAC environmental controls, temperature monitoring systems inside buildings, equipment, or machinery, and process monitoring and control systems. Figure shows a block diagram of the DS18S20, and pin descriptions are given in the Pin Description table. The 64-bit ROM stores the device’s unique serial code. The scratchpad memory contains the 2-byte temperature register that stores the digital output from the temperature sensor. In addition, the scratchpad provides access to the 1-byte upper and

lower alarm trigger registers (TH and TL). The TH and TL registers are nonvolatile (EEPROM), so they will retain data when the device is powered down.

The DS18S20 uses Maxim’s exclusive 1-Wire bus protocol that implements bus communication using one control signal. The control line requires a weak pullup resistor since all devices are linked to the bus via a 3-state or open-drain port (the DQ pin in the case of the DS18S20). In this bus system, the microprocessor (the master device) identifies and addresses devices on the bus using each device’s unique 64-bit code. Because each device has a unique code, the number of devices that can be addressed on one bus is virtually unlimited. The 1-Wire bus protocol, including detailed explanations of the commands and “time slots,” is covered in the 1-Wire Bus System section.

Another feature of the DS18S20 is the ability to operate without an external power supply. Power is instead supplied through the 1-Wire pullup resistor via the DQ pin when the bus is high. The high bus signal also charges an internal capacitor (CPP), which then supplies power to the device when the bus is low. This method of deriving power from the 1-Wire bus is referred to as “parasite power.” As an alternative, the DS18S20 may also be powered by an external supply on VDD.

DS18S20 Block Diagram

DIFFERENT PRECAUTIONS
DURING SOLDERING:
• The bit of soldering iron should be kept clean with the help of file at time to time. • The solder wire should be of smaller thickness. • We should not use extra solder because it may be a cause of short circuit in the conductive path. • The components should not be overheated. • The leads of the components should be clean before soldering, by the send paper. • The bit of a new soldering iron should be clean properly before soldering. • The joint should be heated up to required temperature by which, the solder melts and comes around the joint. The joint should not be disturbed before setting the solder. The good joint looks pointed spot.

b.)

DURING USING POWER SUPPLY:

• switches and fuses should be used in a project circuit. • Earthing is essential in wiring. • We should use insulated wires. • Power supply should be switched off, when it is not required. • If there is a fault in the circuit, then firstly we should repair it. After repairing it connect again the power supply.

c.) DURING TESTING OF PROJECT:
• Each component should be checked before checking the project. • Potentiometer should be adjusted at proper range. • Battery of the testing equipment should be properly checked otherwise it will not measure the actual reading. • The components, which are not doing function properly, should be changed as soon as possible; otherwise, other components may also be damaged by it. • Testing equipment should be in proper range when output measured at any point of the circuit, or component. Otherwise testing equipment may be showed the wrong reading.

CIRCUIT DIAGRAM OF POWER SUPPLY

Voltage Comparator LM 358 The LM158 series consists of two independent, high gain, internally frequency compensated operational amplifiers which were designed specifically to operate from a single power supply over a wide range of voltages. Operation from split power supplies is also possible and the low power supply current drain is independent of the magnitude of the power supply voltage. Application areas include transducer amplifiers, dc gain blocks and all the conventional op amp circuits, which now can be more easily implemented in single power supply systems. For example, the LM158 series can be directly operated off of the standard +5V power supply voltage, which is used in digital systems and will easily provide the required interface electronics without requiring the additional ±15V power supplies. The LM358 and LM2904 are available in a chip sized pack-age (8-Bump micro SMD) using National’s micro SMD pack-age technology.

Unique Characteristics  In the linear mode the input common-mode voltage range includes ground and the output voltage can also swing to ground, even though operated from only a single power supply voltage.   The unity gain cross frequency is temperature compensated. The input bias current is also temperature compensated

Advantages       n Two internally compensated op amps n Eliminates need for dual supplies n Allows direct sensing near GND and VOUT also goes to GND n Compatible with all forms of logic n Power drain suitable for battery operation

Features                 n Available in 8-Bump micro SMD chip sized package, (See AN-1112) n Internally frequency compensated for unity gain n Large dc voltage gain: 100 dB n Wide bandwidth (unity gain): 1 MHz (temperature compensated) Wide power supply range: — Single supply: 3V to 32V — or dual supplies: ±1.5V to ±16V Very low supply current drain (500 µA)—essentially independent of supply voltage n Low input offset voltage: 2 mV n Input common-mode voltage range includes ground n Differential input voltage range equal to the power supply voltage n Large output voltage swing

7 Conclusion
This implementation of a heart monitor involves low cost amplifier and filter components coupled with a sophisticated microcontroller and LCD screen. Because the device is most useful if it is portable it was designed with use of one or two 9V batteries. The amplifier and filter stage of the implementation were successful with an ECG successfully detected and recorded. In doing this the output voltage was found to be strongly related to the quality of contact between the electrodes and the skin and was observed to be highly variable. This complicated the calculation and display of the actual rat since the proposed microcontroller code relied on a fixed reference which the peak of the ECG would cross and trigger the timer. The variability of the voltage output made this approach unfeasible. Using a fixed signal made demonstration of this part of the circuit possible This project successfully implemented an ECG while the Digital Heart Rate counter was only partially successful. The weak signal heart rate signal was amplified in the presence of noise from other muscles and electrical sources but we were unable to create an integrated device which could take this signal and calculate the heart rate.

9

8 Appendix A: Labelled photographs of assembled breadboard and PCB circuit

Figure 10 - Breadboard Implementation of Bio-Signals Amplifier

Figure 11 - Amplifier Stage and Components

I

Figure 12 - Bio-signals Amplification PCB up close

Figure 13 - Processing and Display Stage

II

9 Appendix B: PSPICE/MATLAB Implementation

VSOURCE on the left replicates a heart ECG signal. This schematic contained too many nodes for our student edition of the program to simulate.

III

10 Appendix C: EAGLE PCB Layout design

Figure 14 - PCB Design for Amplification Stage

Figure 15 - PCB Design for Processing Stage

IV

Sponsor Documents

Or use your account on DocShare.tips

Hide

Forgot your password?

Or register your new account on DocShare.tips

Hide

Lost your password? Please enter your email address. You will receive a link to create a new password.

Back to log-in

Close