Designing a dark sensing circuit which outputs logic levels.

Discussion in 'General Electronics Chat' started by Yami, Apr 14, 2019.

  1. Yami

    Thread Starter Member

    Jan 18, 2016
    186
    3
    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
     
  2. sghioto

    Well-Known Member

    Dec 31, 2017
    1,030
    156
    Yes a better idea.
    Check out the LM393.
    SG
     
    Yami likes this.
  3. shteii01

    AAC Fanatic!

    Feb 19, 2010
    4,526
    717
    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
     
    Yami likes this.
  4. Wolframore

    Member

    Jan 21, 2019
    299
    73
    I would design in hysteresis so that it won’t oscillate.
     
    Reloadron and Yami like this.
  5. xox

    Member

    Sep 8, 2017
    333
    70

    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.
     
    Yami likes this.
  6. dl324

    AAC Fanatic!

    Mar 30, 2015
    8,147
    1,959
    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.
     
    Yami likes this.
  7. dl324

    AAC Fanatic!

    Mar 30, 2015
    8,147
    1,959
    LM324 can be used as slow comparators. With a 5V supply, the maximum output voltage is only guaranteed to be 3.3V.
     
    Yami likes this.
  8. xox

    Member

    Sep 8, 2017
    333
    70
    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.)
     
    Yami likes this.
  9. MisterBill2

    Distinguished Member

    Jan 23, 2018
    2,786
    545
    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.
     
    Yami likes this.
  10. xox

    Member

    Sep 8, 2017
    333
    70
    Hmm...so not compatible with certain logic/micro chips then?
     
    Yami likes this.
  11. Yami

    Thread Starter Member

    Jan 18, 2016
    186
    3
    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.
     
  12. Wolframore

    Member

    Jan 21, 2019
    299
    73
    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.
     
    Yami likes this.
  13. MisterBill2

    Distinguished Member

    Jan 23, 2018
    2,786
    545
    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 .
     
    Yami likes this.
  14. Yami

    Thread Starter Member

    Jan 18, 2016
    186
    3
    Ahh this sounds interesting! I'm going to look into this, could you please maybe give some reference.
    Thanks so much
     
  15. MisterBill2

    Distinguished Member

    Jan 23, 2018
    2,786
    545
    look in the IC data book under "Schmidt inverters", and just under :inverters"
     
  16. dl324

    AAC Fanatic!

    Mar 30, 2015
    8,147
    1,959
    You should use a comparator, not an opamp. I'd use an LM393, as mentioned in the first response.

    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.
     
  17. Wolframore

    Member

    Jan 21, 2019
    299
    73
    555 has comparators... :).

    OP needs to google schmitt triggers and comparator circuits. There are tons of examples online.
     
  18. Dodgydave

    AAC Fanatic!

    Jun 22, 2012
    7,751
    1,292
    Use a 555 chip as a comparator it has inbuilt Hysteresis ..


    light-activated-relay.jpg
     
    xox likes this.
  19. xox

    Member

    Sep 8, 2017
    333
    70
    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?
     
  20. Wolframore

    Member

    Jan 21, 2019
    299
    73
    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.
     
    Dodgydave likes this.
Loading...