I'm attempting to determine if the following phototransistor HOA1870-031 is in cutoff.
The HOA1870-031 we have in stock have the cathode of the IR emitter tied to the emitter of the IR detector (phototransistor).
What I want to do is detect whether the phototransistor is in cutoff (the light between the IR emitter and IR detector is blocked).
To do this I'm reading the voltage with an analog input (PA1
) which is connected internally to a comparator (COMP1
) in the STM32F303VC.
When the phototransistor is saturated I read a voltage of ≈230mV
after the voltage drop across the 10KΩ
resister.
When the phototransistor is in cutoff I read a voltage of ≈2.9V
(VCE ≈ VCC ≈ 3V
).
I set the inverting input of COMP1
to VREFINT
and the non-inverting input to PA1
.
I'm also reducing some noise via the configurable hysteresis
for the comparator.
I've tested it and things seem to be working as expected, when the light is blocked between the IR emitter and the IR detector the ISR
I configured is fired.
Although I did go to school for EE I've been writing software for so many years that I've forgotten most of what I had learned (which really sucks).
I dug out all of my old text books which helped me come up with the circuit you see below.
My question here is, am I doing anything obviously wrong?
Is there a better way to accomplish this (detecting if the light is broken between the IR emitter and IR detector)?