Electronic – Use interrupt to determine a change in IR detector

comparatordifferentialinterruptsoperational-amplifier

I have build a schematic to read a counter. The counter has a white point at one of the digits, that I detect with a IR transmitter-receiver. The voltage at the receiver changes from 2.2 to 2.5 volts (with some noise between) when te white point passes. So I use a opamp diff amplifier to change the voltage range to 1 – 3 volts. That signal goes to opamp comparator that changes at 2.2 volt input. I measured the voltage and indeed, only when the white point passes, the voltage is more than 2.2 volts
The output from the last one goes to a arduino that I programmed to count the signal via a interrupt.
The problem is now that I have false counts, but I cannot find why. I use a software debounce that is sure big enough to avoid false detections caused by bounces.
I think it has something to do with the hardware. Hereby a schematic.
Unfortunatly I have no scoop…

schematic

simulate this circuit – Schematic created using CircuitLab

Best Answer

You might need to apply hysteresis to OA2 - this has the effect of minimizing the effect of noise as the signal from OA1 gets close to the threshold point defined by R7. Try a 1k ohm in series with the signal from OA1 to non-inverting input of OA2 and something like a 100k to 1M ohm from output of OA2 back to its non-inverting input. The size of this feedback resistor will set the amount of hysteresis.