Thursday, 18 May 2017

Lighting your garden with LED lights and the sun: a DIY project, part 2.

Some time ago I wrote a short article on a small circuit I made to power on and off my garden lights using only a handful of components and some patience. Since then, however, I’ve dug deeper and found out some other good solutions to the problem.

A quick recap of the problem: At dusk and dawn I’d like my garden lights (powered by 12V DC batteries) to switch themselves on and off without me doing anything: a first step towards total automation ;)

Image 2

My first try at accomplishing this task was using a simple BJT with a voltage divider specifically design to allow a certain bias current when it gets dark. See here for more information on this first raw trial.

The circuit mentioned above works fine. It’s pretty raw but it definitely does its job. A couple of problems however have emerged:

1) I’d like to regulate the electronic switch to turn on and off at different ambient light brightness

2) If the photoresistor is not far away enough from the lights, once it gets dark and the circuit turns the light on, the LED light shines upon the photoresistor making it think that it’s bright outside and therefore it turns the lights off, and then the cycle repeats in an endless loop that stops only in the morning.

Since the BJT is a current controlled switch, it can be a little bit trickier to  use when designing a circuit. Not to mention that when in saturation mode, it drops about 0.3V between emitter and collector, dissipating some more power. N-channel mosfets are voltage controlled switch. If you apply a certain voltage between the gate and the source of a N-channel mosfet, it starts conducting. But the best thing when designing for a N-mosfet in such simple circuits in my opinion, is that you can basically assume that the gate does not absorb any current. Given this information and the Vgs value, in order to decide when to turn on and off the switch you just need to set up a simple voltage divider..

This is the new circuit with a N-channel mosfet (don’t mind the exact model, it’s just for reference):

Image 1

As a bonus point, the N-channel mosfet will dissipate very little power when it’s fully on.

As far as the problem 1) is concerned, a small 0-10k potentiometer below the  photoresistor will surely do the job. I set it to 4k in the picture above. By regulating the potentiometer you change the behaviour of the voltage divider and, for instance, you can make sure that the lights switch on and off approximately within a given time window (or account for changes in ambient light during the year).

This is the behaviour of the gate voltage and of the drain-source voltage depending on the photoresistor value.


Problem 2) is a bit more difficult to solve. Of course, the best solution would be to somehow hide the photoresistor from the LED light, for instance by putting it on top of the garden light’s housing. However, if you cannot do this, you can try to add a bit of hysteresis to the circuit:

Image 3

Ignore V3 which is left open and will be used later to simulate the change in voltage due to the chaning sunlight.

As you can see, aside from switching the position of the potentiometer and the photoresistor, there are 2 major changes:

- A Schmitt trigger (U1) which takes an input at node A and drives the mosfet (a resistor might be needed here).

- A voltage divider by R3 and R4 and a buffer (U2)

The Schmitt trigger has been specifically designed to turn on the mosfet at about 2.5V and turn it off at 6V.

Image 4

Now, suppose that the sun goes down, the photoresistor becomes less conductive, V6 goes up and when it crosses 6V the comparator goes high (V7) driving the mosfet (drain voltage on V8) on which in turn switches on the LED light. The LED light now contributes to lowering the resistance of the photoresistor but if it is far away enough from the light, V6 does not go below 2.5V and the light stays on!!!

The voltage divider R3, R4 and the buffer is needed to shift the hysteresis cycle of the comparator.

The biggest advantages are that:

1) We probably have solved problem 2) stated above.

2) The mosfet (V4) now turns on and off much quicker due to the comparator (V7) action.

Image 5

This new more sophisticated circuit has some advantages and a draw back as well: power consumption of about 100mW (in the worst case). On the plus side, we might have solved problem 2). Is it worth it? I don’t know but it surely was fun to play with.

The first LTspice circuit can be found at this link, while here you find the CAD drawing done with Eagle.

The second LTspice circuit can be found at this other link, while its CAD drawing is here.

No comments:

Post a Comment