Go Down

### Topic: heart rate calculation (Read 260 times)previous topic - next topic

#### karl1993

##### May 24, 2016, 07:22 am
Hi Everyone
i am having troble to calculate the heart beat rate show it on the lcd

so i am using a microphone to detect the heart beat. so far i am sampling at 200 Hz ( so 200 point everyone second)i connect my circuit output to A0, and i am getting digital value from the serial window. however from these bunch of digital value, how am i able to convert to heart beat rate every minute and print it them on to the lcd?
any suggestion? thanks

#### karl1993

#1
##### May 24, 2016, 07:34 am
Hi Everyone
i am having troble to calculate the heart beat rate show it on the lcd

so i am using a microphone to detect the heart beat. so far i am sampling at 200 Hz ( so 200 point everyone second)i connect my circuit output to A0, and i am getting digital value from the serial window. however from these bunch of digital value, how am i able to convert to heart beat rate every minute and print it them on to the lcd?
any suggestion? thanks

#### heninsh

#2
##### May 24, 2016, 08:06 am
Hi !

Quote
and i am getting digital value from the serial window.

#3

#### karl1993

#4
##### May 24, 2016, 08:39 amLast Edit: May 24, 2016, 08:46 am by Coding Badly
Hi !

Code: [Select]
`0000000000043942044500048300000000045446700000000000000000000000000000046400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004614404380000000000004690000000000000000000000000000000046300000000000480000000000000000000000000000000000000000000000000000000000000000000000000000000000000047000000000000046039542500000000000047404704660000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000043941047200000000000000000000000000000000000000000000000004690000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004510000004344270000000000004614630000000000000000000000000000000046400047300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000459428464000000000000000000000000000004490000000000000004660000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044800000000000047144545600000000000000000000000000000000000000000000000000000000047100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000046600000000000004684470000000000000469468000000000000000000000000000000004670047200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000472000000000000470450000000000000047200000000000000000000000000046700004670000000000000000000000000000000000000000000000000000000000000000000000000000000000004740000000000000045343800000000000000470000000000000000000000000000000046500000000000000000000000000467000000000000000000000000000000000000000000000000000000000000000000000000469000004454124380000000000047000000000000000000000000000000000000000000000004520000000000000000000000000000000000000000000000000000000000000000000000000000046900000000000004104170000000000004694680000000000000000000000000000000004660000000000000000000000000000000047500000000000000000000000000000000047300000000000000000000000000000000000000000043841547200000000000046946200000000000000000000000000000000000000000000000000000`

these are my signals output, there are 2000 points , the value that isnt zero indicates the heart beats, as its sampling 200points every second, therefore there wont be just 1 non-zero value in every second even there is just one beat. i dont know what formula to apply to convert these numbers to heart beat rate per minute.

Moderator edit: [code] [/code] tags added.

#### raschemmel

#5
##### May 24, 2016, 11:39 am
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

#### karl1993

#6
##### May 25, 2016, 02:18 am
#include <glcd.h>
#include <glcd_Buildinfo.h>
#include <glcd_Config.h>

// Digital Stethoscope Project
// Monash Final Year Project
// Present by
// Karl Wei
// Ce Wang
// Haoxiang Deng

// include the library code:
#include <LiquidCrystal.h>

// initialimy_pine the library by providing the nuber of pins to it
LiquidCrystal lcd(8,9,4,5,6,7);

unsigned long previousMillis = 0;
const long interval = 5;
int analog_in0 = A0; // Define an integer which is the output from the microphone 1 in to arduino
int analog_in1 = A1; // Define an integer which is the output from the microphone 2 in to arduino
const int button_pin = 3 ;// Define the button pin
const int led_pin = 12 ;// Press botton to light the green led

int sample_points = 0; // Define the interger for the initialised sampling points that we going to take

