Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

heart rate monitor pulse oximeter project

Status
Not open for further replies.

flumplogic

Newbie level 1
Joined
Mar 24, 2012
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,328
waqasalamkhan@hotmail.com is the original email but brought back a postmaster failed so I have posted full email on this site. I hope you guys can help.

Hello there, what a site very helpful. I came across your address on https://www.edaboard.com/threads/176611/ , I am also using the 16f877a pic , however my university has not got pic.h file licence so I can not persist in hitech c, i can use sourceboost and mplab which is what we are provided with. Designing the program is going to be just theory not to application. This is because of the time frame i have to order new parts. I basically have a circuit, initially using bright led and phototransistor, to get a a signal ( with resistors in series, 1k6 and 130k ohms respectively) as the light is switched on i want maximum swing when voltage goes low (5V supply) and current goes up as the resistance across the phototransistor decreases and increases. For some reason, I am not getting an expected noisy output signal, instead its very week, if i amply it, there is just more noise (100Hz internal lighting and sunlight). The choice of resistor in series with the phototransistor is based on datasheet (PT4800E0000F) i need the voltage on oscilloscope to drop from 5V close to zero or do i? The bandpass filter gets rid of the dc component and the low pass part rids high frequencies, i want 2.5Hz has cutt off frequency. ( i.e. between 60bpm to 150bpm).

My query is I need help designing code, using a 4MHz crystal, but with sourceboost, this is the code so far that i would need help on before i put it into isis to simulate. This is the problem, translating this into c from hitech, syntax quite similar but not. I i do this then i can put a pulse in there to test it hence displaying bpm on lcd screen.


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#include // plz include pic . h file here this file is available in hitech
#ifndef _XTAL_FREQ
// Unless specified elsewhere, 4MHz system frequency is assumed
#define _XTAL_FREQ 4000000
#endif
#define rs RD7
#define e RD6
#define lcd_data PORTB
#define buzzer RC1
void beep (void);
void delayms(unsigned int itime);
void blink(void);
void send_config(unsigned char data);
void pulse(void);
void send_char(unsigned char data);
void lcd_goto(unsigned char data);
void lcd_clr(void);
void send_string(const char *s);
void init_lcd(void);
void dis_num(unsigned int data,unsigned char digit);
unsigned int read_an(unsigned char channel);
void prog1(void);
void display(unsigned char c);
unsigned long no=0;
void main (void)
{
TRISA5=0; 
TRISC=0; 
TRISB=0;
TRISD0=1;
TRISD1=0;
TRISD7=0;
TRISD6=0;
TRISD3=0;
init_lcd();
while(1)
{
prog1();
}
 
}
void prog1(void)
{
unsigned int temp1=0,temp2=0;
unsigned char i;
unsigned int hb=1;
while(RD0);
while(!RD0){
hb++;
__delay_ms(1);
}
hb=30000/hb;
lcd_goto(2);
send_string("H.B.R: bpm");
lcd_goto(8);
dis_num(hb,3);
if(hb>87&&RD3==1) //if value of Heart Beat >87 and sound > 85dB
{
beep(); 
lcd_goto(16); 
send_string(" Stay Calm!! "); 
RD3=0; 
}
else if(hb>87)
{
lcd_goto(16);
send_string(" Stay Calm!! "); 
}
else
{
buzzer=0;
lcd_goto(16);
send_string(" Normal :) ");
}
 
}
void delayms(unsigned int itime)
{
for(;itime>0;itime--)
{__delay_ms(1);}
}
 
 
void send_config(unsigned char data) //send lcd configuration 
{
rs=0; //set lcd to configuration mode
lcd_data=data&0xf0; //lcd data port = data
pulse();
lcd_data=(data<<4)&0xf0; pulse(); }
 void pulse(void) {
 e=1; //pulse e to confirm the data 
delayms(1); e=0; delayms(1); }
 void lcd_goto(unsigned char data) //set the location of the lcd cursor 
{ 
//if the given value is (0-15) the //cursor will be at the upper line 
//if the given value is (20-35) the send_config
//cursor will be at the lower line 
//location of the lcd cursor(2X16): 
} 
void lcd_clr(void) //clear the lcd 
{ send_config(0x01); delayms(2); }
 
