Jump to content
Sign in to follow this  
simplelogic

A Sourceboost Program To Count Pulse Signals In A Minute And Display On Lcd

Recommended Posts

after writing in Hi-Tech C, will i be able to compile this in sourceboost, if I can not how do I go about changing this solve problem of programming a microcontroller using 16F84 or what do you recommend for a pic 16F87X or perhaps 16F818/819?

 

//# define

# include < pic . h>
#define  rs   RA2
#define  e   RA1
#define  lcd_data PORTB
#define _XTAL_FREQ 4000000
void delayms(unsigned int itime);
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);
void prog1(void);
unsigned long no=0;
void main (void)
{
TRISA=0;	
TRISB=0;
TRISA3=1;

init_lcd();
delayms(10);
lcd_clr();
delayms(10);
send_string("Heart rate meter");
delayms(1000);
lcd_clr();
delayms(10);
while(1)
{
prog1();
}
}
void prog1(void)
{
unsigned int temp1=0,temp2=0;
unsigned char i;
unsigned int hb=1;
 while(RA3);
 while(!RA3){
 hb++;
 delayms(1);
 }
hb=30000/hb;
lcd_goto(2);
send_string("H.B.R:	bpm");
lcd_goto(8);
dis_num(hb,3);

}
void delayms(unsigned int itime)
{
unsigned int i;
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
 send_config(0x80+data);   //cursor will be at the lower line
}
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;
delayms(1);		//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(0x06);	 //Enable cursor auto increase
}

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);
}

 

I intend to simulate heart beat pulse initially before actually programming the pic and using it in my circuit to record heart rate on lcd screen, can any one help or am I in the wrong forum because I am new here.

Share this post


Link to post
Share on other sites

after writing in Hi-Tech C, will i be able to compile this in sourceboost

 

Try it!

 

if I can not how do I go about changing this

If you wrote, surely you can figure out how to change it

 

 

what do you recommend for a pic 16F87X or perhaps 16F818/819

 

The choice depends on your hardware design and what else you expect it to do

 

 

Have a look here http://www.scribd.com/doc/63480088/Pic-877 . There is something so similar its word for word to the code that you wrote.

Share this post


Link to post
Share on other sites

Go for it!

Once you get it working - check out the circuit in Silicon Chip magazine February 2005.

I kept the op-amp signal amplifier side of it and modified the rest of it and wrote BoostC for a PIC 18F4520 to do both pulse rate and 2-line realtime ECG to a laptop via USB - works well.

Now just waiting for my coronary!

Share this post


Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...