void timerIsr() deosn't work and oscilloscope show anything

I have a project on simulation and realization of a pulsation detector cardiac coupled to an electronic thermometer in proteus but void timerIsr() deosn’t call and show anything in LM016L beside when i open oscilloscope also show nothing

#include<LiquidCrystal.h>
#include <TimerOne.h>
LiquidCrystal lcd(13,12,11,10,9,8);
int HBSensor=4;
int HBCount=0;
int HBCheck=0;
int TimeinSec=0;
int HBperMin=0;
int HBStart=0;
int HBStartCheck=0;
const int sensor=A0;
int led1(1);
int led2(2);
int led3(3);
float tempc;
float vout;
void setup() {
  // put your setup code here, to run once:
  lcd.begin(20,4);
  pinMode(HBSensor, INPUT);
  pinMode(HBStart, INPUT_PULLUP);
  Timer1.initialize(800000);
  Timer1.attachInterrupt(timerIsr);
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Current HB: ");
  lcd.setCursor(0,1);
  lcd.print("Time in Sec :");
  lcd.setCursor(0,2);
  lcd.print("HB per Min :0.0");
  pinMode(sensor, INPUT);
  delay(500);
  pinMode(1, OUTPUT);
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);

}

void loop() {
  // put your main code here, to run repeatedly:
  if(digitalRead(HBStart)==LOW) {
    lcd.setCursor(0,3);
  lcd.print("HB Counting ..");
  HBStartCheck=1;}
  if(HBStartCheck==1){
  if((digitalRead(HBSensor)==HIGH)&&(HBCheck==0)){
    HBCount=HBCount+1;
    HBCheck=1;
    lcd.setCursor(14,0);
    lcd.print(HBCount);
    lcd.print(" ");
  }
  if((digitalRead(HBSensor)==LOW)&&(HBCheck==1)){
    HBCheck=0;
  }
  if(TimeinSec==10){
    HBperMin=HBCount*6;
    HBStartCheck=0;
    lcd.setCursor(14,2);
    lcd.print(HBperMin);
    lcd.print(" ");
    lcd.setCursor(0,3);
    lcd.print("Press Button again.");
    HBCount=0;
    TimeinSec=0;
  }
  vout =analogRead(sensor);
  tempc=(vout*500)/1023;
  lcd.setCursor(0,0);
  lcd.print("in degree C=");
  lcd.print(tempc);
  lcd.setCursor(0,1);
  if (tempc>38){
    digitalWrite(led2,HIGH);
    digitalWrite(led3,LOW);
    digitalWrite(led1,LOW);
  }
  if(tempc>37 && tempc<38){
    digitalWrite(led1,HIGH);
    digitalWrite(led3,LOW);
    digitalWrite(led2,LOW);
  }
  if(tempc<37){
    digitalWrite(led3,HIGH);
    digitalWrite(led1,LOW);
    digitalWrite(led2,LOW);
  }
  }
}
void timerIsr(){
  if(HBStartCheck==1){
    TimeinSec=TimeinSec+1;
    lcd.setCursor(14,1);
    lcd.print(TimeinSec);
    lcd.print("");
  }
}

Well, channel A is connected directly to the "heart sensor" so you have either connected it wrong, or configured it wrong. You have access to all that stuff, we don't.

These should be declared as volatile because they is used in an ISR (and outside) :

HBStartCheck
TimeinSec

I checked it several times and I don't think the problem is from proteus I did like what the professor did , But the most important LM016L doesn't show anything

ninofutaba:
I checked it several times and I don't think the problem is from proteus I did like what the professor did , But the most important LM016L doesn't show anything

That's what I told you. You need to go and research the LM016L component and its settings in Proteus. We can't do that for you.

6v6gt:
These should be declared as volatile because they is used in an ISR (and outside) :

HBStartCheck
TimeinSec

Also they are both multi-byte variables. You should disable interrupts when accessing them from the main loop OR make them byte variables if you can. I believe you can because HBStartCheck can be a boolean and it looks like you intend to reset TimeinSec when it reaches 10.

But the most important LM016L doesn't show anything

LiquidCrystal lcd(13,12,11,10,9,8);

The wiring of the lcd in your image looks nothing like this constructor.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.