AlphaClock is the sort form of “alphanumeric clock” as the displays used can also show text. The following video was done with the first version of the firmware.
One advantage of the Arduino Micro ist that it can be plugged in directly to a breadboard and has a micro USB connector for data transfer and power supply. However from LCD2USB I also know the ATmega in a DIP package. For normal operation with external clock this controller only needs a crystal and two capacitors.
My idea was to combine an ATmega328P with two DL-2416 from 1987 and a DS3231 realtime clock module. The whole thing was also a project to learn to know the development environment as Visual Studio Code and PlatformIO as well as the way how the microcontroller works in terms of interrupt control and PWM.
To transfer the software to the ATmega328P you need an AVR programmer besides the development environment. For this I currently use the “mySmartUSB light” which is compatible to SKT500 and can also be used with avrdude.
The first prototype was built on a breadboard. So I could easily try out different ideas and in the end I found a design which took the following points into account:
- Besides the reset button there are two other buttons to change the display or to activate a menu for other functions.
- Updating the display using an interrupt by the realtime clock module to provide an exact seconds display.
- Controlling the brightness of the displays using PWM.
- Keep the serial interface available for future extensions.
To transfer the software I have used an ISP adapter for breadboards, which you can see on the top left corner on the picture above. The part between the displays and the ATmega328P is the DS3231 real time clock module by Adafruit.
The final schematic is as following (click for a larger view):
Permanent build on a perfboard
As the general function of the hardware was sorted out I created a permanent build on a perfboard. For the displays I used a 40 pin precision IC socket from which I removed four pins to make it clear where the dispays have to be plugged in. In the same way you can combine even more displays without gaps next to each other – maybe I will create something with four or six displays later.
As a first step I built the minimum configuration first – ATmega328P, crystal, capacitors and a socket for the programmer. In addition I also used a protection diode to make sure that the circuit does not get destroyed if the polarity of the power connection using the dedicated connection for this is reversed by accident.
Before continuing there was first a test if the ATmega328P was identified correctly by the AVR programmer.
For the wiring I mostly used enamelled copper wire with a diameter of 0.1 mm – only for the power supply of the displays I used stranded wires as the displays use up to 145 mA and the copper wire only supports 100 mA.
The final build also contains three buttons like on the breadboard.
Compared to the introductionary video I updated the keyboard handling in the settings a bit. In addition to the date and year there is now also a temperature display since the realtime clock module provides this value as well.
The software is open source and available along with the schematic as PDF at https://github.com/arnowelzel/AlphaClock.
During the development some challenges had to be solved:
- Debounced keyboard input and detecting when a key is being held longer.
- Exact update of the seconds display using an interrupt handler.
- Automatic return to the time display when not pressing a key for a while.
- Partly flashing the display when setting parameters.
- Calculating leap years in the date setting to determine the last possible day in February depending on the selected year.
The software now uses the EEPROM of the ATmega328P to store the brightness setting permanently. In addition the schematic was updated to correct the numbering of the buttons.
The clock module turns out to be very reliable. Even over multiple months the time deviation is just in the
Das Uhrenmodul hat sich als sehr zuverlässig erwiesen. Even over several months, the deviation in the time is in the range of just a few seconds. The temperature compensation also contributes to this, which also enables the implementation of a thermometer.