You can check this project out on:
Warning: this circuit deals with mains voltage which is lethal. DO NOT attempt to build it unless you perfectly understand what you are doing. I am in no way responsible for any consequences which result from any use of information on this page.
Waking up in the morning is a daily and early task. Throughout my life I have used different ways of waking up: the usual alarm clock connected to a high power siren and flashing lights, a high power buzzer fed by AA batteries hooked to a portable alarm clock(for when traveling), and of course the most used is the mobile phone alarm.
All these methods have worked, but they provide a rather sudden wake up. Recently I found out about the idea of simulating the sunrise. It seems like a more pleasant way of waking up, especially in the winter, so it had to be tried. I decided to make it as simple as possible for the beginning, so getting a normal radio-alarm-clock and modifying it seemed like a great idea. These clocks are available in many models, some rather cheap, so I picked one up.
Next, off to the hardware store to buy a light source. A 150W halogen reflector seemed right for the job, especially because it was very low price. Added some cable and plug and I had all I needed.
The first task was to open the alarm clock and find the alarm signal. This was not that hard.
Looking at the components, the audio amplifier was a very known part, the TDA2822 (1). As this is one of the components that need to be turned on I followed the power supply traces. The positive led me to a transistor and a Zenner diode – there was a simple voltage stabilizer for it (2). Looking carefully I realized that it was controlled by another transistor and this by another one (3) which is turned on by signals coming from three diodes (4), (5) and (6): there is an OR function implemented there. This is because the radio is turned on by any of the three signals, two from the microcontroller which are the alarm (7) and sleep function and one from the switch. An electrolytic capacitor and some resistors were placed there and this seemed like a filter. At first, I thought that there was no need for one, until I looked at what signal the microcontroller was providing: it was the beep-beep-beep signal which is used alternatively as an alarm (instead of the radio). This is why it needed low pass filtering, to extract a steady dc which would turn on the regulator for the audio amplifier and radio.
The next step was to find a way to power my circuit which will take care of the sunrise simulator. As the function is not that complex, I decided to go for an ATTiny13 microcontroller which I already had. This requires 2.7 to 5V to operate correctly. Guessing that the clock’s controller would be in the similar range, I looked for another regulator on the board and quickly found another zenner diode + transistor pair (8). This provides 4.2V which is excellent for my circuit. Adding my circuit to the regulator’s load shouldn’t be a problem as it provides power for the clock’s display which is rather high compared to how much the ATTiny13 will consume.
In order to dim the light, I needed synchronization with the A.C. network. As there is already an A.C. output from the clock’s transformer I decided to take it from there instead of connecting somehow directly to the mains, although this means being a little offset.
It is now time to put together the little schematic that does it all. Here it is:
Things are rather simple. The “brain” is the Attiny13 microcontroller which should be enough for this simple task.
For the A.C. synchronization I’m going to use the internal comparator. This is because the input threshold of a pin is about 2V (half of VCC) and the transformer outputs about 9Vac so the error for detecting the zero cross is high. R4 and R5 form a divider which provides about 0.1V for the comparator reference. The A.C. signal is fed through a 10K resistor which ensures a current limiting, as the protection diodes inside the microcontroller limit the input range between about -0.6V to VCC+0.6V.
The circuit that I have designed will make a bypass between the clock microcontroller and the clock’s alarm, allowing for the sunrise to be simulated before the alarm is triggered. ALARM_IN and ALARM_OUT pins allow this function to be implemented. R3 is there because it has been removed from the clock’s PCB to allow the bypass.
The lamp is controlled, as expected, via a triac. Because safety is very important, an optoisolator separates the mains from the clock and my circuit and a fuse is included.
Building the circuit has nothing special in it, as it is rather simple. It’s build on a small prototyping PCB adapted for the free space inside the radio. A reset button was included to help with the software development, but it is not needed during normal operation.
Fitting it inside the clock:
Due mostly to lack of space inside the clock I have decided to split things in two parts, putting the triac and optoisolator in a small junction box near the reflector. This solution is temporary and I will improve it once I find something more suitable, the goal being to add a normal socket to allow me to plug any lamp in. A small heat sink ensures that the triac only gets slightly warm during full on with the 150W light bulb.
There is not much to explain about the software. Basically there are two parts: the lamp dimming which uses the interrupts and the control software. For more info on lamp dimming see the wiki.
Lamp dimming requires two parts: first is detecting the zero cross which takes place at the comparator toggle producing an interrupt. At this point the timer is loaded with a previously determined value. The timer overflow interrupt routine triggers the triac. Based on the value that was loaded in the timer counter this event takes place in a certain point during a half period of the A.C. which determines how much time the triac is conducting thus determining the power through the lamp. The timer may be loaded with a value that prevents the triac from ever been triggered, keeping the lamp completely off.
The main part of the software has a three stage functionality. Fist stage is to wait for the alarm. Once it is signaled the lamp is slowly turned on while periodically checking if the alarm is still on, this is the second stage. After the light reaches the maximum intensity the actual alarm in the clock is turned on, for the third stage. When the user turns off the clock alarm the light turns off and the circuit goes back to the first stage.
The time it takes for the light to reach its maximum intensity is determined by a parameter in the software and it is a multiple of 2 minutes. So the minimum is two minutes, the maximum is about 8 hours, if that could be of any use. I have set it for 20 minutes. Of course, this requires me to set the alarm 20 minutes earlier than when I want it to sound.
Software is written in C and compiled with avr gcc. It is available for free for personal use.
And finally, everything put together working:
Everything seems to be working fine, waiting real life testing. But this has to wait for a few days until my vacation is over. Still, the effect seems to be very pleasant: light starts emerging from total darkness, being reddish at the beginning and moving towards a bright white, much like a real sunrise.
If this proves to have a real benefit, I already have future plans for it: build a custom clock from zero, add a memory card for audio, maybe a brighter lamp and more functionality that this setup doesn’t provide.
Update: Apr 21, 2010
After more than a week of testing it the results are in: I managed to wake up before the sound alarm about half the times. For the rest of the times, waking in a lit room seems much better than normal. I am thinking of changing the position of the light and maybe getting a bigger one.
I am really pleased by the effect it has and I am looking forward to proving its good use in wintertime.
Update May 7, 2011
I have just added a 60Hz powerline frequency software version: sunrisesimulator60Hz