interrupt analog sensor??

hi... im trying to run a code base on interrupts but my sensor its an inductive sensor so debugging found that if i print status of the sensor..... it never goes high, that why my code doesn't seem to work..... but its no documented about if its possible to interrupt an analog sensor....

the output of the sensor its no amplified or something like that im connecting directly the sensor output to interrupt0(digital pin).....

what could i do to make the sensor work on interrupt pin.... it works fine in analog pins...

what could i do to make the sensor work on interrupt pin

Start with posting your code. Write down what you expected for behaviour / output Write down what you got ...

Tell us about the sensor, Give a link to the datasheet

what do you mean with:

but its no documented about if its possible to interrupt an analog sensor

copachino: hi... im trying to run a code base on interrupts but my sensor its an inductive sensor so debugging found that if i print status of the sensor..... it never goes high, that why my code doesn't seem to work..... but its no documented about if its possible to interrupt an analog sensor....

the output of the sensor its no amplified or something like that im connecting directly the sensor output to interrupt0(digital pin).....

what could i do to make the sensor work on interrupt pin.... it works fine in analog pins...

Well one could wire the analog sensor to an op-amp comparator circuit which would then output a digital signal compatible with a digital input interrupt pin.

volatile byte rpmcount;
volatile int status;

unsigned int rpm;

unsigned long timeold;

 void rpm_fun()
 {
   //this function its activated once every spin... for now   //
   //
      rpmcount++;
      
 }
void setup()
  {
   Serial.begin(115200);
   //Interrupt 0 it is digital pin 2, 
   // (cambia de HIGH a LOW)
   attachInterrupt(0, rpm_fun, FALLING);
   


   rpmcount = 0;
   rpm = 0;
   timeold = 0;
   status = LOW;
 }

 void loop()
 {
  
   delay(1000);//update rpm every second........;
   detachInterrupt(0);
   //Note: this will be changed 60*1000/(millis() - timeold)*rpmcount for now its only one sample per rpm
   //for multiple samples per spin
   rpm = 60*1000/(millis() - timeold)*rpmcount;
   timeold = millis();
   rpmcount = 0;
   
   //print rmp to the serial port
   Serial.println(rpm,DEC);
   
   //restart the interrupt process
   attachInterrupt(0, rpm_fun, FALLING);

  }

i expected to have a count in rpm of a motor using a gear to trigger the sensor what i got ts nothing rpm count its zero because sensor never passes to high from low.. well the sensor its taked from a car transmission crank so i do not have datasheet and sensor doesn't have serial to search it.. what i meant by its not documented about interrupt an analog sensor, its that there many articles about using interrupts but none of they says if its possible to do it with an analog sensor

retrolefty:

copachino: hi... im trying to run a code base on interrupts but my sensor its an inductive sensor so debugging found that if i print status of the sensor..... it never goes high, that why my code doesn't seem to work..... but its no documented about if its possible to interrupt an analog sensor....

the output of the sensor its no amplified or something like that im connecting directly the sensor output to interrupt0(digital pin).....

what could i do to make the sensor work on interrupt pin.... it works fine in analog pins...

Well one could wire the analog sensor to an op-amp comparator circuit which would then output a digital signal compatible with a digital input interrupt pin.

something like this??? taked from LM329 datasheet

which op amp you thing its good for the job??? i have a Lm329 and also an Lm324N.... and some TL072 audio op amp....

The ATmega328 has a built-in analog comparator circuit that can generate interrupts - see the datasheet section 22 for details.

problem would be that i intend to read RPM and that wont give time to ATmega to do everything