Development of a large digital clock on a LED strip

Once upon a time, when I was a child and just starting to work with electronics, I had a dream of making a huge clock with seven-segment indicators. More precisely, to make a large indicator and connect it to the electronic board of an existing small electronic clock. To make the seven-segment indicators themselves, I considered fluorescent daylight lamps as segments. I had no other ideas at that time. And making a clock with such lamps is not a very good idea.

Over the years, other more practical light sources came into use, in particular, LED strips. They were the ones that served as an incentive to turn my old idea into reality. Having the opportunity and experience of programming microcontrollers, I decided, of course, to independently make an electronic board for a clock with its own functional capabilities. In addition to displaying hours and minutes, I decided to display the date and temperature. In this article, I will not describe in detail the circuit diagram and firmware of the MK. I will only write a brief overview and history of the development of my design.

I started constructing large clocks from LED strip 7 years ago. I bought 3 rolls of cheap LED strip, 5 meters each (4.8 W/m, blue). Based on the available amount of strip (3*5=15 m), I decided on the length of one segment: 50 cm. There are 28 segments in total (4 by 7) plus two dots in the center (one at the bottom and one at the top), separating the hours and minutes. Total – 30 segments. That is, I planned to use up all the available LED strip. The dots are 5 sections of 10 cm each, which is equivalent in length and power to one segment. They are folded into a 10 by 10 cm square.

All sections of the LED strip are placed in a special aluminum profile. This profile, designed for LED strip, can also be freely found on sale. The LED strip is glued inside the profile, and covered with a plastic matte material on top to diffuse the light. All profiles are twisted into a single frame, measuring 320 by 105 cm. I connected the edges of adjacent profiles using metal circles. To increase the rigidity of the entire structure, I screwed on additional aluminum corners in some places.

Fig. 1. Sketch of the clock design

Fig. 1. Sketch of the clock design

The electronic board is based on the Atmega8 microcontroller. The DS3231 clock chip in the form of a module (with a body kit and a CR2032 battery) is plugged into a connector on the board. The DS1621 temperature sensor is connected to the board with a short cable and brought out from the bottom of the box. The board also has three buttons for setting and configuring the clock. From a practical point of view, they are not very convenient, since they are inside the box. Therefore, over time, I supplemented the board with a Bluetooth HC-06 module connected to the UART interface of the MK.

Fig. 2. Structural diagram of the watch electronics

Fig. 2. Structural diagram of the watch electronics

Fig. 3. Main board

Fig. 3. Main board

Fig. 4. Signatures on the main board

Fig. 4. Signatures on the main board

You can connect via Bluetooth from a laptop or smartphone, using any terminal as a program. In turn, the MK program provides a set of text commands for control from such terminals. It is possible not only to set the date and time, but also to change the modes and duration of displaying time, date and temperature in turn. The output of information to the segments is implemented through shift registers 74HC595 and transistor keys of the NPN structure. As the latter, four 8-channel keys ULN2803 were initially used. There were 4 identical daughter boards that were plugged into the main board with the MK. Each of them contained a register, an 8-channel key and output terminals for connecting wires to the segments. By the way, they were the ones that later served as an indirect correspondence between the numbering of bits and segments due to the ease of installation.

Fig. 5. Printed circuit boards with 74HC595 registers and ULN2803 keys

Fig. 5. Printed circuit boards with 74HC595 registers and ULN2803 keys

Fig. 6. Boards in the manufacturing process

Fig. 6. Boards in the manufacturing process

These load keys overheated and eventually failed (I miscalculated a bit). Therefore, I decided to make a board with more powerful transistors. I placed 32 BC139 transistors (2 in reserve) and 4 registers on it. I connected this board with the MK board with wires.

Fig. 7. Board with transistors

Fig. 7. Board with transistors

Fig. 8. Clock design (keys on BC139)

Fig. 8. Clock design (keys on BC139)

The frame itself is used as a common wire for all segments (common plus). Wires to each segment go from the electronics (box 3) through intermediate boxes, in which the plug connections are hidden (boxes 1 and 2). In box 3, in addition to the electronics, there is also a 12V power supply. This design worked reliably for several years. The clock hung in a large room.

Fig. 9. Box with electronics (keys for ULN2803)

Fig. 9. Box with electronics (keys for ULN2803)

Fig. 10. Intermediate box with connectors

Fig. 10. Intermediate box with connectors

Fig. 11. Time display

Fig. 11. Time display

Fig. 12. Displaying the date

Fig. 12. Displaying the date

Fig. 13. Temperature display

Fig. 13. Temperature display

