AVR-based binary clock help/suggestions

15 views
Skip to first unread message

andrew....@gmail.com

unread,
Apr 17, 2017, 2:09:59 PM4/17/17
to Omaha Maker Group
Looking at making myself a binary clock using an attiny2313 or perhaps an atmega32u4 (since those are the two chips I have readily available to me). A while ago, I had one that looked similar to this: https://www.amazon.com/Crystal-Powers-Direct-Binary-Silver/dp/B000YHO28U.

It was neat, and it was fun, but it irked me slightly that it represented hours, minutes, and seconds in a weird binary / decimal hybrid fashion.

So naturally, when I started getting more and more interested in AVR programming (as a result of my keyboard tinkering), making my own binary clock seemed like a good project. And it still does, more or less, but it is also proving out that I probably need some guidance, since I haven't yet figured out how to achieve a "second". Some contenders that I've found are: 
  • 60Hz wall power
  • External crystal
  • Internal oscillator
  • External RTC
  • Read signal from a GPS chip

Some drift will be acceptable, as this is meant primarily to be a novelty piece, but ideally the error rate would be less than one second per day.

I'm also trying to determine the best way to work up a 7x6 (or perhaps 8x8 for future versatility) LED matrix to act as the display. The most straightforward method looks like it would be multiplexing off of the IO pins, but I also started reading about shift registers, which seemed worth exploring further. Research twice, solder once. :)

Primary goals for the project:
  • Track time at least as accurately as the clock in a microwave
  • Display seconds, minutes, hours, day of the month, month, day of the week in binary format
  • Be easily configurable

Secondary goals:
  • Be intuitively configurable
  • Battery backup in case of power failure
  • Use a microUSB cable for power
  • Handle both 12 and 24 hour modes
  • Alternate display modes (which argues for the 8x8 matrix, perhaps using two 8 bit shift registers)
  • Handle leap years
Thoughts, suggestions, and assistance welcome!

Thanks,
Andrew

David Knaack

unread,
Apr 17, 2017, 2:40:08 PM4/17/17
to OMG
You might like my very old AVR-based binary clock project:


I had the same irritation at the binary coded decimal representation on the ThinkGeek binary clock, so I made mine with just three binary registers. The binary coded decimal representation has the advantage of generating more interesting patterns though.

As far as time-keeping, the simplest way is to use a board that supports an RTC. 

There are shields like this one:


that have everything in one package, including buttons for setting the time and a beeper for chimes/alarms (also temperature module, light sensor and several LEDs). For a binary clock project you can use the on-board display for other purposes (debugging, user interface, whatever), or just remove it. However, it would make getting to the pins you need for your led display a little more difficult, and you get a bunch of stuff you don't really need.

A more targeted, cheaper and smaller RTC-only module such as:


would probably be a better choice. There are many similar options, but I'd recommend picking one with the included battery so that your clock retains time through power disconnections.

Most of these RTC modules will drift a fair amount. This is because not much effort is put into preventing temperature-based variation of the crystal resonant frequency. If you want it to keep time better you'll need to pay for a module that is higher tech than what you'll find in the $2 price range, or use an external signal for sync (GPS, power line zero crossings, radio WWV, etc). A silly hack might be to use a cheap digital watch with an alarm set to midnight. Connect the alarm signal to an arduino input, and resync when you get the alarm.

You should check out neopixel LEDs for your display. Lots of RGB LEDs arranged however you want with only one data line to drive the whole thing. Very bright, versatile, and good for animations and such. Available in strips and panels. Costs more than bare LEDs, but they are reasonable, the additional capability and easy of use may be useful for you.

--
Support Omaha Maker Group with purchases you make anyway. Shop Amazon using our Affiliates link, and OMG receives a portion of the proceeds. http://amzn.to/1f3i3ve
 
Leave lurking behind — come visit us at the Makery at 8410 K Street, #5, Omaha (just off 84th & L). We’re nice, we promise. http://bit.ly/1dKnTmC
---
You received this message because you are subscribed to the Google Groups "Omaha Maker Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to omaha-maker-group+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

andrew....@gmail.com

unread,
Apr 17, 2017, 4:00:32 PM4/17/17
to Omaha Maker Group
Including day-of-week, month, day-of-month, was my thought for reclaiming some of the interesting "breadth" that the TG clock accomplished with their binary coded decimal format, while still keeping to a more pure binary encoding. That DS1302 looks like it would meet my main criteria: accurate "enough" that I won't need to adjust the clock every few days, and cheap enough that if I let the magic smoke out, I won't be heartbroken. The idea of combining that with a ublox neo 6m as a way to eliminate the need for a human to set the clock is appealing, even if it does bring in some fear of scope creep. 

It seems like using the ds1302 as the "main" time source and the neo6m as a device which re/sets the main time source at regular intervals (every day/hour/minute/whatever) should work well, but also has the distinct feel of "much easier said than done". :)

The neopixel LEDs look like a lot of fun (thanks for making me aware of them), but overkill for this project, especially at over 20x the price of bare LEDs. And if using both the ds1302 and the neo6m, 6 of the AVR IO pins will be claimed, then the idea of using a couple of shift registers becomes much more enticing.
To unsubscribe from this group and stop receiving emails from it, send an email to omaha-maker-gr...@googlegroups.com.

andrew....@gmail.com

unread,
Apr 18, 2017, 1:15:13 PM4/18/17
to Omaha Maker Group
Going to try with the DS3231, as that is purported to be a 2ppm unit, and may eliminate the need to rely upon an auxiliary time sync source, at least for the first iteration.
Reply all
Reply to author
Forward
0 new messages