void setup()  // Code for run once:
{
lcd.begin(16,2);

// set cursor position to start of first line on the LCD
lcd.setCursor(0,0);
//text to print
lcd.print("     Welcome    ");
// set cusor position to start of next line
lcd.setCursor(0,1);
lcd.print("                ");

pinMode(led_pin, OUTPUT); // initialimy_pine the LED pin as an output:
pinMode(button_pin, INPUT); // initialimy_pine the pushbutton pin as an input:
pinMode(analog_in0,INPUT); // set the pin as input, since the sound will be collect from the microphone 1 in to arduino
pinMode(analog_in1,INPUT); // set the pin as input, since the sound will be collect from the microphone 2 in to arduino

Serial.begin(250000); // allows us to listen to serial communications from the arduino
delay(2000); // wait for 2 second until the arduino to start, this is the time for wating for matlab start to run
}

void loop()  // Code for run repeately
{

unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval) {
previousMillis = currentMillis;

// set cursor position to start of first line on the LCD
lcd.setCursor(0,0);
//text to print
lcd.print("     BPM    ");
// set cusor position to start of next line
lcd.setCursor(0,1);
lcd.print(BPM);
}
}

this is my code so far.

#### raschemmel

#7
##### May 25, 2016, 04:54 am
Quote
this is my code so far.
Please use the CODE TAGS button [</>]
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

#### Delta_G

#8
##### May 25, 2016, 06:07 am
Code: [Select]
`0000000000043942044500048300000000045446700000000000000000000000000000046400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004614404380000000000004690000000000000000000000000000000046300000000000480000000000000000000000000000000000000000000000000000000000000000000000000000000000000047000000000000046039542500000000000047404704660000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000043941047200000000000000000000000000000000000000000000000004690000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004510000004344270000000000004614630000000000000000000000000000000046400047300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000459428464000000000000000000000000000004490000000000000004660000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044800000000000047144545600000000000000000000000000000000000000000000000000000000047100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000046600000000000004684470000000000000469468000000000000000000000000000000004670047200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000472000000000000470450000000000000047200000000000000000000000000046700004670000000000000000000000000000000000000000000000000000000000000000000000000000000000004740000000000000045343800000000000000470000000000000000000000000000000046500000000000000000000000000467000000000000000000000000000000000000000000000000000000000000000000000000469000004454124380000000000047000000000000000000000000000000000000000000000004520000000000000000000000000000000000000000000000000000000000000000000000000000046900000000000004104170000000000004694680000000000000000000000000000000004660000000000000000000000000000000047500000000000000000000000000000000047300000000000000000000000000000000000000000043841547200000000000046946200000000000000000000000000000000000000000000000000000`

these are my signals output, there are 2000 points , the value that isnt zero indicates the heart beats, as its sampling 200points every second, therefore there wont be just 1 non-zero value in every second even there is just one beat. i dont know what formula to apply to convert these numbers to heart beat rate per minute.

Moderator edit: [code] [/code] tags added.

That looks pretty simple.  You need a variable as a counter.  Everytime you read one of those values, if it is not zero but the last one was, add one to the counter.  If it is a zero, or if it is non-zero but the last read was also non-zero then don't add one to the counter.
Ad hoc, ad loc, and quid pro quo.  So little time - so much to know!  ~Jeremy Hillary Boob Ph.D

#### jrdoner

#9
##### May 25, 2016, 06:33 am
I have atrial fibrillation, which means my heartbeat is irregular.  Even my blood pressure cuff can't figure out my heart rate.  Just be advised, test your gadget on people who don't have afib, or you'll get closure on the project.

#### raschemmel

#10
##### May 25, 2016, 09:37 pm
I was a Hospital Corpsman in the Air Force. When I took vital signs I could sample for no less than 15 seconds and up to a minute depending on the patient's conditions. You should NOT have any result until at LEAST 15 seconds. The accuracy goes up with each additional 15 second sample. There should be NO ZEROS ! If the heart rate is ZERO the patient is DEAD !

Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

Go Up

Please enter a valid email to subscribe