Designing a dark sensing circuit which outputs logic levels.

Thread Starter

Yami

Joined Jan 18, 2016
354
Hi guys, I would like help on designing a dark sensing circuit which outputs either a logic high or low depending on the threshold set.
I have included a schematic of the circuit I am using at the moment. The component values were chosen mainly by trial and error. I am using a 10Kohm potentiometer to set the threshold. Any ideas on improving the circuit? I was hoping that someone could help me go through with calculation on choosing component values. I'm having trouble setting the threshold to the exact point I want.

For further reference what other sort of circuit could I have used to get the desired output. I also thought of using a comparator (good idea?).

Thanks in advance for the help

transistor circuit.jpg
 

shteii01

Joined Feb 19, 2010
4,644
R3.
What is the max resistance?
What is the min resistance?
Does resistance change linearly?

I am seeing the 7Ps here: Proper Prior Planning Prevents Piss Poor Performance
 

xox

Joined Sep 8, 2017
838
Hi guys, I would like help on designing a dark sensing circuit which outputs either a logic high or low depending on the threshold set.

I have included a schematic of the circuit I am using at the moment. The component values were chosen mainly by trial and error. I am using a 10Kohm potentiometer to set the threshold. Any ideas on improving the circuit? I was hoping that someone could help me go through with calculation on choosing component values. I'm having trouble setting the threshold to the exact point I want.


For further reference what other sort of circuit could I have used to get the desired output. I also thought of using a comparator (good idea?).


Thanks in advance for the help


View attachment 174973

Yes transistors can be very finicky. You really need additional components to get precise performance out of them. Comparators are much more stable. I actually used cheap LM324 op amps instead (didn't have any comparators at the time) and got pretty good results.
 

dl324

Joined Mar 30, 2015
16,916
I also thought of using a comparator (good idea?).
It's a better idea. You'll have more precise control of the threshold level and it's straightforward to add hysteresis to prevent oscillation if the light level changes slowly at the trip point.
 

xox

Joined Sep 8, 2017
838
LM324 can be used as slow comparators. With a 5V supply, the maximum output voltage is only guaranteed to be 3.3V.
Precisely. Not exactly the best choice of hardware but works in a pinch and anyway much more predictable results than a single transistor setup. Plus since there's no feedback loop a single op amp can be used. (No need to feed the output to a voltage follower that is.)
 

MisterBill2

Joined Jan 23, 2018
18,479
This looks a whole lot like a circuit that was presented about a month ago and discussed a whole lot. So there exists a thread with at least 30 comments covering it in detail. In addition there are at least two sites that contain many circuits of both light detectors and dark detectors.
 

Thread Starter

Yami

Joined Jan 18, 2016
354
Thanks everyone for the help. So which op amp do you reckon should be good enough for the job. I only used the transistors as it was something I had laying around.

@MisterBill2 - please could you direct me to the thread which you are referring to.
@Wolframore - yes I was thinking of that, but I haven't properly wrapped my head round 'hysteresis'

Thanks again everyone, really appreciate it.
 

Wolframore

Joined Jan 21, 2019
2,610
Yami, the concept is simple. You want a turn on point that is higher than a turn off point based on your sensor output. Another option is to use CMOS chip or a voltage divider that trips the different points. Without the separation you can have the circuit turn on and off as it reaches the trip point.
 

MisterBill2

Joined Jan 23, 2018
18,479
This looks a whole lot like a circuit that was presented about a month ago and discussed a whole lot. So there exists a thread with at least 30 comments covering it in detail. In addition there are at least two sites that contain many circuits of both light detectors and dark detectors.
It was in this same "general electronics chat" forum, it should still be on the list, it may even be under "dark detector". I don't know any tricks for searching by topic on that list, unfortunately.
"Hysteresis" in a comparator circuit is the difference in switching voltage between the rising voltage trip point and the falling voltage trip point. In comparators it is useful for preventing oscillation as a trip point is passed .
 

Thread Starter

Yami

Joined Jan 18, 2016
354
Another option is to use CMOS chip or a voltage divider that trips the different points. Without the separation you can have the circuit turn on and off as it reaches the trip point.
Ahh this sounds interesting! I'm going to look into this, could you please maybe give some reference.
Thanks so much
 

dl324

Joined Mar 30, 2015
16,916
So which op amp do you reckon should be good enough for the job.
You should use a comparator, not an opamp. I'd use an LM393, as mentioned in the first response.

I only used the transistors as it was something I had laying around.
You should add some LM393 and LM358 to the parts you have on hand. They're dual comparators and opamps, respectively. LM339 and LM324 are quad versions.
 

xox

Joined Sep 8, 2017
838
Use a 555 chip as a comparator it has inbuilt Hysteresis ..
Interesting use of a 555 there! Thing about hysteresis though is that it isn't always necessary to incorporate into a circuit, is it? If you have a very sensitive dark-sensing circuit for example you just aren't going to have much fluctuation around the trip point and so no real need to mitigate for hysteresis. Correct?
 

Wolframore

Joined Jan 21, 2019
2,610
Interesting use of a 555 there! Thing about hysteresis though is that it isn't always necessary to incorporate into a circuit, is it? If you have a very sensitive dark-sensing circuit for example you just aren't going to have much fluctuation around the trip point and so no real need to mitigate for hysteresis. Correct?
I have seen many dusk to dawn lights blink like a strobe light at dawn and dusk... temperature may play into it as well... it warms up and affects values.... Just what happens in real life as opposed to on paper or lab setting.
 
Top