Arduino smart project: Heart rate

 

 The purpose of this project is to build a virtual prototype, once you have an analog signal from a sencor. From this point, you need to use a digital oscilloscope to read the signal from the sencor and use it in PSpice. That way you can start creating a prototype in OrCAD Capture and PSpic based on the real signal.

 

The task at hand is...

That you have to build an analog heart rate sencor that can be attached to the fingertip and measure the transparency of the blood.

To put it briefly...

When the heart gives a pulse, the finger becomes less transparent due to blood circulation. Shortly after, the finger becomes more transparent again - until the next pulse. 

The sencor consists of an IR LED (SFH 487-2) and a phototransistor (SFH 309 NPN). The phototransistor gives a voltage level, that is dependent on light intensity. When there is a lot of light, the phototransistor's impedance is low, and it gives a low voltage as well. When a pulse occurs, the phototransistor will then give a higher voltage, and shortly after it will get decrease.

The sencor can be mounted on a wooden clothespeg, like the one you see in the picture below. You can also see an example here

This project should be compatible with Arduino Uno (ATMEGA328 µC) that has 5V logic. It's a good idea make your sencor can be supplied with 5V.

 

 

 

 The signal from the sencor will look like this, if the pulse is measured while sitting still for a while:

 

 Save this signal in a text file with two columns. The first column is seconds and the other one contains voltage levels. You file should look like this:

 

 Import this file to OrCAD Capture and PSpice by using a PWL source. Rund the simulation to find out if you get the same signal, that you see in the oscilloscope. If you did everything right, you should get a signal as seen in the image below.

 

 

 Now you have to remove the offset from the signal. It should be around 1,6V, depending on the finger. For this you can use a low-pass filter. 

 

 Calculate the cutoff frequency so the signal stays intact. Think of the human heart beat - it's around 30-200 beats per minute. If you convert this into frequency, it's 0,5-3,4Hz. This makes it 0,5-3,4 beats per second.

 The cutoff frequency has to be lower than 0,5Hz in order to keep the signal consistency. If you set it at 0,1Hz and choose a 10µF capacitor, you end up with a resistor at 150k. Below you can see the signal you get after filtering.

 

 The signal's offset is now 0V. The easiest way to continue now, is to use a double power supply. It's easy to design this in Capture and PSpice, but later on this will make your project more complicated. You can instead make a reference voltage - ideally at 2,5V, and make the signal have a voltage offset at 2.5V. You can do this by using a Zener diode with Zener voltage at 2.4V. Now you can amplify the signal without clipping it.

 

 

Video tutorial

 

 Now you can filter your signal for high frequency noise by using an inverting active low-pass filter.
 The gain is set to -1 and the cutoff frequency at 5Hz.

 If you use a 330nF capacitor, you will need a parallel resistor at 100k.
 For a -1 gain, you just need to use a R1 = 100k.

 Try and simulate your filter by using the MCP6001 Rail to Rail opamp. It is a relatively non-expensive opamp, and here PSpice gives you the opportunity of testing that it works with your circuit. If works as it should, then you can buy the MCP6001, which is an IC package containing one opamp, or the MCP6002 with 2 opamps, or the MCP6004 with 4 opamps. 

 

 

 

 Amplify and invert the signal back to normal by using a simple inverting opamp. Use a potentiometer to adjust the gain up to 100.

 

 Now the signal is ready to be read by the microcontroller. It can be done by using an ADC. But for this example, you are going to use a microcontroller only to calculate the heartbeat rate per minute. Therefore you only need to put a square signal into the microcontroller. You can do this by using a comparator.

 Here you can use a "data-slicer" comparator with hysteresis, which is set at 500mV. The term "data-slicer" means that there is no need for a voltage reference, because there is a low-pass filter with a high time constant (?), that provides a DC average of the signal as a reference. 

 

 

 If you also wish to have the possibility of seeing the cardiograph, you can use a voltage buffer in parallel with the comparator, so you can have an output, where it is possible to see the cardiograph.

 

Video tutorial

 

 From version 17.2 it is reasier to use a Device Model Interface (DMI) in Capture and PSpice, which you can programme in C/C++. There are two exercises that can help you get started with using a DMI. 

 After the comparator, you can use a DMI in PSpice in order to simulate a microcontroller. Use the same DMI as the one you made for these two exercises. The DMI must consist of a CLK port, an IN port, and a 10-bit (or higher) OUT port. 

 

 You have to programme your DMI in order to read the signal from the comparator at the IN port and the signal from the CLK port. Set this to 1kHz to make things easier.

 Your DMI is going to count the CLK pulses for every heart beat. The DMI can then calculate the heartbeat rate and output it as a binary number at the OUT port. 

 

Video tutorial

 

 Do you wish to create a PCB that you can plug into your Arduino Uno? We have made a template for you, so you can use it to create a shield. In order to do so, you have to finish the PCB Design exercises. If you use components that do not exist in the database, then you have to find a symbol in Capture and a footprint as well. We made video tutorials to help you with this. Find them in the Tips & Tricks section.

Download files for Arduino Uno Shield

Here you can download the .zip file, which contains all the necessary files you need to create a Arduino Uno Shield. Open the file with a .zip reading program. There is an exercise in PCB Design exercises that teaches you how to get started with the template. 

zip arduinouno_shield_orcad_files.zip (27.3 KB)

 

 Use the following components:

 

1x through-hole female header

  • Pitch: 2,54mm (sensor's input - 3pin)
 

 

5x through-hole male headers

  • Pitch: 2,54mm
  • (4x Arduino's pin rows, 1x 2pin for the cardiograph output)

 

1x MCP6004 R2R opamp package through-hole

  • Pitch: 2,54mm
  • (use an IC socket)
  

 

1x 100nF decoupling capacitor close to the MCP6004's power pin (optionally)

  • Pitch: 2,5mm

 

Resistors ø2,3mm x 6mm

  • Pitch: 9mm

 

1x potentiometer ACP

  • 9mm

 

1x zener 2,4V diode BZX79-C2V4

 

1x 330nF MKT capacitor

  • Pitch: 5mm

 

2x 10uF ceramic capacitor SMD 1206 (3216 Metric)

 

Video tutorials

Cookies

Nordcad anvender cookies til at indsamle viden om anvendelsen af hjemmesiden, og for at sikre brugere den bedste oplevelse. Hvis du klikker videre på siden, accepterer du vores brug af cookies.

Nordcad AS
Kløvervegen 7
NO-2052 Jessheim

   


tel.: +47 21 55 28 28
info@nordcad.no  

We'd like to connect with you!