This Leitch studio clock is designed to work with a timecode signal for best accuracy. Timecode generators are expensive so I built one with an ESP32 dev board.
The timecode signal is a stream of digital data, 80 bits for each frame of data. In Europe there are 25 frames per sec (EBU) and in the US 30 (SMPTE). Each bit is encoded in Manchester style, with a signal inversion at the start of each bit period and a further inversion halfway though the bit if it’s a “1”.
Here is a snapshot of the generated EBU waveform representing 010000001111
For the software we just need an accurate source of time and accurate pulse generation.
Time is obtained from the internet NTP server using the ESP32 Arduino library to keep the ESP32 local time in sync with NTP and to handle GMT/DST issues.
A hardware timer is set to fire every 250uS (for EBU) to output start bit and mid bit transitions. When all 80 bits have been sent the frame counter is incremented. When all frames have been sent the whole data packet is updated with the current time and the process repeats.
Source code: https://github.com/ynformatics/SMPTE
Rather than using a separate enclosure I fixed the ESP32 module inside the case. A source of 5V power is available on the main PCB and there is a spare selector switch available for entering configuration mode. The timecode signal output is wired directly to the input of the clock. If needed this can be daisy chained to other clocks.
Here is a video of the modified clock powering up. There is a short delay while connecting to WiFi and getting the time. Once the timecode data starts, the clock registers all hands to the 12 o’clock position, moves them to the correct time and then maintains time in sync with the timecode data.