Introduction: LED Light Timer
Half of my family tends to fall asleep with the light on. It doesn't feel right to leave the light on all night, so we `improved' the two lamps to have a timer that turns off after twenty minutes.
Here's the basic setup. We used this IKEA LED lamp. It has a wall socket transformer that produces an output of 4 volts; a cable runs from the transformer to the lamp, with a switch in the middle. The lamp itself is a single white LED, which probably needs about 3.3 volts; I didn't verify this.
We insert the timer somewhere in the cord. It doesn't matter whether the timer is before or after the switch, it works the same in both cases. The timer is based on a capacitor discharging through a resistor, coupled to a MOSFET transistor, and it doesn't contain more than those three components. I explain the working of the timer in more detail below.
If you want to make this yourself, then this is what you will need:
- An LED lamp with a section of low-voltage cord that you can cut; any voltage up to, say, 24 volts will do, but most are between 4 and 12 volts. Our IKEA lamp works perfectly for this. A lamp with a halogen bulb might not work well with this timer, since it draws much more current and doesn't cut off cleanly; you'd need to do some tests. Do make sure that you're working with low voltage - don't try this on a cable that carries mains voltage!
- A logic-level MOSFET, with turn-on voltage below 4 volts; we used the IRF3708 (datasheet) in the TO-220AB package.
- A large electrolytic capacitor (we used 470 muF)
- A large resistor (we used 4.7 MOhm)
- A little piece of stripboard or veroboard (although one can also build the timer without)
- A push-button switch (normally off, push-for-on)
- A container to house the timer
- A volt meter, or an LED, to to determine the polarity of the cable wires
- Some soldering skills.
Step 1: Cutting the Cord
Cut the cord somewhere between the transformer and the lamp. Use the volt meter to check that the voltage is what you expect it to be, and find out which wires carry the positive and the negative poles.
Step 2: The Circuit and the Timing
The circuit is a very simple RC timer (see e.g. here, here, or here), using a MOSFET (Q1) as a switch. MOSFETs start conducting when the gate-to-source voltage (between the lower two pins) becomes more than a threshold, which for the IRF3708 is between 0.5 and 2 volts. Above this threshold the resistance from drain to source (the rightmost two pins) is very low, in the milliohms. If the gate-to-source voltage is lower than 0.5, then the MOSFET blocks all current, with essentially infinite resistance.
The circuit functions as follows. When the button S1 is pressed, the capacitor is charged to 4V; then the gate of MOSFET Q1 is at 4V, and the MOSFET is completely open, with very low resistance, and the LED D1 sees the full voltage drop of 4V; the lamp is on.
When S1 is released, the capacitor starts to discharge through resistor R1, and the voltage at the gate of Q1 slowly decreases. Somewhere around 2 volts the MOSFET starts to close, decreasing the voltage drop over the LED D1. When the voltage drop over D1 has decreased from 4V to around 3.3V the LED no longer conducts, and the light goes out. After that the capacitor continues to slowly discharge itself.
(thanks to Scheme-It for the online circuit-design software)
Step 3: Intermezzo: Determining the Values of the Capacitor and the Resistor
To be honest, I determined the values of the capacitor and the resistor by trial-and-error. A quick calculation (see below) told me that I needed both values to be rather large; I took the largest resistor I had and played around with different large capacitors. I was looking for 20-30 minutes timer time without the circuit becoming too bulky. Some of the capacitors with higher capacitance are really bulky, and then the circuit wouldn't fit in the container.
You can get a rough estimate from calculating the `RC constant' (see Wikipedia for more information). Multiply the resistance with the capacitance: in our case 470 muF times 4.5 MOhm, or in scientific notation 470E-6 F times 4.5E6 Ohm, which is 2115 FOhm. Farad times Ohm is seconds, so this gives a time of about two thousand seconds, or 36 minutes. This is the time over which the capacitor's charge reduces by a factor 2.7, so from 4V to about 1.5V. In fact the LED turns off a little earlier than that, since the threshold voltage of the MOSFET is closer to two volts. Hence the twenty minutes time span, roughly.
Step 4: Building the Circuit
We used stripboard to make the circuit. The button is connected via two wires, the other components are on the board.
The button can be connected just by two wires, but to minimize the risk of short circuits it's better to encapsulate the contacts in heat-shrinking silicon tubing.
Step 5: Finishing Up
Connect the circuit to the wires on both ends. Keep an eye on the polarity; the wrong polarity probably won't break anything, but the circuit won't do anything. Assemble everything into the container - and make sure that no short circuits can be made.
Step 6: Comments and Alternatives
- For the IKEA lamp the wires were too thick for the holes in the stripboard. I drilled bigger holes for the wires, but as a result the soldering didn't go well - there was too much free space and not enough copper to solder to. Next time I would thin out the wire and use the original holes instead of using the whole wire with larger holes.
- If you don't want to use stripboard or veroboard, you can also simply solder the connections together. It always gets messy, but if you're careful to make the right connections, this will give you a nice and small package.
- This simple circuit only works because the LED doesn't use much current (about 0.75 amps) and cuts off quite early when the voltage drop over the LED starts to decrease. When the gate-source voltage decreases, the drain-source resistance increases, and the MOSFET starts dissipating heat; it's thanks to this early cut-off that in this case this heat never is a problem. However, if you have a halogen lamp, then I expect this is very different - I would guess that then the currents are significantly higher, and continue all the way to zero voltage drop. For a halogen lamp I would advise to carefully monitor the temperature of the MOSFET, especially during the turn-off period.