0
\$\begingroup\$

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)?

Currently implemented circuit

\$\endgroup\$
3
  • \$\begingroup\$ For a cleaner cutoff recess the devices in a 5mm aperture. But for high volume PD’s are far more accurate without hFE tolerances \$\endgroup\$ Jan 23, 2021 at 17:28
  • \$\begingroup\$ Looks good. You might check that high levels of ambient light can not pull the analog voltage too near the lower hysteresis threshold, when the aperture is blocked. Not likely, but sunlight might do it. You can reduce sensitivity by decreasing value of collector resistor. \$\endgroup\$
    – glen_geek
    Jan 23, 2021 at 18:14
  • \$\begingroup\$ The thing to keep in mind is that the transistor is trying to draw a fixed (approximately) amount of current. With a 10k resistor, the voltage across the resistor is negligeable, so the voltage across the transistor is very near Vc. BUT. If you use the isolator in a circuit with a larger resistor, the resistor voltage will be larger (Ohm's Law, right?) and the transistor voltage will be less - and in the worst case the transistor leakage could cause what looks like saturation. So keep in mind that your test is only valid for the resistor value (10k) which you have used. \$\endgroup\$ Jan 23, 2021 at 19:33

1 Answer 1

2
\$\begingroup\$

That all looks fine.

  • You have current limiting on your LED. If it's an infrared LED it will have a forward voltage drop of about 1.4 V which leaves 1.6 V across its resistor. The current will be V/R = 1.6/100 = 16 mA which should be fine.
  • Your 10k resistor on the transistor will limit the maximum on current to 3/10k = 0.3 mA which is also fine.

I would have suggested using hysteresis but you've addressed that already.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.