This is a binary clock, which represents the time using a series of dots. There are three columns, The leftmost column represents the hour, the middle column represents the minute, and the rightmost column represents the second. Each number is displayed as a binary string. When a light is on it represents a one, and when it is off it is a zero. There are two buttons on the back which are used to change the current time by increasing the minute or hour.
Video |
download |
---|
This project uses a Renesas RL78 microcontroller running at 8MHz to control the clock and operate the display. We also use a low-cost, extremely accurate, DS3231M I2C real-time clock (RTC) for keeping the time. The display is a 5x7 Bi-Color Matrix. The third color is achieved by combining the other two colors together. The device is powered via a micro-USB port, the same as found in most smart phones. The RTC is connected to a CR2032 battery to provide power when the device is not on. This battery will not power the MCU or the display, it just prevents the time from resetting from loss of power. There are two buttons on the back of the device that are used to set the hours and minutes.
Schematic | Board layout | |
The software running on the MCU is written entirely in assembly. It consists of several sections, starting with initial MCU setup. In this setup section the internal registers of the RL78 MCU are assigned values to define the clock speed, port configurations, I2C configurations, 12-bit Interval Timer setup, and interrupt service routine assignments. The RTC is setup to provide an interrupt alarm every second. Then we assign initial values to the variables stored in RAM such as the status of the hours and minutes buttons and we get the current time from the RTC and store the hours, minutes, and seconds into RAM as well.
In the main program loop, the MCU is put to sleep and wakes up once every 3ms from the 12-bit interval timer. Every 3ms when the interval timer wakes up the MCU the display is updated by lighting up each column one at a time. This happens approximately 330 times per second, for a display refresh rate of 80Hz. At this refresh rate we do not see any sign of flicker in the display. Every 15ms the MCU checks to see if either of the buttons (minute/hour buttons) are pressed. When a button is pressed the time is increased in RAM and the new value is sent to the RTC so it can also update it's time values.
Last modified:Mon, Jan 23, 2023.