Using an op-amp for resistive sensors

Thread Starter

xox

Joined Sep 8, 2017
838
I've been working on this project to design a simple LED nightlight using a photoresistor over the past couple of weeks and having initially went with using a single transistor to control the circuit I've finally decided to just use an op-amp instead. The main problems with the transistor configuration:

(1) No clear-cut transition from off to on. The LED gradually brightens, but controlling the range of resistances in an acceptable way is difficult.
(2) Wild variations in triggering due to environmental temperature changes; getting even slightly-consistent results under different conditions is basically impossible.

Thinking about how a comparator works, it dawned on me that an op-amp would result in a much more precise circuit. So the idea was simply to set up two voltage dividers, one as a reference to control the cut-on threshold and the other as input from the sensor. When the resistance of the sensor goes above 39K ohms the LED should light.

Screenshot from 2017-10-12 14-57-08.png

I haven't breadboarded it yet, but it seems like it should work okay. Does the design have any major weaknesses? Also, could the circuit be simplified even further?
 

bertus

Joined Apr 5, 2008
22,270
Hello,

Make the 1K resistors higher, like 20 to 40K.
A comparator will give you a sharper cut-off.
Most comparators have an open collector output.
This means that there must be a load between the powersupply and the output of the comparator.

Bertus
 

Thread Starter

xox

Joined Sep 8, 2017
838
Thank you!

So just curious, why is it important to raise the resistance of the voltage-divider legs? Also, it appears that their adjustment could be used to control the sensitivity of the circuit (where lower values would result in a higher level of sensitivity and vice-versa). Is that correct?

One more thing, the fact that there must be a load at the output basically means that it couldn't be used as input to a microcontroller, or what?
 

bertus

Joined Apr 5, 2008
22,270
Hello,

A simple resistor from the output of the comparator to the powersupply is enough to get signal in the output.
As for the higher bottom resistor.
When the top resistor changes from 40K to 39K, the voltage change on the 1K resistor will be (0.1219 to 0.125) = -3.1 mV
When the top resistor changes from 40K to 39K, the voltage change on the 40K resistor will be (2.5 to 2.5316) = -31.6 mV

Bertus
 

Thread Starter

xox

Joined Sep 8, 2017
838
Funny, so I had it completely backwards. And a simple resistor at the output of the comparator is all that's needed to use as an input to a no-load circuit. Okay, thanks for the help, bertus!
 

crutschow

Joined Mar 14, 2008
34,285
why is it important to raise the resistance of the voltage-divider legs? Also, it appears that their adjustment could be used to control the sensitivity of the circuit (where lower values would result in a higher level of sensitivity and vice-versa). Is that correct?
Not necessarily.
The maximum sensitivity (maximum voltage change for a give change in sensor resistor) is when the lower resistance is equal to the photoresistor resistance at the trip point.
 

Thread Starter

xox

Joined Sep 8, 2017
838
Not necessarily.
The maximum sensitivity (maximum voltage change for a give change in sensor resistor) is when the lower resistance is equal to the photoresistor resistance at the trip point.
Ah, that makes sense. So too high and the sensitivity just diverges as it does with lower resistances. Thanks!
 

hrs

Joined Jun 13, 2014
394
About the load resistor that Bertus mentioned, I found it helpful to look at the functional block diagram of the TI LM393 datasheet. As you can see on page 9, when the ouput transistor is conducting it will sink all current to ground and the "open collector" will be near ground voltage. When it is switched off the collector will float to whatever voltage is applied to it. So a resistor to Vcc will pull the output to Vcc.
 

Attachments

Thread Starter

xox

Joined Sep 8, 2017
838
About the load resistor that Bertus mentioned, I found it helpful to look at the functional block diagram of the TI LM393 datasheet. As you can see on page 9, when the ouput transistor is conducting it will sink all current to ground and the "open collector" will be near ground voltage. When it is switched off the collector will float to whatever voltage is applied to it. So a resistor to Vcc will pull the output to Vcc.
On a side note, I love these TI datasheets. They show you things like the internal layout of the comparator on a transistor level, which is really useful for understanding the differences between various op-amp designs. Very cool.
 
Last edited:

Audioguru

Joined Dec 20, 2007
11,248
A comparator will oscillate or amplify its own random noise when its inputs are near its trip point. Therefore hysteresis is always added (one or two resistors).
 
Top