aswathymohan
Member level 4
- Joined
- Nov 11, 2012
- Messages
- 68
- Helped
- 5
- Reputation
- 10
- Reaction score
- 5
- Trophy points
- 1,288
- Activity points
- 1,727
Hi
Pl post the mikroc code for the calculation of heart beat monitoring system using pic16f877a..I have seen a thread here..I just copied and did the same thing where i may confused with the calculation of heart beat per min.pl help...
Pl post the mikroc code for the calculation of heart beat monitoring system using pic16f877a..I have seen a thread here..I just copied and did the same thing where i may confused with the calculation of heart beat per min.pl help...
Code:
// LCD module connections
sbit LCD_RS at RB0_bit;
sbit LCD_EN at RB1_bit;
sbit LCD_D4 at RB2_bit;
sbit LCD_D5 at RB3_bit;
sbit LCD_D6 at RB4_bit;
sbit LCD_D7 at RB5_bit;
sbit LCD_RS_Direction at TRISB0_bit;
sbit LCD_EN_Direction at TRISB1_bit;
sbit LCD_D4_Direction at TRISB2_bit;
sbit LCD_D5_Direction at TRISB3_bit;
sbit LCD_D6_Direction at TRISB4_bit;
sbit LCD_D7_Direction at TRISB5_bit;
// End LCD module connections
unsigned inputsignal=0;
unsigned int firstRun = 1;
unsigned int cnt=0; // Define variable cnt == 1KHz clk
long HR=0;
char *text;
unsigned char outlcd;
char uart_rd;
char uart_rd1[15];
void call();
void interrupt() {
cnt++; // Interrupt causes cnt to be incremented by 1
TMR0 = 194; // Timer TMR0 is returned its initial value
INTCON = 0x20; // Bit T0IE is set, bit T0IF is cleared
}
void main()
{
OPTION_REG = 0x84; // Prescaler is assigned to timer TMR0
ADCON0=0X81; // Pins AN1 is configured as analog
TRISA = 0xFF; // All port A pins are configured as inputs
ADCON1=0X00;
//TRISC = 0; // All port C pins are configured as outputs
TRISD = 0; // All port D pins are configured as outputs
//PORTC = 0x00; // Reset port C
PORTD = 0x00; // Reset port D
UART1_Init(9600);
delay_ms(100);
//ADCON1.F4 = 0 ; // VSS voltage reference
//ADCON1.F7 = 1 ; //A/D Conversion Result Format Select bit adfm=1
//ADCON0 = 0x07; // A/D is enabled and AN1 is analog input
Lcd_Init(); // LCD display initialization
Lcd_Cmd(_LCD_CURSOR_OFF); // LCD command (cursor off)
Lcd_Cmd(_LCD_CLEAR); // LCD command (clear LCD)
text = "WELCOME...... "; // Define the first message
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1,2,text); // Write the first message in the first line
text ="HEART BEAT METER";
Lcd_Out(2,1,text);
delay_ms(100);
delay_ms(100);
delay_ms(100);
delay_ms(100);
delay_ms(100);
while(1)
{
inputsignal = ADC_Read(1);
if (inputsignal>=64)
{
delay_ms(50);
if (firstRun==1)
{
firstRun = 0;
cnt = 0; // Variable cnt is assigned a 0
TMR0 = 194; // Timer T0 counts from 194 to 255
INTCON = 0xA0; // Enable interrupt TMR0
}
else
{
//find heart rate
Lcd_Cmd(_LCD_CLEAR);
text="Heart rate=";
Lcd_Out(1,1,text);
//number of interrupt is time between two pulses in ms
HR=60000/cnt;
outlcd=HR/100 ; //hundreds digit in HR
Lcd_Chr(1,12,48+outlcd); // Write result in ASCII format
outlcd=(HR/100)%10;//tens digit in HR
Lcd_Chr_CP(48+outlcd);
outlcd=(HR)%10 ;//ones digit in HR
Lcd_Chr_CP(48+outlcd);
Lcd_out(2,5,"puls/min.");
//Lcd_Cmd(_LCD_CLEAR);
//rest vlaue of counter
//and start next test
cnt = 0 ;
TMR0 = 194; // Timer T0 counts from 194 to 255
INTCON = 0xA0; // Enable interrupt TMR0
}
}
}
}