# Sensor range and speed based on resistor

I have 4 of these sensor circuits and can't quite figure out the optimal resistor value to use.

Here's what I assume (which somewhere I may be wrong):

The datasheet for the IC states leakage current is +/- 1uA which means its a 5 mega ohm resistor in a voltage divider calculation.

So if I made the pull-up a 2 mega ohm resistor, then 5/7 * 5 = 3.57 volts in if photo-transistor doesn't turn on. which is logic 1 input for many gates but I'm not even using that high of resistor.

But then I learned transistors have capacitance in them and I think my photo-transistor has a 15uS turn-on and turn-off time?

So given this circuit, I chose schmitt trigger because I want the signal to be clean and fast.

I made a microcontroller circuit (connected output of this circuit to demultiplexer input then output of that to one micro's GPIO pin through a resistor) to try to sense when light goes on and off.

I gave roughly a 15uS between each sensor before microcontroller selects the next sensor to sense for light.

Then if light is detected within that 15uS then a 1ms timer starts to see if the light turns off. If it does then detection is complete.

So is my choice of 560K a good pull-up resistor value or do I need to increase detection timing? and what about the schmitt triggers? Is that a good idea for cleaning up signals or is there a better reason to replace them with just inverters (74HC04)?

the phototransistor is an everlight pt334-6c

• No, a leakage current of 1uA does not mean that the phototransistor can be treated like a 5 megohm resistor. Please provide a link to the datasheet for the sensor. – Elliot Alderson Aug 30 '18 at 19:16

Without knowing the details of your device or your setup, it's clear that you are misreading the data sheet. Leakage current is simply the current you can expect when there is no light falling on the device - and if it weren't for your schematic there would be no way to know that it IS a phototransistor.

What you need to worry about instead is the current flow in the device when it is fully illuminated. Note that this should be a minimum number, and should take into account the fact that, over time, the optical path may accumulate dust and dirt. Once you determine this, using half to one third that value as a trigger level seems reasonable.

Then you can calculate your resistor value as you have done.

As it stands, your circuit is likely to be sensitive to any stray light, potentially including things like room lighting.

TL:DR - You probably want a much smaller resistor.

EDIT - With the phototransistor identified as a PT334-6C, the data sheet is informative. It identifies the collector current as about 2 mA with 1 mw/cm^2 of light shining on it. I don't know if your light source will actually produce this power, but let's assume that it is the case.

Giving yourself a 50% margin, the maximum current will be 1 mA. You do not identify the value of Vcc, but let's assume 5 volts. Then a 5k resistor will be an excellent choice. At full illumination the Schmitt trigger input will be about 0 volts (actually about 0.4 according to the data sheet). This should provide plenty of margin. The dark current, which you specified as 1 uA, will provide a 5 mV drop when the beam is blocked, so the worst-case dark voltage will be 4.995 volts.

Of course, all of this assumes that you can provide enough optical power. This may or may not be the case, and you do not seem to realize the necessity of calculating (or, better yet, measuring) it.

• But when full light goes on, isn't the current entering the schmitt trigger equal to 0? I mean if the NPN base is high then collector is basically grounded (maybe plus a tiny bit of resistance)? and why much smaller? I don't want to narrow the light path – Mike Aug 30 '18 at 22:59
• Sigh. Is that a phototransistor or not? If so the base is not "high"or "low" in the sense you seem to think it is. And for 74HC14s the input current is always less than 1 uA. So I'm not sure what part of your previous makes any sense. – WhatRoughBeast Aug 31 '18 at 0:47
• yes its a phototransistor at the input feeding the 74HC14's. – Mike Aug 31 '18 at 23:27
• @Mike - OK. So what do you mean by the base being high? When light is full on the transistor, it draws the nominal maximum current it's rated for, and since you have not identified the phototransistor there is no way to tell what that is. If your load resistor is large enough, the collector-emitter voltage will be very small. How large a resistor and how small a voltage depend on the transistor. So how about you stop playing hard-to-get and identify your transistor? In any event, leakage current is entirely the wrong thing to be using. – WhatRoughBeast Sep 1 '18 at 0:56
• PT334-6C is the phototransistor – Mike Sep 1 '18 at 2:18