Over time, I wanted to hang the clock outside. To do this, first of all, it was necessary to protect the structure from moisture and precipitation. For this purpose, I decided to completely upgrade the LED strip to a waterproof one. At the same time, I wanted the clock to shine much brighter and be visible even in daylight. I found a cool waterproof bright white LED strip with a power of 24 W / m on sale. On it, the LEDs are located more densely than on the previous strip, and they are brighter. I also made small additions to the frame design – I added 2 additional segments. In the first “eight” – a diagonal segment at the bottom, and in the last – an inclined segment in the lower right corner. They are connected to the remaining two backup channels of the output keys (in total, I have 4 registers of 8 bits, or 32 channels). These additional segments are needed to be able to display your Nika on Habr amateur radio call sign R3EQ: the first “eight” has the letter “R” and the last one has the letter “Q”.

Fig. 14. Updated sketch of the watch

Fig. 14. Updated sketch of the watch

After updating the LED strip, I coated some places with sealant, especially the places where the wires were soldered, to further prevent moisture from getting in. I abandoned the common power bus in the form of the structure itself and decided to connect a separate pair of wires to each segment. This completely eliminates possible problems with voltage drop.

I also made significant changes to the electronics. Due to the increased load, I had to update the power supply. More precisely, I installed two of them: one for the first half of the dial, the other for the second and for powering the electronic board. I also updated the board with registers and transistor keys, placing the transistors in one row for the purpose of mounting them on a heat sink. A piece of aluminum angle of the appropriate length was used as a heat sink. After all, with such a new load (1A per segment), the transistors began to heat up quite well.

Fig. 15. Updated board with transistors

Fig. 15. Updated board with transistors

Fig. 16. Placement of transistors on the heat sink

Fig. 16. Placement of transistors on the heat sink

I placed all the above-mentioned guts in a new case – a sealed metal electrical cabinet. It turned out to be quite heavy, and therefore I did not attach it to the clock frame and hung it nearby. The connections between the electrical cabinet and the indicator are made by many pairs of wires laid in a corrugated pipe, through two round 32-pin sealed connectors on the bottom of the cabinet.

Fig. 17. Distribution of wire pairs on the connector pins

Fig. 17. Distribution of wire pairs on the connector pins

From the intermediate distribution boxes, the wires are routed into segments through cable channels behind the structure. Instead of the Bluetooth module, I decided to install a homemade UART-TCP/IP converter (Telnet server) to control the clock from a terminal at any distance via a local network or the Internet. This converter is described in my very first publication on Habr.

Fig. 18. Cabinet with updated electronics for watches

Fig. 18. Cabinet with updated electronics for watches

Fig. 19. View of the updated clock during daytime

Fig. 19. View of the updated clock during daytime

I also added a new useful function to the firmware – brightness control. Technically, this is implemented on the MK timer with the PWM mode. Accordingly, with the help of PWM, the voltage supplied to all segments is regulated by changing the pulse duty cycle. The PWM signal from the corresponding MK output goes to the “OE” terminals of the registers. By the way, I came up with this implementation after I had manufactured the printed circuit boards. Therefore, I had to make do with it (you can see it in Fig. 15). There are 10 brightness gradations, including zero brightness, when the clock is not lit. Terminal commands are “y0”, …, “y9”. As is known, the dependence of the visible glow of LEDs on the voltage applied to them is not linear, but has a “convex” characteristic in favor of the consumer. That is, for example, 50% of the applied voltage corresponds to 75% of the brightness. In this way, in particular, it is possible to reduce the voltage on the LEDs by approximately 10-20%, while losing almost nothing in brightness. It is on the penultimate brightness gradation (“y8”) that I operate the watch. It is worth understanding that the PWM itself creates flickering of the LEDs at a certain frequency, such as invisible to the eyes. I chose a really high PWM frequency (1.35 kHz), which practically does not interfere with the eyes. But I provided for switching the PWM frequency with special commands “f1”, …, “f5” for experimental purposes. In this case, the timer dividers provided in the MC are switched in the firmware. The frequencies were 10.5 Hz (the flickering is clearly visible to everyone), 42.2 Hz, 168.75 Hz, 1.35 kHz, 10.8 kHz. At the highest PWM frequency of 10.8 kHz, with the same average brightness, the watch glows a little dimmer. Apparently, at this frequency, the LEDs no longer have time to gain full brightness. The most optimal frequency is 1.35 kHz. The disadvantage of PWM at this frequency is a quiet whistle from the electrical cabinet with the same frequency. But it is audible in a room with perfect silence (with the load connected, of course).

A year later, I wanted to upgrade the design again. Namely, I wanted the watch to display atmospheric pressure. The most common, cheap and fairly accurate sensor is BMP280. Together with the sensor, my design uses a 3.3V-5V I2C level matching circuit module, since the sensor operates from 3.3V, and my circuit operates from 5V. These modules are used in their designs by Arduino developers.

Fig. 20. Pressure sensor and level matcher

Fig. 20. Pressure sensor and level matcher

