Before I get started on the details of this clock, I would like to give a big Thanks to the people at OSH Park. I have been using their services for about 9 years now, and they provide consistently good quality boards at a reasonable price. If you look through my projects here, all the PCBs I have designed are purple. Their service makes it possible for me to build multiple projects in a year, compared to the old days where a run of PCBs was so expensive that 1 or 2 a year was all that was affordable. Thanks, OSH Park!

 Most of the boards in this project are mounted with threaded standoffs to a single plate that attaches to the outer skin of the case. The front side of that plate has the 4 display driver PCBs, small LED mounting boards for the discrete red/green indicator LEDs and an ambient light sensor board. The LED character displays and the discrete LED indicators are all capable of displaying in red or green, under control of the display driver chips.

The display drive boards have "stacking" connectors to interconnect up to 4 characters in a row, passing power and I2C signals directly from board to board. The limit of 4 characters comes from the number of choices for the I2C address offered by the IS31FL3730 driver chips. The driver boards can be assembled to be in contact with the characters on either side, or to have the inter-character space be empty. In this case, the inter-character spaces are empty with the exception of the 2 discrete LEDs between the hours and minutes displays. At the left end of the display are two discrete LEDs to indicate AM/PM when run in 12 hour mode. At the right end is the ambient light sensor which is used to dim the displays according to the room lighting. After this picture was taken, another discrete LED was added in the lower right corner to indicate whether the alarm is set.

In previous projects with these displays, I left the inside of the display area bare metal, and it reflected enough light that too much of the internals are visible. Painting the mounting plate black was done to try to reduce that.

On the back side of the mounting plate (L to R), the Filter Regulator board, Miscellaneous LED Controller board, Clock board  and the CPU board can be seen.

Input power comes into the system at 12V on the upper left corner of the picture. It is regulated down to 3.3V for the rest of the system on the Filter Regulator board. The board below the Filter Regulator board is the Miscellaneous LED Control board which handles all of the discrete LEDs on the front side of the plate. To the right of these boards is the clock board. It is an NXP PCF2127 clock/calendar chip with a backup battery mounted on the exposed side of the board for easy access. The rightmost board is the Processor board. It uses an ATSAMD21E18A chip.

Almost all of the communications in this clock are done via I2C. The only part of this clock that is not interfaced via I2C is the rotary encoder. Two I2C ports are configured on the processor. The Miscellaneous LED Controller board uses an IS31FL3730 chip (same as the character driver boards), which must go on a different bus than the 4 character display driver boards because there would be an address collision. The ambient light sensor lives on the same I2C bus as the character displays. The Clock and part of the user interface live on the same I2C bus as the Miscellaneous LED Controller.

Both sides of the electronics plate can be seen here. The display modules have been installed on the character driver boards too.

One of the ways to minimize traffic on the I2C buses in a system like this is to use the "Interrupt" signal from various I2C interfaced devices. The clock chip is configured in software to drive an interrupt signal once per second, so it is not necessary to poll the clock continuously, just wait for a rising edge on the interrupt signal which is tied to a GPIO input. Similarly, the user interface uses an I2C port expander chip (TCA9554) to monitor the DIP switch and up to 4 buttons. If one of the inputs on the port expander changes, it will assert it's interrupt signal until the processor reads the data register via the I2C bus.

This is the first time that I have used a rotary encoder in a software monitored configuration. I was concerned that monitoring it via the I2C bus would add too much delay, so the 2 phase signals and the push button are wired directly into the GPIO signals on the processor. That probably was not necessary, but it was done before I had the software driver written to test it, so I left it in place.

Components of the user interface are shown here.

On the left, is the port expander board with the 4 position DIP switch and ESD protection. Immediately to the right is a small board with tactile push buttons on it. This design is only using 2 of them, though the board supports up to 4. Button signals are routed to the port expander board, using the un-used DIP switch pins. On the right end is the rotary encoder. It also has ESD protection to keep from killing the GPIO inputs on the processor. The piece of aluminum that the boards are mounted to is a temporary thing to keep the small boards from flopping around and shorting to other bits. It is also a good way to verify that my CAD models are good for the boards.