void send_string(const char *s) 
//send a string to display in the lcd 
{ rs = 1; while (*s)send_char (*s++); } 
void send_char(unsigned char data) //send lcd character 
{ rs =1; __delay_us(40); //set lcd to display mode 
lcd_data=data&0xf0; //lcd data port = data 
pulse(); lcd_data=(data<<4)&0xf0; pulse();
 } 
void init_lcd(void) { 
rs=0;e=0; //command mode 
delayms(10); //delay 10ms
 lcd_data=0x30; //load initial nibble
 pulse(); //Latch initial code 
delayms(5); //delay 5ms 
pulse(); //Latch initial code 
delayms(1); //delay 1ms 
pulse(); //Latch initial code 
lcd_data=0x20; pulse(); //Latch initial code //configure 
lcd send_config(0x28); //Set 4-bit mode, 2 lines 
send_config(0xF); //Switch off display 
send_config(0x01); //Clear Display 
send_config(0x06); //Enable cursor auto increase //
send_config(0x80); //Zero display address 
void dis_num(unsigned int data,unsigned char digit) {
 if(digit>3)
send_char('0'+(data/1000)%10);
if(digit>2)
send_char('0'+(data/100)%10);
if(digit>1)
send_char('0'+(data/10)%10);
if(digit>0)
send_char('0'+(data/1)%10);
}
 
void beep(void) // beep generator
{
buzzer=1;
delayms(300);
buzzer=0;
delayms(200);
buzzer=1;
delayms(300);
buzzer=0;
delayms(200);
buzzer=1;
delayms(300);
buzzer=0;
delayms(200);
buzzer=1;
delayms(300);
buzzer=0;
delayms(200);
buzzer=1;
delayms(300);
buzzer=0;
delayms(200);
 
}

 
Last edited by a moderator:

Hi.....even we are working on the same project,how far did u come along in this project.My hex file is not building
**broken link removed**
i followed this post mostly and the circuit is working fine.
though the name says its for anger measurement...it is useful in this context too.

waqasalamkhan@hotmail.com is the original email but brought back a postmaster failed so I have posted full email on this site. I hope you guys can help.

Hello there, what a site very helpful. I came across your address on https://www.edaboard.com/threads/176611/ , I am also using the 16f877a pic , however my university has not got pic.h file licence so I can not persist in hitech c, i can use sourceboost and mplab which is what we are provided with. Designing the program is going to be just theory not to application. This is because of the time frame i have to order new parts. I basically have a circuit, initially using bright led and phototransistor, to get a a signal ( with resistors in series, 1k6 and 130k ohms respectively) as the light is switched on i want maximum swing when voltage goes low (5V supply) and current goes up as the resistance across the phototransistor decreases and increases. For some reason, I am not getting an expected noisy output signal, instead its very week, if i amply it, there is just more noise (100Hz internal lighting and sunlight). The choice of resistor in series with the phototransistor is based on datasheet (PT4800E0000F) i need the voltage on oscilloscope to drop from 5V close to zero or do i? The bandpass filter gets rid of the dc component and the low pass part rids high frequencies, i want 2.5Hz has cutt off frequency. ( i.e. between 60bpm to 150bpm).

My query is I need help designing code, using a 4MHz crystal, but with sourceboost, this is the code so far that i would need help on before i put it into isis to simulate. This is the problem, translating this into c from hitech, syntax quite similar but not. I i do this then i can put a pulse in there to test it hence displaying bpm on lcd screen.


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#include // plz include pic . h file here this file is available in hitech
#ifndef _XTAL_FREQ
// Unless specified elsewhere, 4MHz system frequency is assumed
#define _XTAL_FREQ 4000000
#endif
#define rs RD7
#define e RD6
#define lcd_data PORTB
#define buzzer RC1
void beep (void);
void delayms(unsigned int itime);
void blink(void);
void send_config(unsigned char data);
void pulse(void);
void send_char(unsigned char data);
void lcd_goto(unsigned char data);
void lcd_clr(void);
void send_string(const char *s);
void init_lcd(void);
void dis_num(unsigned int data,unsigned char digit);
unsigned int read_an(unsigned char channel);
void prog1(void);
void display(unsigned char c);
unsigned long no=0;
void main (void)
{
TRISA5=0; 
TRISC=0; 
TRISB=0;
TRISD0=1;
TRISD1=0;
TRISD7=0;
TRISD6=0;
TRISD3=0;
init_lcd();
while(1)
{
prog1();
}
 
}
void prog1(void)
{
unsigned int temp1=0,temp2=0;
unsigned char i;
unsigned int hb=1;
while(RD0);
while(!RD0){
hb++;
__delay_ms(1);
}
hb=30000/hb;
lcd_goto(2);
send_string("H.B.R: bpm");
lcd_goto(8);
dis_num(hb,3);
if(hb>87&&RD3==1) //if value of Heart Beat >87 and sound > 85dB
{
beep(); 
lcd_goto(16); 
send_string(" Stay Calm!! "); 
RD3=0; 
}
else if(hb>87)
{
lcd_goto(16);
send_string(" Stay Calm!! "); 
}
else
{
buzzer=0;
lcd_goto(16);
send_string(" Normal :) ");
}
 
}
void delayms(unsigned int itime)
{
for(;itime>0;itime--)
{__delay_ms(1);}
}
 
 
void send_config(unsigned char data) //send lcd configuration 
{
rs=0; //set lcd to configuration mode
lcd_data=data&0xf0; //lcd data port = data
pulse();
lcd_data=(data<<4)&0xf0; pulse(); }
 void pulse(void) {
 e=1; //pulse e to confirm the data 
delayms(1); e=0; delayms(1); }
 void lcd_goto(unsigned char data) //set the location of the lcd cursor 
{ 
//if the given value is (0-15) the //cursor will be at the upper line 
//if the given value is (20-35) the send_config
//cursor will be at the lower line 
//location of the lcd cursor(2X16): 
} 
void lcd_clr(void) //clear the lcd 
{ send_config(0x01); delayms(2); }
 
void send_string(const char *s) 
//send a string to display in the lcd 
{ rs = 1; while (*s)send_char (*s++); } 
void send_char(unsigned char data) //send lcd character 
{ rs =1; __delay_us(40); //set lcd to display mode 
lcd_data=data&0xf0; //lcd data port = data 
pulse(); lcd_data=(data<<4)&0xf0; pulse();
 } 
void init_lcd(void) { 
rs=0;e=0; //command mode 
delayms(10); //delay 10ms
 lcd_data=0x30; //load initial nibble
 pulse(); //Latch initial code 
delayms(5); //delay 5ms 
pulse(); //Latch initial code 
delayms(1); //delay 1ms 
pulse(); //Latch initial code 
lcd_data=0x20; pulse(); //Latch initial code //configure 
lcd send_config(0x28); //Set 4-bit mode, 2 lines 
send_config(0xF); //Switch off display 
send_config(0x01); //Clear Display 
send_config(0x06); //Enable cursor auto increase //
send_config(0x80); //Zero display address 
void dis_num(unsigned int data,unsigned char digit) {
 if(digit>3)
send_char('0'+(data/1000)%10);
if(digit>2)
send_char('0'+(data/100)%10);
if(digit>1)
send_char('0'+(data/10)%10);
if(digit>0)
send_char('0'+(data/1)%10);
}
 
void beep(void) // beep generator
{
buzzer=1;
delayms(300);
buzzer=0;
delayms(200);
buzzer=1;
delayms(300);
buzzer=0;
delayms(200);
buzzer=1;
delayms(300);
buzzer=0;
delayms(200);
buzzer=1;
delayms(300);
buzzer=0;
delayms(200);
buzzer=1;
delayms(300);
buzzer=0;
delayms(200);
 
}

 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top