Avoiding Arduino, there is detailed documentation (datasheet) for this sensor. To obtain information about the pressure, it is necessary to enter a bunch of calculations into the MK firmware. These calculations did not fit into the memory of the Atmega8 MK. Therefore, I drew and made a new board for the Atmega32 MK, and transferred all the firmware to it. On this board, I provided a connection diagram for a common analog NTC temperature sensor (thermistor) of 10 kOhm to measure and display the temperature at a longer distance from the clock. Along with this, I decided to abandon the homemade UART-TCP/IP adapter, buying a similar device in a separate small box on Aliexpress for cheap. But its UART interface is implemented on a DB9 connector with electrical levels of a computer COM port (RS-232). Therefore, on the new board I provided a MAX232 level converter chip, through which the new adapter is connected. I did not install buttons on the new board, and their functionality was excluded from the firmware.

Fig. 21. Updated electronics diagram

Fig. 21. Updated electronics diagram

Fig. 22. New clock board on Atmega32

Fig. 22. New clock board on Atmega32

Fig. 23. View of the new board from the soldering side

Fig. 23. View of the new board from the soldering side

Fig. 24. View of the new board from the connection side

Fig. 24. View of the new board from the connection side

Fig. 25. Updated electrical cabinet filling

Fig. 25. Updated electrical cabinet filling

In addition, I have supplemented the firmware with other new functions and terminal commands. In addition to time, date and temperature, atmospheric pressure and an arbitrary combination were added to the autoscroll. This combination can be composed independently segment by segment or byte by byte using commands specially provided for this purpose.

Fig. 26. The command

Fig. 26. The command “76:C7:E7:48” outputs the word “HURRAH!”

I made a calculator for calculating the HEX code of a combination of segments in Excel.

Fig. 27. Calculator for calculating the segment combination code in Excel

Fig. 27. Calculator for calculating the segment combination code in Excel

Autoscroll page durations are also still flexibly configurable via the terminal. It is possible to switch between temperature sensors for display (DS1621 or NTC). The “info” command outputs all sensor information to the terminal.

The watch can be controlled by commands from the terminal via TCP not only manually, but also automatically. There are terminal programs that support script programming. But I did it easier – I created the simplest Telnet client in the Visual Studio 2022 development environment using the and libraries. The goal of this idea is to supplement my watch with a few more functions without changing the firmware of the MC. In particular, I wanted the brightness of the watch to decrease at a certain time at night and increase in the morning. This is exactly what I implemented with my simple application. This program is executed in the command line. When calling the program, arguments are specified – text strings that will be sent in turn to the specified TCP server, which is the watch (more precisely, the TCP / IP – RS-232 adapter installed in the watch). Calling the program with the desired arguments, i.e. brightness parameters, is carried out in the Windows Task Scheduler according to a pre-set scenario.

Fig. 28. Windows scheduler for clock management

Fig. 28. Windows scheduler for clock management

Considering that the watch has a mode for displaying arbitrary information (an arbitrary combination of segments), which is sent to it via TCP with a special command, it is possible to use the watch as an indicator. In particular, to implement a program for displaying time and date on the watch entirely on a computer. Unfortunately, the speed of updating information is not very high. More often than 3 times per second, I was unable to update the information on the dial. This is due to the suboptimal implementation of the algorithm for receiving information via UART in the MK firmware. However, for some applications, this speed is quite sufficient. One of the following articles will discuss just one of such applications.

Finally, a few more photos of the watch.

Fig. 29. Evening of March 1, 2023.

Fig. 29. Evening of March 1, 2023.

Fig. 30. On command “r3eq” R3EQ is displayed on the clock

Fig. 30. On command “r3eq” R3EQ is displayed on the clock

Fig. 31. On the “all” command, all segments on the clock light up.

Fig. 31. On the “all” command, all segments on the clock light up.

Fig. 32. View of the watch from a distance of 700 meters

Fig. 32. View of the watch from a distance of 700 meters

For a year and a half of using the watch, there was not a single failure in its operation. Although no, there was one failure on May 31 of this year. This is exactly what I wanted to write about. In the morning, I noticed that the watch would periodically go out and then go out. That is, they are on for about 10 minutes and off for 5 minutes. Even rebooting did not help. But at the full brightness parameter, they are constantly on, and everything is fine. I spent the whole day trying to figure out the reason. It turned out that the parameter of the timer divider responsible for PWM (brightness control), stored in the EEPROM of the microcontroller, had gone wrong. That is, the PWM frequency parameter controlled by the commands “f1”, …, “f5”. It somehow went beyond its limits, switching to an unintended “f0”. And according to the timer configuration register in the AVR microcontroller, the zero divider corresponds to switching the T1 timer to an external clock source via pin T1. And this pin in my circuit coincided with the strobe pin of the second register. It turns out that my timer, responsible for the PWM, began to be clocked by the strobe signal to the register, which is formed no more often than once a second. Thus, the PWM pulsation frequency dropped significantly, and the brightness setting turned into periodic switching on and off of the clock.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *