This led matrix display clock uses the DCF77 time signal transmitter located near Frankfurt in Germany as its time source
.
.
.
.
The code is based on the Noise Resilient DCF77 decoder library by Udo Klein GitHub - udoklein/dcf77: Noise resilient DCF77 decoder library for Arduino.
The main hardware is an STM32F103C8T6 ("Bluepill") using the STM32Duino Arduino core (2.2.0) and a display module based on an HT1632 controller and a 4 panel LED matrix. The receiver is a Canaduino DCF77 kit but with a home made 20CM ferrite antenna. To ensure a quick start after a power failure, the clock utilises the inbuilt RTC of the Bluepill in a low power domain clocked with a 32.768kHz watch crystal and powered by a supercap.
The DCF77 library is accurate and has excellent performance. I made a few hand changes to get it to work with the latest official version of the STM32Duino Arduino core. These are mentioned later.
Actually, the STM32F103C8T6, with its 72MHz clock and 128kB RAM is overkill for this application but I used it because the clock base I used was originally designed for a now obsolete AI-Thinker A7 GPS/GPRS module which required up to three serial ports, which of course, the Bluepill can supply. However, because of another problem, that is the HT1632 display controller interfering with the time signal receiver module, I was happy that I did use the Bluepill. The internal oscillator of the HT1632 runs at 265kHz and I found by experiment that by disabling this internal oscillator and replacing it with a lower frequency signal at 190kHz, the interference problems disappeared. This 190kHz signal is now supplied by one of the Bluepill's PWM enabled timers.
The extra large antenna (20CM) is also probably also overkill for this application especially as the current clock location is only 400kM south of Frankfurt. I made it for another DCF77 project which I'll soon be working on, that is to use the DCF77 phase encoded signal for more precise time keeping based on this design DCF77 receiver resources. It does, however, have the advantage that the clock is insensitive to its orientation (and also to most sources of interference). That is, the antenna does not have to directed perpendicularly towards Frankfurt. This antenna is, incidentally, very simple to make but the trick is to tune it correctly and that really requires a signal generator and oscilloscope.
Main hardware component summary:
STM32F103C8T6 Bluepill
HT1632C display panel 32x8 e.g. https://www.ebay.com/itm/401111914275
Canaduino DCF77 receiver (others will probably be fine depending on operating distance from Frankfurt) DCF77 Empfänger Funkuhr Receiver 77.5kHz For Europe
Antenna construction (for those who choose not to use the one supplied with the DCF77 module):
A 200mm long, 10mm diameter ferrite rod with 250 turns of 0.19mm enamelled copper wire on a slippable thin cardboard former. The coil is wound in three layers. Layers 1 and 2 are 100 turns each. Layer 3, the outermost layer, has the remaining 50 turns. A 470pf polyester capacitor joins the coil and acts also as the output terminal.
It should be tuned, together with an oscilloscope and signal generator, to resonate as 77.5kHz by sliding the coil former on the ferrite rod. Finally, the coil should be fixed in place, say with heat shrink sleeving.
I've included two zip files. One is based on the Simple_Clock example dcf77/examples/Simple_Clock at master · udoklein/dcf77 · GitHub with minor modifications to the .ino file and including the library file dcf77.cpp which has been modified to support also the stm32 Bluepill with the STM32duino Arduino core. This is very basic and supplied for troubleshooting and demonstration. It outputs only to the serial console. I've tested this also with an Arduino Uno to verify that it still works on other platforms after the modifications.
The second zip is the complete software for the illustrated led matrix clock. It includes exactly the same modified library file dcf77.cpp as in the revised Simple_Clock however the .ino file currently runs only on a Bluepill.
The modifications to dcf77.cpp were not particularly extensive. In
fact, the STM32duino core is quite true to the Arduino model. The main thing I changed was to use explicitly a hardware timer, configured to run at 1 MHz with an overflow each ms, instead of Systick. This makes it similar to how AVR devices are handled. The changes are marked with tag.
Actually, I built this clock so that I now have three six digit clocks, each with a different time source, where I can, with great satisfaction, watch the seconds digits clicking over simultaneously on all three clocks. The other two clocks are (a) a Nixie with IN12 tubes using NTP as a time source and (b) a vacuum fluorescent display (IV-4) clock with a GPS unit as time source. All are illustrated in the accompanying picture.
I have included all code and a schematic in case someone is interested in duplicating this led matrix clock .
Dot Matrix Clock Schematic
DCF77_Bluepill_V0_01.pdf (38.8 KB)
Zip Simple Clock (for troubleshooting and demonstration)
Simple_Clock_ST_V0_04.zip (38.6 KB)
Zip LED matrix clock
Dcf77_BluepillHT1632_V1_01P.zip (46.0 KB)
Additional notes:
-
Whereas the definition of "Bluepill" is quite standard, usually a STM32F103 Arm Cortex 3, the term "Blackpill" can apply to a much wider variety of boards usually with the common feature that the PCB is coloured black. The one I have is based on an STM32F411 Arm Cortex 4.
-
Many of the DCF77 modules offer an inverted and a non-inverted output. In case it is not clear, the non-inverted output is usually the one which is high between 80% and 90% of the time and low for the remainder. However, not all modules are consistent. If it doesn't work with one, try the other.
-
The fonts for the dot matrix display, and maybe some code, were cribbed from a development by @anon57585045 and others.
-
I'm not an expert on the STM32duino platform but most of the development using the Bluepill board is anyway pure "Arduino" and there may also be other better solutions for integrating the dcf77 library with this platform. This does, however, work.