Close

Ancient History

A project log for A Digital Real Time Clock

over-engineering what should be a simple device

zaphodzaphod 05/25/2021 at 23:540 Comments

This project actually began in the fall of 2019. I needed to learn verilog  for an internship (they only taught me VHDL in school), and so I was messing around with a couple different FPGA dev boards (Terasic DE10-Lite, and the TinyFPGA AX2). Eventually I figured it would be fun to try and make a PCB with an FPGA on it, since I'd never done that before.

Since I didn't want to just make a dev board I needed a project, and I thought it would be cool to try and make a freestanding digital real time clock.

I also had some other requirements:

In order to meet these objectives I came up with the following architecture:

Master Oscillator:

This is the ticking heart of the clock. It would be cool to build my own very accurate oscillator, but that's a project unto itself. It would also be cool to use a surplus rubidium frequency standard as the master oscillator, but that would also be a bit of an undertaking. Therefore to keep things simple (for now) I decided to use a prebuilt oscillator module (more discussion about the specific part later). However, I'd like to keep the counting logic oscillator agnostic, in order to ensure that its easy to swap out the oscillator at a later date.

Counting Logic:

every tick of the oscillator needs to be counted, and every 1/f ticks the counting logic should increment a seconds register. This is the FPGA  part of this project.

Time Computation:

Could I compute time and date from a seconds register, drive a display, read some buttons, and deal with a UART/USB connection from an FPGA? yeah probably. Do I want to? not particularly. Therefore all of these tasks will be carried out by a microcontroller.

Display:

should be something nice and friendly to read, preferably with some flexibility since I want to display strings like:

"PST: 19:32.57, 12 NOV 2022"
in a way that doesn't require learning how to decode an array of blinking LEDs.


Set/Reset Interface:

Finally I need a way to set the time that the clock displays. Since the Time computation is going to be handled in a microcontroller, the set reset interface needs to talk to the microcontroller. I decided that the easiest way to set the time would be over a USB serial port since then I could write a little utility that would synchronize the clock to current time of the computer that its plugged into.

In the next post I'll talk about the parts I picked, and the version 1 hardware design.

Discussions