1
\$\begingroup\$

I want to make a light detector using a phototransistor. To do that I connected a phototransistor and apotentiometer to the open drain comparator as in the diagram below.

When the light is dim, everything is OK, but when light is bright (normally or even slightly bright) then the LED lights even when voltage of the potentiometer is more than 700mV higher than the voltage of the phototransistor.

Specifically, when I turn the potentiometer knob, the voltage between the voltage source and the comparator output rises gradually until it hits maximum around the point where comparator inputs values are equal and then it remains constant.

So my problem is that comparator doesn't work like a step function, but more like a gradually increasing function.

What am I doing wrong?

schematic

simulate this circuit – Schematic created using CircuitLab

\$\endgroup\$
14
  • \$\begingroup\$ What does the datasheet (should be linked in the Q) say about operating off 3.3V supply? \$\endgroup\$
    – user16324
    Commented Feb 7, 2021 at 14:48
  • 1
    \$\begingroup\$ Datasheet for the comparator. Note the part about common mode input voltages. Are you exceeding the allowed range for your supply voltage? \$\endgroup\$ Commented Feb 7, 2021 at 16:15
  • 1
    \$\begingroup\$ Supply voltage and common input mode voltage are different things. You're using an allowed supply voltage, but what about your common mode input voltage? \$\endgroup\$ Commented Feb 7, 2021 at 16:30
  • 3
    \$\begingroup\$ The others have already indirecly said that the input voltages must be 0...1.8V for reliable comparisons. I add that your circuit can easily work as an oscillator. If you build it on a breadboard the stray capacitances can collect anything, The same happens with long input wires. As the last nail your schematic doesn't show a slightest decoupling capacitor to prevent operating voltage instability. I would add say 100nF ceramic between the Vcc and GND with as short wires as possible. BTW is the ambient light constant or does it flicker at some maybe invisible high frequency? \$\endgroup\$
    – user136077
    Commented Feb 7, 2021 at 16:57
  • 2
    \$\begingroup\$ One other random guess: R1 is huge for the light range you're interested in. The phototransistor gives ~ 0.5 uA per lx into 2Mohm, so your gain is something like 1 volt per lx, which means the phototransistor is saturated most of the time. I think the circuit should still work in saturation, but I would test with a 100k resistor and see if your problem goes away. \$\endgroup\$ Commented Feb 7, 2021 at 17:20

2 Answers 2

1
\$\begingroup\$

In all practical cases you will want to include some amount of hysteresis. Otherwise, you will experience jitter in the output. And allowing that is always a bad thing. So you must design in some hysteresis behavior. For this, you'll need positive feedback.

Also, the TEPT5700 has only two pins: collector and emitter. The NPN base is floating and responds to photons impinging so as to generate recombination current to allow current from collector to emitter.

Finally, the TEPT5700 specifications focus on \$V_\text{CE}=5\:\text{V}\$. You are using \$V_\text{CE}\le 3.3\:\text{V}\$.

You can achieve this with a simple circuit using two BJTs:

schematic

simulate this circuit – Schematic created using CircuitLab

Left side is the circuit with hysteresis. Right side is the circuit that activates an LED on the basis of light input.

You can make some adjustments, if needed, for light level. For example, for a wider hysteresis band you might try setting \$R_2\$ and \$R_3\$ to \$47\:\text{k}\Omega\$ and \$R_1\$ to \$8.1\:\text{k}\Omega\$. Etc. Basically, play around with \$R_2\$ and \$R_3\$ and also, separately, \$R_1\$.

I've intentionally left off a potentiometer for the above circuit. But you can sink unwanted phototransistor current by reducing \$R_1\$, for example. So that's a likely place for a potentiometer. But I'll leave that detail to you.

\$\endgroup\$
0
\$\begingroup\$

So my problem is that comparator doesn't work like a step function, but more like gradually increasing function

This sounds like the op-amp gives constantly on/off signal to the led, as the voltage of the phototransistor and the Voltage of the potentiometer are getting really close + due to the parasitic/stray capacitances the comparison of the two is fluctuating.

\$\endgroup\$

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.