DIY Digital Alarm Clock With FM Radio
by RobBest in Circuits > Microcontrollers
2239 Views, 14 Favorites, 0 Comments
DIY Digital Alarm Clock With FM Radio
I started this project because my Philips AJ3400 FM Radio Alarm Clock stopped working. Initially I wanted to repair it but because of the integrated hardware this was not possible. Instead of throwing it away I decided to reuse the housing and some of its hardware to build my own Digital FM Radio Alarm Clock. I tried to keep the control for most functionality the same as the original Philips AJ3400 FM Radio Alarm Clock. Deviations from the original control was done because it felt more logical to change it.
The main features of this Alarm Clock are:
- Setting and showing the clock time
- FM radio with preset functionality. Ten presets can be stored
- Two alarm times
- Giving an alarm using a beep signal or the sound of an FM radio station
- Snooze timer and sleep timer
- Volume control
- Display brightness control
- Battery backup
The clock was designed around a PIC16F18075 Microcontroller programmed with the JAL programing language.
Supplies
You need to have the following components for this project:
- A piece of breadboard
- PIC microcontroller 16F18075 or compatible
- Real Time Clock IC DS3231
- FM Radio Tuner IC RDA5807
- Digital potentiometer IC X9C104
- Audio Amplifier LM386N
- 3.3 Volt voltage regulator LP2950-3.3
- Level shifter
- IC sockets: 1 * 40 pin, 2 * 8 pin
- Transistors: 5 * BC640
- Ceramic capacitor: 8 * 100nF
- Electrolytic capacitors: 3 * 220uF/16V, 1 * 1uF/16V
- Resistor array of 1k
- Resistors: 1 * 33k, 8 * 10k, 6 * 1k, 14 * 150 Ohm, 1 * 22 Ohm
- 4 large 7-segment displays
- Male header and female header 20 pins
- Optional: Female header 6 pins for PIC programmer
Design Choices
I decided to reuse the following hardware from the original AJ3400:
- Housing
- Keyboard
- Loudspeaker
- Power Supply
The display of the original Alarm Clock is made with LEDs using a frame that separates the LEDs. These LEDs are – like the IC – integrated on the PCB. The following pictures show this. Initially I wanted to reuse the LED frame and create a 7-Segment display using separate LEDs but because of the non-standard spacing this was not an easy task to do so I decided to use standard – large – 7-segment displays. The design was initially made on a breadboard.
Any PIC Microcontroller can be used as long as it has the following features:
- Sufficient ROM. The program uses around 6384 bytes of ROM
- Sufficient RAM. The program uses around 177 bytes of RAM
- Sufficient IO-pins. Almost all pins of the 40-pin PIC are used
- On-board Pulse Width Modulation (PWM) hardware for generating a beep tone
- Sufficient timers. The program uses 3 timers in total:
- One for multiplexing the 7-segment display
- One for generating a beep tone using the PWM hardware
- One for switching the beep tone on and off
I started the development with a PIC16F18076 40-pin microcontroller but since I had more samples of the PIC16F18075, I used this type in the final design. The only thing I had to change was to include the device file of the PIC16F18075 instead of the PIC16F18076 and recompile the program. No program changes where needed.
The Hardware
Since the whole clock implementation could have been done with the PIC, I decided to use a DS3231 Real Time Clock (RTC) IC which is controlled via an IIC interface. I used this chip because of its battery backup feature which is handy when there is a short power outage (hardly happens in The Netherlands). This AJ3400 has a compartment for 2 AAA batteries that serve as backup power when the power goes down. And since I was using the DS3231 I decided to use its alarm functionality too. This IC has the capability to set and monitor 2 alarm times.
For the FM radio I used the RDA5807M single chip FM Radio tuner which is controlled via an IIC interface. This chip has a volume control feature but since I also needed to control the volume of the beep signal, I used the X9C104 digital potentiometer to control the volume of both the FM radio as well as the beep signal. The output of the volume control signal is fed to an LM386N audio amplifier.
The RDA5807M operates at 3.0 V – 3.3 V. The PIC can also operate at 3.3 V but because of the 7-Segment displays I decided to operate the PIC at the default voltage of the AJ3400 power supply which is 5.0 Volt. Because of this choice, a level shifter was needed between IIC pins of the PIC and the IIC pins of the RDA5807M.
The whole design is built on 2 breadboards, one for the 7-segment displays and one for the PIC and the other components. See the schematic diagrams on how to connect the components and how the boards are connected via a header. Both breadboard are mounted as a sandwich.
The Software
All control is done by the PIC microcontroller. In the attached document you find how to operate the DIY clock. For the development I connected a PICKit3 programmer to the board which uses two pins where the keyboard is connected to. The result of this is that 2 keys cannot be used during development and are then temporary replaced by 2 other keys when a setting called ‘USING_PROGRAMMER’ is defined. For the final version this setting is commented out so that all keys are used.
The program is written in JAL and uses the following available JAL libraries:
- PIC16F18075 device file
- IIC hardware communication library
- DS3231 real time clock library
- RDA5807M FM radio tuner library
- Digital potentiometer x9c10x library
If you want to use another PIC you just have to include the device file of that PIC and recompile the program. If that PIC has the required on-board features the program will compile and run without any problems on another PIC.
The JAL source files and the Intel Hex file for programming the PIC are attached. Since I can only upload .txt files I renamed all .jal source files to .txt and also renamed the .hex file to a .txt file.
If you are interested in using the PIC microcontroller with JAL – a Pascal like programming language – visit the JAL website.
The Final Result
The video shows the following functionality:
- Power on the Alarm Clock and changing the time
- Changing the display brightness
- Setting alarm 1 using the FM radio and snooze the alarm
- Setting alarm 2 using a beep signal and turn off the alarm
- Search for an FM Radio channel and store it in a preset including volume adjustment
- Sleep timer
I added an operating manual for this DIY Digital Alarm Clock with FM radio.
Have fun building your own project and looking forward to your reactions.