2
\$\begingroup\$

The simple way to connect a phototransistor to an MCU is shown in this question. But it requires a Schmitt trigger input which I won't have on my target platform, i.e. either an STM8 at 5V or an STM32F0 at 3V.

I fear that a direct connection without a Schmitt trigger stage might bias the input somewhere between high and low, causing undesired effects such as increased current consumption, additional losses and eventually damage. I need to keep BOM cost low, so I would like to avoid a Schmitt trigger IC (e.g. a single-gate 74x14) ans use a discrete circuit instead.

Are there any simple transistor circuits that can be used for this application?

\$\endgroup\$
4
  • 1
    \$\begingroup\$ Such a single gate is less than 2.5 cents in quantity. You really need it any cheaper? \$\endgroup\$ Commented Feb 2, 2014 at 12:59
  • 1
    \$\begingroup\$ @SpehroPefhany agreed, though keep in mind many (perhaps most, on this site) people aren't buying them in quantity, and may live in places of the world where parts availability isn't so great. If it costs you $20 to get anything shipped, and you are only building 1, using a transistor that you already have is much cheaper. \$\endgroup\$
    – Phil Frost
    Commented Feb 2, 2014 at 13:08
  • \$\begingroup\$ @PhilFrost Sure. The OP's question involves appliance-grade MCUs so I think he or she is into volume. Two transistors and a handful of resistors might still make sense, but... \$\endgroup\$ Commented Feb 2, 2014 at 13:34
  • \$\begingroup\$ @SpehroPefhany You're right, I'm "into volume" and the simple answer to "You really need it any cheaper?" would be yes. As always, reality is a bit more complicated. Eventually I will have volume big enough to achieve 2.5 cents, but this might take several years in this particular line of business. For the first years, cost will be at around 4 cents. So I prefer using jelly-bean parts that already have sufficient volume taking into account other products. In consequence, a bunch of BJTs and resistors is just as much as 0.5 cents, and for me it is definitely worthwhile to save 3.5 cents. \$\endgroup\$
    – realtime
    Commented Feb 2, 2014 at 19:23

1 Answer 1

1
\$\begingroup\$

If you want to avoid the output of your phototransistor being anywhere between GND and Vcc, the solution is simple: add more gain. Just follow it with another amplifier of any kind. It doesn't need to be a Schmitt trigger, though the hysteresis it adds helps avoid rapidly switching between on/off states when the phototransistor is near the threshold.

Alternately, consider using an analog input, if you have one. This would not only allow you to detect light/no light, but how much light. You could then adjust the sensitivity of the phototransistor easily in software.

\$\endgroup\$
2
  • \$\begingroup\$ I don't see how additional gain will help. There will still be an illumination level where the voltage output is not within safe voltage ranges. Moreover, this would increase the sensitivity significantly, wasting an important degree of freedom. Using an analog input is an option for the STM32F0, but for the STM8 in question all analog inputs are already taken. \$\endgroup\$
    – realtime
    Commented Feb 2, 2014 at 19:36
  • \$\begingroup\$ @realtime more gain helps because the range of input voltages that would result in an output voltage between GND and Vcc becomes smaller as gain increases. When you have "enough" gain, even thermal noise is enough to saturate the amplifier. It only increases your sensitivity if you make it amplify the difference about 0V. A common-emitter amplifier has a threshold of 0.7-ish volts. Design your phototransistor circuit so at the desired light threshold the output is about that. Or, design a different amplifier with a different threshold. There are many solutions, but all involve more gain. \$\endgroup\$
    – Phil Frost
    Commented Feb 3, 2014 at 13:30

Your Answer

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

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