PIC24 bedside table alarm clock


Markus Gritsch posted pictures of his PIC24 bedside table alarm clock in the project log forum:

Another year, another clock, but for the first time for my alarm clocks. I am not using an MSP430 but a PIC24 instead. Standby current is with 5.5 µA only slightly higher than that of my MSP430 based ones. Time keeping is done using the RTCC pheripheral, which I also used for the first time.
It can be seen in action in this YouTube video
Friendly green digits :)
And of course it has a LiFePO4 battery on its back, being charged every few years using my new USB charger.
A photo transistor is also included to dim the display in the dark. Much nices to the eyes when checking what time it is in the middle of the night.

Source code and schematic are available in the forum.

Check out the video after the break.

Join the Conversation


  1. Nice layout :-) A beautiful piece of work.
    You should add one of those rolling-ball vibration sensors, then it can light up by just grabbing it…

  2. …does it play an MP3 alarm sound too? Because otherwise the PIC24 is just about the mother of all overkills – this could probably be done even with the utterly ancient PIC16F84. Maybe I’m thinking too small here – we should use a RasPi…!

    1. If you want to use a PIC16F84, feel free to do so for whatever you want. But declaring a ~2$ controller with merely 8 kB RAM as being overkill for a one-off hobby project…

      1. …you mean a 16-bit (!) controller with built-in hardware multiplier, hardware divider (!) and hardware 32-bit CRC generator, 5 input captures and 5 output compares each with their own dedicated timer, and a friggin’ JTAG interface…? Yes. Yes, I’m definitely calling that overkill, even beyond the 64K of flash that’s about 63.5K more than one needs to make a clock. This is why we need octa-core CPUs and multiple gigabytes of RAM just to check our email these days and thanks, I’ll have none of that attitude. Price has nothing to do with this. You’re free to use whatever you want, obviously, just don’t be surprised when I call it as I see it.

      2. A bit tetchy from Max, and rather a bit unfair. Max, you’ve gotta give Markus credit that in this day and age, he is not using an Arduino board and struggling with power consumption… :-p ;-)
        I use the internal MCU RTCC and the ADC for my clock too. More parts? No siree.
        And I have a small pile of PICs, many bought at discount during Farnell sales. Some very nice discounts too, so one’s personal assessment of cost will be different from person to person.
        Thus, my hobby projects for one might also have MCUs that are obviously ‘not optimized’ for its purpose… *yawn*

      3. Why someone suggests using a more expensive part with fewer features just for the sake of using an 8 bit micro always quite eludes me. But I even programmed the thing in C instead of assembly, so I am unworthy anyways :)
        Building an alarm clock with a less powerful device? Been there, done that: The first three references in the forum post link to clocks built with MSP430G (Value Line) MCUs, the least powerful being the MSP430G2452 which has 2 kB of Flash, 128 Bytes of RAM, and just one timer.
        But, alas, a 16-bit architecture, so complete overkill by Max standards again. And, most importantly, it has the detested hardware multiplier. This damn, damn hardware multiplier. Why do they put it into everything, completely ruining the fun. Hopeless. I can clearly see the straightforward line of reasoning and the connection between this and the octa-core CPUs in our desktops. Inevitable :))
        So, Max, please keep your helpful comments coming. I find them quite entertaining.

    2. I always end up using modern cheap PICs, even though I still have 4 of them PIC16F84As.
      A PIC16F84A don’t have much peripherals…

  3. Ditto re the clever layout.

    I think the hand-drawn schematic has a mistake. 72nf for the caps on the 32kHz crystal?

    Also, I’m skeptical about your power estimates. Even if you are only driving the segment LEDs at 1mA, I can’t see how you’re going to get over a year of battery life…

    1. Thanks for the comment about the layout :)

      ad schematic: The crystal caps are 12 pF. The schematic currently reads 12 nF and I will update the image soon. Thanks for pointing out the nano pico typo. As for the 7 1 misunderstanding: See e.g. http://english.stackexchange.com/questions/62586/why-is-1-hand-written-without-a-serif-and-7-without-a-dash — I am from Europe.

      ad battery life: The LiFePO4 battery I use reads 700 mAh. The clock consumes 5.5 uA when sleeping and about 90 mA at full brightness. Every time when checking the time the display stays on for 4 seconds. So lets say I check the time ten times per day:
      .7 Ah / (5.5e-6 A * 24 h + 90e-3 A * 4 sec * 10 / 3600 ) = 618 days

      1. Don’t forget to include the self-discharge of the LiPo when you’re estimating operating life from a single charge! LiPo discharges at about 3-5% per month, according to the interwebs.

        Also, not all of those 700mAh are usable – there’s always some “headroom” required to estimate life. So, I suspect you’ll get roundabout a year from your battery.

        However, an LED clock that lasts one year on a battery? Nice work!


      2. Of course. The calculation above was only ment as an example of how to do the calculation, not as an exact result.

      3. I feel uneasy with this generalizing of lithium battery chemistries. Applying LiPo characteristics on LiFePO4??! Is it good engineering? I’m pretty sure prismatic lithium polymer battery packs self-discharges faster than LiFePO4 cells.

        IMHO I think you are wrong about the 700mAh. The battery fine print told the honest story, 550mAh. The 700mAh printed in large bold letters are the typical “mine is biggar than yours” tactic in a country where consumer protection is scanty. The manufacturers have competed and now they have mostly defaulted to an optimistic claim, for marketing purposes. I’m sure it’s true at some level, maybe at the top end of a 3 sigma population. It’s China, buyer beware, that’s all.

      4. I am no expert, but it seems LiPo and LiFePO4 cells do not differ *that* much regarding self-discharge rate. One PDF I found says 5%/month for LiPo and 3%/month for LiFePO4, without specifying the manufacturer of the cells in more detail (http://w1sye.org/wp-content/uploads/2013/01/Lithium-Iron-Phosphate-Batteries.pdf).

        And, again, the calculation was only ment to be a rough estimate, more in the range of finding the order of magnitude. Will it last a week, an month, a year? Inserting 550 mA does not change it that much. Other assumptions in my use case have a much bigger impact: Checking the time more often will greatly reduce how long it lasts with one charge. Looking at the time at night in the dark will greatly increase the lifetime, since the brightness of the LEDs is dynamically dimmed using a photo transistor.

      5. Heh heh, no worries, just shooting the breeze. ;-)
        I guess since the Das Auto disaster, I’ve been more sensitive to inconsistency in engineering… plus this blog is a great place for all of us to nitpick. :-p

      6. Anyway my response was @Tom, it got interspersed, sorry if there is a short-circuit somewhere.
        I still do not understand why some posts have Reply links and some do not…

  4. Somewhere around 20 years ago I worked at a company that used enough microcontrollers to get the attention of Microchip sales reps. Their rep gave us a thing we called the “Pic Clock.” It was very similar to this clock but the layout was a bit different. Obviously a much older controller. Buttons below the display, taller, and only as wide as the LED display. The back side of the PCB had a two AA battery holder for power.

    I could swear I took it home when the company downsized me out of a job, and when the whole Ahmed clock story blew up, I searched several boxes of electronic stuff to find it, but I didn’t. I wanted to post online about it then and how it looked like a bomb timer straight from the central movie prop supply…

    1. Maybe this (Google it): AN615 Clock Design Using Low Power/Cost Techniques
      An LED clock AN, a very old one (PIC16C54A), I don’t remember any LED clocks or display in their later app notes.

      1. I was disappointed that the app note had no picture or board layout to compare to our “Pic Clock,” but that is almost certainly it. The time of publication of the app note is about right, and the 16c54 sounds right too. Now I want to start digging through all my boxes of parts and boards and stuff again to find it. Really what this means is I need to sort and inventory all my electronic parts and stuff so I can find things. No point in having stuff that you can’t find when you need it.

        Ironically, at the time I was working for an electric forklift manufacturer. The forklifts had a battery that weighed around a ton. I got to work on the design of DC motor controllers that could PWM 600 amps of current at 36V. Low power microcontroller design was not really a concern. :)

  5. Love your clock! For a hand made project on perfboard, it looks not only professional but artistic (in a nerdy sort of way) Thanks for sharing the project- I am thinking to make something similar after seeing your efforts.

Leave a comment

Your email address will not be published. Required fields are marked *

Notify me of followup comments via e-mail. You can also subscribe without commenting.