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.
SMPTE/EBU description here and the bit format of timecode here
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.
2 thoughts on “SMPTE/EBU Timecode generator”
Got your code working. I was wondering if an ESP32 could be used to power two different units? I have a 1RU Leitch that has two units side-by-side. I wanted to present one in localtime and another in GMT.
Love the code and project.
Thanks, glad you find it of use. I’ve made some mods here that may be of use.
You just need to specify the pin you want for Gmt output in Frame::begin(). You’ll see I’ve just added xxxGmt variables to hold the GMT data. Frame::setTime() converts the localtime to Gmt time for use by Frame::updateTime(). The code need tidying and I haven’t tested it but it does compile and may give you some ideas,