Initial Arduino driver perfboard circuit:
Once I had one module working with the Arduino, I quickly decided the Arduino wasn’t very nice to look at. I decided I would go for a minimalist layout, with just the atmega, using its internal oscillator and talking to a dedicated battery-backed RTC. The ATmega would use its internal 8MHz oscillator so I programmed the fuses to that effect. The next step was to ditch the arduino bootloader (which didn’t work well with the internal oscillator) and get a real AVR programmer, which i did on ebay for the measly sum of $4.
After soldering 3 large modules to the Arduino (note the data bus on top) Small modules not installed yet
I then did the same for the smaller 2 display modules, with a slightly different chip enable configuration. With this I managed to address all 20 characters individually. Debugging a layout with that many wires was not easy, given that they are all on the same bus, so one thing going wrong in the bus means either they all fail, or only some chips work (if the failure is in a chip or digit select line or a bad solder joint/short). Add to it that the displays show nothing if the data is invalid, it was tricky to know what went wrong.
I first had it running keeping rough time using the ATmega’s internal 8MHz oscillator, but it would drift extremely quickly, as is expected of a “+/-2% RC oscillator”. Still it was nice to finally see the displays doing something semi-useful by themselves after all those years in the parts bucket.
This is when I received my two DS1307 RTC modules from ebay. First, I dutifully let the smoke out of the first one by swapping power and ground wires. Happy that I had ordered two of them, i proceeded with the other. The strange part is the battery arrived installed in the RTC already, and they had square wave output turned on, which drained the battery much faster for no reason! I promptly turned it off. Mounting it to the breadboard was a bit annoying, since I wanted it in the back, but with the battery slot accessible. I ended up using some of the pins as standoffs, and some double sided tape. I don’t need it to be too sturdy anyway.
I made good use of Akafugu’s i2c RTC library for talking to the RTC, setting and querying the time. The read functions populates a simple struct that the program can then access. I use a big array of strings to represent text, that I read directly from the actual hour/minute value.
During development I was powering this contraption from my computer’s usb port through the tinyusb isp programmer, which worked wonderfully. Once I switched to a usb charger brick as a power source, I started having some really strange issues. It would suddenly stop refreshing the displayed time, and I would have to unplug and plug it back in, and it would work well for another few hours. I was told that bad power could cause lockups of the chip, so I sourced some caps to add filtering and smoothing between VCC and ground (an electrolytic and a ceramic cap, like most of the Atmel design notes prescribe).This is what the board looks after I mounted the RTC and the filter caps.
It’s a bit messy: I used 30AWG single strand wire that I soldered using a fine metcal tip and tweezers. The fancy automatic stripper tool I got earlier proved to be very useful and enjoyable to use, stripping multiple wires at one with the same length.
My best friend during this project.
The extremely poor quality of the breadboard I used did not help, with pads lifting way too easily if a bit too much heat was applied, and a solder sucker used at the same time.
Makin' it pretty
I wanted a good looking case for it, so I headed out to makercase and designed a t-slot box to cut with the laser I have at work. It’s all made from 1/4” acrylic, but because I wanted transparent red and could only get ⅛” at Tap Plastics, I cut another piece of transparent ⅛” to sandwich with the already-cut case. I also added holes for the power wire and a rectangular cutout for a toggle switch I’ll use to enable daylight savings time, all because I was lazy and didn’t include programming buttons for hours/minutes. (I set the time by programming the device with code that sets the correct date/time in the RTC at bootup, then I flash my regular code). I might revisit and add a minute +/- button eventually, since even with the RTC it drifts a little bit. (minutes over months) but the inherent fuzziness makes it fine anyway.
I chose to display the minutes, with “to” or “past” and the hour on the bottom. The clock updates every five minutes.
I also had some issues with some times of the day not fitting in the display (“TWENTYFIVE TO ELEVEN” was the longest string) so I used “>” and “<” for “PAST” and “TO”. (as seen in the code)
I decided against displaying AM or PM, since that particular display module cannot display a dot alongside a character, and I didn’t want to add an extra LED.
The code is all available in the files section. Unfortunately I do not have a schematic but most of it can be figured out from the code as well and pretty much follows the schematic. Any pins not actually connected to the atmega were either left floating or strapped to their proper logic level according to the datasheet.