ESD protection is handled with large TVS diodes between the switch signals and chassis ground. The TVS diodes are pretty much just zener diodes that are optimized for shunting fast, high voltage pulses to ground. All of the TVS diodes are connected to the case ground through large copper pours on the board layouts to the metal standoffs attaching them to the case. Chassis ground is also the same connection as the power ground, but the chassis is not used for carrying power supply or signal currents. All of the mount areas for the user interface boards were kept clear of powder coating to insure a good electrical connection to the case.

The case for this clock is formed from 0.030" 5051 aluminum. Shown below are the top and bottom parts of the enclosure.

Holes for the user interface boards can be seen in the top part. The front and back covers are attached with machine screws into "rivet nuts" that are installed in the holes. They are visible on the flanges of the top cover that are against the table top. The bottom cover will also be attached with the rivet nuts, but when I took the picture, they had still not been delivered.

The electronics plate gets installed in the top cover.

The user interface boards are still to be installed. The unlabelled blue box is a logic level 2 channel logic level UART board that I use for debugging.
Once all the fitting is done, I disassembled the box and powder coated it. All the completed boards are now installed and a front cover/filter cut from gray acrylic plastic. When I powder coated the box, I coated the inside of the display area as well as the outside of the box. After assembling and testing, the display looks much better than the ones that I left as bare metal in the display area.

Since there are 3 different PCBs involved in the user interface there are a lot of screw heads to be seen. If I were to do this project again, I would have laid out a single board with all of the user controls on it.

The two gray push buttons are used to select entry modes for alarm clock and real time clock setting. The rotary encoder knob is used to adjust the time settings up or down. Pushing on the rotary encoder knob will enable or disable the alarm clock. Only 2 of the 4 DIP switches are used, one selects red or green displays and the other selects 12 hour or 24 hour display mode.

The only hardware remaining to be done is the sounder for the alarm clock. It will be installed on the back cover of the box. I wanted fairly accurate musical notes on the alarm sounder. When I was messing around with a speaker and a function generator, driving the speaker with a square wave sounded really harsh and irritating. A sine wave sounded best to me, but a triangle wave is pretty reasonable. In order to get accurate frequency control, I am using one of the timers on the processor chip, from a crystal reference. The timer puts out a square wave. My first thought was to filter the square wave down to a sine wave with an LC filter. Unfortunately, inductors in the right value range to filter 500Hz to 1KHz were either out of stock or big and expensive. It occurred to me that integrating the square wave would give me a triangle wave which sounds OK to me. I simulated an integrator circuit in LT spice and it looked perfect. I laid out a board with the integrator and a small (1W) audio amp chip and sent it out. I am looking forward to building that board and testing it to see if it works as well as it simulated...

Looking at this project, there are a bunch of low cost PCBs and a messy, time consuming to make, wiring harness. This method of building stuff works OK for a prototype or one-off project, but it would be prohibitively expensive to manufacture. Just for curiosity, I laid out one board with all 4 of the Character Drivers, and displays, all of the discrete LEDs and the Miscellaneous LED Controller chip, the Ambient Light Sensor, and an I2C mux chip.  The area of the new PCB is somewhat less than the area of all of the boards that it replaces. The result of that is a less expensive display board with a much simpler wiring harness. On the other hand, it loses the flexibility to change the configuration. If I were going to make more of these clocks, I would use that board and lay out a single board with the user controls, processor, clock and power supply. A 2 board system would have a MUCH simpler wiring harness and take less time to assemble, especially if I was farming out the PCB stuffing.

All told, I am pretty happy with the final appearance of this clock. The reduced form factor and different color choice is a significant improvement to me.

Schematics and some discussion of each board follow in the project logs area.