Microcontroller › 8051 › Bluetooth heart rate monitor?
- This topic has 6 replies, 3 voices, and was last updated 10 years, 5 months ago by John Jameson.
-
AuthorPosts
-
January 30, 2014 at 5:19 pm #2837John JamesonParticipant
Hey guys,
Just wondering can I use an 8051 chip to monitor someone’s heartbeat and then send the results via bluetooth to a pc/phone?
(programmed via keil)
January 31, 2014 at 4:43 am #10911AJISH ALFREDParticipantHi John,
It is very much possible. Heart beat sensor modules and bluetooth modules are available which can be easily interfaced with the microcontroller.
February 15, 2014 at 10:45 pm #11030John JamesonParticipantYa I was checking out some circuits online and various programs(although its been years since I did any programming)
This one seemed simple enough for the sensing side anyway
<code>
sbit SENSOR = P1^0; //sensor connected to pinunsigned int beatms;float bpm;char buf[20];void main(){// -=-=- Intialize variables -=-=-=lcdInit();// -=-=- Welcome LCD Message -=-=-=lcdClear();lcdGotoXY(0,0); // 1st Line of LCD// “xxxxxxxxxxxxxxxx”lcdPrint(“DIGITAL HEART”);lcdGotoXY(0,1); // 2nd Line of LCD// “xxxxxxxxxxxxxxxx”lcdPrint(“BEAT MONITOR”);beatms=0; // will store duration between two pulses// -=-=- Program Loop -=-=-=while(1){while(SENSOR==0);// wait for high pulse from sensorDelayNmS(10); // 10ms delay so that it does not listen to any noisebeatms = 10; // start counting beatms from 10ms since we have delay after pulsewhile(SENSOR==1)// wait until signal is high{DelayNmS(1); //wait 1msecbeatms++; //keep incrementing counter each 1ms}while(SENSOR==0) //keep looping till signal goes back high, wait for next{DelayNmS(1); //wait 1msecbeatms++; //keep incrementing counter each 1ms}// beatms variable will now have time in ms between two high edge pulselcdClear();lcdGotoXY(0,0);lcdPrint(“HEART RATE : “);bpm = (float)60000/beatms;if(bpm > 200){lcdGotoXY(0,1);sprintf (buf, “Processing……”); // Invalid, Wait for next cyclelcdPrint(buf);} else {lcdGotoXY(0,1);sprintf (buf, “%0.0f BPM”, bpm); // Display reading in BPMlcdPrint(buf);}}}<code>Went and created a new project in Keil and built it but got error C202: ‘P1’: undefined identifierI know it something really obviousFebruary 16, 2014 at 1:22 pm #11033AJISH ALFREDParticipantHi,
The error dialogue means, you frogot to include the header file having the defenition of P1.
I think this must be it
#include<reg51.h>
February 17, 2014 at 6:57 pm #11046John JamesonParticipantThis code is in Keil btw
Ya I had tried adding #include<reg51.h> to it but I was meet with this then
sensor.c(15): warning C206: ‘lcdInit’: missing function-prototypesensor.c(17): warning C206: ‘lcdClear’: missing function-prototypesensor.c(18): warning C206: ‘lcdGotoXY’: missing function-prototypesensor.c(18): error C267: ‘lcdGotoXY’: requires ANSI-style prototypeIs there a couple of things I’m doing wrong?Like should I specifing the folder in which the header file is contained? i.e #include<atmel/reg51.h>Or should I be adding the header file to the source group?Although I did do a copy of the reg51 header file and added to the folder where the sensor code was saved and tried building it using#include “reg51.h” but got the same errorMarch 9, 2014 at 4:24 am #11252SHAH DISHANT H.ParticipantHi,
You have used various functions for LCD but you have not defined them in this program and because of that you are facing this errors.
From which site you have got this program? Post the link here.
May be they will have something like #include “lcd.h” but its not present in your code. We need to include that also.
April 7, 2014 at 5:15 pm #11496John JamesonParticipantDecided to scrap the previous code and try something different.Been trying to work this.
<code>
- #include reg51.h
- //#include
- void _nop_(void);
- #define delay_us _nop_(); //generates 1 microsecond
- #define LCD P3
- sbit RS=P2^0; //connect p0.0 to rs pin of lcd
- sbit EN=P2^2; //connect p0.1 to en pin of lcd
- sbit RW=P2^1;
- sbit PULSE=P0^0; //pulse input from heart beat sensor
- //sbit LED=P1^0; //led indicator for pulse indication
- void integer_lcd(int);
- void init_lcd(void);
- void cmd_lcd(unsigned char);
- void write_lcd(unsigned char);
- void delay_ms(unsigned int);
- unsigned int num=0;
- unsigned int num1=0;
- unsigned int dig_1,dig_2,dig_3,dig_4,test=0;
- unsigned int dig_11,dig_21,dig_31,dig_41,test1=0,test2=0;
- unsigned char k=0;
- void main(void)
- {
- init_lcd();
- //LED=0;
- write_lcd(‘H’);
- write_lcd(‘E’);
- write_lcd(‘A’);
- write_lcd(‘R’);
- write_lcd(‘T’);
- write_lcd(‘ ‘);
- write_lcd(‘B’);
- write_lcd(‘E’);
- write_lcd(‘A’);
- write_lcd(‘T’);
- write_lcd(‘ ‘);
- write_lcd(‘ ‘);
- write_lcd(‘ ‘);
- write_lcd(‘ ‘);
- write_lcd(‘ ‘);
- write_lcd(‘ ‘);
- cmd_lcd(0xc0);
- write_lcd(‘ ‘);
- write_lcd(‘ ‘);
- write_lcd(‘ ‘);
- write_lcd(‘ ‘);
- write_lcd(‘ ‘);
- write_lcd(‘ ‘);
- write_lcd(‘ ‘);
- write_lcd(‘ ‘);
- write_lcd(‘C’);
- write_lcd(‘O’);
- write_lcd(‘U’);
- write_lcd(‘N’);
- write_lcd(‘T’);
- write_lcd(‘E’);
- write_lcd(‘R’);
- delay_ms(300);
- cmd_lcd(0x01);
- write_lcd(‘B’);
- write_lcd(‘e’);
- write_lcd(‘a’);
- write_lcd(‘t’);
- write_lcd(‘s’);
- write_lcd(‘:’);
- write_lcd(48);
- write_lcd(48);
- write_lcd(48);
- write_lcd(48);
- while(1)
- {
- if(PULSE==1) //check for input pulse from sensor
- {
- cmd_lcd(0x01);
- test++;
- num=test;
- dig_4=num%10;
- num=num/10;
- dig_3=num%10;
- num=num/10;
- dig_2=num%10;
- dig_1=num/10;
- if(test==9999)
- test=0;
- write_lcd(‘B’);
- write_lcd(‘e’);
- write_lcd(‘a’);
- write_lcd(‘t’);
- write_lcd(‘s’);
- write_lcd(‘:’);
- write_lcd(dig_1+48);
- write_lcd(dig_2+48);
- write_lcd(dig_3+48);
- write_lcd(dig_4+48);
- //LED=1;
- delay_ms(50);
- //LED=0;
- }
- }
- }
- ////////////////////////////////////////////////////////////////
- void init_lcd(void)
- {
- delay_ms(10); //delay 10 milliseconds
- cmd_lcd(0x38); //8 bit initialize, 5×7 character font, 16×2 display
- cmd_lcd(0x0e); //lcd on, cursor on
- cmd_lcd(0x06); //right shift cursor automatically after each character is displayed
- cmd_lcd(0x01); //clear lcd
- }
- //transmit command or instruction to lcd
- void cmd_lcd(unsigned char c)
- {
- EN=1;
- RW=0;//set enable pin
- RS=0; //clear register select pin
- LCD=c; //load 8 bit data
- EN=0; //clear enable pin
- delay_ms(2); //delay 2 milliseconds
- }
- //transmit a character to be displayed on lcd
- void write_lcd(unsigned char c)
- {
- EN=1; //set enable pin
- RW=0;
- RS=1; //set register select pin
- LCD=c; //load 8 bit data
- EN=0; //clear enable pin
- delay_ms(2); //delay 2 milliseconds
- }
- //generates delay in milli seconds
- void delay_ms(unsigned int i)
- {
- unsigned int j;
- while(i–>0)
- {
- for(j=0;j<500;j++)
- {
- ;
- }
- }
- }
- <code>
- I think this only works as a pulse counter so to calculate the beats per minute a time reference is needed I think.
When I load it onto my chip,the welcome message comes up on the lcd and then everytime I put my finger on the lrd the no of beats increment by 1 on the lcd screen.
-
AuthorPosts
- You must be logged in to reply to this topic.