0
\$\begingroup\$

I have designed this circuit to switch on a light (R2) when it gets dark. The circuit works fine, however I have a small problem.

schematic

simulate this circuit – Schematic created using CircuitLab

As you can probably guess, when it gets dark the voltage at the gate drops and the mosfet is turned off, the relay is turned on and the light is turned on as well. Now as you might have guessed, the light shines on the photoresistor, makes its resistance drop, turns on the mosfet, turns off the relay and turns the light off. This is pretty much an infinite loop...

Of course I could put the photoresistor in a place that cannot be reached by the lamp's light, but I was wondering if one could devise a circuit to avoid such an infinite loop, perhaps a circuit "with memory". What possible solutions could I try?

I thought of a timer that prevents temporarily the mosfet to change state after it has just changed its state, say for the next 12 hours, but I'm not sure how to do such a thing or if simpler options exist.

Then again I might be overthinking things and I could just put the photoresistor in a place not reached by the light of the lamp...

\$\endgroup\$
8
  • \$\begingroup\$ What are you going to do with the circuit? \$\endgroup\$
    – dirac16
    May 4, 2017 at 17:46
  • \$\begingroup\$ @dirac16 turn on and off a light. \$\endgroup\$
    – mickkk
    May 4, 2017 at 17:49
  • \$\begingroup\$ UM doesn't that circuit turn ON when it gets brighter? LDRs usually have less resistance with more light. \$\endgroup\$
    – Trevor_G
    May 4, 2017 at 18:08
  • \$\begingroup\$ @mickkk maybe you could play with R1 to set a threshold voltage for the circuit to undergo transitions. For a typical LDR, a 60W bulb lighting at 1m would bring the LDR's resistance down to a few k ohms. But for bright sunlight, the resistance would drop to a few ohms. \$\endgroup\$
    – dirac16
    May 4, 2017 at 18:25
  • \$\begingroup\$ @Trevor, yes, sorry, my fault, now it should be ok. \$\endgroup\$
    – mickkk
    May 4, 2017 at 18:27

5 Answers 5

2
\$\begingroup\$

Issue with twilight is ambient + lamp = oscillation. It needs to get a lot brighter to turn back on. I think I would have designed it like this with some added hysteresis.

schematic

simulate this circuit – Schematic created using CircuitLab

Of course if the light is bright and close to the sensor even that will not work. Some shielding from the light may still be warranted. Note, the light should not go on and off when a cloud passes by either so some playing with values is warranted. Maybe add some trim-pots till you get it the way you need it.

\$\endgroup\$
2
\$\begingroup\$

Your state machine has two states right now: "on" and "off" and only one way to transition out of a state (the light sensor) You could add another sensor (time) and introduce another state or two to delay the transitions but the machine will always cycle. This might be ok if your relay was fast and quiet (so no one will notice) then having it check by transitioning from "on" to "off after an hour or whatever. When it's in "off", if the ambient light is bright enough then it'll stay off. Otherwise it'll pop back into "on" then wait for an hour again. A very simple way to make a delay is to discharge a large capacitor with a resistor in parallel and use a comparator to trigger the next state.

\$\endgroup\$
2
\$\begingroup\$

What you need is a little hysteresis in your circuit. That means the on and off thresholds aren't the same. You set the band between the two thresholds large enough so that the extra light into the sensor from the light that was just turned on doesn't bump it back to the off state.

This kind of circuit has been discussed many times here before. See:

https://electronics.stackexchange.com/a/191625/4512
https://electronics.stackexchange.com/a/53681/4512

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

Between the gate of the mosfet and the light sensitive potential divider fit a comparator and ensure there is a little bit of positive feedback aka hysteresis. This will ensure that when the light turns on, the signal at the light sensitive potential divider has to rise significantly higher than the falling (lamp on) trigger point in order to deactivate the lamp circuit.

You might be able to do it with an NPN BJT. When the lamp activates the BJT turns on and partially reduces R1 by shunting it with a 10 kohm resistor in parallel.

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

Try shielding the photosensor with a tube that prevents light from falling onto it, and add some deadband to the sensor as so:

enter image description here

You can experiment with the value, try something in the range of 20K to 200K. This should also extend the life of the relay by making it switch less frequently and with more authority.

\$\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.